Merge lp:~widelands-dev/widelands/compiler_warnings into lp:widelands
- compiler_warnings
- Merge into trunk
Status: | Merged |
---|---|
Merged at revision: | 7642 |
Proposed branch: | lp:~widelands-dev/widelands/compiler_warnings |
Merge into: | lp:widelands |
Diff against target: |
880 lines (+96/-98) 28 files modified
src/ai/ai_help_structs.h (+2/-2) src/economy/cmd_call_economy_balance.cc (+1/-1) src/economy/cmd_call_economy_balance.h (+1/-1) src/game_io/game_cmd_queue_packet.cc (+1/-1) src/logic/bob.cc (+2/-2) src/logic/cmd_calculate_statistics.h (+1/-1) src/logic/cmd_delete_message.h (+1/-1) src/logic/cmd_incorporate.h (+1/-1) src/logic/cmd_luacoroutine.h (+1/-1) src/logic/cmd_luascript.h (+1/-1) src/logic/cmd_queue.cc (+2/-5) src/logic/cmd_queue.h (+6/-6) src/logic/constructionsite.cc (+0/-1) src/logic/dismantlesite.cc (+0/-1) src/logic/immovable.cc (+8/-4) src/logic/immovable.h (+1/-1) src/logic/instances.cc (+2/-2) src/logic/instances.h (+10/-11) src/logic/playercommand.cc (+10/-10) src/logic/playercommand.h (+29/-29) src/logic/replay_game_controller.h (+1/-1) src/logic/soldier.cc (+6/-6) src/logic/soldier.h (+2/-2) src/logic/worker.cc (+2/-2) src/network/netclient.cc (+2/-2) src/network/nethost.cc (+1/-1) src/network/network.cc (+1/-1) src/network/network.h (+1/-1) |
To merge this branch: | bzr merge lp:~widelands-dev/widelands/compiler_warnings |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
TiborB | Approve | ||
GunChleoc | Needs Resubmitting | ||
Review via email: mp+278240@code.launchpad.net |
Commit message
Description of the change
Fixed compiler warnings.
TiborB (tiborb95) wrote : | # |
GunChleoc (gunchleoc) wrote : | # |
I will redesign this - the reason that I left them as signed int is that this is the way they are saved. It is better if I change the packets though.
GunChleoc (gunchleoc) wrote : | # |
This should be ready for review again. I found a nice article on comparing signed and unsigned values:
http://
So, I made the remaining comparisions safe (where it was not easy or not possible to change the data type).
TiborB (tiborb95) wrote : | # |
I believe m_walkstart, m_walkstart, m_combat_walkend and m_combat_walkstart can also be easily changed to uint32_t... have you considered it?
GunChleoc (gunchleoc) wrote : | # |
Variables like that are all over the code base, we actually have an open bug for this. It isn't always as easy as it looks though, I tried fixing them in the network code and it stopped working. So, better take this in small bits and pieces - resulting bugs might be hard to track down.
TiborB (tiborb95) wrote : | # |
OK, if you tried and it was complicated - good for me..
Preview Diff
1 | === modified file 'src/ai/ai_help_structs.h' |
2 | --- src/ai/ai_help_structs.h 2015-11-21 18:25:56 +0000 |
3 | +++ src/ai/ai_help_structs.h 2015-11-25 10:54:29 +0000 |
4 | @@ -446,8 +446,8 @@ |
5 | |
6 | // used to track amount of wares produced by building |
7 | uint32_t stocklevel_; |
8 | - int32_t stocklevel_time; // time when stocklevel_ was last time recalculated |
9 | - int32_t last_dismantle_time_; |
10 | + uint32_t stocklevel_time; // time when stocklevel_ was last time recalculated |
11 | + uint32_t last_dismantle_time_; |
12 | int32_t construction_decision_time_; |
13 | |
14 | uint32_t unoccupied_count_; |
15 | |
16 | === modified file 'src/economy/cmd_call_economy_balance.cc' |
17 | --- src/economy/cmd_call_economy_balance.cc 2015-10-24 15:42:37 +0000 |
18 | +++ src/economy/cmd_call_economy_balance.cc 2015-11-25 10:54:29 +0000 |
19 | @@ -31,7 +31,7 @@ |
20 | namespace Widelands { |
21 | |
22 | CmdCallEconomyBalance::CmdCallEconomyBalance |
23 | - (int32_t const starttime, Economy * const economy, uint32_t const timerid) |
24 | + (uint32_t const starttime, Economy * const economy, uint32_t const timerid) |
25 | : GameLogicCommand(starttime) |
26 | { |
27 | m_flag = economy->get_arbitrary_flag(); |
28 | |
29 | === modified file 'src/economy/cmd_call_economy_balance.h' |
30 | --- src/economy/cmd_call_economy_balance.h 2014-09-19 12:54:54 +0000 |
31 | +++ src/economy/cmd_call_economy_balance.h 2015-11-25 10:54:29 +0000 |
32 | @@ -33,7 +33,7 @@ |
33 | struct CmdCallEconomyBalance : public GameLogicCommand { |
34 | CmdCallEconomyBalance () : GameLogicCommand(0), m_timerid(0) {} ///< for load and save |
35 | |
36 | - CmdCallEconomyBalance (int32_t starttime, Economy *, uint32_t timerid); |
37 | + CmdCallEconomyBalance (uint32_t starttime, Economy *, uint32_t timerid); |
38 | |
39 | void execute (Game &) override; |
40 | |
41 | |
42 | === modified file 'src/game_io/game_cmd_queue_packet.cc' |
43 | --- src/game_io/game_cmd_queue_packet.cc 2015-10-24 15:42:37 +0000 |
44 | +++ src/game_io/game_cmd_queue_packet.cc 2015-11-25 10:54:29 +0000 |
45 | @@ -94,7 +94,7 @@ |
46 | // Write all commands |
47 | |
48 | // Find all the items in the current cmdqueue |
49 | - int32_t time = game.get_gametime(); |
50 | + uint32_t time = game.get_gametime(); |
51 | size_t nhandled = 0; |
52 | |
53 | while (nhandled < cmdq.m_ncmds) { |
54 | |
55 | === modified file 'src/logic/bob.cc' |
56 | --- src/logic/bob.cc 2015-10-25 08:06:00 +0000 |
57 | +++ src/logic/bob.cc 2015-11-25 10:54:29 +0000 |
58 | @@ -760,7 +760,7 @@ |
59 | |
60 | void Bob::move_update(Game & game, State &) |
61 | { |
62 | - if (m_walkend <= game.get_gametime()) { |
63 | + if (static_cast<uint32_t>(m_walkend) <= game.get_gametime()) { |
64 | end_walk(); |
65 | return pop_task(game); |
66 | } else |
67 | @@ -822,7 +822,7 @@ |
68 | spos.y += end.field->get_height() * HEIGHT_FACTOR; |
69 | spos.y -= start.field->get_height() * HEIGHT_FACTOR; |
70 | |
71 | - assert(m_walkstart <= game.get_gametime()); |
72 | + assert(static_cast<uint32_t>(m_walkstart) <= game.get_gametime()); |
73 | assert(m_walkstart < m_walkend); |
74 | float f = |
75 | static_cast<float>(game.get_gametime() - m_walkstart) |
76 | |
77 | === modified file 'src/logic/cmd_calculate_statistics.h' |
78 | --- src/logic/cmd_calculate_statistics.h 2015-01-31 16:03:59 +0000 |
79 | +++ src/logic/cmd_calculate_statistics.h 2015-11-25 10:54:29 +0000 |
80 | @@ -28,7 +28,7 @@ |
81 | |
82 | struct CmdCalculateStatistics : public GameLogicCommand { |
83 | CmdCalculateStatistics() : GameLogicCommand(0) {} // For savegame loading |
84 | - CmdCalculateStatistics(int32_t const _duetime) : |
85 | + CmdCalculateStatistics(uint32_t const _duetime) : |
86 | GameLogicCommand(_duetime) {} |
87 | |
88 | // Write these commands to a file (for savegames) |
89 | |
90 | === modified file 'src/logic/cmd_delete_message.h' |
91 | --- src/logic/cmd_delete_message.h 2014-09-29 12:37:07 +0000 |
92 | +++ src/logic/cmd_delete_message.h 2015-11-25 10:54:29 +0000 |
93 | @@ -37,7 +37,7 @@ |
94 | /// the savegame. |
95 | struct CmdDeleteMessage : public Command { |
96 | CmdDeleteMessage |
97 | - (int32_t const t, PlayerNumber const p, MessageId const m) |
98 | + (uint32_t const t, PlayerNumber const p, MessageId const m) |
99 | : Command(t), player(p), message(m) |
100 | {} |
101 | |
102 | |
103 | === modified file 'src/logic/cmd_incorporate.h' |
104 | --- src/logic/cmd_incorporate.h 2014-10-03 17:26:18 +0000 |
105 | +++ src/logic/cmd_incorporate.h 2015-11-25 10:54:29 +0000 |
106 | @@ -27,7 +27,7 @@ |
107 | |
108 | struct CmdIncorporate : public GameLogicCommand { |
109 | CmdIncorporate() : GameLogicCommand(0), worker(nullptr) {} // For savegame loading |
110 | - CmdIncorporate (int32_t const t, Worker * const w) |
111 | + CmdIncorporate (uint32_t const t, Worker * const w) |
112 | : GameLogicCommand(t), worker(w) |
113 | {} |
114 | |
115 | |
116 | === modified file 'src/logic/cmd_luacoroutine.h' |
117 | --- src/logic/cmd_luacoroutine.h 2015-01-31 16:03:59 +0000 |
118 | +++ src/logic/cmd_luacoroutine.h 2015-11-25 10:54:29 +0000 |
119 | @@ -29,7 +29,7 @@ |
120 | |
121 | struct CmdLuaCoroutine : public GameLogicCommand { |
122 | CmdLuaCoroutine() : GameLogicCommand(0), m_cr(nullptr) {} // For savegame loading |
123 | - CmdLuaCoroutine(int32_t const _duetime, LuaCoroutine * const cr) : |
124 | + CmdLuaCoroutine(uint32_t const _duetime, LuaCoroutine * const cr) : |
125 | GameLogicCommand(_duetime), m_cr(cr) {} |
126 | |
127 | ~CmdLuaCoroutine() { |
128 | |
129 | === modified file 'src/logic/cmd_luascript.h' |
130 | --- src/logic/cmd_luascript.h 2014-09-19 12:54:54 +0000 |
131 | +++ src/logic/cmd_luascript.h 2015-11-25 10:54:29 +0000 |
132 | @@ -29,7 +29,7 @@ |
133 | struct CmdLuaScript : public GameLogicCommand { |
134 | CmdLuaScript() : GameLogicCommand(0) {} // For savegame loading |
135 | CmdLuaScript |
136 | - (int32_t const _duetime, const std::string& script) : |
137 | + (uint32_t const _duetime, const std::string& script) : |
138 | GameLogicCommand(_duetime), script_(script) {} |
139 | |
140 | // Write these commands to a file (for savegames) |
141 | |
142 | === modified file 'src/logic/cmd_queue.cc' |
143 | --- src/logic/cmd_queue.cc 2015-11-14 15:58:29 +0000 |
144 | +++ src/logic/cmd_queue.cc 2015-11-25 10:54:29 +0000 |
145 | @@ -98,9 +98,8 @@ |
146 | ++ m_ncmds; |
147 | } |
148 | |
149 | -int32_t CmdQueue::run_queue(int32_t const interval, uint32_t & game_time_var) { |
150 | +void CmdQueue::run_queue(int32_t const interval, uint32_t & game_time_var) { |
151 | uint32_t const final = game_time_var + interval; |
152 | - int32_t cnt = 0; |
153 | |
154 | while (game_time_var < final) { |
155 | std::priority_queue<CmdItem> & current_cmds = m_cmds[game_time_var % CMD_QUEUE_BUCKET_SIZE]; |
156 | @@ -131,8 +130,6 @@ |
157 | |
158 | assert(final - game_time_var == 0); |
159 | game_time_var = final; |
160 | - |
161 | - return cnt; |
162 | } |
163 | |
164 | |
165 | @@ -173,7 +170,7 @@ |
166 | uint16_t const packet_version = fr.unsigned_16(); |
167 | if (packet_version == kCurrentPacketVersion) { |
168 | set_duetime(fr.unsigned_32()); |
169 | - int32_t const gametime = egbase.get_gametime(); |
170 | + uint32_t const gametime = egbase.get_gametime(); |
171 | if (duetime() < gametime) |
172 | throw GameDataError |
173 | ("duetime (%i) < gametime (%i)", duetime(), gametime); |
174 | |
175 | === modified file 'src/logic/cmd_queue.h' |
176 | --- src/logic/cmd_queue.h 2015-11-14 15:58:29 +0000 |
177 | +++ src/logic/cmd_queue.h 2015-11-25 10:54:29 +0000 |
178 | @@ -85,17 +85,17 @@ |
179 | * the same for all parallel simulation. |
180 | */ |
181 | struct Command { |
182 | - Command (const int32_t _duetime) : m_duetime(_duetime) {} |
183 | + Command (const uint32_t _duetime) : m_duetime(_duetime) {} |
184 | virtual ~Command (); |
185 | |
186 | virtual void execute (Game &) = 0; |
187 | virtual uint8_t id() const = 0; |
188 | |
189 | - int32_t duetime() const {return m_duetime;} |
190 | - void set_duetime(int32_t const t) {m_duetime = t;} |
191 | + uint32_t duetime() const {return m_duetime;} |
192 | + void set_duetime(uint32_t const t) {m_duetime = t;} |
193 | |
194 | private: |
195 | - int32_t m_duetime; |
196 | + uint32_t m_duetime; |
197 | }; |
198 | |
199 | |
200 | @@ -107,7 +107,7 @@ |
201 | * for all instances of a game to ensure parallel simulation. |
202 | */ |
203 | struct GameLogicCommand : public Command { |
204 | - GameLogicCommand (int32_t const _duetime) : Command(_duetime) {} |
205 | + GameLogicCommand (uint32_t const _duetime) : Command(_duetime) {} |
206 | |
207 | // Write these commands to a file (for savegames) |
208 | virtual void write |
209 | @@ -158,7 +158,7 @@ |
210 | // the internal time as well. the game_time_var represents the current game |
211 | // time, which we update and with which we must mess around (to run all |
212 | // queued cmd.s) and which we update (add the interval) |
213 | - int32_t run_queue(int32_t interval, uint32_t & game_time_var); |
214 | + void run_queue(int32_t interval, uint32_t & game_time_var); |
215 | |
216 | void flush(); // delete all commands in the queue now |
217 | |
218 | |
219 | === modified file 'src/logic/constructionsite.cc' |
220 | --- src/logic/constructionsite.cc 2015-11-11 09:53:54 +0000 |
221 | +++ src/logic/constructionsite.cc 2015-11-25 10:54:29 +0000 |
222 | @@ -322,7 +322,6 @@ |
223 | void ConstructionSite::draw |
224 | (const EditorGameBase & game, RenderTarget & dst, const FCoords& coords, const Point& pos) |
225 | { |
226 | - assert(0 <= game.get_gametime()); |
227 | const uint32_t gametime = game.get_gametime(); |
228 | uint32_t tanim = gametime - m_animstart; |
229 | |
230 | |
231 | === modified file 'src/logic/dismantlesite.cc' |
232 | --- src/logic/dismantlesite.cc 2015-11-11 09:53:54 +0000 |
233 | +++ src/logic/dismantlesite.cc 2015-11-25 10:54:29 +0000 |
234 | @@ -232,7 +232,6 @@ |
235 | void DismantleSite::draw |
236 | (const EditorGameBase& game, RenderTarget& dst, const FCoords& coords, const Point& pos) |
237 | { |
238 | - assert(0 <= game.get_gametime()); |
239 | const uint32_t gametime = game.get_gametime(); |
240 | uint32_t tanim = gametime - m_animstart; |
241 | |
242 | |
243 | === modified file 'src/logic/immovable.cc' |
244 | --- src/logic/immovable.cc 2015-11-14 15:58:29 +0000 |
245 | +++ src/logic/immovable.cc 2015-11-25 10:54:29 +0000 |
246 | @@ -524,7 +524,7 @@ |
247 | ============================== |
248 | */ |
249 | |
250 | -constexpr uint8_t kCurrentPacketVersionImmovable = 6; |
251 | +constexpr uint8_t kCurrentPacketVersionImmovable = 7; |
252 | |
253 | // Supporting older versions for map loading |
254 | void Immovable::Loader::load(FileRead & fr, uint8_t const packet_version) |
255 | @@ -596,9 +596,13 @@ |
256 | } |
257 | } |
258 | |
259 | - imm.m_program_step = fr.signed_32(); |
260 | + if (packet_version > 6) { |
261 | + imm.m_program_step = fr.unsigned_32(); |
262 | + } else { |
263 | + imm.m_program_step = fr.signed_32(); |
264 | + } |
265 | |
266 | - if (packet_version >= 3 && packet_version <= 5){ |
267 | + if (packet_version >= 3 && packet_version <= 5) { |
268 | imm.m_reserved_by_worker = fr.unsigned_8(); |
269 | } |
270 | if (packet_version >= 4) { |
271 | @@ -661,7 +665,7 @@ |
272 | fw.string(m_program ? m_program->name() : ""); |
273 | |
274 | fw.unsigned_32(m_program_ptr); |
275 | - fw.signed_32(m_program_step); |
276 | + fw.unsigned_32(m_program_step); |
277 | |
278 | if (m_action_data) { |
279 | fw.c_string(m_action_data->name()); |
280 | |
281 | === modified file 'src/logic/immovable.h' |
282 | --- src/logic/immovable.h 2015-11-11 09:52:55 +0000 |
283 | +++ src/logic/immovable.h 2015-11-25 10:54:29 +0000 |
284 | @@ -239,7 +239,7 @@ |
285 | #else |
286 | uint32_t m_anim_construction_total; |
287 | uint32_t m_anim_construction_done; |
288 | - int32_t m_program_step; ///< time of next step |
289 | + uint32_t m_program_step; ///< time of next step |
290 | #endif |
291 | std::string m_construct_string; |
292 | |
293 | |
294 | === modified file 'src/logic/instances.cc' |
295 | --- src/logic/instances.cc 2015-11-20 18:16:22 +0000 |
296 | +++ src/logic/instances.cc 2015-11-25 10:54:29 +0000 |
297 | @@ -40,7 +40,7 @@ |
298 | namespace Widelands { |
299 | |
300 | CmdDestroyMapObject::CmdDestroyMapObject |
301 | - (int32_t const t, MapObject & o) |
302 | + (uint32_t const t, MapObject & o) |
303 | : GameLogicCommand(t), obj_serial(o.serial()) |
304 | {} |
305 | |
306 | @@ -90,7 +90,7 @@ |
307 | fw.unsigned_32(mos.get_object_file_index_or_zero(egbase.objects().get_object(obj_serial))); |
308 | } |
309 | |
310 | -CmdAct::CmdAct(int32_t const t, MapObject & o, int32_t const a) : |
311 | +CmdAct::CmdAct(uint32_t const t, MapObject & o, int32_t const a) : |
312 | GameLogicCommand(t), obj_serial(o.serial()), arg(a) |
313 | {} |
314 | |
315 | |
316 | === modified file 'src/logic/instances.h' |
317 | --- src/logic/instances.h 2015-10-24 21:42:55 +0000 |
318 | +++ src/logic/instances.h 2015-11-25 10:54:29 +0000 |
319 | @@ -307,15 +307,6 @@ |
320 | HeaderFleet = 11, |
321 | }; |
322 | |
323 | - protected: |
324 | - /** |
325 | - * MapObjects like trees are reserved by a worker that is walking |
326 | - * towards them, so that e.g. two lumberjacks don't attempt to |
327 | - * work on the same tree simultaneously or two hunters try to hunt |
328 | - * the same animal. |
329 | - */ |
330 | - bool m_reserved_by_worker; |
331 | - |
332 | public: |
333 | |
334 | /** |
335 | @@ -394,6 +385,14 @@ |
336 | Serial m_serial; |
337 | LogSink * m_logsink; |
338 | |
339 | + /** |
340 | + * MapObjects like trees are reserved by a worker that is walking |
341 | + * towards them, so that e.g. two lumberjacks don't attempt to |
342 | + * work on the same tree simultaneously or two hunters try to hunt |
343 | + * the same animal. |
344 | + */ |
345 | + bool m_reserved_by_worker; |
346 | + |
347 | private: |
348 | DISALLOW_COPY_AND_ASSIGN(MapObject); |
349 | }; |
350 | @@ -515,7 +514,7 @@ |
351 | |
352 | struct CmdDestroyMapObject : public GameLogicCommand { |
353 | CmdDestroyMapObject() : GameLogicCommand(0), obj_serial(0) {} ///< For savegame loading |
354 | - CmdDestroyMapObject (int32_t t, MapObject &); |
355 | + CmdDestroyMapObject (uint32_t t, MapObject &); |
356 | void execute (Game &) override; |
357 | |
358 | void write(FileWrite &, EditorGameBase &, MapObjectSaver &) override; |
359 | @@ -529,7 +528,7 @@ |
360 | |
361 | struct CmdAct : public GameLogicCommand { |
362 | CmdAct() : GameLogicCommand(0), obj_serial(0), arg(0) {} ///< For savegame loading |
363 | - CmdAct (int32_t t, MapObject &, int32_t a); |
364 | + CmdAct (uint32_t t, MapObject &, int32_t a); |
365 | |
366 | void execute (Game &) override; |
367 | |
368 | |
369 | === modified file 'src/logic/playercommand.cc' |
370 | --- src/logic/playercommand.cc 2015-11-11 09:52:55 +0000 |
371 | +++ src/logic/playercommand.cc 2015-11-25 10:54:29 +0000 |
372 | @@ -93,7 +93,7 @@ |
373 | |
374 | /*** class PlayerCommand ***/ |
375 | |
376 | -PlayerCommand::PlayerCommand (const int32_t time, const PlayerNumber s) |
377 | +PlayerCommand::PlayerCommand (const uint32_t time, const PlayerNumber s) |
378 | : GameLogicCommand (time), m_sender(s), m_cmdserial(0) |
379 | {} |
380 | |
381 | @@ -330,7 +330,7 @@ |
382 | |
383 | /*** class Cmd_BuildRoad ***/ |
384 | |
385 | -CmdBuildRoad::CmdBuildRoad (int32_t t, int32_t p, Path & pa) : |
386 | +CmdBuildRoad::CmdBuildRoad (uint32_t t, int32_t p, Path & pa) : |
387 | PlayerCommand(t, p), |
388 | path (&pa), |
389 | start (pa.get_start()), |
390 | @@ -1122,7 +1122,7 @@ |
391 | |
392 | /*** class Cmd_SetWarePriority ***/ |
393 | CmdSetWarePriority::CmdSetWarePriority |
394 | - (const int32_t _duetime, const PlayerNumber _sender, |
395 | + (const uint32_t _duetime, const PlayerNumber _sender, |
396 | PlayerImmovable & imm, |
397 | const int32_t type, const DescriptionIndex index, const int32_t priority) |
398 | : |
399 | @@ -1201,7 +1201,7 @@ |
400 | |
401 | /*** class Cmd_SetWareMaxFill ***/ |
402 | CmdSetWareMaxFill::CmdSetWareMaxFill |
403 | - (const int32_t _duetime, const PlayerNumber _sender, |
404 | + (const uint32_t _duetime, const PlayerNumber _sender, |
405 | PlayerImmovable & imm, |
406 | const DescriptionIndex index, const uint32_t max_fill) |
407 | : |
408 | @@ -1274,7 +1274,7 @@ |
409 | |
410 | |
411 | CmdChangeTargetQuantity::CmdChangeTargetQuantity |
412 | - (const int32_t _duetime, const PlayerNumber _sender, |
413 | + (const uint32_t _duetime, const PlayerNumber _sender, |
414 | const uint32_t _economy, const DescriptionIndex _ware_type) |
415 | : |
416 | PlayerCommand(_duetime, _sender), |
417 | @@ -1319,7 +1319,7 @@ |
418 | |
419 | |
420 | CmdSetWareTargetQuantity::CmdSetWareTargetQuantity |
421 | - (const int32_t _duetime, const PlayerNumber _sender, |
422 | + (const uint32_t _duetime, const PlayerNumber _sender, |
423 | const uint32_t _economy, |
424 | const DescriptionIndex _ware_type, |
425 | const uint32_t _permanent) |
426 | @@ -1381,7 +1381,7 @@ |
427 | |
428 | |
429 | CmdResetWareTargetQuantity::CmdResetWareTargetQuantity |
430 | - (const int32_t _duetime, const PlayerNumber _sender, |
431 | + (const uint32_t _duetime, const PlayerNumber _sender, |
432 | const uint32_t _economy, |
433 | const DescriptionIndex _ware_type) |
434 | : |
435 | @@ -1437,7 +1437,7 @@ |
436 | |
437 | |
438 | CmdSetWorkerTargetQuantity::CmdSetWorkerTargetQuantity |
439 | - (const int32_t _duetime, const PlayerNumber _sender, |
440 | + (const uint32_t _duetime, const PlayerNumber _sender, |
441 | const uint32_t _economy, |
442 | const DescriptionIndex _ware_type, |
443 | const uint32_t _permanent) |
444 | @@ -1499,7 +1499,7 @@ |
445 | |
446 | |
447 | CmdResetWorkerTargetQuantity::CmdResetWorkerTargetQuantity |
448 | - (const int32_t _duetime, const PlayerNumber _sender, |
449 | + (const uint32_t _duetime, const PlayerNumber _sender, |
450 | const uint32_t _economy, |
451 | const DescriptionIndex _ware_type) |
452 | : |
453 | @@ -1894,7 +1894,7 @@ |
454 | |
455 | /*** struct Cmd_SetStockPolicy ***/ |
456 | CmdSetStockPolicy::CmdSetStockPolicy |
457 | - (int32_t time, PlayerNumber p, |
458 | + (uint32_t time, PlayerNumber p, |
459 | Warehouse & wh, bool isworker, DescriptionIndex ware, |
460 | Warehouse::StockPolicy policy) |
461 | : PlayerCommand(time, p) |
462 | |
463 | === modified file 'src/logic/playercommand.h' |
464 | --- src/logic/playercommand.h 2015-11-11 09:53:54 +0000 |
465 | +++ src/logic/playercommand.h 2015-11-25 10:54:29 +0000 |
466 | @@ -44,7 +44,7 @@ |
467 | */ |
468 | class PlayerCommand : public GameLogicCommand { |
469 | public: |
470 | - PlayerCommand (int32_t time, PlayerNumber); |
471 | + PlayerCommand (uint32_t time, PlayerNumber); |
472 | |
473 | /// For savegame loading |
474 | PlayerCommand() : GameLogicCommand(0), m_sender(0), m_cmdserial(0) {} |
475 | @@ -68,7 +68,7 @@ |
476 | struct CmdBulldoze:public PlayerCommand { |
477 | CmdBulldoze() : PlayerCommand(), serial(0), recurse(0) {} // For savegame loading |
478 | CmdBulldoze |
479 | - (const int32_t t, const int32_t p, |
480 | + (const uint32_t t, const int32_t p, |
481 | PlayerImmovable & pi, |
482 | const bool _recurse = false) |
483 | : PlayerCommand(t, p), serial(pi.serial()), recurse(_recurse) |
484 | @@ -92,7 +92,7 @@ |
485 | struct CmdBuild:public PlayerCommand { |
486 | CmdBuild() : PlayerCommand() {} // For savegame loading |
487 | CmdBuild |
488 | - (const int32_t _duetime, |
489 | + (const uint32_t _duetime, |
490 | const int32_t p, |
491 | const Coords c, |
492 | const DescriptionIndex i) |
493 | @@ -116,7 +116,7 @@ |
494 | |
495 | struct CmdBuildFlag:public PlayerCommand { |
496 | CmdBuildFlag() : PlayerCommand() {} // For savegame loading |
497 | - CmdBuildFlag (const int32_t t, const int32_t p, const Coords c) : |
498 | + CmdBuildFlag (const uint32_t t, const int32_t p, const Coords c) : |
499 | PlayerCommand(t, p), coords(c) |
500 | {} |
501 | |
502 | @@ -137,7 +137,7 @@ |
503 | struct CmdBuildRoad:public PlayerCommand { |
504 | CmdBuildRoad() : |
505 | PlayerCommand(), path(nullptr), start(), nsteps(0), steps(nullptr) {} // For savegame loading |
506 | - CmdBuildRoad (int32_t, int32_t, Path &); |
507 | + CmdBuildRoad (uint32_t, int32_t, Path &); |
508 | CmdBuildRoad (StreamRead &); |
509 | |
510 | virtual ~CmdBuildRoad (); |
511 | @@ -159,7 +159,7 @@ |
512 | |
513 | struct CmdFlagAction : public PlayerCommand { |
514 | CmdFlagAction() : PlayerCommand(), serial(0) {} // For savegame loading |
515 | - CmdFlagAction (const int32_t t, const int32_t p, const Flag & f) : |
516 | + CmdFlagAction (const uint32_t t, const int32_t p, const Flag & f) : |
517 | PlayerCommand(t, p), serial(f.serial()) |
518 | {} |
519 | |
520 | @@ -180,7 +180,7 @@ |
521 | |
522 | struct CmdStartStopBuilding : public PlayerCommand { |
523 | CmdStartStopBuilding() : PlayerCommand(), serial(0) {} // For savegame loading |
524 | - CmdStartStopBuilding (const int32_t t, const PlayerNumber p, Building & b) |
525 | + CmdStartStopBuilding (const uint32_t t, const PlayerNumber p, Building & b) |
526 | : PlayerCommand(t, p), serial(b.serial()) |
527 | {} |
528 | |
529 | @@ -200,7 +200,7 @@ |
530 | |
531 | struct CmdMilitarySiteSetSoldierPreference : public PlayerCommand { |
532 | CmdMilitarySiteSetSoldierPreference() : PlayerCommand(), serial(0) {} // For savegame loading |
533 | - CmdMilitarySiteSetSoldierPreference (const int32_t t, const PlayerNumber p, Building & b, uint8_t prefs) |
534 | + CmdMilitarySiteSetSoldierPreference (const uint32_t t, const PlayerNumber p, Building & b, uint8_t prefs) |
535 | : PlayerCommand(t, p), serial(b.serial()), preference(prefs) |
536 | {} |
537 | |
538 | @@ -220,7 +220,7 @@ |
539 | }; |
540 | struct CmdStartOrCancelExpedition : public PlayerCommand { |
541 | CmdStartOrCancelExpedition() : PlayerCommand() {} // For savegame loading |
542 | - CmdStartOrCancelExpedition (int32_t const t, PlayerNumber const p, Building & b) |
543 | + CmdStartOrCancelExpedition (uint32_t const t, PlayerNumber const p, Building & b) |
544 | : PlayerCommand(t, p), serial(b.serial()) |
545 | {} |
546 | |
547 | @@ -241,7 +241,7 @@ |
548 | struct CmdEnhanceBuilding:public PlayerCommand { |
549 | CmdEnhanceBuilding() : PlayerCommand(), serial(0) {} // For savegame loading |
550 | CmdEnhanceBuilding |
551 | - (const int32_t _duetime, |
552 | + (const uint32_t _duetime, |
553 | const int32_t p, |
554 | Building & b, |
555 | const DescriptionIndex i) |
556 | @@ -267,7 +267,7 @@ |
557 | struct CmdDismantleBuilding:public PlayerCommand { |
558 | CmdDismantleBuilding() : PlayerCommand(), serial(0) {} // For savegame loading |
559 | CmdDismantleBuilding |
560 | - (const int32_t t, const int32_t p, |
561 | + (const uint32_t t, const int32_t p, |
562 | PlayerImmovable & pi) |
563 | : PlayerCommand(t, p), serial(pi.serial()) |
564 | {} |
565 | @@ -290,7 +290,7 @@ |
566 | struct CmdEvictWorker : public PlayerCommand { |
567 | CmdEvictWorker() : PlayerCommand(), serial(0) {} // For savegame loading |
568 | CmdEvictWorker |
569 | - (const int32_t t, const int32_t p, |
570 | + (const uint32_t t, const int32_t p, |
571 | Worker & w) |
572 | : PlayerCommand(t, p), serial(w.serial()) |
573 | {} |
574 | @@ -313,7 +313,7 @@ |
575 | struct CmdShipScoutDirection : public PlayerCommand { |
576 | CmdShipScoutDirection() : PlayerCommand(), serial(0) {} // For savegame loading |
577 | CmdShipScoutDirection |
578 | - (int32_t const t, PlayerNumber const p, Serial s, WalkingDir direction) |
579 | + (uint32_t const t, PlayerNumber const p, Serial s, WalkingDir direction) |
580 | : PlayerCommand(t, p), serial(s), dir(direction) |
581 | {} |
582 | |
583 | @@ -335,7 +335,7 @@ |
584 | struct CmdShipConstructPort : public PlayerCommand { |
585 | CmdShipConstructPort() : PlayerCommand(), serial(0) {} // For savegame loading |
586 | CmdShipConstructPort |
587 | - (int32_t const t, PlayerNumber const p, Serial s, Coords c) |
588 | + (uint32_t const t, PlayerNumber const p, Serial s, Coords c) |
589 | : PlayerCommand(t, p), serial(s), coords(c) |
590 | {} |
591 | |
592 | @@ -357,7 +357,7 @@ |
593 | struct CmdShipExploreIsland : public PlayerCommand { |
594 | CmdShipExploreIsland() : PlayerCommand(), serial(0) {} // For savegame loading |
595 | CmdShipExploreIsland |
596 | - (int32_t const t, PlayerNumber const p, Serial s, IslandExploreDirection direction) |
597 | + (uint32_t const t, PlayerNumber const p, Serial s, IslandExploreDirection direction) |
598 | : PlayerCommand(t, p), serial(s), island_explore_direction(direction) |
599 | {} |
600 | |
601 | @@ -379,7 +379,7 @@ |
602 | struct CmdShipSink : public PlayerCommand { |
603 | CmdShipSink() : PlayerCommand(), serial(0) {} // For savegame loading |
604 | CmdShipSink |
605 | - (int32_t const t, PlayerNumber const p, Serial s) |
606 | + (uint32_t const t, PlayerNumber const p, Serial s) |
607 | : PlayerCommand(t, p), serial(s) |
608 | {} |
609 | |
610 | @@ -400,7 +400,7 @@ |
611 | struct CmdShipCancelExpedition : public PlayerCommand { |
612 | CmdShipCancelExpedition() : PlayerCommand(), serial(0) {} // For savegame loading |
613 | CmdShipCancelExpedition |
614 | - (int32_t const t, PlayerNumber const p, Serial s) |
615 | + (uint32_t const t, PlayerNumber const p, Serial s) |
616 | : PlayerCommand(t, p), serial(s) |
617 | {} |
618 | |
619 | @@ -428,7 +428,7 @@ |
620 | m_priority(0) |
621 | {} |
622 | CmdSetWarePriority |
623 | - (int32_t duetime, PlayerNumber sender, |
624 | + (uint32_t duetime, PlayerNumber sender, |
625 | PlayerImmovable &, |
626 | int32_t type, DescriptionIndex index, int32_t priority); |
627 | |
628 | @@ -453,7 +453,7 @@ |
629 | struct CmdSetWareMaxFill : public PlayerCommand { |
630 | CmdSetWareMaxFill() : PlayerCommand(), m_serial(0), m_index(), m_max_fill(0) {} // For savegame loading |
631 | CmdSetWareMaxFill |
632 | - (int32_t duetime, PlayerNumber, |
633 | + (uint32_t duetime, PlayerNumber, |
634 | PlayerImmovable &, |
635 | DescriptionIndex, uint32_t maxfill); |
636 | |
637 | @@ -477,7 +477,7 @@ |
638 | struct CmdChangeTargetQuantity : public PlayerCommand { |
639 | CmdChangeTargetQuantity() : PlayerCommand(), m_economy(0), m_ware_type() {} // For savegame loading. |
640 | CmdChangeTargetQuantity |
641 | - (int32_t duetime, PlayerNumber sender, |
642 | + (uint32_t duetime, PlayerNumber sender, |
643 | uint32_t economy, DescriptionIndex index); |
644 | |
645 | // Write/Read these commands to/from a file (for savegames). |
646 | @@ -501,7 +501,7 @@ |
647 | struct CmdSetWareTargetQuantity : public CmdChangeTargetQuantity { |
648 | CmdSetWareTargetQuantity() : CmdChangeTargetQuantity(), m_permanent(0) {} |
649 | CmdSetWareTargetQuantity |
650 | - (int32_t duetime, PlayerNumber sender, |
651 | + (uint32_t duetime, PlayerNumber sender, |
652 | uint32_t economy, DescriptionIndex index, |
653 | uint32_t permanent); |
654 | |
655 | @@ -523,7 +523,7 @@ |
656 | struct CmdResetWareTargetQuantity : public CmdChangeTargetQuantity { |
657 | CmdResetWareTargetQuantity() : CmdChangeTargetQuantity() {} |
658 | CmdResetWareTargetQuantity |
659 | - (int32_t duetime, PlayerNumber sender, |
660 | + (uint32_t duetime, PlayerNumber sender, |
661 | uint32_t economy, DescriptionIndex index); |
662 | |
663 | // Write/Read these commands to/from a file (for savegames). |
664 | @@ -541,7 +541,7 @@ |
665 | struct CmdSetWorkerTargetQuantity : public CmdChangeTargetQuantity { |
666 | CmdSetWorkerTargetQuantity() : CmdChangeTargetQuantity(), m_permanent(0) {} |
667 | CmdSetWorkerTargetQuantity |
668 | - (int32_t duetime, PlayerNumber sender, |
669 | + (uint32_t duetime, PlayerNumber sender, |
670 | uint32_t economy, DescriptionIndex index, |
671 | uint32_t permanent); |
672 | |
673 | @@ -563,7 +563,7 @@ |
674 | struct CmdResetWorkerTargetQuantity : public CmdChangeTargetQuantity { |
675 | CmdResetWorkerTargetQuantity() : CmdChangeTargetQuantity() {} |
676 | CmdResetWorkerTargetQuantity |
677 | - (int32_t duetime, PlayerNumber sender, |
678 | + (uint32_t duetime, PlayerNumber sender, |
679 | uint32_t economy, DescriptionIndex index); |
680 | |
681 | // Write/Read these commands to/from a file (for savegames). |
682 | @@ -581,7 +581,7 @@ |
683 | struct CmdChangeTrainingOptions : public PlayerCommand { |
684 | CmdChangeTrainingOptions() : PlayerCommand(), serial(0), attribute(0), value(0) {} // For savegame loading |
685 | CmdChangeTrainingOptions |
686 | - (const int32_t t, |
687 | + (const uint32_t t, |
688 | const PlayerNumber p, |
689 | TrainingSite & ts, |
690 | const int32_t at, |
691 | @@ -609,7 +609,7 @@ |
692 | struct CmdDropSoldier : public PlayerCommand { |
693 | CmdDropSoldier () : PlayerCommand(), serial(0), soldier(0) {} // for savegames |
694 | CmdDropSoldier |
695 | - (const int32_t t, |
696 | + (const uint32_t t, |
697 | const int32_t p, |
698 | Building & b, |
699 | const int32_t _soldier) |
700 | @@ -635,7 +635,7 @@ |
701 | struct CmdChangeSoldierCapacity : public PlayerCommand { |
702 | CmdChangeSoldierCapacity () : PlayerCommand(), serial(0), val(0) {} // for savegames |
703 | CmdChangeSoldierCapacity |
704 | - (const int32_t t, const int32_t p, Building & b, const int32_t i) |
705 | + (const uint32_t t, const int32_t p, Building & b, const int32_t i) |
706 | : PlayerCommand(t, p), serial(b.serial()), val(i) |
707 | {} |
708 | |
709 | @@ -658,7 +658,7 @@ |
710 | /////////////TESTING STUFF |
711 | struct CmdEnemyFlagAction : public PlayerCommand { |
712 | CmdEnemyFlagAction() : PlayerCommand(), serial(0), number(0) {} // For savegame loading |
713 | - CmdEnemyFlagAction(int32_t t, int32_t p, const Flag& f, uint32_t num) |
714 | + CmdEnemyFlagAction(uint32_t t, int32_t p, const Flag& f, uint32_t num) |
715 | : PlayerCommand(t, p), serial(f.serial()), number(num) { |
716 | } |
717 | |
718 | @@ -733,7 +733,7 @@ |
719 | */ |
720 | struct CmdSetStockPolicy : PlayerCommand { |
721 | CmdSetStockPolicy |
722 | - (int32_t time, PlayerNumber p, |
723 | + (uint32_t time, PlayerNumber p, |
724 | Warehouse & wh, bool isworker, DescriptionIndex ware, |
725 | Warehouse::StockPolicy policy); |
726 | |
727 | |
728 | === modified file 'src/logic/replay_game_controller.h' |
729 | --- src/logic/replay_game_controller.h 2015-03-01 09:21:20 +0000 |
730 | +++ src/logic/replay_game_controller.h 2015-11-25 10:54:29 +0000 |
731 | @@ -46,7 +46,7 @@ |
732 | |
733 | private: |
734 | struct CmdReplayEnd : public Widelands::Command { |
735 | - CmdReplayEnd (int32_t const _duetime) : Widelands::Command(_duetime) {} |
736 | + CmdReplayEnd (uint32_t const _duetime) : Widelands::Command(_duetime) {} |
737 | virtual void execute (Widelands::Game & game); |
738 | virtual uint8_t id() const; |
739 | }; |
740 | |
741 | === modified file 'src/logic/soldier.cc' |
742 | --- src/logic/soldier.cc 2015-10-25 08:06:00 +0000 |
743 | +++ src/logic/soldier.cc 2015-11-25 10:54:29 +0000 |
744 | @@ -1317,7 +1317,7 @@ |
745 | |
746 | void Soldier::move_in_battle_update(Game & game, State &) |
747 | { |
748 | - if (static_cast<int32_t>(game.get_gametime() - m_combat_walkend) >= 0) { |
749 | + if (game.get_gametime() >= m_combat_walkend) { |
750 | switch (m_combat_walking) { |
751 | case CD_NONE: |
752 | break; |
753 | @@ -1590,7 +1590,7 @@ |
754 | signal_handled(); |
755 | } |
756 | |
757 | - if (state.ivar1 > game.get_gametime()) |
758 | + if ((state.ivar1 >= 0) && (static_cast<uint32_t>(state.ivar1) > game.get_gametime())) |
759 | return schedule_act(game, state.ivar1 - game.get_gametime()); |
760 | |
761 | // When task updated, dead is near! |
762 | @@ -1804,8 +1804,8 @@ |
763 | |
764 | soldier.m_combat_walking = static_cast<CombatWalkingDir>(fr.unsigned_8()); |
765 | if (soldier.m_combat_walking != CD_NONE) { |
766 | - soldier.m_combat_walkstart = fr.signed_32(); |
767 | - soldier.m_combat_walkend = fr.signed_32(); |
768 | + soldier.m_combat_walkstart = fr.unsigned_32(); |
769 | + soldier.m_combat_walkend = fr.unsigned_32(); |
770 | } |
771 | |
772 | m_battle = fr.unsigned_32(); |
773 | @@ -1856,8 +1856,8 @@ |
774 | |
775 | fw.unsigned_8(m_combat_walking); |
776 | if (m_combat_walking != CD_NONE) { |
777 | - fw.signed_32(m_combat_walkstart); |
778 | - fw.signed_32(m_combat_walkend); |
779 | + fw.unsigned_32(m_combat_walkstart); |
780 | + fw.unsigned_32(m_combat_walkend); |
781 | } |
782 | |
783 | fw.unsigned_32(mos.get_object_file_index_or_zero(m_battle)); |
784 | |
785 | === modified file 'src/logic/soldier.h' |
786 | --- src/logic/soldier.h 2015-10-21 16:43:30 +0000 |
787 | +++ src/logic/soldier.h 2015-11-25 10:54:29 +0000 |
788 | @@ -278,8 +278,8 @@ |
789 | /// the new states. I thought that it is cleaner to have this variable |
790 | /// separate. |
791 | CombatWalkingDir m_combat_walking; |
792 | - int32_t m_combat_walkstart; |
793 | - int32_t m_combat_walkend; |
794 | + uint32_t m_combat_walkstart; |
795 | + uint32_t m_combat_walkend; |
796 | |
797 | /** |
798 | * If the soldier is involved in a challenge, it is assigned a battle |
799 | |
800 | === modified file 'src/logic/worker.cc' |
801 | --- src/logic/worker.cc 2015-11-11 09:56:22 +0000 |
802 | +++ src/logic/worker.cc 2015-11-25 10:54:29 +0000 |
803 | @@ -1938,7 +1938,7 @@ |
804 | for (;;) { |
805 | const WorkerProgram & program = dynamic_cast<const WorkerProgram&>(*state.program); |
806 | |
807 | - if (static_cast<uint32_t>(state.ivar1) >= program.get_size()) |
808 | + if ((state.ivar1 >= 0) && (static_cast<uint32_t>(state.ivar1) >= program.get_size())) |
809 | return pop_task(game); |
810 | |
811 | const Action & action = *program.get_action(state.ivar1); |
812 | @@ -2613,7 +2613,7 @@ |
813 | } |
814 | } |
815 | |
816 | - if (state.ivar1 < game.get_gametime()) { // time to die? |
817 | + if ((state.ivar1 < 0) || (static_cast<uint32_t>(state.ivar1) < game.get_gametime())) { // time to die? |
818 | molog("[fugitive]: die\n"); |
819 | return schedule_destroy(game); |
820 | } |
821 | |
822 | === modified file 'src/network/netclient.cc' |
823 | --- src/network/netclient.cc 2015-11-08 17:31:06 +0000 |
824 | +++ src/network/netclient.cc 2015-11-25 10:54:29 +0000 |
825 | @@ -82,7 +82,7 @@ |
826 | bool server_is_waiting; |
827 | |
828 | /// Data for the last time message we sent. |
829 | - int32_t lasttimestamp; |
830 | + uint32_t lasttimestamp; |
831 | uint32_t lasttimestamp_realtime; |
832 | |
833 | /// The real target speed, in milliseconds per second. |
834 | @@ -253,7 +253,7 @@ |
835 | |
836 | if |
837 | (d->server_is_waiting && |
838 | - d->game->get_gametime() == d->time.networktime()) |
839 | + d->game->get_gametime() == static_cast<uint32_t>(d->time.networktime())) |
840 | { |
841 | send_time(); |
842 | d->server_is_waiting = false; |
843 | |
844 | === modified file 'src/network/nethost.cc' |
845 | --- src/network/nethost.cc 2015-11-08 17:31:06 +0000 |
846 | +++ src/network/nethost.cc 2015-11-25 10:54:29 +0000 |
847 | @@ -2458,7 +2458,7 @@ |
848 | |
849 | void NetHost::syncreport() |
850 | { |
851 | - assert(d->game->get_gametime() == d->syncreport_time); |
852 | + assert(d->game->get_gametime() == static_cast<uint32_t>(d->syncreport_time)); |
853 | |
854 | d->syncreport = d->game->get_sync_hash(); |
855 | d->syncreport_arrived = true; |
856 | |
857 | === modified file 'src/network/network.cc' |
858 | --- src/network/network.cc 2015-11-08 17:31:06 +0000 |
859 | +++ src/network/network.cc 2015-11-25 10:54:29 +0000 |
860 | @@ -24,7 +24,7 @@ |
861 | |
862 | |
863 | |
864 | -CmdNetCheckSync::CmdNetCheckSync(int32_t const dt, SyncCallback * const cb) : |
865 | +CmdNetCheckSync::CmdNetCheckSync(uint32_t const dt, SyncCallback * const cb) : |
866 | Command (dt), m_callback(cb) |
867 | {} |
868 | |
869 | |
870 | === modified file 'src/network/network.h' |
871 | --- src/network/network.h 2015-11-08 17:31:06 +0000 |
872 | +++ src/network/network.h 2015-11-25 10:54:29 +0000 |
873 | @@ -45,7 +45,7 @@ |
874 | * to schedule taking a synchronization hash. |
875 | */ |
876 | struct CmdNetCheckSync : public Widelands::Command { |
877 | - CmdNetCheckSync (int32_t dt, SyncCallback *); |
878 | + CmdNetCheckSync (uint32_t dt, SyncCallback *); |
879 | |
880 | void execute (Widelands::Game &) override; |
881 |
I am bit nervous about all that static_casts. All variable that can be reworked to uint32_t should be reworked. I know this might be a lot of work...
Alternativelly I would vote for assert(x>=0) before all (remaining) static_casts. To be on safe side...