Merge lp:~widelands-dev/widelands/cleanup_playercommand_enums into lp:widelands
- cleanup_playercommand_enums
- Merge into trunk
Status: | Merged |
---|---|
Merged at revision: | 9186 |
Proposed branch: | lp:~widelands-dev/widelands/cleanup_playercommand_enums |
Merge into: | lp:widelands |
Diff against target: |
662 lines (+112/-151) 5 files modified
src/logic/playercommand.cc (+78/-129) src/logic/playercommand.h (+9/-6) src/logic/queue_cmd_factory.cc (+6/-6) src/logic/queue_cmd_ids.h (+13/-7) src/logic/replay.cc (+6/-3) |
To merge this branch: | bzr merge lp:~widelands-dev/widelands/cleanup_playercommand_enums |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Toni Förster | Approve | ||
Review via email: mp+369267@code.launchpad.net |
Commit message
Get rid of duplicate listing of player commands. This breaks compatibility for replays only.
Description of the change
Keeping 2 lists of the same player commands is a bit nuts, so I got rid of one of them.
Since replays become incompatible pretty fast anyway, I decided not to add any compatibility code.
bunnybot (widelandsofficial) wrote : | # |
Benedikt Straub (nordfriese) wrote : | # |
Looks good to me. Some comments in the diff.
bunnybot (widelandsofficial) wrote : | # |
Continuous integration builds have changed state:
Travis build 5260. State: passed. Details: https:/
Appveyor build 5037. State: failed. Details: https:/
GunChleoc (gunchleoc) wrote : | # |
Addressed code review. Thanks for the review
Toni Förster (stonerl) : | # |
GunChleoc (gunchleoc) wrote : | # |
@bunnybot merge
bunnybot (widelandsofficial) wrote : | # |
Continuous integration builds have changed state:
Travis build 5341. State: passed. Details: https:/
Appveyor build 5111. State: success. Details: https:/
Preview Diff
1 | === modified file 'src/logic/playercommand.cc' | |||
2 | --- src/logic/playercommand.cc 2019-06-23 14:28:50 +0000 | |||
3 | +++ src/logic/playercommand.cc 2019-08-26 10:38:04 +0000 | |||
4 | @@ -74,108 +74,83 @@ | |||
5 | 74 | 74 | ||
6 | 75 | } // namespace | 75 | } // namespace |
7 | 76 | 76 | ||
8 | 77 | // NOTE keep numbers of existing entries as they are to ensure backward compatible savegame loading | ||
9 | 78 | enum { | ||
10 | 79 | PLCMD_UNUSED = 0, | ||
11 | 80 | PLCMD_BULLDOZE = 1, | ||
12 | 81 | PLCMD_BUILD = 2, | ||
13 | 82 | PLCMD_BUILDFLAG = 3, | ||
14 | 83 | PLCMD_BUILDROAD = 4, | ||
15 | 84 | PLCMD_FLAGACTION = 5, | ||
16 | 85 | PLCMD_STARTSTOPBUILDING = 6, | ||
17 | 86 | PLCMD_ENHANCEBUILDING = 7, | ||
18 | 87 | PLCMD_CHANGETRAININGOPTIONS = 8, | ||
19 | 88 | PLCMD_DROPSOLDIER = 9, | ||
20 | 89 | PLCMD_CHANGESOLDIERCAPACITY = 10, | ||
21 | 90 | PLCMD_ENEMYFLAGACTION = 11, | ||
22 | 91 | PLCMD_SETWAREPRIORITY = 12, | ||
23 | 92 | PLCMD_SETWARETARGETQUANTITY = 13, | ||
24 | 93 | PLCMD_RESETWARETARGETQUANTITY = 14, | ||
25 | 94 | PLCMD_SETWORKERTARGETQUANTITY = 15, | ||
26 | 95 | PLCMD_RESETWORKERTARGETQUANTITY = 16, | ||
27 | 96 | // Used to be PLCMD_CHANGEMILITARYCONFIG | ||
28 | 97 | PLCMD_MESSAGESETSTATUSREAD = 18, | ||
29 | 98 | PLCMD_MESSAGESETSTATUSARCHIVED = 19, | ||
30 | 99 | PLCMD_SETSTOCKPOLICY = 20, | ||
31 | 100 | PLCMD_SETINPUTMAXFILL = 21, | ||
32 | 101 | PLCMD_DISMANTLEBUILDING = 22, | ||
33 | 102 | PLCMD_EVICTWORKER = 23, | ||
34 | 103 | PLCMD_MILITARYSITESETSOLDIERPREFERENCE = 24, | ||
35 | 104 | PLCMD_SHIP_EXPEDITION = 25, | ||
36 | 105 | PLCMD_SHIP_SCOUT = 26, | ||
37 | 106 | PLCMD_SHIP_EXPLORE = 27, | ||
38 | 107 | PLCMD_SHIP_CONSTRUCT = 28, | ||
39 | 108 | PLCMD_SHIP_SINK = 29, | ||
40 | 109 | PLCMD_SHIP_CANCELEXPEDITION = 30, | ||
41 | 110 | PLCMD_PROPOSE_TRADE = 31, | ||
42 | 111 | }; | ||
43 | 112 | |||
44 | 113 | /*** class PlayerCommand ***/ | 77 | /*** class PlayerCommand ***/ |
45 | 114 | 78 | ||
46 | 115 | PlayerCommand::PlayerCommand(const uint32_t time, const PlayerNumber s) | 79 | PlayerCommand::PlayerCommand(const uint32_t time, const PlayerNumber s) |
47 | 116 | : GameLogicCommand(time), sender_(s), cmdserial_(0) { | 80 | : GameLogicCommand(time), sender_(s), cmdserial_(0) { |
48 | 117 | } | 81 | } |
49 | 118 | 82 | ||
50 | 83 | void PlayerCommand::write_id_and_sender(StreamWrite& ser) { | ||
51 | 84 | ser.unsigned_8(static_cast<uint8_t>(id())); | ||
52 | 85 | ser.unsigned_8(sender()); | ||
53 | 86 | } | ||
54 | 87 | |||
55 | 119 | PlayerCommand* PlayerCommand::deserialize(StreamRead& des) { | 88 | PlayerCommand* PlayerCommand::deserialize(StreamRead& des) { |
58 | 120 | switch (des.unsigned_8()) { | 89 | switch (static_cast<QueueCommandTypes>(des.unsigned_8())) { |
59 | 121 | case PLCMD_BULLDOZE: | 90 | case QueueCommandTypes::kBulldoze: |
60 | 122 | return new CmdBulldoze(des); | 91 | return new CmdBulldoze(des); |
62 | 123 | case PLCMD_BUILD: | 92 | case QueueCommandTypes::kBuild: |
63 | 124 | return new CmdBuild(des); | 93 | return new CmdBuild(des); |
65 | 125 | case PLCMD_BUILDFLAG: | 94 | case QueueCommandTypes::kBuildFlag: |
66 | 126 | return new CmdBuildFlag(des); | 95 | return new CmdBuildFlag(des); |
68 | 127 | case PLCMD_BUILDROAD: | 96 | case QueueCommandTypes::kBuildRoad: |
69 | 128 | return new CmdBuildRoad(des); | 97 | return new CmdBuildRoad(des); |
71 | 129 | case PLCMD_FLAGACTION: | 98 | case QueueCommandTypes::kFlagAction: |
72 | 130 | return new CmdFlagAction(des); | 99 | return new CmdFlagAction(des); |
74 | 131 | case PLCMD_STARTSTOPBUILDING: | 100 | case QueueCommandTypes::kStartStopBuilding: |
75 | 132 | return new CmdStartStopBuilding(des); | 101 | return new CmdStartStopBuilding(des); |
89 | 133 | case PLCMD_SHIP_EXPEDITION: | 102 | case QueueCommandTypes::kEnhanceBuilding: |
77 | 134 | return new CmdStartOrCancelExpedition(des); | ||
78 | 135 | case PLCMD_SHIP_SCOUT: | ||
79 | 136 | return new CmdShipScoutDirection(des); | ||
80 | 137 | case PLCMD_SHIP_EXPLORE: | ||
81 | 138 | return new CmdShipExploreIsland(des); | ||
82 | 139 | case PLCMD_SHIP_CONSTRUCT: | ||
83 | 140 | return new CmdShipConstructPort(des); | ||
84 | 141 | case PLCMD_SHIP_SINK: | ||
85 | 142 | return new CmdShipSink(des); | ||
86 | 143 | case PLCMD_SHIP_CANCELEXPEDITION: | ||
87 | 144 | return new CmdShipCancelExpedition(des); | ||
88 | 145 | case PLCMD_ENHANCEBUILDING: | ||
90 | 146 | return new CmdEnhanceBuilding(des); | 103 | return new CmdEnhanceBuilding(des); |
92 | 147 | case PLCMD_CHANGETRAININGOPTIONS: | 104 | |
93 | 105 | case QueueCommandTypes::kChangeTrainingOptions: | ||
94 | 148 | return new CmdChangeTrainingOptions(des); | 106 | return new CmdChangeTrainingOptions(des); |
96 | 149 | case PLCMD_DROPSOLDIER: | 107 | case QueueCommandTypes::kDropSoldier: |
97 | 150 | return new CmdDropSoldier(des); | 108 | return new CmdDropSoldier(des); |
99 | 151 | case PLCMD_CHANGESOLDIERCAPACITY: | 109 | case QueueCommandTypes::kChangeSoldierCapacity: |
100 | 152 | return new CmdChangeSoldierCapacity(des); | 110 | return new CmdChangeSoldierCapacity(des); |
102 | 153 | case PLCMD_ENEMYFLAGACTION: | 111 | case QueueCommandTypes::kEnemyFlagAction: |
103 | 154 | return new CmdEnemyFlagAction(des); | 112 | return new CmdEnemyFlagAction(des); |
105 | 155 | case PLCMD_SETWAREPRIORITY: | 113 | |
106 | 114 | case QueueCommandTypes::kSetWarePriority: | ||
107 | 156 | return new CmdSetWarePriority(des); | 115 | return new CmdSetWarePriority(des); |
109 | 157 | case PLCMD_SETWARETARGETQUANTITY: | 116 | case QueueCommandTypes::kSetWareTargetQuantity: |
110 | 158 | return new CmdSetWareTargetQuantity(des); | 117 | return new CmdSetWareTargetQuantity(des); |
112 | 159 | case PLCMD_RESETWARETARGETQUANTITY: | 118 | case QueueCommandTypes::kResetWareTargetQuantity: |
113 | 160 | return new CmdResetWareTargetQuantity(des); | 119 | return new CmdResetWareTargetQuantity(des); |
115 | 161 | case PLCMD_SETWORKERTARGETQUANTITY: | 120 | case QueueCommandTypes::kSetWorkerTargetQuantity: |
116 | 162 | return new CmdSetWorkerTargetQuantity(des); | 121 | return new CmdSetWorkerTargetQuantity(des); |
118 | 163 | case PLCMD_RESETWORKERTARGETQUANTITY: | 122 | case QueueCommandTypes::kResetWorkerTargetQuantity: |
119 | 164 | return new CmdResetWorkerTargetQuantity(des); | 123 | return new CmdResetWorkerTargetQuantity(des); |
121 | 165 | case PLCMD_MESSAGESETSTATUSREAD: | 124 | |
122 | 125 | case QueueCommandTypes::kMessageSetStatusRead: | ||
123 | 166 | return new CmdMessageSetStatusRead(des); | 126 | return new CmdMessageSetStatusRead(des); |
125 | 167 | case PLCMD_MESSAGESETSTATUSARCHIVED: | 127 | case QueueCommandTypes::kMessageSetStatusArchived: |
126 | 168 | return new CmdMessageSetStatusArchived(des); | 128 | return new CmdMessageSetStatusArchived(des); |
128 | 169 | case PLCMD_SETSTOCKPOLICY: | 129 | |
129 | 130 | case QueueCommandTypes::kSetStockPolicy: | ||
130 | 170 | return new CmdSetStockPolicy(des); | 131 | return new CmdSetStockPolicy(des); |
132 | 171 | case PLCMD_SETINPUTMAXFILL: | 132 | case QueueCommandTypes::kSetInputMaxFill: |
133 | 172 | return new CmdSetInputMaxFill(des); | 133 | return new CmdSetInputMaxFill(des); |
135 | 173 | case PLCMD_DISMANTLEBUILDING: | 134 | case QueueCommandTypes::kDismantleBuilding: |
136 | 174 | return new CmdDismantleBuilding(des); | 135 | return new CmdDismantleBuilding(des); |
138 | 175 | case PLCMD_EVICTWORKER: | 136 | case QueueCommandTypes::kEvictWorker: |
139 | 176 | return new CmdEvictWorker(des); | 137 | return new CmdEvictWorker(des); |
141 | 177 | case PLCMD_MILITARYSITESETSOLDIERPREFERENCE: | 138 | case QueueCommandTypes::kMilitarysiteSetSoldierPreference: |
142 | 178 | return new CmdMilitarySiteSetSoldierPreference(des); | 139 | return new CmdMilitarySiteSetSoldierPreference(des); |
143 | 140 | |||
144 | 141 | case QueueCommandTypes::kStartOrCancelExpedition: | ||
145 | 142 | return new CmdStartOrCancelExpedition(des); | ||
146 | 143 | case QueueCommandTypes::kShipScoutDirection: | ||
147 | 144 | return new CmdShipScoutDirection(des); | ||
148 | 145 | case QueueCommandTypes::kShipExploreIsland: | ||
149 | 146 | return new CmdShipExploreIsland(des); | ||
150 | 147 | case QueueCommandTypes::kShipConstructPort: | ||
151 | 148 | return new CmdShipConstructPort(des); | ||
152 | 149 | case QueueCommandTypes::kShipSink: | ||
153 | 150 | return new CmdShipSink(des); | ||
154 | 151 | case QueueCommandTypes::kShipCancelExpedition: | ||
155 | 152 | return new CmdShipCancelExpedition(des); | ||
156 | 153 | |||
157 | 179 | default: | 154 | default: |
158 | 180 | throw wexception("PlayerCommand::deserialize(): Invalid command id encountered"); | 155 | throw wexception("PlayerCommand::deserialize(): Invalid command id encountered"); |
159 | 181 | } | 156 | } |
160 | @@ -226,8 +201,7 @@ | |||
161 | 226 | } | 201 | } |
162 | 227 | 202 | ||
163 | 228 | void CmdBulldoze::serialize(StreamWrite& ser) { | 203 | void CmdBulldoze::serialize(StreamWrite& ser) { |
166 | 229 | ser.unsigned_8(PLCMD_BULLDOZE); | 204 | write_id_and_sender(ser); |
165 | 230 | ser.unsigned_8(sender()); | ||
167 | 231 | ser.unsigned_32(serial); | 205 | ser.unsigned_32(serial); |
168 | 232 | ser.unsigned_8(recurse); | 206 | ser.unsigned_8(recurse); |
169 | 233 | } | 207 | } |
170 | @@ -273,8 +247,7 @@ | |||
171 | 273 | } | 247 | } |
172 | 274 | 248 | ||
173 | 275 | void CmdBuild::serialize(StreamWrite& ser) { | 249 | void CmdBuild::serialize(StreamWrite& ser) { |
176 | 276 | ser.unsigned_8(PLCMD_BUILD); | 250 | write_id_and_sender(ser); |
175 | 277 | ser.unsigned_8(sender()); | ||
177 | 278 | ser.signed_16(bi); | 251 | ser.signed_16(bi); |
178 | 279 | write_coords_32(&ser, coords); | 252 | write_coords_32(&ser, coords); |
179 | 280 | } | 253 | } |
180 | @@ -317,8 +290,7 @@ | |||
181 | 317 | } | 290 | } |
182 | 318 | 291 | ||
183 | 319 | void CmdBuildFlag::serialize(StreamWrite& ser) { | 292 | void CmdBuildFlag::serialize(StreamWrite& ser) { |
186 | 320 | ser.unsigned_8(PLCMD_BUILDFLAG); | 293 | write_id_and_sender(ser); |
185 | 321 | ser.unsigned_8(sender()); | ||
187 | 322 | write_coords_32(&ser, coords); | 294 | write_coords_32(&ser, coords); |
188 | 323 | } | 295 | } |
189 | 324 | 296 | ||
190 | @@ -387,8 +359,7 @@ | |||
191 | 387 | } | 359 | } |
192 | 388 | 360 | ||
193 | 389 | void CmdBuildRoad::serialize(StreamWrite& ser) { | 361 | void CmdBuildRoad::serialize(StreamWrite& ser) { |
196 | 390 | ser.unsigned_8(PLCMD_BUILDROAD); | 362 | write_id_and_sender(ser); |
195 | 391 | ser.unsigned_8(sender()); | ||
197 | 392 | write_coords_32(&ser, start); | 363 | write_coords_32(&ser, start); |
198 | 393 | ser.unsigned_16(nsteps); | 364 | ser.unsigned_16(nsteps); |
199 | 394 | 365 | ||
200 | @@ -444,8 +415,7 @@ | |||
201 | 444 | } | 415 | } |
202 | 445 | 416 | ||
203 | 446 | void CmdFlagAction::serialize(StreamWrite& ser) { | 417 | void CmdFlagAction::serialize(StreamWrite& ser) { |
206 | 447 | ser.unsigned_8(PLCMD_FLAGACTION); | 418 | write_id_and_sender(ser); |
205 | 448 | ser.unsigned_8(sender()); | ||
207 | 449 | ser.unsigned_8(0); | 419 | ser.unsigned_8(0); |
208 | 450 | ser.unsigned_32(serial); | 420 | ser.unsigned_32(serial); |
209 | 451 | } | 421 | } |
210 | @@ -497,8 +467,7 @@ | |||
211 | 497 | } | 467 | } |
212 | 498 | 468 | ||
213 | 499 | void CmdStartStopBuilding::serialize(StreamWrite& ser) { | 469 | void CmdStartStopBuilding::serialize(StreamWrite& ser) { |
216 | 500 | ser.unsigned_8(PLCMD_STARTSTOPBUILDING); | 470 | write_id_and_sender(ser); |
215 | 501 | ser.unsigned_8(sender()); | ||
217 | 502 | ser.unsigned_32(serial); | 471 | ser.unsigned_32(serial); |
218 | 503 | } | 472 | } |
219 | 504 | 473 | ||
220 | @@ -535,8 +504,7 @@ | |||
221 | 535 | } | 504 | } |
222 | 536 | 505 | ||
223 | 537 | void CmdMilitarySiteSetSoldierPreference::serialize(StreamWrite& ser) { | 506 | void CmdMilitarySiteSetSoldierPreference::serialize(StreamWrite& ser) { |
226 | 538 | ser.unsigned_8(PLCMD_MILITARYSITESETSOLDIERPREFERENCE); | 507 | write_id_and_sender(ser); |
225 | 539 | ser.unsigned_8(sender()); | ||
227 | 540 | ser.unsigned_32(serial); | 508 | ser.unsigned_32(serial); |
228 | 541 | ser.unsigned_8(static_cast<uint8_t>(preference)); | 509 | ser.unsigned_8(static_cast<uint8_t>(preference)); |
229 | 542 | } | 510 | } |
230 | @@ -605,8 +573,7 @@ | |||
231 | 605 | } | 573 | } |
232 | 606 | 574 | ||
233 | 607 | void CmdStartOrCancelExpedition::serialize(StreamWrite& ser) { | 575 | void CmdStartOrCancelExpedition::serialize(StreamWrite& ser) { |
236 | 608 | ser.unsigned_8(PLCMD_SHIP_EXPEDITION); | 576 | write_id_and_sender(ser); |
235 | 609 | ser.unsigned_8(sender()); | ||
237 | 610 | ser.unsigned_32(serial); | 577 | ser.unsigned_32(serial); |
238 | 611 | } | 578 | } |
239 | 612 | 579 | ||
240 | @@ -653,8 +620,7 @@ | |||
241 | 653 | } | 620 | } |
242 | 654 | 621 | ||
243 | 655 | void CmdEnhanceBuilding::serialize(StreamWrite& ser) { | 622 | void CmdEnhanceBuilding::serialize(StreamWrite& ser) { |
246 | 656 | ser.unsigned_8(PLCMD_ENHANCEBUILDING); | 623 | write_id_and_sender(ser); |
245 | 657 | ser.unsigned_8(sender()); | ||
247 | 658 | ser.unsigned_32(serial); | 624 | ser.unsigned_32(serial); |
248 | 659 | ser.unsigned_16(bi); | 625 | ser.unsigned_16(bi); |
249 | 660 | } | 626 | } |
250 | @@ -700,8 +666,7 @@ | |||
251 | 700 | } | 666 | } |
252 | 701 | 667 | ||
253 | 702 | void CmdDismantleBuilding::serialize(StreamWrite& ser) { | 668 | void CmdDismantleBuilding::serialize(StreamWrite& ser) { |
256 | 703 | ser.unsigned_8(PLCMD_DISMANTLEBUILDING); | 669 | write_id_and_sender(ser); |
255 | 704 | ser.unsigned_8(sender()); | ||
257 | 705 | ser.unsigned_32(serial); | 670 | ser.unsigned_32(serial); |
258 | 706 | } | 671 | } |
259 | 707 | 672 | ||
260 | @@ -744,8 +709,7 @@ | |||
261 | 744 | } | 709 | } |
262 | 745 | 710 | ||
263 | 746 | void CmdEvictWorker::serialize(StreamWrite& ser) { | 711 | void CmdEvictWorker::serialize(StreamWrite& ser) { |
266 | 747 | ser.unsigned_8(PLCMD_EVICTWORKER); | 712 | write_id_and_sender(ser); |
265 | 748 | ser.unsigned_8(sender()); | ||
267 | 749 | ser.unsigned_32(serial); | 713 | ser.unsigned_32(serial); |
268 | 750 | } | 714 | } |
269 | 751 | 715 | ||
270 | @@ -799,8 +763,7 @@ | |||
271 | 799 | } | 763 | } |
272 | 800 | 764 | ||
273 | 801 | void CmdShipScoutDirection::serialize(StreamWrite& ser) { | 765 | void CmdShipScoutDirection::serialize(StreamWrite& ser) { |
276 | 802 | ser.unsigned_8(PLCMD_SHIP_SCOUT); | 766 | write_id_and_sender(ser); |
275 | 803 | ser.unsigned_8(sender()); | ||
277 | 804 | ser.unsigned_32(serial); | 767 | ser.unsigned_32(serial); |
278 | 805 | ser.unsigned_8(static_cast<uint8_t>(dir)); | 768 | ser.unsigned_8(static_cast<uint8_t>(dir)); |
279 | 806 | } | 769 | } |
280 | @@ -857,8 +820,7 @@ | |||
281 | 857 | } | 820 | } |
282 | 858 | 821 | ||
283 | 859 | void CmdShipConstructPort::serialize(StreamWrite& ser) { | 822 | void CmdShipConstructPort::serialize(StreamWrite& ser) { |
286 | 860 | ser.unsigned_8(PLCMD_SHIP_CONSTRUCT); | 823 | write_id_and_sender(ser); |
285 | 861 | ser.unsigned_8(sender()); | ||
287 | 862 | ser.unsigned_32(serial); | 824 | ser.unsigned_32(serial); |
288 | 863 | write_coords_32(&ser, coords); | 825 | write_coords_32(&ser, coords); |
289 | 864 | } | 826 | } |
290 | @@ -918,8 +880,7 @@ | |||
291 | 918 | } | 880 | } |
292 | 919 | 881 | ||
293 | 920 | void CmdShipExploreIsland::serialize(StreamWrite& ser) { | 882 | void CmdShipExploreIsland::serialize(StreamWrite& ser) { |
296 | 921 | ser.unsigned_8(PLCMD_SHIP_EXPLORE); | 883 | write_id_and_sender(ser); |
295 | 922 | ser.unsigned_8(sender()); | ||
297 | 923 | ser.unsigned_32(serial); | 884 | ser.unsigned_32(serial); |
298 | 924 | ser.unsigned_8(static_cast<uint8_t>(island_explore_direction)); | 885 | ser.unsigned_8(static_cast<uint8_t>(island_explore_direction)); |
299 | 925 | } | 886 | } |
300 | @@ -967,8 +928,7 @@ | |||
301 | 967 | } | 928 | } |
302 | 968 | 929 | ||
303 | 969 | void CmdShipSink::serialize(StreamWrite& ser) { | 930 | void CmdShipSink::serialize(StreamWrite& ser) { |
306 | 970 | ser.unsigned_8(PLCMD_SHIP_SINK); | 931 | write_id_and_sender(ser); |
305 | 971 | ser.unsigned_8(sender()); | ||
307 | 972 | ser.unsigned_32(serial); | 932 | ser.unsigned_32(serial); |
308 | 973 | } | 933 | } |
309 | 974 | 934 | ||
310 | @@ -1012,8 +972,7 @@ | |||
311 | 1012 | } | 972 | } |
312 | 1013 | 973 | ||
313 | 1014 | void CmdShipCancelExpedition::serialize(StreamWrite& ser) { | 974 | void CmdShipCancelExpedition::serialize(StreamWrite& ser) { |
316 | 1015 | ser.unsigned_8(PLCMD_SHIP_CANCELEXPEDITION); | 975 | write_id_and_sender(ser); |
315 | 1016 | ser.unsigned_8(sender()); | ||
317 | 1017 | ser.unsigned_32(serial); | 976 | ser.unsigned_32(serial); |
318 | 1018 | } | 977 | } |
319 | 1019 | 978 | ||
320 | @@ -1124,8 +1083,7 @@ | |||
321 | 1124 | } | 1083 | } |
322 | 1125 | 1084 | ||
323 | 1126 | void CmdSetWarePriority::serialize(StreamWrite& ser) { | 1085 | void CmdSetWarePriority::serialize(StreamWrite& ser) { |
326 | 1127 | ser.unsigned_8(PLCMD_SETWAREPRIORITY); | 1086 | write_id_and_sender(ser); |
325 | 1128 | ser.unsigned_8(sender()); | ||
327 | 1129 | ser.unsigned_32(serial_); | 1087 | ser.unsigned_32(serial_); |
328 | 1130 | ser.unsigned_8(type_); | 1088 | ser.unsigned_8(type_); |
329 | 1131 | ser.signed_32(index_); | 1089 | ser.signed_32(index_); |
330 | @@ -1238,8 +1196,7 @@ | |||
331 | 1238 | } | 1196 | } |
332 | 1239 | 1197 | ||
333 | 1240 | void CmdSetInputMaxFill::serialize(StreamWrite& ser) { | 1198 | void CmdSetInputMaxFill::serialize(StreamWrite& ser) { |
336 | 1241 | ser.unsigned_8(PLCMD_SETINPUTMAXFILL); | 1199 | write_id_and_sender(ser); |
335 | 1242 | ser.unsigned_8(sender()); | ||
337 | 1243 | ser.unsigned_32(serial_); | 1200 | ser.unsigned_32(serial_); |
338 | 1244 | ser.signed_32(index_); | 1201 | ser.signed_32(index_); |
339 | 1245 | if (type_ == wwWARE) { | 1202 | if (type_ == wwWARE) { |
340 | @@ -1279,7 +1236,7 @@ | |||
341 | 1279 | } | 1236 | } |
342 | 1280 | 1237 | ||
343 | 1281 | void CmdChangeTargetQuantity::serialize(StreamWrite& ser) { | 1238 | void CmdChangeTargetQuantity::serialize(StreamWrite& ser) { |
345 | 1282 | ser.unsigned_8(sender()); | 1239 | // Subclasses take care of writing their id() and sender() |
346 | 1283 | ser.unsigned_32(economy()); | 1240 | ser.unsigned_32(economy()); |
347 | 1284 | ser.unsigned_8(ware_type()); | 1241 | ser.unsigned_8(ware_type()); |
348 | 1285 | } | 1242 | } |
349 | @@ -1330,7 +1287,7 @@ | |||
350 | 1330 | } | 1287 | } |
351 | 1331 | 1288 | ||
352 | 1332 | void CmdSetWareTargetQuantity::serialize(StreamWrite& ser) { | 1289 | void CmdSetWareTargetQuantity::serialize(StreamWrite& ser) { |
354 | 1333 | ser.unsigned_8(PLCMD_SETWARETARGETQUANTITY); | 1290 | write_id_and_sender(ser); |
355 | 1334 | CmdChangeTargetQuantity::serialize(ser); | 1291 | CmdChangeTargetQuantity::serialize(ser); |
356 | 1335 | ser.unsigned_32(permanent_); | 1292 | ser.unsigned_32(permanent_); |
357 | 1336 | } | 1293 | } |
358 | @@ -1377,7 +1334,7 @@ | |||
359 | 1377 | } | 1334 | } |
360 | 1378 | 1335 | ||
361 | 1379 | void CmdResetWareTargetQuantity::serialize(StreamWrite& ser) { | 1336 | void CmdResetWareTargetQuantity::serialize(StreamWrite& ser) { |
363 | 1380 | ser.unsigned_8(PLCMD_RESETWARETARGETQUANTITY); | 1337 | write_id_and_sender(ser); |
364 | 1381 | CmdChangeTargetQuantity::serialize(ser); | 1338 | CmdChangeTargetQuantity::serialize(ser); |
365 | 1382 | } | 1339 | } |
366 | 1383 | 1340 | ||
367 | @@ -1428,7 +1385,7 @@ | |||
368 | 1428 | } | 1385 | } |
369 | 1429 | 1386 | ||
370 | 1430 | void CmdSetWorkerTargetQuantity::serialize(StreamWrite& ser) { | 1387 | void CmdSetWorkerTargetQuantity::serialize(StreamWrite& ser) { |
372 | 1431 | ser.unsigned_8(PLCMD_SETWORKERTARGETQUANTITY); | 1388 | write_id_and_sender(ser); |
373 | 1432 | CmdChangeTargetQuantity::serialize(ser); | 1389 | CmdChangeTargetQuantity::serialize(ser); |
374 | 1433 | ser.unsigned_32(permanent_); | 1390 | ser.unsigned_32(permanent_); |
375 | 1434 | } | 1391 | } |
376 | @@ -1479,7 +1436,7 @@ | |||
377 | 1479 | } | 1436 | } |
378 | 1480 | 1437 | ||
379 | 1481 | void CmdResetWorkerTargetQuantity::serialize(StreamWrite& ser) { | 1438 | void CmdResetWorkerTargetQuantity::serialize(StreamWrite& ser) { |
381 | 1482 | ser.unsigned_8(PLCMD_RESETWORKERTARGETQUANTITY); | 1439 | write_id_and_sender(ser); |
382 | 1483 | CmdChangeTargetQuantity::serialize(ser); | 1440 | CmdChangeTargetQuantity::serialize(ser); |
383 | 1484 | } | 1441 | } |
384 | 1485 | 1442 | ||
385 | @@ -1497,8 +1454,7 @@ | |||
386 | 1497 | } | 1454 | } |
387 | 1498 | 1455 | ||
388 | 1499 | void CmdChangeTrainingOptions::serialize(StreamWrite& ser) { | 1456 | void CmdChangeTrainingOptions::serialize(StreamWrite& ser) { |
391 | 1500 | ser.unsigned_8(PLCMD_CHANGETRAININGOPTIONS); | 1457 | write_id_and_sender(ser); |
390 | 1501 | ser.unsigned_8(sender()); | ||
392 | 1502 | ser.unsigned_32(serial); | 1458 | ser.unsigned_32(serial); |
393 | 1503 | ser.unsigned_8(static_cast<uint8_t>(attribute)); | 1459 | ser.unsigned_8(static_cast<uint8_t>(attribute)); |
394 | 1504 | ser.unsigned_16(value); | 1460 | ser.unsigned_16(value); |
395 | @@ -1550,8 +1506,7 @@ | |||
396 | 1550 | } | 1506 | } |
397 | 1551 | 1507 | ||
398 | 1552 | void CmdDropSoldier::serialize(StreamWrite& ser) { | 1508 | void CmdDropSoldier::serialize(StreamWrite& ser) { |
401 | 1553 | ser.unsigned_8(PLCMD_DROPSOLDIER); | 1509 | write_id_and_sender(ser); |
400 | 1554 | ser.unsigned_8(sender()); | ||
402 | 1555 | ser.unsigned_32(serial); | 1510 | ser.unsigned_32(serial); |
403 | 1556 | ser.unsigned_32(soldier); | 1511 | ser.unsigned_32(soldier); |
404 | 1557 | } | 1512 | } |
405 | @@ -1625,8 +1580,7 @@ | |||
406 | 1625 | } | 1580 | } |
407 | 1626 | 1581 | ||
408 | 1627 | void CmdChangeSoldierCapacity::serialize(StreamWrite& ser) { | 1582 | void CmdChangeSoldierCapacity::serialize(StreamWrite& ser) { |
411 | 1628 | ser.unsigned_8(PLCMD_CHANGESOLDIERCAPACITY); | 1583 | write_id_and_sender(ser); |
410 | 1629 | ser.unsigned_8(sender()); | ||
412 | 1630 | ser.unsigned_32(serial); | 1584 | ser.unsigned_32(serial); |
413 | 1631 | ser.signed_16(val); | 1585 | ser.signed_16(val); |
414 | 1632 | } | 1586 | } |
415 | @@ -1702,8 +1656,7 @@ | |||
416 | 1702 | } | 1656 | } |
417 | 1703 | 1657 | ||
418 | 1704 | void CmdEnemyFlagAction::serialize(StreamWrite& ser) { | 1658 | void CmdEnemyFlagAction::serialize(StreamWrite& ser) { |
421 | 1705 | ser.unsigned_8(PLCMD_ENEMYFLAGACTION); | 1659 | write_id_and_sender(ser); |
420 | 1706 | ser.unsigned_8(sender()); | ||
422 | 1707 | ser.unsigned_8(1); | 1660 | ser.unsigned_8(1); |
423 | 1708 | ser.unsigned_32(serial); | 1661 | ser.unsigned_32(serial); |
424 | 1709 | ser.unsigned_8(sender()); | 1662 | ser.unsigned_8(sender()); |
425 | @@ -1808,8 +1761,7 @@ | |||
426 | 1808 | } | 1761 | } |
427 | 1809 | 1762 | ||
428 | 1810 | void CmdMessageSetStatusRead::serialize(StreamWrite& ser) { | 1763 | void CmdMessageSetStatusRead::serialize(StreamWrite& ser) { |
431 | 1811 | ser.unsigned_8(PLCMD_MESSAGESETSTATUSREAD); | 1764 | write_id_and_sender(ser); |
430 | 1812 | ser.unsigned_8(sender()); | ||
432 | 1813 | ser.unsigned_32(message_id().value()); | 1765 | ser.unsigned_32(message_id().value()); |
433 | 1814 | } | 1766 | } |
434 | 1815 | 1767 | ||
435 | @@ -1821,8 +1773,7 @@ | |||
436 | 1821 | } | 1773 | } |
437 | 1822 | 1774 | ||
438 | 1823 | void CmdMessageSetStatusArchived::serialize(StreamWrite& ser) { | 1775 | void CmdMessageSetStatusArchived::serialize(StreamWrite& ser) { |
441 | 1824 | ser.unsigned_8(PLCMD_MESSAGESETSTATUSARCHIVED); | 1776 | write_id_and_sender(ser); |
440 | 1825 | ser.unsigned_8(sender()); | ||
442 | 1826 | ser.unsigned_32(message_id().value()); | 1777 | ser.unsigned_32(message_id().value()); |
443 | 1827 | } | 1778 | } |
444 | 1828 | 1779 | ||
445 | @@ -1888,8 +1839,7 @@ | |||
446 | 1888 | } | 1839 | } |
447 | 1889 | 1840 | ||
448 | 1890 | void CmdSetStockPolicy::serialize(StreamWrite& ser) { | 1841 | void CmdSetStockPolicy::serialize(StreamWrite& ser) { |
451 | 1891 | ser.unsigned_8(PLCMD_SETSTOCKPOLICY); | 1842 | write_id_and_sender(ser); |
450 | 1892 | ser.unsigned_8(sender()); | ||
452 | 1893 | ser.unsigned_32(warehouse_); | 1843 | ser.unsigned_32(warehouse_); |
453 | 1894 | ser.unsigned_8(isworker_); | 1844 | ser.unsigned_8(isworker_); |
454 | 1895 | ser.unsigned_8(ware_); | 1845 | ser.unsigned_8(ware_); |
455 | @@ -1972,8 +1922,7 @@ | |||
456 | 1972 | } | 1922 | } |
457 | 1973 | 1923 | ||
458 | 1974 | void CmdProposeTrade::serialize(StreamWrite& ser) { | 1924 | void CmdProposeTrade::serialize(StreamWrite& ser) { |
461 | 1975 | ser.unsigned_8(PLCMD_PROPOSE_TRADE); | 1925 | write_id_and_sender(ser); |
460 | 1976 | ser.unsigned_8(sender()); | ||
462 | 1977 | ser.unsigned_32(trade_.initiator); | 1926 | ser.unsigned_32(trade_.initiator); |
463 | 1978 | ser.unsigned_32(trade_.receiver); | 1927 | ser.unsigned_32(trade_.receiver); |
464 | 1979 | serialize_bill_of_materials(trade_.items_to_send, &ser); | 1928 | serialize_bill_of_materials(trade_.items_to_send, &ser); |
465 | 1980 | 1929 | ||
466 | === modified file 'src/logic/playercommand.h' | |||
467 | --- src/logic/playercommand.h 2019-06-23 14:28:50 +0000 | |||
468 | +++ src/logic/playercommand.h 2019-08-26 10:38:04 +0000 | |||
469 | @@ -52,6 +52,8 @@ | |||
470 | 52 | PlayerCommand() : GameLogicCommand(0), sender_(0), cmdserial_(0) { | 52 | PlayerCommand() : GameLogicCommand(0), sender_(0), cmdserial_(0) { |
471 | 53 | } | 53 | } |
472 | 54 | 54 | ||
473 | 55 | void write_id_and_sender(StreamWrite& ser); | ||
474 | 56 | |||
475 | 55 | PlayerNumber sender() const { | 57 | PlayerNumber sender() const { |
476 | 56 | return sender_; | 58 | return sender_; |
477 | 57 | } | 59 | } |
478 | @@ -62,6 +64,7 @@ | |||
479 | 62 | cmdserial_ = s; | 64 | cmdserial_ = s; |
480 | 63 | } | 65 | } |
481 | 64 | 66 | ||
482 | 67 | // For networking and replays | ||
483 | 65 | virtual void serialize(StreamWrite&) = 0; | 68 | virtual void serialize(StreamWrite&) = 0; |
484 | 66 | static Widelands::PlayerCommand* deserialize(StreamRead&); | 69 | static Widelands::PlayerCommand* deserialize(StreamRead&); |
485 | 67 | 70 | ||
486 | @@ -138,7 +141,7 @@ | |||
487 | 138 | void read(FileRead&, EditorGameBase&, MapObjectLoader&) override; | 141 | void read(FileRead&, EditorGameBase&, MapObjectLoader&) override; |
488 | 139 | 142 | ||
489 | 140 | QueueCommandTypes id() const override { | 143 | QueueCommandTypes id() const override { |
491 | 141 | return QueueCommandTypes::kFlag; | 144 | return QueueCommandTypes::kBuildFlag; |
492 | 142 | } | 145 | } |
493 | 143 | 146 | ||
494 | 144 | void execute(Game&) override; | 147 | void execute(Game&) override; |
495 | @@ -207,7 +210,7 @@ | |||
496 | 207 | void read(FileRead&, EditorGameBase&, MapObjectLoader&) override; | 210 | void read(FileRead&, EditorGameBase&, MapObjectLoader&) override; |
497 | 208 | 211 | ||
498 | 209 | QueueCommandTypes id() const override { | 212 | QueueCommandTypes id() const override { |
500 | 210 | return QueueCommandTypes::kStopBuilding; | 213 | return QueueCommandTypes::kStartStopBuilding; |
501 | 211 | } | 214 | } |
502 | 212 | 215 | ||
503 | 213 | explicit CmdStartStopBuilding(StreamRead&); | 216 | explicit CmdStartStopBuilding(StreamRead&); |
504 | @@ -257,7 +260,7 @@ | |||
505 | 257 | void read(FileRead&, EditorGameBase&, MapObjectLoader&) override; | 260 | void read(FileRead&, EditorGameBase&, MapObjectLoader&) override; |
506 | 258 | 261 | ||
507 | 259 | QueueCommandTypes id() const override { | 262 | QueueCommandTypes id() const override { |
509 | 260 | return QueueCommandTypes::kPortStartExpedition; | 263 | return QueueCommandTypes::kStartOrCancelExpedition; |
510 | 261 | } | 264 | } |
511 | 262 | 265 | ||
512 | 263 | explicit CmdStartOrCancelExpedition(StreamRead&); | 266 | explicit CmdStartOrCancelExpedition(StreamRead&); |
513 | @@ -356,7 +359,7 @@ | |||
514 | 356 | void read(FileRead&, EditorGameBase&, MapObjectLoader&) override; | 359 | void read(FileRead&, EditorGameBase&, MapObjectLoader&) override; |
515 | 357 | 360 | ||
516 | 358 | QueueCommandTypes id() const override { | 361 | QueueCommandTypes id() const override { |
518 | 359 | return QueueCommandTypes::kShipScout; | 362 | return QueueCommandTypes::kShipScoutDirection; |
519 | 360 | } | 363 | } |
520 | 361 | 364 | ||
521 | 362 | explicit CmdShipScoutDirection(StreamRead&); | 365 | explicit CmdShipScoutDirection(StreamRead&); |
522 | @@ -408,7 +411,7 @@ | |||
523 | 408 | void read(FileRead&, EditorGameBase&, MapObjectLoader&) override; | 411 | void read(FileRead&, EditorGameBase&, MapObjectLoader&) override; |
524 | 409 | 412 | ||
525 | 410 | QueueCommandTypes id() const override { | 413 | QueueCommandTypes id() const override { |
527 | 411 | return QueueCommandTypes::kShipExplore; | 414 | return QueueCommandTypes::kShipExploreIsland; |
528 | 412 | } | 415 | } |
529 | 413 | 416 | ||
530 | 414 | explicit CmdShipExploreIsland(StreamRead&); | 417 | explicit CmdShipExploreIsland(StreamRead&); |
531 | @@ -431,7 +434,7 @@ | |||
532 | 431 | void read(FileRead&, EditorGameBase&, MapObjectLoader&) override; | 434 | void read(FileRead&, EditorGameBase&, MapObjectLoader&) override; |
533 | 432 | 435 | ||
534 | 433 | QueueCommandTypes id() const override { | 436 | QueueCommandTypes id() const override { |
536 | 434 | return QueueCommandTypes::kSinkShip; | 437 | return QueueCommandTypes::kShipSink; |
537 | 435 | } | 438 | } |
538 | 436 | 439 | ||
539 | 437 | explicit CmdShipSink(StreamRead&); | 440 | explicit CmdShipSink(StreamRead&); |
540 | 438 | 441 | ||
541 | === modified file 'src/logic/queue_cmd_factory.cc' | |||
542 | --- src/logic/queue_cmd_factory.cc 2019-06-09 10:33:51 +0000 | |||
543 | +++ src/logic/queue_cmd_factory.cc 2019-08-26 10:38:04 +0000 | |||
544 | @@ -34,13 +34,13 @@ | |||
545 | 34 | switch (id) { | 34 | switch (id) { |
546 | 35 | case QueueCommandTypes::kBuild: | 35 | case QueueCommandTypes::kBuild: |
547 | 36 | return *new CmdBuild(); | 36 | return *new CmdBuild(); |
549 | 37 | case QueueCommandTypes::kFlag: | 37 | case QueueCommandTypes::kBuildFlag: |
550 | 38 | return *new CmdBuildFlag(); | 38 | return *new CmdBuildFlag(); |
551 | 39 | case QueueCommandTypes::kBuildRoad: | 39 | case QueueCommandTypes::kBuildRoad: |
552 | 40 | return *new CmdBuildRoad(); | 40 | return *new CmdBuildRoad(); |
553 | 41 | case QueueCommandTypes::kFlagAction: | 41 | case QueueCommandTypes::kFlagAction: |
554 | 42 | return *new CmdFlagAction(); | 42 | return *new CmdFlagAction(); |
556 | 43 | case QueueCommandTypes::kStopBuilding: | 43 | case QueueCommandTypes::kStartStopBuilding: |
557 | 44 | return *new CmdStartStopBuilding(); | 44 | return *new CmdStartStopBuilding(); |
558 | 45 | case QueueCommandTypes::kEnhanceBuilding: | 45 | case QueueCommandTypes::kEnhanceBuilding: |
559 | 46 | return *new CmdEnhanceBuilding(); | 46 | return *new CmdEnhanceBuilding(); |
560 | @@ -80,17 +80,17 @@ | |||
561 | 80 | return *new CmdMilitarySiteSetSoldierPreference(); | 80 | return *new CmdMilitarySiteSetSoldierPreference(); |
562 | 81 | case QueueCommandTypes::kProposeTrade: | 81 | case QueueCommandTypes::kProposeTrade: |
563 | 82 | return *new CmdProposeTrade(); | 82 | return *new CmdProposeTrade(); |
565 | 83 | case QueueCommandTypes::kSinkShip: | 83 | case QueueCommandTypes::kShipSink: |
566 | 84 | return *new CmdShipSink(); | 84 | return *new CmdShipSink(); |
567 | 85 | case QueueCommandTypes::kShipCancelExpedition: | 85 | case QueueCommandTypes::kShipCancelExpedition: |
568 | 86 | return *new CmdShipCancelExpedition(); | 86 | return *new CmdShipCancelExpedition(); |
570 | 87 | case QueueCommandTypes::kPortStartExpedition: | 87 | case QueueCommandTypes::kStartOrCancelExpedition: |
571 | 88 | return *new CmdStartOrCancelExpedition(); | 88 | return *new CmdStartOrCancelExpedition(); |
572 | 89 | case QueueCommandTypes::kShipConstructPort: | 89 | case QueueCommandTypes::kShipConstructPort: |
573 | 90 | return *new CmdShipConstructPort(); | 90 | return *new CmdShipConstructPort(); |
575 | 91 | case QueueCommandTypes::kShipScout: | 91 | case QueueCommandTypes::kShipScoutDirection: |
576 | 92 | return *new CmdShipScoutDirection(); | 92 | return *new CmdShipScoutDirection(); |
578 | 93 | case QueueCommandTypes::kShipExplore: | 93 | case QueueCommandTypes::kShipExploreIsland: |
579 | 94 | return *new CmdShipExploreIsland(); | 94 | return *new CmdShipExploreIsland(); |
580 | 95 | case QueueCommandTypes::kDestroyMapObject: | 95 | case QueueCommandTypes::kDestroyMapObject: |
581 | 96 | return *new CmdDestroyMapObject(); | 96 | return *new CmdDestroyMapObject(); |
582 | 97 | 97 | ||
583 | === modified file 'src/logic/queue_cmd_ids.h' | |||
584 | --- src/logic/queue_cmd_ids.h 2019-06-09 10:33:51 +0000 | |||
585 | +++ src/logic/queue_cmd_ids.h 2019-08-26 10:38:04 +0000 | |||
586 | @@ -33,17 +33,21 @@ | |||
587 | 33 | 33 | ||
588 | 34 | namespace Widelands { | 34 | namespace Widelands { |
589 | 35 | 35 | ||
591 | 36 | enum class QueueCommandTypes { | 36 | // The command types are used by the QueueCmdFactory, for network serialization |
592 | 37 | // and for savegame compatibility. | ||
593 | 38 | // DO NOT change the order | ||
594 | 39 | // TODO(GunChleoc): Whenever we break savegame compatibility, clean this up and change data type to uint16_t. | ||
595 | 40 | enum class QueueCommandTypes : uint8_t { | ||
596 | 37 | 41 | ||
597 | 38 | /* ID zero is reserved and must never be used */ | 42 | /* ID zero is reserved and must never be used */ |
598 | 39 | kNone = 0, | 43 | kNone = 0, |
599 | 40 | 44 | ||
600 | 41 | /* PLAYER COMMANDS BELOW */ | 45 | /* PLAYER COMMANDS BELOW */ |
601 | 42 | kBuild, | 46 | kBuild, |
603 | 43 | kFlag, | 47 | kBuildFlag, |
604 | 44 | kBuildRoad, | 48 | kBuildRoad, |
605 | 45 | kFlagAction, | 49 | kFlagAction, |
607 | 46 | kStopBuilding, | 50 | kStartStopBuilding, |
608 | 47 | kEnhanceBuilding, | 51 | kEnhanceBuilding, |
609 | 48 | kBulldoze, | 52 | kBulldoze, |
610 | 49 | 53 | ||
611 | @@ -73,12 +77,14 @@ | |||
612 | 73 | kMilitarysiteSetSoldierPreference, | 77 | kMilitarysiteSetSoldierPreference, |
613 | 74 | kProposeTrade, // 27 | 78 | kProposeTrade, // 27 |
614 | 75 | 79 | ||
616 | 76 | kSinkShip = 121, | 80 | kShipSink = 121, |
617 | 77 | kShipCancelExpedition, | 81 | kShipCancelExpedition, |
619 | 78 | kPortStartExpedition, | 82 | kStartOrCancelExpedition, |
620 | 79 | kShipConstructPort, | 83 | kShipConstructPort, |
623 | 80 | kShipScout, | 84 | kShipScoutDirection, |
624 | 81 | kShipExplore, | 85 | kShipExploreIsland, |
625 | 86 | |||
626 | 87 | // The commands below are never serialized, but we still keep the IDs stable for savegame compatibility. | ||
627 | 82 | 88 | ||
628 | 83 | kDestroyMapObject, | 89 | kDestroyMapObject, |
629 | 84 | kAct, // 128 | 90 | kAct, // 128 |
630 | 85 | 91 | ||
631 | === modified file 'src/logic/replay.cc' | |||
632 | --- src/logic/replay.cc 2019-02-24 22:50:04 +0000 | |||
633 | +++ src/logic/replay.cc 2019-08-26 10:38:04 +0000 | |||
634 | @@ -38,8 +38,9 @@ | |||
635 | 38 | namespace Widelands { | 38 | namespace Widelands { |
636 | 39 | 39 | ||
637 | 40 | // File format definitions | 40 | // File format definitions |
638 | 41 | constexpr uint32_t kReplayKnownToDesync = 0x2E21A100; | ||
639 | 41 | constexpr uint32_t kReplayMagic = 0x2E21A101; | 42 | constexpr uint32_t kReplayMagic = 0x2E21A101; |
641 | 42 | constexpr uint8_t kCurrentPacketVersion = 2; | 43 | constexpr uint8_t kCurrentPacketVersion = 3; |
642 | 43 | constexpr uint32_t kSyncInterval = 200; | 44 | constexpr uint32_t kSyncInterval = 200; |
643 | 44 | 45 | ||
644 | 45 | enum { pkt_end = 2, pkt_playercommand = 3, pkt_syncreport = 4 }; | 46 | enum { pkt_end = 2, pkt_playercommand = 3, pkt_syncreport = 4 }; |
645 | @@ -93,13 +94,15 @@ | |||
646 | 93 | 94 | ||
647 | 94 | try { | 95 | try { |
648 | 95 | const uint32_t magic = cmdlog_->unsigned_32(); | 96 | const uint32_t magic = cmdlog_->unsigned_32(); |
650 | 96 | if (magic == 0x2E21A100) | 97 | if (magic == kReplayKnownToDesync) { |
651 | 97 | // Note: This was never released as part of a build | 98 | // Note: This was never released as part of a build |
652 | 98 | throw wexception("%s is a replay from a version that is known to have desync " | 99 | throw wexception("%s is a replay from a version that is known to have desync " |
653 | 99 | "problems", | 100 | "problems", |
654 | 100 | filename.c_str()); | 101 | filename.c_str()); |
656 | 101 | if (magic != kReplayMagic) | 102 | } |
657 | 103 | if (magic != kReplayMagic) { | ||
658 | 102 | throw wexception("%s apparently not a valid replay file", filename.c_str()); | 104 | throw wexception("%s apparently not a valid replay file", filename.c_str()); |
659 | 105 | } | ||
660 | 103 | 106 | ||
661 | 104 | const uint8_t packet_version = cmdlog_->unsigned_8(); | 107 | const uint8_t packet_version = cmdlog_->unsigned_8(); |
662 | 105 | if (packet_version != kCurrentPacketVersion) { | 108 | if (packet_version != kCurrentPacketVersion) { |
Continuous integration builds have changed state:
Travis build 5244. State: passed. Details: https:/ /travis- ci.org/ widelands/ widelands/ builds/ 549982685. /ci.appveyor. com/project/ widelands- dev/widelands/ build/_ widelands_ dev_widelands_ cleanup_ playercommand_ enums-5023.
Appveyor build 5023. State: success. Details: https:/