Merge lp:~widelands-dev/widelands/const_portdock_fleet_and_ship_functions into lp:widelands
- const_portdock_fleet_and_ship_functions
- Merge into trunk
Proposed by
GunChleoc
Status: | Merged |
---|---|
Merged at revision: | 8818 |
Proposed branch: | lp:~widelands-dev/widelands/const_portdock_fleet_and_ship_functions |
Merge into: | lp:widelands |
Diff against target: |
855 lines (+95/-96) 42 files modified
src/ai/defaultai_seafaring.cc (+1/-1) src/economy/flag.cc (+1/-1) src/economy/flag.h (+1/-1) src/economy/fleet.cc (+6/-6) src/economy/fleet.h (+6/-6) src/economy/portdock.cc (+7/-7) src/economy/portdock.h (+5/-5) src/economy/road.cc (+1/-1) src/economy/road.h (+1/-1) src/economy/ware_instance.cc (+1/-1) src/economy/ware_instance.h (+1/-1) src/logic/map_objects/bob.cc (+1/-1) src/logic/map_objects/bob.h (+1/-1) src/logic/map_objects/immovable.cc (+1/-1) src/logic/map_objects/immovable.h (+1/-1) src/logic/map_objects/map_object.cc (+1/-1) src/logic/map_objects/map_object.h (+1/-1) src/logic/map_objects/tribes/building.cc (+1/-1) src/logic/map_objects/tribes/building.h (+1/-1) src/logic/map_objects/tribes/carrier.cc (+1/-1) src/logic/map_objects/tribes/carrier.h (+1/-1) src/logic/map_objects/tribes/productionsite.cc (+1/-1) src/logic/map_objects/tribes/productionsite.h (+1/-1) src/logic/map_objects/tribes/ship.cc (+1/-1) src/logic/map_objects/tribes/ship.h (+2/-2) src/logic/map_objects/tribes/soldier.cc (+1/-1) src/logic/map_objects/tribes/soldier.h (+1/-1) src/logic/map_objects/tribes/warehouse.cc (+7/-8) src/logic/map_objects/tribes/warehouse.h (+1/-1) src/logic/map_objects/tribes/worker.cc (+1/-1) src/logic/map_objects/tribes/worker.h (+1/-1) src/scripting/lua_map.cc (+3/-3) src/wui/buildingwindow.cc (+2/-2) src/wui/buildingwindow.h (+1/-1) src/wui/constructionsitewindow.cc (+1/-1) src/wui/dismantlesitewindow.cc (+1/-1) src/wui/inputqueuedisplay.cc (+17/-17) src/wui/inputqueuedisplay.h (+2/-2) src/wui/portdockwaresdisplay.cc (+7/-7) src/wui/portdockwaresdisplay.h (+1/-1) src/wui/productionsitewindow.cc (+1/-1) src/wui/warehousewindow.cc (+1/-1) |
To merge this branch: | bzr merge lp:~widelands-dev/widelands/const_portdock_fleet_and_ship_functions |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Notabilis | diff | Approve | |
Review via email: mp+354301@code.launchpad.net |
Commit message
Made as many functions as possible const in portdock, fleet and ship and followed the snowball effect
Description of the change
const functions give the compiler more room for optimization.
To post a comment you must log in.
Revision history for this message
bunnybot (widelandsofficial) wrote : | # |
Revision history for this message
Notabilis (notabilis27) wrote : | # |
Diff is looking good.
I haven't bothered compiling or testing myself, but Travis seems to be fine.
review:
Approve
(diff)
Revision history for this message
GunChleoc (gunchleoc) wrote : | # |
Thanks! Change is trivial, so that should be sufficient.
@bunnybot merge
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'src/ai/defaultai_seafaring.cc' |
2 | --- src/ai/defaultai_seafaring.cc 2018-08-16 16:10:43 +0000 |
3 | +++ src/ai/defaultai_seafaring.cc 2018-09-05 07:39:19 +0000 |
4 | @@ -126,7 +126,7 @@ |
5 | for (const WarehouseSiteObserver& wh_obs : warehousesites) { |
6 | if (wh_obs.bo->is(BuildingAttribute::kPort)) { |
7 | ports_count += 1; |
8 | - if (Widelands::PortDock* pd = wh_obs.site->get_portdock()) { |
9 | + if (const Widelands::PortDock* pd = wh_obs.site->get_portdock()) { |
10 | if (pd->expedition_started()) { |
11 | expeditions_in_prep += 1; |
12 | } |
13 | |
14 | === modified file 'src/economy/flag.cc' |
15 | --- src/economy/flag.cc 2018-08-09 11:11:15 +0000 |
16 | +++ src/economy/flag.cc 2018-09-05 07:39:19 +0000 |
17 | @@ -967,7 +967,7 @@ |
18 | flag.molog("BUG: flag_job_request_callback: worker not found in list\n"); |
19 | } |
20 | |
21 | -void Flag::log_general_info(const Widelands::EditorGameBase& egbase) { |
22 | +void Flag::log_general_info(const Widelands::EditorGameBase& egbase) const { |
23 | molog("Flag at %i,%i\n", position_.x, position_.y); |
24 | |
25 | Widelands::PlayerImmovable::log_general_info(egbase); |
26 | |
27 | === modified file 'src/economy/flag.h' |
28 | --- src/economy/flag.h 2018-08-09 11:11:15 +0000 |
29 | +++ src/economy/flag.h 2018-09-05 07:39:19 +0000 |
30 | @@ -163,7 +163,7 @@ |
31 | |
32 | void add_flag_job(Game&, DescriptionIndex workerware, const std::string& programname); |
33 | |
34 | - void log_general_info(const EditorGameBase&) override; |
35 | + void log_general_info(const EditorGameBase&) const override; |
36 | |
37 | protected: |
38 | bool init(EditorGameBase&) override; |
39 | |
40 | === modified file 'src/economy/fleet.cc' |
41 | --- src/economy/fleet.cc 2018-04-07 16:59:00 +0000 |
42 | +++ src/economy/fleet.cc 2018-09-05 07:39:19 +0000 |
43 | @@ -324,11 +324,11 @@ |
44 | return true; |
45 | } |
46 | |
47 | -uint32_t Fleet::count_ships() { |
48 | +uint32_t Fleet::count_ships() const { |
49 | return ships_.size(); |
50 | } |
51 | |
52 | -uint32_t Fleet::count_ships_heading_here(EditorGameBase& egbase, PortDock* port) { |
53 | +uint32_t Fleet::count_ships_heading_here(EditorGameBase& egbase, PortDock* port) const { |
54 | uint32_t ships_on_way = 0; |
55 | for (uint16_t s = 0; s < ships_.size(); s += 1) { |
56 | if (ships_[s]->get_destination(egbase) == port) { |
57 | @@ -339,10 +339,10 @@ |
58 | return ships_on_way; |
59 | } |
60 | |
61 | -uint32_t Fleet::count_ports() { |
62 | +uint32_t Fleet::count_ports() const { |
63 | return ports_.size(); |
64 | } |
65 | -bool Fleet::get_act_pending() { |
66 | +bool Fleet::get_act_pending() const { |
67 | return act_pending_; |
68 | } |
69 | |
70 | @@ -568,7 +568,7 @@ |
71 | } |
72 | } |
73 | |
74 | -bool Fleet::has_ports() { |
75 | +bool Fleet::has_ports() const { |
76 | return !ports_.empty(); |
77 | } |
78 | |
79 | @@ -863,7 +863,7 @@ |
80 | } |
81 | } |
82 | |
83 | -void Fleet::log_general_info(const EditorGameBase& egbase) { |
84 | +void Fleet::log_general_info(const EditorGameBase& egbase) const { |
85 | MapObject::log_general_info(egbase); |
86 | |
87 | molog("%" PRIuS " ships and %" PRIuS " ports\n", ships_.size(), ports_.size()); |
88 | |
89 | === modified file 'src/economy/fleet.h' |
90 | --- src/economy/fleet.h 2018-04-16 07:03:12 +0000 |
91 | +++ src/economy/fleet.h 2018-09-05 07:39:19 +0000 |
92 | @@ -92,17 +92,17 @@ |
93 | void remove_ship(EditorGameBase& egbase, Ship* ship); |
94 | void add_port(EditorGameBase& egbase, PortDock* port); |
95 | void remove_port(EditorGameBase& egbase, PortDock* port); |
96 | - bool has_ports(); |
97 | + bool has_ports() const; |
98 | |
99 | - void log_general_info(const EditorGameBase&) override; |
100 | + void log_general_info(const EditorGameBase&) const override; |
101 | |
102 | bool get_path(PortDock& start, PortDock& end, Path& path); |
103 | void add_neighbours(PortDock& pd, std::vector<RoutingNodeNeighbour>& neighbours); |
104 | |
105 | - uint32_t count_ships(); |
106 | - uint32_t count_ships_heading_here(EditorGameBase& egbase, PortDock* port); |
107 | - uint32_t count_ports(); |
108 | - bool get_act_pending(); |
109 | + uint32_t count_ships() const; |
110 | + uint32_t count_ships_heading_here(EditorGameBase& egbase, PortDock* port) const; |
111 | + uint32_t count_ports() const; |
112 | + bool get_act_pending() const; |
113 | |
114 | protected: |
115 | void act(Game&, uint32_t data) override; |
116 | |
117 | === modified file 'src/economy/portdock.cc' |
118 | --- src/economy/portdock.cc 2018-04-16 07:03:12 +0000 |
119 | +++ src/economy/portdock.cc 2018-09-05 07:39:19 +0000 |
120 | @@ -384,10 +384,10 @@ |
121 | /** |
122 | * Return the number of wares or workers of the given type that are waiting at the dock. |
123 | */ |
124 | -uint32_t PortDock::count_waiting(WareWorker waretype, DescriptionIndex wareindex) { |
125 | +uint32_t PortDock::count_waiting(WareWorker waretype, DescriptionIndex wareindex) const { |
126 | uint32_t count = 0; |
127 | |
128 | - for (ShippingItem& shipping_item : waiting_) { |
129 | + for (const ShippingItem& shipping_item : waiting_) { |
130 | WareInstance* ware; |
131 | Worker* worker; |
132 | shipping_item.get(owner().egbase(), &ware, &worker); |
133 | @@ -407,12 +407,12 @@ |
134 | /** |
135 | * Return the number of wares or workers waiting at the dock. |
136 | */ |
137 | -uint32_t PortDock::count_waiting() { |
138 | +uint32_t PortDock::count_waiting() const { |
139 | return waiting_.size(); |
140 | } |
141 | |
142 | /// \returns whether an expedition was started or is even ready |
143 | -bool PortDock::expedition_started() { |
144 | +bool PortDock::expedition_started() const { |
145 | return (expedition_bootstrap_ != nullptr) || expedition_ready_; |
146 | } |
147 | |
148 | @@ -423,7 +423,7 @@ |
149 | expedition_bootstrap_->start(); |
150 | } |
151 | |
152 | -ExpeditionBootstrap* PortDock::expedition_bootstrap() { |
153 | +ExpeditionBootstrap* PortDock::expedition_bootstrap() const { |
154 | return expedition_bootstrap_.get(); |
155 | } |
156 | |
157 | @@ -440,7 +440,7 @@ |
158 | expedition_bootstrap_.reset(nullptr); |
159 | } |
160 | |
161 | -void PortDock::log_general_info(const EditorGameBase& egbase) { |
162 | +void PortDock::log_general_info(const EditorGameBase& egbase) const { |
163 | PlayerImmovable::log_general_info(egbase); |
164 | |
165 | if (warehouse_) { |
166 | @@ -454,7 +454,7 @@ |
167 | fleet_ ? fleet_->serial() : 0, need_ship_ ? "true" : "false", waiting_.size()); |
168 | } |
169 | |
170 | - for (ShippingItem& shipping_item : waiting_) { |
171 | + for (const ShippingItem& shipping_item : waiting_) { |
172 | molog(" IT %u, destination %u\n", shipping_item.object_.serial(), |
173 | shipping_item.destination_dock_.serial()); |
174 | } |
175 | |
176 | === modified file 'src/economy/portdock.h' |
177 | --- src/economy/portdock.h 2018-04-07 16:59:00 +0000 |
178 | +++ src/economy/portdock.h 2018-09-05 07:39:19 +0000 |
179 | @@ -115,13 +115,13 @@ |
180 | |
181 | void ship_arrived(Game&, Ship&); |
182 | |
183 | - void log_general_info(const EditorGameBase&) override; |
184 | + void log_general_info(const EditorGameBase&) const override; |
185 | |
186 | - uint32_t count_waiting(WareWorker waretype, DescriptionIndex wareindex); |
187 | - uint32_t count_waiting(); |
188 | + uint32_t count_waiting(WareWorker waretype, DescriptionIndex wareindex) const; |
189 | + uint32_t count_waiting() const; |
190 | |
191 | // Returns true if a expedition is started or ready to be send out. |
192 | - bool expedition_started(); |
193 | + bool expedition_started() const; |
194 | |
195 | // Called when the button in the warehouse window is pressed. |
196 | void start_expedition(); |
197 | @@ -129,7 +129,7 @@ |
198 | |
199 | // May return nullptr when there is no expedition ongoing or if the |
200 | // expedition ship is already underway. |
201 | - ExpeditionBootstrap* expedition_bootstrap(); |
202 | + ExpeditionBootstrap* expedition_bootstrap() const; |
203 | |
204 | // Gets called by the ExpeditionBootstrap as soon as all wares and workers are available. |
205 | void expedition_bootstrap_complete(Game& game); |
206 | |
207 | === modified file 'src/economy/road.cc' |
208 | --- src/economy/road.cc 2018-07-12 06:02:15 +0000 |
209 | +++ src/economy/road.cc 2018-09-05 07:39:19 +0000 |
210 | @@ -632,7 +632,7 @@ |
211 | // Don't bother with checks here, since the next ware will cause them anyway |
212 | } |
213 | |
214 | -void Road::log_general_info(const EditorGameBase& egbase) { |
215 | +void Road::log_general_info(const EditorGameBase& egbase) const { |
216 | PlayerImmovable::log_general_info(egbase); |
217 | molog("wallet: %i\n", wallet_); |
218 | } |
219 | |
220 | === modified file 'src/economy/road.h' |
221 | --- src/economy/road.h 2018-07-12 06:02:15 +0000 |
222 | +++ src/economy/road.h 2018-09-05 07:39:19 +0000 |
223 | @@ -124,7 +124,7 @@ |
224 | void remove_worker(Worker&) override; |
225 | void assign_carrier(Carrier&, uint8_t); |
226 | |
227 | - void log_general_info(const EditorGameBase&) override; |
228 | + void log_general_info(const EditorGameBase&) const override; |
229 | |
230 | protected: |
231 | bool init(EditorGameBase&) override; |
232 | |
233 | === modified file 'src/economy/ware_instance.cc' |
234 | --- src/economy/ware_instance.cc 2018-04-07 16:59:00 +0000 |
235 | +++ src/economy/ware_instance.cc 2018-09-05 07:39:19 +0000 |
236 | @@ -502,7 +502,7 @@ |
237 | return transfer_ ? dynamic_cast<PlayerImmovable*>(transfer_nextstep_.get(game)) : nullptr; |
238 | } |
239 | |
240 | -void WareInstance::log_general_info(const EditorGameBase& egbase) { |
241 | +void WareInstance::log_general_info(const EditorGameBase& egbase) const { |
242 | MapObject::log_general_info(egbase); |
243 | |
244 | molog("Ware: %s\n", descr().name().c_str()); |
245 | |
246 | === modified file 'src/economy/ware_instance.h' |
247 | --- src/economy/ware_instance.h 2018-04-07 16:59:00 +0000 |
248 | +++ src/economy/ware_instance.h 2018-09-05 07:39:19 +0000 |
249 | @@ -93,7 +93,7 @@ |
250 | return transfer_; |
251 | } |
252 | |
253 | - void log_general_info(const EditorGameBase& egbase) override; |
254 | + void log_general_info(const EditorGameBase& egbase) const override; |
255 | |
256 | private: |
257 | ObjectPointer location_; |
258 | |
259 | === modified file 'src/logic/map_objects/bob.cc' |
260 | --- src/logic/map_objects/bob.cc 2018-04-27 06:11:05 +0000 |
261 | +++ src/logic/map_objects/bob.cc 2018-09-05 07:39:19 +0000 |
262 | @@ -902,7 +902,7 @@ |
263 | } |
264 | |
265 | /// Give debug information. |
266 | -void Bob::log_general_info(const EditorGameBase& egbase) { |
267 | +void Bob::log_general_info(const EditorGameBase& egbase) const { |
268 | FORMAT_WARNINGS_OFF; |
269 | molog("Owner: %p\n", owner_); |
270 | FORMAT_WARNINGS_ON; |
271 | |
272 | === modified file 'src/logic/map_objects/bob.h' |
273 | --- src/logic/map_objects/bob.h 2018-04-07 16:59:00 +0000 |
274 | +++ src/logic/map_objects/bob.h 2018-09-05 07:39:19 +0000 |
275 | @@ -270,7 +270,7 @@ |
276 | RenderTarget* dst) const; |
277 | |
278 | // For debug |
279 | - void log_general_info(const EditorGameBase&) override; |
280 | + void log_general_info(const EditorGameBase&) const override; |
281 | |
282 | // default tasks |
283 | void reset_tasks(Game&); |
284 | |
285 | === modified file 'src/logic/map_objects/immovable.cc' |
286 | --- src/logic/map_objects/immovable.cc 2018-07-13 07:46:36 +0000 |
287 | +++ src/logic/map_objects/immovable.cc 2018-09-05 07:39:19 +0000 |
288 | @@ -1332,7 +1332,7 @@ |
289 | /** |
290 | * Dump general information |
291 | */ |
292 | -void PlayerImmovable::log_general_info(const EditorGameBase& egbase) { |
293 | +void PlayerImmovable::log_general_info(const EditorGameBase& egbase) const { |
294 | BaseImmovable::log_general_info(egbase); |
295 | |
296 | FORMAT_WARNINGS_OFF; |
297 | |
298 | === modified file 'src/logic/map_objects/immovable.h' |
299 | --- src/logic/map_objects/immovable.h 2018-07-08 16:10:50 +0000 |
300 | +++ src/logic/map_objects/immovable.h 2018-09-05 07:39:19 +0000 |
301 | @@ -357,7 +357,7 @@ |
302 | return workers_; |
303 | } |
304 | |
305 | - void log_general_info(const EditorGameBase&) override; |
306 | + void log_general_info(const EditorGameBase&) const override; |
307 | |
308 | /** |
309 | * These functions are called when a ware or worker arrives at |
310 | |
311 | === modified file 'src/logic/map_objects/map_object.cc' |
312 | --- src/logic/map_objects/map_object.cc 2018-07-23 09:04:47 +0000 |
313 | +++ src/logic/map_objects/map_object.cc 2018-09-05 07:39:19 +0000 |
314 | @@ -543,7 +543,7 @@ |
315 | logsink_ = sink; |
316 | } |
317 | |
318 | -void MapObject::log_general_info(const EditorGameBase&) { |
319 | +void MapObject::log_general_info(const EditorGameBase&) const { |
320 | } |
321 | |
322 | /** |
323 | |
324 | === modified file 'src/logic/map_objects/map_object.h' |
325 | --- src/logic/map_objects/map_object.h 2018-05-12 04:18:21 +0000 |
326 | +++ src/logic/map_objects/map_object.h 2018-09-05 07:39:19 +0000 |
327 | @@ -302,7 +302,7 @@ |
328 | void set_logsink(LogSink*); |
329 | |
330 | /// Called when a new logsink is set. Used to give general information. |
331 | - virtual void log_general_info(const EditorGameBase&); |
332 | + virtual void log_general_info(const EditorGameBase&) const; |
333 | |
334 | Player* get_owner() const { |
335 | return owner_; |
336 | |
337 | === modified file 'src/logic/map_objects/tribes/building.cc' |
338 | --- src/logic/map_objects/tribes/building.cc 2018-04-27 06:11:05 +0000 |
339 | +++ src/logic/map_objects/tribes/building.cc 2018-09-05 07:39:19 +0000 |
340 | @@ -669,7 +669,7 @@ |
341 | } |
342 | } |
343 | |
344 | -void Building::log_general_info(const EditorGameBase& egbase) { |
345 | +void Building::log_general_info(const EditorGameBase& egbase) const { |
346 | PlayerImmovable::log_general_info(egbase); |
347 | |
348 | molog("position: (%i, %i)\n", position_.x, position_.y); |
349 | |
350 | === modified file 'src/logic/map_objects/tribes/building.h' |
351 | --- src/logic/map_objects/tribes/building.h 2018-05-24 10:19:21 +0000 |
352 | +++ src/logic/map_objects/tribes/building.h 2018-09-05 07:39:19 +0000 |
353 | @@ -282,7 +282,7 @@ |
354 | return old_buildings_; |
355 | } |
356 | |
357 | - void log_general_info(const EditorGameBase&) override; |
358 | + void log_general_info(const EditorGameBase&) const override; |
359 | |
360 | // Use on training sites only. |
361 | virtual void change_train_priority(uint32_t, int32_t) { |
362 | |
363 | === modified file 'src/logic/map_objects/tribes/carrier.cc' |
364 | --- src/logic/map_objects/tribes/carrier.cc 2018-08-13 05:50:58 +0000 |
365 | +++ src/logic/map_objects/tribes/carrier.cc 2018-09-05 07:39:19 +0000 |
366 | @@ -406,7 +406,7 @@ |
367 | return start_task_movepath(game, path, idx, descr().get_right_walk_anims(does_carry_ware())); |
368 | } |
369 | |
370 | -void Carrier::log_general_info(const Widelands::EditorGameBase& egbase) { |
371 | +void Carrier::log_general_info(const Widelands::EditorGameBase& egbase) const { |
372 | molog("Carrier at %i,%i\n", get_position().x, get_position().y); |
373 | |
374 | Worker::log_general_info(egbase); |
375 | |
376 | === modified file 'src/logic/map_objects/tribes/carrier.h' |
377 | --- src/logic/map_objects/tribes/carrier.h 2018-08-09 11:11:15 +0000 |
378 | +++ src/logic/map_objects/tribes/carrier.h 2018-09-05 07:39:19 +0000 |
379 | @@ -62,7 +62,7 @@ |
380 | void start_task_transport(Game&, int32_t fromflag); |
381 | bool start_task_walktoflag(Game&, int32_t flag, bool offset = false); |
382 | |
383 | - void log_general_info(const EditorGameBase&) override; |
384 | + void log_general_info(const EditorGameBase&) const override; |
385 | |
386 | static Task const taskRoad; |
387 | |
388 | |
389 | === modified file 'src/logic/map_objects/tribes/productionsite.cc' |
390 | --- src/logic/map_objects/tribes/productionsite.cc 2018-06-19 08:52:49 +0000 |
391 | +++ src/logic/map_objects/tribes/productionsite.cc 2018-09-05 07:39:19 +0000 |
392 | @@ -739,7 +739,7 @@ |
393 | return true; |
394 | } |
395 | |
396 | -void ProductionSite::log_general_info(const EditorGameBase& egbase) { |
397 | +void ProductionSite::log_general_info(const EditorGameBase& egbase) const { |
398 | Building::log_general_info(egbase); |
399 | |
400 | molog("is_stopped: %u\n", is_stopped_); |
401 | |
402 | === modified file 'src/logic/map_objects/tribes/productionsite.h' |
403 | --- src/logic/map_objects/tribes/productionsite.h 2018-07-08 16:10:50 +0000 |
404 | +++ src/logic/map_objects/tribes/productionsite.h 2018-09-05 07:39:19 +0000 |
405 | @@ -165,7 +165,7 @@ |
406 | explicit ProductionSite(const ProductionSiteDescr& descr); |
407 | ~ProductionSite() override; |
408 | |
409 | - void log_general_info(const EditorGameBase&) override; |
410 | + void log_general_info(const EditorGameBase&) const override; |
411 | |
412 | bool is_stopped() const { |
413 | return is_stopped_; |
414 | |
415 | === modified file 'src/logic/map_objects/tribes/ship.cc' |
416 | --- src/logic/map_objects/tribes/ship.cc 2018-07-08 15:16:16 +0000 |
417 | +++ src/logic/map_objects/tribes/ship.cc 2018-09-05 07:39:19 +0000 |
418 | @@ -1027,7 +1027,7 @@ |
419 | scale, dst); |
420 | } |
421 | |
422 | -void Ship::log_general_info(const EditorGameBase& egbase) { |
423 | +void Ship::log_general_info(const EditorGameBase& egbase) const { |
424 | Bob::log_general_info(egbase); |
425 | |
426 | molog("Ship belongs to fleet: %u\n destination: %s\n lastdock: %s\n", |
427 | |
428 | === modified file 'src/logic/map_objects/tribes/ship.h' |
429 | --- src/logic/map_objects/tribes/ship.h 2018-07-12 05:44:15 +0000 |
430 | +++ src/logic/map_objects/tribes/ship.h 2018-09-05 07:39:19 +0000 |
431 | @@ -117,7 +117,7 @@ |
432 | |
433 | uint32_t calculate_sea_route(Game& game, PortDock& pd, Path* finalpath = nullptr) const; |
434 | |
435 | - void log_general_info(const EditorGameBase&) override; |
436 | + void log_general_info(const EditorGameBase&) const override; |
437 | |
438 | uint32_t get_nritems() const { |
439 | return items_.size(); |
440 | @@ -196,7 +196,7 @@ |
441 | } |
442 | |
443 | // whether the ship's expedition is in state "island-exploration" (circular movement) |
444 | - bool is_exploring_island() { |
445 | + bool is_exploring_island() const { |
446 | return expedition_->island_exploration; |
447 | } |
448 | |
449 | |
450 | === modified file 'src/logic/map_objects/tribes/soldier.cc' |
451 | --- src/logic/map_objects/tribes/soldier.cc 2018-07-13 10:35:16 +0000 |
452 | +++ src/logic/map_objects/tribes/soldier.cc 2018-09-05 07:39:19 +0000 |
453 | @@ -1546,7 +1546,7 @@ |
454 | } |
455 | } |
456 | |
457 | -void Soldier::log_general_info(const EditorGameBase& egbase) { |
458 | +void Soldier::log_general_info(const EditorGameBase& egbase) const { |
459 | Worker::log_general_info(egbase); |
460 | molog("[Soldier]\n"); |
461 | molog("Levels: %d/%d/%d/%d\n", health_level_, attack_level_, defense_level_, evade_level_); |
462 | |
463 | === modified file 'src/logic/map_objects/tribes/soldier.h' |
464 | --- src/logic/map_objects/tribes/soldier.h 2018-04-07 16:59:00 +0000 |
465 | +++ src/logic/map_objects/tribes/soldier.h 2018-09-05 07:39:19 +0000 |
466 | @@ -258,7 +258,7 @@ |
467 | void heal(uint32_t); |
468 | void damage(uint32_t); /// Damage quantity of health points |
469 | |
470 | - void log_general_info(const EditorGameBase&) override; |
471 | + void log_general_info(const EditorGameBase&) const override; |
472 | |
473 | bool is_on_battlefield(); |
474 | bool is_attacking_player(Game&, Player&); |
475 | |
476 | === modified file 'src/logic/map_objects/tribes/warehouse.cc' |
477 | --- src/logic/map_objects/tribes/warehouse.cc 2018-04-07 16:59:00 +0000 |
478 | +++ src/logic/map_objects/tribes/warehouse.cc 2018-09-05 07:39:19 +0000 |
479 | @@ -1337,17 +1337,16 @@ |
480 | return portdock_->expedition_bootstrap()->inputqueue(index, type); |
481 | } |
482 | |
483 | -void Warehouse::log_general_info(const EditorGameBase& egbase) { |
484 | +void Warehouse::log_general_info(const EditorGameBase& egbase) const { |
485 | Building::log_general_info(egbase); |
486 | |
487 | if (descr().get_isport()) { |
488 | - PortDock* pd_tmp = portdock_; |
489 | - if (pd_tmp) { |
490 | - molog("Port dock: %u\n", pd_tmp->serial()); |
491 | - molog("port needs ship: %s\n", (pd_tmp->get_need_ship()) ? "true" : "false"); |
492 | - molog("wares and workers waiting: %u\n", pd_tmp->count_waiting()); |
493 | - molog("exped. in progr.: %s\n", (pd_tmp->expedition_started()) ? "true" : "false"); |
494 | - Fleet* fleet = pd_tmp->get_fleet(); |
495 | + if (portdock_) { |
496 | + molog("Port dock: %u\n", portdock_->serial()); |
497 | + molog("port needs ship: %s\n", (portdock_->get_need_ship()) ? "true" : "false"); |
498 | + molog("wares and workers waiting: %u\n", portdock_->count_waiting()); |
499 | + molog("exped. in progr.: %s\n", (portdock_->expedition_started()) ? "true" : "false"); |
500 | + Fleet* fleet = portdock_->get_fleet(); |
501 | if (fleet) { |
502 | molog("* fleet: %u\n", fleet->serial()); |
503 | molog(" ships: %u, ports: %u\n", fleet->count_ships(), fleet->count_ports()); |
504 | |
505 | === modified file 'src/logic/map_objects/tribes/warehouse.h' |
506 | --- src/logic/map_objects/tribes/warehouse.h 2018-04-07 16:59:00 +0000 |
507 | +++ src/logic/map_objects/tribes/warehouse.h 2018-09-05 07:39:19 +0000 |
508 | @@ -214,7 +214,7 @@ |
509 | // Will throw an exception otherwise. |
510 | InputQueue& inputqueue(DescriptionIndex, WareWorker) override; |
511 | |
512 | - void log_general_info(const EditorGameBase&) override; |
513 | + void log_general_info(const EditorGameBase&) const override; |
514 | |
515 | private: |
516 | class SoldierControl : public Widelands::SoldierControl { |
517 | |
518 | === modified file 'src/logic/map_objects/tribes/worker.cc' |
519 | --- src/logic/map_objects/tribes/worker.cc 2018-08-09 11:11:15 +0000 |
520 | +++ src/logic/map_objects/tribes/worker.cc 2018-09-05 07:39:19 +0000 |
521 | @@ -1051,7 +1051,7 @@ |
522 | } |
523 | |
524 | /// Log basic information. |
525 | -void Worker::log_general_info(const EditorGameBase& egbase) { |
526 | +void Worker::log_general_info(const EditorGameBase& egbase) const { |
527 | Bob::log_general_info(egbase); |
528 | |
529 | if (upcast(PlayerImmovable, loc, location_.get(egbase))) { |
530 | |
531 | === modified file 'src/logic/map_objects/tribes/worker.h' |
532 | --- src/logic/map_objects/tribes/worker.h 2018-07-26 11:28:05 +0000 |
533 | +++ src/logic/map_objects/tribes/worker.h 2018-09-05 07:39:19 +0000 |
534 | @@ -138,7 +138,7 @@ |
535 | } |
536 | |
537 | // debug |
538 | - void log_general_info(const EditorGameBase&) override; |
539 | + void log_general_info(const EditorGameBase&) const override; |
540 | |
541 | // worker-specific tasks |
542 | void start_task_transfer(Game&, Transfer*); |
543 | |
544 | === modified file 'src/scripting/lua_map.cc' |
545 | --- src/scripting/lua_map.cc 2018-07-11 08:32:54 +0000 |
546 | +++ src/scripting/lua_map.cc 2018-09-05 07:39:19 +0000 |
547 | @@ -4569,7 +4569,7 @@ |
548 | EditorGameBase& egbase = get_egbase(L); |
549 | |
550 | if (is_a(Game, &egbase)) { |
551 | - PortDock* pd = get(L, egbase)->get_portdock(); |
552 | + const PortDock* pd = get(L, egbase)->get_portdock(); |
553 | if (pd) { |
554 | if (pd->expedition_started()) { |
555 | return 1; |
556 | @@ -4932,7 +4932,7 @@ |
557 | } |
558 | |
559 | if (upcast(Game, game, &egbase)) { |
560 | - PortDock* pd = wh->get_portdock(); |
561 | + const PortDock* pd = wh->get_portdock(); |
562 | if (!pd) { |
563 | return 0; |
564 | } |
565 | @@ -4963,7 +4963,7 @@ |
566 | } |
567 | |
568 | if (upcast(Game, game, &egbase)) { |
569 | - PortDock* pd = wh->get_portdock(); |
570 | + const PortDock* pd = wh->get_portdock(); |
571 | if (!pd) { |
572 | return 0; |
573 | } |
574 | |
575 | === modified file 'src/wui/buildingwindow.cc' |
576 | --- src/wui/buildingwindow.cc 2018-09-01 08:36:08 +0000 |
577 | +++ src/wui/buildingwindow.cc 2018-09-05 07:39:19 +0000 |
578 | @@ -204,7 +204,7 @@ |
579 | if (can_act) { |
580 | // Check if this is a port building and if yes show expedition button |
581 | if (upcast(Widelands::Warehouse const, warehouse, building)) { |
582 | - if (Widelands::PortDock* pd = warehouse->get_portdock()) { |
583 | + if (const Widelands::PortDock* pd = warehouse->get_portdock()) { |
584 | expeditionbtn_ = new UI::Button( |
585 | capsbuttons, "start_or_cancel_expedition", 0, 0, 34, 34, UI::ButtonStyle::kWuiMenu, |
586 | g_gr->images().get("images/wui/buildings/start_expedition.png")); |
587 | @@ -537,7 +537,7 @@ |
588 | |
589 | void BuildingWindow::create_input_queue_panel(UI::Box* const box, |
590 | Widelands::Building& b, |
591 | - Widelands::InputQueue* const iq, |
592 | + const Widelands::InputQueue& iq, |
593 | bool show_only) { |
594 | // The *max* width should be larger than the default width |
595 | box->add(new InputQueueDisplay(box, 0, 0, *igbase(), b, iq, show_only)); |
596 | |
597 | === modified file 'src/wui/buildingwindow.h' |
598 | --- src/wui/buildingwindow.h 2018-08-10 07:42:57 +0000 |
599 | +++ src/wui/buildingwindow.h 2018-09-05 07:39:19 +0000 |
600 | @@ -89,7 +89,7 @@ |
601 | void clicked_goto(); |
602 | |
603 | void |
604 | - create_input_queue_panel(UI::Box*, Widelands::Building&, Widelands::InputQueue*, bool = false); |
605 | + create_input_queue_panel(UI::Box*, Widelands::Building&, const Widelands::InputQueue&, bool = false); |
606 | |
607 | bool is_dying_; |
608 | |
609 | |
610 | === modified file 'src/wui/constructionsitewindow.cc' |
611 | --- src/wui/constructionsitewindow.cc 2018-08-14 13:40:46 +0000 |
612 | +++ src/wui/constructionsitewindow.cc 2018-09-05 07:39:19 +0000 |
613 | @@ -55,7 +55,7 @@ |
614 | // Add the wares queue |
615 | for (uint32_t i = 0; i < construction_site->get_nrwaresqueues(); ++i) |
616 | box.add(new InputQueueDisplay( |
617 | - &box, 0, 0, *igbase(), *construction_site, construction_site->get_waresqueue(i))); |
618 | + &box, 0, 0, *igbase(), *construction_site, *construction_site->get_waresqueue(i))); |
619 | |
620 | get_tabs()->add("wares", g_gr->images().get(pic_tab_wares), &box, _("Building materials")); |
621 | |
622 | |
623 | === modified file 'src/wui/dismantlesitewindow.cc' |
624 | --- src/wui/dismantlesitewindow.cc 2018-07-14 11:22:51 +0000 |
625 | +++ src/wui/dismantlesitewindow.cc 2018-09-05 07:39:19 +0000 |
626 | @@ -49,7 +49,7 @@ |
627 | // Add the wares queue |
628 | for (uint32_t i = 0; i < dismantle_site->get_nrwaresqueues(); ++i) |
629 | BuildingWindow::create_input_queue_panel( |
630 | - &box, *dismantle_site, dismantle_site->get_waresqueue(i), true); |
631 | + &box, *dismantle_site, *dismantle_site->get_waresqueue(i), true); |
632 | |
633 | get_tabs()->add("wares", g_gr->images().get(pic_tab_wares), &box, _("Building materials")); |
634 | think(); |
635 | |
636 | === modified file 'src/wui/inputqueuedisplay.cc' |
637 | --- src/wui/inputqueuedisplay.cc 2018-07-23 01:18:36 +0000 |
638 | +++ src/wui/inputqueuedisplay.cc 2018-09-05 07:39:19 +0000 |
639 | @@ -38,7 +38,7 @@ |
640 | int32_t const y, |
641 | InteractiveGameBase& igb, |
642 | Widelands::Building& building, |
643 | - Widelands::InputQueue* const queue, |
644 | + const Widelands::InputQueue& queue, |
645 | bool show_only) |
646 | : UI::Panel(parent, x, y, 0, 28), |
647 | igb_(igb), |
648 | @@ -47,21 +47,21 @@ |
649 | priority_radiogroup_(nullptr), |
650 | increase_max_fill_(nullptr), |
651 | decrease_max_fill_(nullptr), |
652 | - index_(queue->get_index()), |
653 | - type_(queue->get_type()), |
654 | + index_(queue.get_index()), |
655 | + type_(queue.get_type()), |
656 | max_fill_indicator_(g_gr->images().get(pic_max_fill_indicator)), |
657 | - cache_size_(queue->get_max_size()), |
658 | - cache_max_fill_(queue->get_max_fill()), |
659 | + cache_size_(queue.get_max_size()), |
660 | + cache_max_fill_(queue.get_max_fill()), |
661 | total_height_(0), |
662 | show_only_(show_only) { |
663 | if (type_ == Widelands::wwWARE) { |
664 | const Widelands::WareDescr& ware = |
665 | - *queue->owner().tribe().get_ware_descr(queue_->get_index()); |
666 | + *queue.owner().tribe().get_ware_descr(queue_.get_index()); |
667 | set_tooltip(ware.descname().c_str()); |
668 | icon_ = ware.icon(); |
669 | } else { |
670 | const Widelands::WorkerDescr& worker = |
671 | - *queue->owner().tribe().get_worker_descr(queue_->get_index()); |
672 | + *queue.owner().tribe().get_worker_descr(queue_.get_index()); |
673 | set_tooltip(worker.descname().c_str()); |
674 | icon_ = worker.icon(); |
675 | } |
676 | @@ -92,7 +92,7 @@ |
677 | uint32_t pbs = show_only_ ? 0 : PriorityButtonSize; |
678 | uint32_t ctrl_b_size = show_only_ ? 0 : 2 * WARE_MENU_PIC_WIDTH; |
679 | |
680 | - cache_size_ = queue_->get_max_size(); |
681 | + cache_size_ = queue_.get_max_size(); |
682 | |
683 | update_priority_buttons(); |
684 | update_max_fill_buttons(); |
685 | @@ -109,12 +109,12 @@ |
686 | * Compare the current InputQueue state with the cached state; update if necessary. |
687 | */ |
688 | void InputQueueDisplay::think() { |
689 | - if (static_cast<uint32_t>(queue_->get_max_size()) != cache_size_) |
690 | + if (static_cast<uint32_t>(queue_.get_max_size()) != cache_size_) |
691 | max_size_changed(); |
692 | |
693 | // TODO(sirver): It seems cache_max_fill_ is not really useful for anything. |
694 | - if (static_cast<uint32_t>(queue_->get_max_fill()) != cache_max_fill_) { |
695 | - cache_max_fill_ = queue_->get_max_fill(); |
696 | + if (static_cast<uint32_t>(queue_.get_max_fill()) != cache_max_fill_) { |
697 | + cache_max_fill_ = queue_.get_max_fill(); |
698 | compute_max_fill_buttons_enabled_state(); |
699 | } |
700 | } |
701 | @@ -126,11 +126,11 @@ |
702 | if (!cache_size_) |
703 | return; |
704 | |
705 | - cache_max_fill_ = queue_->get_max_fill(); |
706 | + cache_max_fill_ = queue_.get_max_fill(); |
707 | |
708 | - uint32_t nr_inputs_to_draw = std::min(queue_->get_filled(), cache_size_); |
709 | + uint32_t nr_inputs_to_draw = std::min(queue_.get_filled(), cache_size_); |
710 | uint32_t nr_missing_to_draw = |
711 | - std::min(queue_->get_missing(), cache_max_fill_) + cache_size_ - cache_max_fill_; |
712 | + std::min(queue_.get_missing(), cache_max_fill_) + cache_size_ - cache_max_fill_; |
713 | if (nr_inputs_to_draw > cache_max_fill_) { |
714 | nr_missing_to_draw -= nr_inputs_to_draw - cache_max_fill_; |
715 | } |
716 | @@ -160,7 +160,7 @@ |
717 | uint16_t pw = max_fill_indicator_->width(); |
718 | point.y = Border; |
719 | point.x = Border + CellWidth + CellSpacing + |
720 | - (queue_->get_max_fill() * (CellWidth + CellSpacing)) - CellSpacing / 2 - pw / 2; |
721 | + (queue_.get_max_fill() * (CellWidth + CellSpacing)) - CellSpacing / 2 - pw / 2; |
722 | dst.blit(point, max_fill_indicator_); |
723 | } |
724 | } |
725 | @@ -349,7 +349,7 @@ |
726 | } |
727 | |
728 | void InputQueueDisplay::increase_max_fill_clicked() { |
729 | - assert(cache_max_fill_ < queue_->get_max_size()); |
730 | + assert(cache_max_fill_ < queue_.get_max_size()); |
731 | if (!igb_.can_act(building_.owner().player_number())) { |
732 | return; |
733 | } |
734 | @@ -370,6 +370,6 @@ |
735 | if (decrease_max_fill_) |
736 | decrease_max_fill_->set_enabled(cache_max_fill_ > 0); |
737 | if (increase_max_fill_) |
738 | - increase_max_fill_->set_enabled(cache_max_fill_ < queue_->get_max_size()); |
739 | + increase_max_fill_->set_enabled(cache_max_fill_ < queue_.get_max_size()); |
740 | } |
741 | } |
742 | |
743 | === modified file 'src/wui/inputqueuedisplay.h' |
744 | --- src/wui/inputqueuedisplay.h 2018-04-07 16:59:00 +0000 |
745 | +++ src/wui/inputqueuedisplay.h 2018-09-05 07:39:19 +0000 |
746 | @@ -56,7 +56,7 @@ |
747 | int32_t y, |
748 | InteractiveGameBase& igb, |
749 | Widelands::Building& building, |
750 | - Widelands::InputQueue* queue, |
751 | + const Widelands::InputQueue& queue, |
752 | bool = false); |
753 | ~InputQueueDisplay() override; |
754 | |
755 | @@ -66,7 +66,7 @@ |
756 | private: |
757 | InteractiveGameBase& igb_; |
758 | Widelands::Building& building_; |
759 | - Widelands::InputQueue* queue_; |
760 | + const Widelands::InputQueue& queue_; |
761 | UI::Radiogroup* priority_radiogroup_; |
762 | UI::Button* increase_max_fill_; |
763 | UI::Button* decrease_max_fill_; |
764 | |
765 | === modified file 'src/wui/portdockwaresdisplay.cc' |
766 | --- src/wui/portdockwaresdisplay.cc 2018-04-07 16:59:00 +0000 |
767 | +++ src/wui/portdockwaresdisplay.cc 2018-09-05 07:39:19 +0000 |
768 | @@ -36,24 +36,24 @@ |
769 | * Display wares or workers that are waiting to be shipped from a port. |
770 | */ |
771 | struct PortDockWaresDisplay : AbstractWaresDisplay { |
772 | - PortDockWaresDisplay(Panel* parent, uint32_t width, PortDock& pd, Widelands::WareWorker type); |
773 | + PortDockWaresDisplay(Panel* parent, uint32_t width, const PortDock& pd, Widelands::WareWorker type); |
774 | |
775 | std::string info_for_ware(Widelands::DescriptionIndex ware) override; |
776 | |
777 | private: |
778 | - PortDock& portdock_; |
779 | + const PortDock& portdock_; |
780 | }; |
781 | |
782 | PortDockWaresDisplay::PortDockWaresDisplay(Panel* parent, |
783 | uint32_t width, |
784 | - PortDock& pd, |
785 | + const Widelands::PortDock& pd, |
786 | Widelands::WareWorker type) |
787 | : AbstractWaresDisplay(parent, 0, 0, pd.owner().tribe(), type, false), portdock_(pd) { |
788 | set_inner_size(width, 0); |
789 | } |
790 | |
791 | std::string PortDockWaresDisplay::info_for_ware(Widelands::DescriptionIndex ware) { |
792 | - uint32_t count = portdock_.count_waiting(get_type(), ware); |
793 | + const uint32_t count = portdock_.count_waiting(get_type(), ware); |
794 | return boost::lexical_cast<std::string>(count); |
795 | } |
796 | |
797 | @@ -64,7 +64,7 @@ |
798 | */ |
799 | AbstractWaresDisplay* create_portdock_wares_display(UI::Panel* parent, |
800 | uint32_t width, |
801 | - PortDock& pd, |
802 | + const PortDock& pd, |
803 | Widelands::WareWorker type) { |
804 | return new PortDockWaresDisplay(parent, width, pd, type); |
805 | } |
806 | @@ -75,8 +75,8 @@ |
807 | UI::Box& box = *new UI::Box(parent, 0, 0, UI::Box::Vertical); |
808 | |
809 | // Add the input queues. |
810 | - for (InputQueue* wq : wh.get_portdock()->expedition_bootstrap()->queues()) { |
811 | - box.add(new InputQueueDisplay(&box, 0, 0, igb, wh, wq, true)); |
812 | + for (const InputQueue* wq : wh.get_portdock()->expedition_bootstrap()->queues()) { |
813 | + box.add(new InputQueueDisplay(&box, 0, 0, igb, wh, *wq, true)); |
814 | } |
815 | |
816 | return &box; |
817 | |
818 | === modified file 'src/wui/portdockwaresdisplay.h' |
819 | --- src/wui/portdockwaresdisplay.h 2018-04-07 16:59:00 +0000 |
820 | +++ src/wui/portdockwaresdisplay.h 2018-09-05 07:39:19 +0000 |
821 | @@ -30,7 +30,7 @@ |
822 | |
823 | AbstractWaresDisplay* create_portdock_wares_display(UI::Panel* parent, |
824 | uint32_t width, |
825 | - Widelands::PortDock& pd, |
826 | + const Widelands::PortDock& pd, |
827 | Widelands::WareWorker type); |
828 | |
829 | UI::Box* create_portdock_expedition_display(UI::Panel* parent, |
830 | |
831 | === modified file 'src/wui/productionsitewindow.cc' |
832 | --- src/wui/productionsitewindow.cc 2018-08-14 13:40:46 +0000 |
833 | +++ src/wui/productionsitewindow.cc 2018-09-05 07:39:19 +0000 |
834 | @@ -82,7 +82,7 @@ |
835 | |
836 | for (uint32_t i = 0; i < inputqueues.size(); ++i) { |
837 | prod_box->add( |
838 | - new InputQueueDisplay(prod_box, 0, 0, *igbase(), *production_site, inputqueues[i])); |
839 | + new InputQueueDisplay(prod_box, 0, 0, *igbase(), *production_site, *inputqueues[i])); |
840 | } |
841 | |
842 | get_tabs()->add("wares", g_gr->images().get(pic_tab_wares), prod_box, _("Wares")); |
843 | |
844 | === modified file 'src/wui/warehousewindow.cc' |
845 | --- src/wui/warehousewindow.cc 2018-08-14 13:40:46 +0000 |
846 | +++ src/wui/warehousewindow.cc 2018-09-05 07:39:19 +0000 |
847 | @@ -193,7 +193,7 @@ |
848 | new WarehouseWaresPanel(get_tabs(), Width, *igbase(), *warehouse, Widelands::wwWORKER), |
849 | _("Workers")); |
850 | |
851 | - if (Widelands::PortDock* pd = warehouse->get_portdock()) { |
852 | + if (const Widelands::PortDock* pd = warehouse->get_portdock()) { |
853 | get_tabs()->add("dock_wares", g_gr->images().get(pic_tab_dock_wares), |
854 | create_portdock_wares_display(get_tabs(), Width, *pd, Widelands::wwWARE), |
855 | _("Wares waiting to be shipped")); |
Continuous integration builds have changed state:
Travis build 3899. State: passed. Details: https:/ /travis- ci.org/ widelands/ widelands/ builds/ 424681733. /ci.appveyor. com/project/ widelands- dev/widelands/ build/_ widelands_ dev_widelands_ const_portdock_ fleet_and_ ship_functions- 3697.
Appveyor build 3697. State: failed. Details: https:/