Merge lp:~widelands-dev/widelands/bug-1658489-epedition-tab into lp:widelands

Proposed by Klaus Halfmann
Status: Merged
Merged at revision: 8290
Proposed branch: lp:~widelands-dev/widelands/bug-1658489-epedition-tab
Merge into: lp:widelands
Diff against target: 149 lines (+55/-15)
4 files modified
src/economy/expedition_bootstrap.cc (+6/-1)
src/economy/expedition_bootstrap.h (+28/-11)
src/graphic/align.h (+12/-0)
src/wui/buildingwindow.cc (+9/-3)
To merge this branch: bzr merge lp:~widelands-dev/widelands/bug-1658489-epedition-tab
Reviewer Review Type Date Requested Status
GunChleoc Approve
Klaus Halfmann Needs Resubmitting
kaputtnik (community) testing Approve
Review via email: mp+317047@code.launchpad.net

Description of the change

Fixed the bug in buildingwindow.cc + some minor changes.

Moral: Notifications are global. So when receiving one check if it is for you.

To post a comment you must log in.
Revision history for this message
kaputtnik (franku) wrote :

As far i can see the bug is fixed :-)

But the indentation of code is broken. Looks like widelands c++ code uses tabs for indentation, whereas you use spaces?

review: Approve (testing)
Revision history for this message
GunChleoc (gunchleoc) wrote :

The code for the fix looks good to me - there are quite a lot of other code changes though, and I don't know what they are for (see diff comments).

I agree with merging the improved comments.

review: Needs Fixing
Revision history for this message
Klaus Halfmann (klaus-halfmann) wrote :

Will clean up the code along your comments, thx.

Revision history for this message
GunChleoc (gunchleoc) wrote :

Sounds good to me :)

If you have an idea on how to get rid of the compiler warnings elegantly, please do go ahead. They are annoying, but behave differently with the different compilers.

Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 1943. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/201326099.
Appveyor build 1778. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_bug_1658489_epedition_tab-1778.

Revision history for this message
Klaus Halfmann (klaus-halfmann) wrote :

Reworked that code going to compile/tets/push this now

Revision history for this message
Klaus Halfmann (klaus-halfmann) wrote :

Lets try again

review: Needs Resubmitting
Revision history for this message
GunChleoc (gunchleoc) wrote :

You still have code changes in src/graphic/align.h and src/wui/building_ui.cc that are unrelated to this branch ;)

Revision history for this message
Klaus Halfmann (klaus-halfmann) wrote :

Mhh, you did annotate this as "needs fixing".
If you insist I will include these changes in some other branch ...

Revision history for this message
GunChleoc (gunchleoc) wrote :

Yes please. It makes for a confusing commit history (see my comments). I also like to "smuggle" in some small improvements here and there in a branch, but it must at least be documented and explained in the commit message. If the commit should break something, it will make it harder to find later on if it isn't commented.

Revision history for this message
Klaus Halfmann (klaus-halfmann) wrote :

Can this go in now?

I am vaction now and would like to start some other things...

review: Needs Resubmitting
Revision history for this message
GunChleoc (gunchleoc) wrote :

Yes. Thanks for the fix and the cleanup :)

@bunnybot merge

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/economy/expedition_bootstrap.cc'
2--- src/economy/expedition_bootstrap.cc 2017-02-12 09:10:57 +0000
3+++ src/economy/expedition_bootstrap.cc 2017-02-17 18:17:30 +0000
4@@ -91,8 +91,12 @@
5 warehouse->refresh_options(*igb);
6 }
7
8+/**
9+ * Cancel the Expediton by putting back all wares and workers.
10+‚ */
11 void ExpeditionBootstrap::cancel(Game& game) {
12- // Put all wares from the WaresQueues back into the warehouse
13+
14+ // Put all wares from the WaresQueues back into the warehouse
15 Warehouse* const warehouse = portdock_->get_warehouse();
16 for (std::unique_ptr<InputQueue>& iq : queues_) {
17 if (iq->get_type() == wwWARE) {
18@@ -112,6 +116,7 @@
19 if (upcast(InteractiveGameBase, igb, warehouse->owner().egbase().get_ibase())) {
20 warehouse->refresh_options(*igb);
21 }
22+
23 Notifications::publish(NoteExpeditionCanceled(this));
24 }
25
26
27=== modified file 'src/economy/expedition_bootstrap.h'
28--- src/economy/expedition_bootstrap.h 2017-02-12 09:10:57 +0000
29+++ src/economy/expedition_bootstrap.h 2017-02-17 18:17:30 +0000
30@@ -38,9 +38,15 @@
31 class Warehouse;
32 class Worker;
33
34-// Handles the mustering of workers and wares in a port for one Expedition. This
35-// object is created in the port dock as soon as the start expedition button is
36-// pressed. As soon as the ship is loaded, this object gets destroyed.
37+/**
38+ * Handles the mustering of workers and wares in a port for an Expedition.
39+ *
40+ * This object is created in the port dock as soon as the start expedition button is
41+ * pressed. As soon as the ship is loaded, this object gets destroyed.
42+ * In case the Expedition is ::cancel()ed the wares will be returned to the port dock.
43+ * It is the responsibility of the Owner to finally dispose a canceled ExpeditionBootstrap.
44+ */
45+
46 class ExpeditionBootstrap {
47 public:
48 ExpeditionBootstrap(PortDock* const portdock);
49@@ -53,9 +59,12 @@
50 // the corresponding warehouse.
51 void cancel(Game& game);
52
53- // Returns a list of workers and wares that are ready to go to an
54- // expedition. Ownership is transferred and the object is in an undefined
55- // state after this and must be deleted.
56+ /**
57+ * Returns a list of workers and wares that are ready to go to an expediton.
58+ *
59+ * Ownership is transferred and the object is in an undefined
60+ * state after this and must be deleted.
61+ */
62 void get_waiting_workers_and_wares(Game&,
63 const TribeDescr&,
64 std::vector<Worker*>* return_workers,
65@@ -73,11 +82,18 @@
66 // Delete all wares we currently handle.
67 void cleanup(EditorGameBase& egbase);
68
69- // Save/Load this into a file. The actual data is stored in the buildingdata
70- // packet, and there in the warehouse data packet. The version parameter is
71- // the version number of the Warehouse packet.
72- void
73- load(Warehouse& warehouse, FileRead& fr, Game& game, MapObjectLoader& mol, uint16_t version);
74+ /** Load this from a file.
75+ *
76+ * The actual data is stored in the buildingdata
77+ * packet, and there in the warehouse data packet.
78+ */
79+ void load(Warehouse& warehouse, FileRead& fr, Game& game, MapObjectLoader& mol, uint16_t version);
80+
81+ /** Save this into a file.
82+ *
83+ * The actual data is stored in the buildingdata
84+ * packet, and there in the warehouse data packet.
85+ */
86 void save(FileWrite& fw, Game& game, MapObjectSaver& mos);
87
88 private:
89@@ -87,6 +103,7 @@
90 // Tests if all wares for the expedition have arrived. If so, informs the portdock.
91 void is_ready(Game& game);
92
93+ /** The Expedition is bootstapped here. */
94 PortDock* const portdock_; // not owned
95 Economy* economy_;
96
97
98=== modified file 'src/graphic/align.h'
99--- src/graphic/align.h 2017-01-25 18:55:59 +0000
100+++ src/graphic/align.h 2017-02-17 18:17:30 +0000
101@@ -24,6 +24,18 @@
102
103 namespace UI {
104
105+/**
106+ * This Enum is a binary mix of one-dimensional and two-dimensional alignments.
107+ *
108+ * bits 0,1 values 0,1,2,3 are horizontal
109+ * bits 2,3 values 0,4,8,12 are vertical
110+ *
111+ * mixed aligenments are results of a binary | operation.
112+ */
113+
114+ // TODO(klaus.halfmann): as this is not a real enum all compiler warnings about
115+ // incomplete usage are useless.
116+
117 enum class Align {
118 kLeft = 0,
119 kHCenter = 1,
120
121=== modified file 'src/wui/buildingwindow.cc'
122--- src/wui/buildingwindow.cc 2017-01-28 14:53:28 +0000
123+++ src/wui/buildingwindow.cc 2017-02-17 18:17:30 +0000
124@@ -159,9 +159,6 @@
125 // Check if this is a port building and if yes show expedition button
126 if (upcast(Widelands::Warehouse const, warehouse, &building_)) {
127 if (Widelands::PortDock* pd = warehouse->get_portdock()) {
128- expedition_canceled_subscriber_ =
129- Notifications::subscribe<Widelands::NoteExpeditionCanceled>([this](
130- const Widelands::NoteExpeditionCanceled&) { update_expedition_button(true); });
131 expeditionbtn_ =
132 new UI::Button(capsbuttons, "start_or_cancel_expedition", 0, 0, 34, 34,
133 g_gr->images().get("images/ui_basic/but4.png"),
134@@ -170,6 +167,15 @@
135 expeditionbtn_->sigclicked.connect(
136 boost::bind(&BuildingWindow::act_start_or_cancel_expedition, boost::ref(*this)));
137 capsbuttons->add(expeditionbtn_, UI::Align::kHCenter);
138+
139+ expedition_canceled_subscriber_ =
140+ Notifications::subscribe<Widelands::NoteExpeditionCanceled>([this, pd](
141+ const Widelands::NoteExpeditionCanceled& canceled) {
142+ // Check this was not just any but our Expedition
143+ if (canceled.bootstrap == pd->expedition_bootstrap()) {
144+ update_expedition_button(true);
145+ }
146+ });
147 }
148 } else if (upcast(const Widelands::ProductionSite, productionsite, &building_)) {
149 if (!is_a(Widelands::MilitarySite, productionsite)) {

Subscribers

People subscribed via source and target branches

to status/vote changes: