Merge lp:~widelands-dev/widelands/bug-1823612-llvm8-build-errors into lp:widelands
- bug-1823612-llvm8-build-errors
- Merge into trunk
Status: | Merged | ||||
---|---|---|---|---|---|
Merged at revision: | 9042 | ||||
Proposed branch: | lp:~widelands-dev/widelands/bug-1823612-llvm8-build-errors | ||||
Merge into: | lp:widelands | ||||
Diff against target: |
2084 lines (+414/-372) 40 files modified
src/ai/ai_help_structs.cc (+4/-4) src/ai/defaultai.cc (+15/-17) src/ai/defaultai_warfare.cc (+0/-1) src/economy/economy.cc (+2/-2) src/economy/ware_instance.cc (+2/-2) src/editor/tools/info_tool.cc (+1/-1) src/editor/ui_menus/tool_menu.cc (+8/-8) src/graphic/gl/initialize.cc (+24/-24) src/graphic/gl/utils.cc (+2/-2) src/io/filesystem/test/test_filesystem.cc (+70/-70) src/logic/map_objects/bob.cc (+8/-8) src/logic/map_objects/immovable.cc (+4/-4) src/logic/map_objects/tribes/building.cc (+4/-4) src/logic/map_objects/tribes/production_program.cc (+65/-55) src/logic/map_objects/tribes/productionsite.cc (+11/-10) src/logic/map_objects/tribes/productionsite.h (+3/-3) src/logic/map_objects/tribes/program_result.h (+19/-3) src/logic/map_objects/tribes/trainingsite.cc (+2/-2) src/logic/map_objects/tribes/tribe_descr.cc (+1/-1) src/logic/map_objects/tribes/worker.cc (+10/-10) src/logic/map_objects/world/terrain_description.h (+9/-1) src/logic/mapdifferenceregion.h (+6/-6) src/logic/maphollowregion.cc (+14/-11) src/logic/maphollowregion.h (+16/-8) src/logic/maptriangleregion.cc (+26/-26) src/logic/maptriangleregion.h (+1/-1) src/logic/player.cc (+2/-2) src/map_io/map_buildingdata_packet.cc (+3/-2) src/map_io/map_players_view_packet.cc (+47/-47) src/map_io/s2map.cc (+1/-1) src/scripting/lua_bases.cc (+1/-1) src/scripting/lua_game.cc (+7/-7) src/scripting/lua_map.cc (+17/-17) src/sound/sound_handler.cc (+1/-1) src/ui_basic/box.cc (+1/-1) src/ui_basic/editbox.cc (+4/-3) src/ui_basic/unique_window.h (+0/-3) src/ui_fsmenu/main.cc (+1/-1) src/ui_fsmenu/netsetup_lan.cc (+1/-1) src/wui/interactive_player.cc (+1/-1) |
||||
To merge this branch: | bzr merge lp:~widelands-dev/widelands/bug-1823612-llvm8-build-errors | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
hessenfarmer | test | Approve | |
GunChleoc | Needs Resubmitting | ||
Review via email: mp+365644@code.launchpad.net |
Commit message
Fix compile errors for clang 8.
Description of the change
I am still on Clang 6, so we have to wait for Travis to see if this is indeed fixed.
bunnybot (widelandsofficial) wrote : | # |
GunChleoc (gunchleoc) wrote : | # |
This is ready for review now, targeted at Build 20.
hessenfarmer (stephan-lutz) wrote : | # |
Found at least one questionable change in ai code see inline.
needs intensive testing of programs especially for the mines
TiborB (tiborb95) wrote : | # |
Yes, it is obviously a typo but I suggest not to touch it unless it is followed by some training. BTW, I plan to came return and spend some time on AI in about two months....
hessenfarmer (stephan-lutz) wrote : | # |
BTW: what was the reason for change the Program result code, as the previous revision did already compile with clang 8?
bunnybot (widelandsofficial) wrote : | # |
Continuous integration builds have changed state:
Travis build 4706. State: errored. Details: https:/
Appveyor build 4492. State: success. Details: https:/
GunChleoc (gunchleoc) wrote : | # |
Which changes do you mean exactly? Please point me to the commit in the commit log for this branch, or to the line in the code.
All that the AI change does is to assign a value to the same element only once instead of twice. Do you want me to record the value assignment that I deleted in a comment?
TiborB (tiborb95) wrote : | # |
@Gun, I am not sure whom you are asking, but still I left the comment in the code....
hessenfarmer (stephan-lutz) wrote : | # |
@Tibor:
I think that was addressed to my question. I was just wondering what is the reason behind commit 9048. I am a little bit concerned due to the commit message whether the programs still work as desired. Especially whether the statistics fix (result no-stats) still works.
hessenfarmer (stephan-lutz) wrote : | # |
for the AI part we could leave this as it is now (i.e. nothing has changed) and record a bug to fix inputs[19] in this part of the code.
TiborB (tiborb95) wrote : | # |
@hessenfarmer - the bug is too much as no real harm is done here, todo in the code would be enough....
GunChleoc (gunchleoc) wrote : | # |
I have added a TODO to the AI code.
I have verified that no_stats is not affected by the bugfix in the production programs. I don't know if we ever entered the buggy state, but if we did, this will actually fix the stats: If duration was not set for these programs, Widelands would have picked a duration between 0 and 3 ms, depending on the ID of the current program state (Failed, Skipped, Completed..). Now, the duration is always 0 ms like it should be.
hessenfarmer (stephan-lutz) wrote : | # |
ok thanks for the explanation.
did some playtesting. Found no anomalies.
bunnybot (widelandsofficial) wrote : | # |
Continuous integration builds have changed state:
Travis build 4709. State: passed. Details: https:/
Appveyor build 4495. State: success. Details: https:/
GunChleoc (gunchleoc) wrote : | # |
Thanks!
Let's have it.
@bunnybot merge
Preview Diff
1 | === modified file 'src/ai/ai_help_structs.cc' |
2 | --- src/ai/ai_help_structs.cc 2019-02-23 11:00:49 +0000 |
3 | +++ src/ai/ai_help_structs.cc 2019-04-10 16:40:56 +0000 |
4 | @@ -1148,12 +1148,12 @@ |
5 | if (this_player_team != mytn) { |
6 | log("%2d: Team changed %d -> %d\n", pn, this_player_team, mytn); |
7 | this_player_team = mytn; |
8 | - }; |
9 | + } |
10 | if (all_stats[opn].team_number != pltn) { |
11 | log("%2d: Team changed for player %d: %d -> %d\n", pn, opn, all_stats[opn].team_number, |
12 | pltn); |
13 | all_stats[opn].team_number = pltn; |
14 | - }; |
15 | + } |
16 | } |
17 | } |
18 | |
19 | @@ -1248,7 +1248,7 @@ |
20 | uint32_t PlayersStrengths::get_player_power(Widelands::PlayerNumber pn) { |
21 | if (all_stats.count(pn) > 0) { |
22 | return all_stats[pn].players_power; |
23 | - }; |
24 | + } |
25 | return 0; |
26 | } |
27 | |
28 | @@ -1256,7 +1256,7 @@ |
29 | uint32_t PlayersStrengths::get_player_land(Widelands::PlayerNumber pn) { |
30 | if (all_stats.count(pn) > 0) { |
31 | return all_stats[pn].players_land; |
32 | - }; |
33 | + } |
34 | return 0; |
35 | } |
36 | |
37 | |
38 | === modified file 'src/ai/defaultai.cc' |
39 | --- src/ai/defaultai.cc 2019-03-24 13:13:34 +0000 |
40 | +++ src/ai/defaultai.cc 2019-04-10 16:40:56 +0000 |
41 | @@ -327,7 +327,7 @@ |
42 | case SchedulerTaskId::kRoadCheck: |
43 | if (check_economies()) { // is a must |
44 | return; |
45 | - }; |
46 | + } |
47 | set_taskpool_task_time(gametime + 1000, SchedulerTaskId::kRoadCheck); |
48 | // testing 5 roads |
49 | { |
50 | @@ -337,7 +337,7 @@ |
51 | if (improve_roads(gametime)) { |
52 | // if significant change takes place do not go on |
53 | break; |
54 | - }; |
55 | + } |
56 | } |
57 | } |
58 | break; |
59 | @@ -380,7 +380,7 @@ |
60 | if (check_productionsites(gametime)) { |
61 | // if significant change takes place do not go on |
62 | break; |
63 | - }; |
64 | + } |
65 | } |
66 | } |
67 | break; |
68 | @@ -413,7 +413,7 @@ |
69 | if (check_mines_(gametime)) { |
70 | // if significant change takes place do not go on |
71 | break; |
72 | - }; |
73 | + } |
74 | } |
75 | } |
76 | break; |
77 | @@ -460,7 +460,7 @@ |
78 | if (get_land_owner(game().map(), coords) == player_number()) { |
79 | ++conquered_wh; |
80 | } |
81 | - }; |
82 | + } |
83 | if (!basic_economy_established) { |
84 | assert(!persistent_data->remaining_basic_buildings.empty()); |
85 | log("%2d: Basic economy not achieved, %" PRIuS " building(s) missing, f.e.: %s\n", |
86 | @@ -3078,7 +3078,6 @@ |
87 | (bf->military_in_constr_nearby + bf->military_unstationed) < |
88 | concurent_ms_in_constr_no_enemy) { |
89 | // it will conquer new buildable spots for buildings or mines |
90 | - ; |
91 | } else if (bf->defense_msite_allowed && |
92 | (bf->military_in_constr_nearby + bf->military_unstationed) < |
93 | concurent_ms_in_constr_enemy_nearby) { |
94 | @@ -3514,15 +3513,15 @@ |
95 | if (!has_building && flag.nr_of_roads() == 1) { |
96 | return false; |
97 | } else if (is_warehouse && flag.nr_of_roads() <= 3) { |
98 | - ; |
99 | + // Do nothing |
100 | } else if (needs_warehouse) { |
101 | - ; |
102 | + // Do nothing |
103 | } else if (flag.current_wares() > 5) { |
104 | - ; |
105 | + // Do nothing |
106 | } else if (has_building && std::rand() % 3 == 0) { |
107 | - ; |
108 | + // Do nothing |
109 | } else if (std::rand() % 10 == 0) { |
110 | - ; |
111 | + // Do nothing |
112 | } else { |
113 | return false; |
114 | } |
115 | @@ -3753,8 +3752,6 @@ |
116 | // if we are within grace time, it is OK, just go on |
117 | if (eco->dismantle_grace_time > gametime && |
118 | eco->dismantle_grace_time != std::numeric_limits<uint32_t>::max()) { |
119 | - ; |
120 | - |
121 | // if grace time is not set, this is probably first time without a warehouse and we must |
122 | // set it |
123 | } else if (eco->dismantle_grace_time == std::numeric_limits<uint32_t>::max()) { |
124 | @@ -5458,10 +5455,11 @@ |
125 | inputs[14] = (bo.current_stats - 50) / 10; |
126 | inputs[15] = management_data.get_military_number_at(123) / 10; |
127 | inputs[16] = 0; |
128 | - inputs[17] = (inputs_on_stock) ? 0 : -2; |
129 | + // TODO(GunChleoc): This is overwritten below due to a typo |
130 | + // inputs[17] = (inputs_on_stock) ? 0 : -2; |
131 | inputs[18] = (suppliers_exist) ? 0 : -3; |
132 | - ; |
133 | inputs[17] = (inputs_on_stock) ? 0 : -4; |
134 | + // Nothing on inputs[19] |
135 | inputs[20] = |
136 | (mines_per_type[bo.mines].in_construction + mines_per_type[bo.mines].finished == 1) ? |
137 | 3 : |
138 | @@ -6060,7 +6058,7 @@ |
139 | // 2. in new flags to be processed yet |
140 | if (remove_from_dqueue<Widelands::Flag>(new_flags, flag)) { |
141 | return; |
142 | - }; |
143 | + } |
144 | |
145 | // 3. Or in neither of them |
146 | } else if (upcast(Road const, road, &pi)) { |
147 | @@ -6152,7 +6150,7 @@ |
148 | // (used when testing possible port location) |
149 | if (f->nodecaps() & BUILDCAPS_MINE) { |
150 | mineable_fields_count += 1; |
151 | - }; |
152 | + } |
153 | |
154 | // add neighbours to a queue (duplicates are no problem) |
155 | // to relieve AI/CPU we skip every second field in each direction |
156 | |
157 | === modified file 'src/ai/defaultai_warfare.cc' |
158 | --- src/ai/defaultai_warfare.cc 2019-02-23 11:00:49 +0000 |
159 | +++ src/ai/defaultai_warfare.cc 2019-04-10 16:40:56 +0000 |
160 | @@ -266,7 +266,6 @@ |
161 | inputs[3] = (is_warehouse) ? 2 : 0; |
162 | inputs[4] = (site->second.attack_soldiers_competency > 15) ? 2 : 0; |
163 | inputs[5] = (site->second.attack_soldiers_competency > 25) ? 4 : 0; |
164 | - ; |
165 | inputs[6] = |
166 | (2 * site->second.defenders_strength > 3 * site->second.attack_soldiers_strength) ? |
167 | 2 : |
168 | |
169 | === modified file 'src/economy/economy.cc' |
170 | --- src/economy/economy.cc 2019-02-23 11:00:49 +0000 |
171 | +++ src/economy/economy.cc 2019-04-10 16:40:56 +0000 |
172 | @@ -434,9 +434,9 @@ |
173 | RequestList::iterator const it = std::find(requests_.begin(), requests_.end(), &req); |
174 | |
175 | if (it == requests_.end()) { |
176 | - FORMAT_WARNINGS_OFF; |
177 | + FORMAT_WARNINGS_OFF |
178 | log("WARNING: remove_request(%p) not in list\n", &req); |
179 | - FORMAT_WARNINGS_ON; |
180 | + FORMAT_WARNINGS_ON |
181 | return; |
182 | } |
183 | |
184 | |
185 | === modified file 'src/economy/ware_instance.cc' |
186 | --- src/economy/ware_instance.cc 2019-02-23 11:00:49 +0000 |
187 | +++ src/economy/ware_instance.cc 2019-04-10 16:40:56 +0000 |
188 | @@ -187,9 +187,9 @@ |
189 | |
190 | WareInstance::~WareInstance() { |
191 | if (supply_) { |
192 | - FORMAT_WARNINGS_OFF; |
193 | + FORMAT_WARNINGS_OFF |
194 | molog("Ware %u still has supply %p\n", descr_index_, supply_); |
195 | - FORMAT_WARNINGS_ON; |
196 | + FORMAT_WARNINGS_ON |
197 | delete supply_; |
198 | } |
199 | } |
200 | |
201 | === modified file 'src/editor/tools/info_tool.cc' |
202 | --- src/editor/tools/info_tool.cc 2019-02-23 11:00:49 +0000 |
203 | +++ src/editor/tools/info_tool.cc 2019-04-10 16:40:56 +0000 |
204 | @@ -74,7 +74,7 @@ |
205 | } break; |
206 | default: |
207 | break; |
208 | - }; |
209 | + } |
210 | |
211 | if (caps & Widelands::BUILDCAPS_FLAG) { |
212 | /** TRANSLATORS: Editor terrain property: space for a flag */ |
213 | |
214 | === modified file 'src/editor/ui_menus/tool_menu.cc' |
215 | --- src/editor/ui_menus/tool_menu.cc 2019-02-23 11:00:49 +0000 |
216 | +++ src/editor/ui_menus/tool_menu.cc 2019-04-10 16:40:56 +0000 |
217 | @@ -56,15 +56,15 @@ |
218 | this, pos, g_gr->images().get("images/wui/editor/editor_menu_tool_" pic ".png"), tooltip); \ |
219 | pos.x += width + spacing; |
220 | |
221 | - ADD_BUTTON("change_height", _("Change height")); |
222 | - ADD_BUTTON("noise_height", _("Random height")); |
223 | - ADD_BUTTON("set_terrain", _("Terrain")); |
224 | - ADD_BUTTON("place_immovable", _("Immovables")); |
225 | - ADD_BUTTON("place_bob", _("Animals")); |
226 | - ADD_BUTTON("change_resources", _("Resources")); |
227 | - ADD_BUTTON("set_port_space", _("Set port space")); |
228 | + ADD_BUTTON("change_height", _("Change height")) |
229 | + ADD_BUTTON("noise_height", _("Random height")) |
230 | + ADD_BUTTON("set_terrain", _("Terrain")) |
231 | + ADD_BUTTON("place_immovable", _("Immovables")) |
232 | + ADD_BUTTON("place_bob", _("Animals")) |
233 | + ADD_BUTTON("change_resources", _("Resources")) |
234 | + ADD_BUTTON("set_port_space", _("Set port space")) |
235 | ADD_BUTTON("set_origin", _("Set the position that will have the coordinates (0, 0). This will " |
236 | - "be the top-left corner of a generated minimap.")); |
237 | + "be the top-left corner of a generated minimap.")) |
238 | |
239 | set_inner_size(offs.x + (width + spacing) * num_tools, offs.y + (height + spacing)); |
240 | |
241 | |
242 | === modified file 'src/graphic/gl/initialize.cc' |
243 | --- src/graphic/gl/initialize.cc 2019-02-23 22:42:03 +0000 |
244 | +++ src/graphic/gl/initialize.cc 2019-04-10 16:40:56 +0000 |
245 | @@ -101,17 +101,17 @@ |
246 | glbinding::setAfterCallback([](const glbinding::FunctionCall& call) { |
247 | log("%s(", call.function->name()); |
248 | for (size_t i = 0; i < call.parameters.size(); ++i) { |
249 | - FORMAT_WARNINGS_OFF; |
250 | + FORMAT_WARNINGS_OFF |
251 | log("%p", call.parameters[i].get()); |
252 | - FORMAT_WARNINGS_ON; |
253 | + FORMAT_WARNINGS_ON |
254 | if (i < call.parameters.size() - 1) |
255 | log(", "); |
256 | } |
257 | log(")"); |
258 | if (call.returnValue) { |
259 | - FORMAT_WARNINGS_OFF; |
260 | + FORMAT_WARNINGS_OFF |
261 | log(" -> %p", call.returnValue.get()); |
262 | - FORMAT_WARNINGS_ON; |
263 | + FORMAT_WARNINGS_ON |
264 | } |
265 | const auto error = glGetError(); |
266 | log(" [%s]\n", gl_error_to_string(error)); |
267 | @@ -151,26 +151,26 @@ |
268 | |
269 | LOG_SDL_GL_ATTRIBUTE(SDL_GL_RED_SIZE) |
270 | LOG_SDL_GL_ATTRIBUTE(SDL_GL_GREEN_SIZE) |
271 | - LOG_SDL_GL_ATTRIBUTE(SDL_GL_BLUE_SIZE); |
272 | - LOG_SDL_GL_ATTRIBUTE(SDL_GL_ALPHA_SIZE); |
273 | - LOG_SDL_GL_ATTRIBUTE(SDL_GL_BUFFER_SIZE); |
274 | - LOG_SDL_GL_ATTRIBUTE(SDL_GL_DOUBLEBUFFER); |
275 | - LOG_SDL_GL_ATTRIBUTE(SDL_GL_DEPTH_SIZE); |
276 | - LOG_SDL_GL_ATTRIBUTE(SDL_GL_STENCIL_SIZE); |
277 | - LOG_SDL_GL_ATTRIBUTE(SDL_GL_ACCUM_RED_SIZE); |
278 | - LOG_SDL_GL_ATTRIBUTE(SDL_GL_ACCUM_GREEN_SIZE); |
279 | - LOG_SDL_GL_ATTRIBUTE(SDL_GL_ACCUM_BLUE_SIZE); |
280 | - LOG_SDL_GL_ATTRIBUTE(SDL_GL_ACCUM_ALPHA_SIZE); |
281 | - LOG_SDL_GL_ATTRIBUTE(SDL_GL_STEREO); |
282 | - LOG_SDL_GL_ATTRIBUTE(SDL_GL_MULTISAMPLEBUFFERS); |
283 | - LOG_SDL_GL_ATTRIBUTE(SDL_GL_MULTISAMPLESAMPLES); |
284 | - LOG_SDL_GL_ATTRIBUTE(SDL_GL_ACCELERATED_VISUAL); |
285 | - LOG_SDL_GL_ATTRIBUTE(SDL_GL_CONTEXT_MAJOR_VERSION); |
286 | - LOG_SDL_GL_ATTRIBUTE(SDL_GL_CONTEXT_MINOR_VERSION); |
287 | - LOG_SDL_GL_ATTRIBUTE(SDL_GL_CONTEXT_FLAGS); |
288 | - LOG_SDL_GL_ATTRIBUTE(SDL_GL_CONTEXT_PROFILE_MASK); |
289 | - LOG_SDL_GL_ATTRIBUTE(SDL_GL_SHARE_WITH_CURRENT_CONTEXT); |
290 | - LOG_SDL_GL_ATTRIBUTE(SDL_GL_FRAMEBUFFER_SRGB_CAPABLE); |
291 | + LOG_SDL_GL_ATTRIBUTE(SDL_GL_BLUE_SIZE) |
292 | + LOG_SDL_GL_ATTRIBUTE(SDL_GL_ALPHA_SIZE) |
293 | + LOG_SDL_GL_ATTRIBUTE(SDL_GL_BUFFER_SIZE) |
294 | + LOG_SDL_GL_ATTRIBUTE(SDL_GL_DOUBLEBUFFER) |
295 | + LOG_SDL_GL_ATTRIBUTE(SDL_GL_DEPTH_SIZE) |
296 | + LOG_SDL_GL_ATTRIBUTE(SDL_GL_STENCIL_SIZE) |
297 | + LOG_SDL_GL_ATTRIBUTE(SDL_GL_ACCUM_RED_SIZE) |
298 | + LOG_SDL_GL_ATTRIBUTE(SDL_GL_ACCUM_GREEN_SIZE) |
299 | + LOG_SDL_GL_ATTRIBUTE(SDL_GL_ACCUM_BLUE_SIZE) |
300 | + LOG_SDL_GL_ATTRIBUTE(SDL_GL_ACCUM_ALPHA_SIZE) |
301 | + LOG_SDL_GL_ATTRIBUTE(SDL_GL_STEREO) |
302 | + LOG_SDL_GL_ATTRIBUTE(SDL_GL_MULTISAMPLEBUFFERS) |
303 | + LOG_SDL_GL_ATTRIBUTE(SDL_GL_MULTISAMPLESAMPLES) |
304 | + LOG_SDL_GL_ATTRIBUTE(SDL_GL_ACCELERATED_VISUAL) |
305 | + LOG_SDL_GL_ATTRIBUTE(SDL_GL_CONTEXT_MAJOR_VERSION) |
306 | + LOG_SDL_GL_ATTRIBUTE(SDL_GL_CONTEXT_MINOR_VERSION) |
307 | + LOG_SDL_GL_ATTRIBUTE(SDL_GL_CONTEXT_FLAGS) |
308 | + LOG_SDL_GL_ATTRIBUTE(SDL_GL_CONTEXT_PROFILE_MASK) |
309 | + LOG_SDL_GL_ATTRIBUTE(SDL_GL_SHARE_WITH_CURRENT_CONTEXT) |
310 | + LOG_SDL_GL_ATTRIBUTE(SDL_GL_FRAMEBUFFER_SRGB_CAPABLE) |
311 | #undef LOG_SDL_GL_ATTRIBUTE |
312 | |
313 | GLboolean glBool; |
314 | |
315 | === modified file 'src/graphic/gl/utils.cc' |
316 | --- src/graphic/gl/utils.cc 2017-11-28 17:29:49 +0000 |
317 | +++ src/graphic/gl/utils.cc 2019-04-10 16:40:56 +0000 |
318 | @@ -57,7 +57,7 @@ |
319 | } // namespace |
320 | |
321 | const char* gl_error_to_string(const GLenum err) { |
322 | - CLANG_DIAG_OFF("-Wswitch-enum"); |
323 | + CLANG_DIAG_OFF("-Wswitch-enum") |
324 | #define LOG(a) \ |
325 | case a: \ |
326 | return #a |
327 | @@ -74,7 +74,7 @@ |
328 | break; |
329 | } |
330 | #undef LOG |
331 | - CLANG_DIAG_ON("-Wswitch-enum"); |
332 | + CLANG_DIAG_ON("-Wswitch-enum") |
333 | return "unknown"; |
334 | } |
335 | |
336 | |
337 | === modified file 'src/io/filesystem/test/test_filesystem.cc' |
338 | --- src/io/filesystem/test/test_filesystem.cc 2019-02-23 11:00:49 +0000 |
339 | +++ src/io/filesystem/test/test_filesystem.cc 2019-04-10 16:40:56 +0000 |
340 | @@ -65,66 +65,66 @@ |
341 | |
342 | // RealFSImpl is constructed with a root directory... |
343 | |
344 | - TEST_CANONICALIZE_NAME("", "path", cwd + "/path"); |
345 | - TEST_CANONICALIZE_NAME(".", "path", cwd + "/path"); |
346 | + TEST_CANONICALIZE_NAME("", "path", cwd + "/path") |
347 | + TEST_CANONICALIZE_NAME(".", "path", cwd + "/path") |
348 | |
349 | - TEST_CANONICALIZE_NAME("/home", "path", "/home/path"); |
350 | - TEST_CANONICALIZE_NAME("/opt", "path", "/opt/path"); |
351 | - TEST_CANONICALIZE_NAME("/opt/test", "path", "/opt/test/path"); |
352 | - TEST_CANONICALIZE_NAME("/opt", "some/path", "/opt/some/path"); |
353 | + TEST_CANONICALIZE_NAME("/home", "path", "/home/path") |
354 | + TEST_CANONICALIZE_NAME("/opt", "path", "/opt/path") |
355 | + TEST_CANONICALIZE_NAME("/opt/test", "path", "/opt/test/path") |
356 | + TEST_CANONICALIZE_NAME("/opt", "some/path", "/opt/some/path") |
357 | |
358 | // single dot is removed (root path)... |
359 | |
360 | - TEST_CANONICALIZE_NAME("./home/me", "path", cwd + "/home/me/path"); |
361 | - TEST_CANONICALIZE_NAME("/home/./you", "path", "/home/you/path"); |
362 | - TEST_CANONICALIZE_NAME("/home/us/.", "path", "/home/us/path"); |
363 | + TEST_CANONICALIZE_NAME("./home/me", "path", cwd + "/home/me/path") |
364 | + TEST_CANONICALIZE_NAME("/home/./you", "path", "/home/you/path") |
365 | + TEST_CANONICALIZE_NAME("/home/us/.", "path", "/home/us/path") |
366 | |
367 | // single dot is removed (file path)... |
368 | |
369 | - TEST_CANONICALIZE_NAME("/opt", "./no/where", "/opt/no/where"); |
370 | - TEST_CANONICALIZE_NAME("/opt", "some/./where", "/opt/some/where"); |
371 | - TEST_CANONICALIZE_NAME("/opt", "any/where/.", "/opt/any/where"); |
372 | + TEST_CANONICALIZE_NAME("/opt", "./no/where", "/opt/no/where") |
373 | + TEST_CANONICALIZE_NAME("/opt", "some/./where", "/opt/some/where") |
374 | + TEST_CANONICALIZE_NAME("/opt", "any/where/.", "/opt/any/where") |
375 | |
376 | // empty path nodes are removed (root path)... |
377 | |
378 | - TEST_CANONICALIZE_NAME("//usr/empty", "path", "/usr/empty/path"); |
379 | - TEST_CANONICALIZE_NAME("/usr//empty", "path", "/usr/empty/path"); |
380 | - TEST_CANONICALIZE_NAME("/usr/empty/", "path", "/usr/empty/path"); |
381 | - TEST_CANONICALIZE_NAME("/usr/empty//", "path", "/usr/empty/path"); |
382 | + TEST_CANONICALIZE_NAME("//usr/empty", "path", "/usr/empty/path") |
383 | + TEST_CANONICALIZE_NAME("/usr//empty", "path", "/usr/empty/path") |
384 | + TEST_CANONICALIZE_NAME("/usr/empty/", "path", "/usr/empty/path") |
385 | + TEST_CANONICALIZE_NAME("/usr/empty//", "path", "/usr/empty/path") |
386 | |
387 | // empty path nodes are removed (file path)... |
388 | |
389 | - TEST_CANONICALIZE_NAME("/usr", "/empty/path", "/usr/empty/path"); |
390 | - TEST_CANONICALIZE_NAME("/usr", "//empty/path", "/usr/empty/path"); |
391 | - TEST_CANONICALIZE_NAME("/usr", "empty//path", "/usr/empty/path"); |
392 | - TEST_CANONICALIZE_NAME("/usr", "empty/path/", "/usr/empty/path"); |
393 | - TEST_CANONICALIZE_NAME("/usr", "empty/path//", "/usr/empty/path"); |
394 | + TEST_CANONICALIZE_NAME("/usr", "/empty/path", "/usr/empty/path") |
395 | + TEST_CANONICALIZE_NAME("/usr", "//empty/path", "/usr/empty/path") |
396 | + TEST_CANONICALIZE_NAME("/usr", "empty//path", "/usr/empty/path") |
397 | + TEST_CANONICALIZE_NAME("/usr", "empty/path/", "/usr/empty/path") |
398 | + TEST_CANONICALIZE_NAME("/usr", "empty/path//", "/usr/empty/path") |
399 | |
400 | // '..' moves up a directory in the path (root path)... |
401 | |
402 | - TEST_CANONICALIZE_NAME("/usr/../home", "path", "/home/path"); |
403 | - TEST_CANONICALIZE_NAME("/usr/../../home", "path", "/home/path"); |
404 | - TEST_CANONICALIZE_NAME("/usr/test/..", "path", "/usr/path"); |
405 | - TEST_CANONICALIZE_NAME("/usr/one/../two/..", "path", "/usr/path"); |
406 | - TEST_CANONICALIZE_NAME("/usr/one/../a/b/..", "path", "/usr/a/path"); |
407 | + TEST_CANONICALIZE_NAME("/usr/../home", "path", "/home/path") |
408 | + TEST_CANONICALIZE_NAME("/usr/../../home", "path", "/home/path") |
409 | + TEST_CANONICALIZE_NAME("/usr/test/..", "path", "/usr/path") |
410 | + TEST_CANONICALIZE_NAME("/usr/one/../two/..", "path", "/usr/path") |
411 | + TEST_CANONICALIZE_NAME("/usr/one/../a/b/..", "path", "/usr/a/path") |
412 | |
413 | // '..' moves up a directory in the path (file path)... |
414 | |
415 | - TEST_CANONICALIZE_NAME("/home/test", "../path", "/home/path"); |
416 | - TEST_CANONICALIZE_NAME("/home/test", "../../path", "/path"); |
417 | - TEST_CANONICALIZE_NAME("/home/test", "../../../path", "/path"); |
418 | - |
419 | - TEST_CANONICALIZE_NAME("/home/test", "path/..", "/home/test"); |
420 | - TEST_CANONICALIZE_NAME("/home/test", "path/../..", "/home"); |
421 | - |
422 | - TEST_CANONICALIZE_NAME("/home/test", "path/../one", "/home/test/one"); |
423 | - TEST_CANONICALIZE_NAME("/home/test", "path/../../one", "/home/one"); |
424 | - TEST_CANONICALIZE_NAME("/home/test", "path/../../../one", "/one"); |
425 | - TEST_CANONICALIZE_NAME("/home/test", "path/../../../../one", "/one"); |
426 | + TEST_CANONICALIZE_NAME("/home/test", "../path", "/home/path") |
427 | + TEST_CANONICALIZE_NAME("/home/test", "../../path", "/path") |
428 | + TEST_CANONICALIZE_NAME("/home/test", "../../../path", "/path") |
429 | + |
430 | + TEST_CANONICALIZE_NAME("/home/test", "path/..", "/home/test") |
431 | + TEST_CANONICALIZE_NAME("/home/test", "path/../..", "/home") |
432 | + |
433 | + TEST_CANONICALIZE_NAME("/home/test", "path/../one", "/home/test/one") |
434 | + TEST_CANONICALIZE_NAME("/home/test", "path/../../one", "/home/one") |
435 | + TEST_CANONICALIZE_NAME("/home/test", "path/../../../one", "/one") |
436 | + TEST_CANONICALIZE_NAME("/home/test", "path/../../../../one", "/one") |
437 | |
438 | // ...but not a '..' coming from two different strings... |
439 | |
440 | - TEST_CANONICALIZE_NAME("/home/test/.", "./path", "/home/test/path"); |
441 | + TEST_CANONICALIZE_NAME("/home/test/.", "./path", "/home/test/path") |
442 | |
443 | #ifdef _WIN32 |
444 | // Check drive letter handling. |
445 | @@ -140,53 +140,53 @@ |
446 | setenv("HOME", "/my/home", 1); |
447 | std::string cwd = RealFSImpl("").get_working_directory(); |
448 | |
449 | - TEST_CANONICALIZE_NAME("~", "path", "/my/home/path"); |
450 | - TEST_CANONICALIZE_NAME("~/test", "path", "/my/home/test/path"); |
451 | + TEST_CANONICALIZE_NAME("~", "path", "/my/home/path") |
452 | + TEST_CANONICALIZE_NAME("~/test", "path", "/my/home/test/path") |
453 | |
454 | setenv("HOME", "/somewhere", 1); |
455 | - TEST_CANONICALIZE_NAME("~", "path", "/somewhere/path"); |
456 | + TEST_CANONICALIZE_NAME("~", "path", "/somewhere/path") |
457 | |
458 | // ~ at the start of the path overrides the root |
459 | |
460 | - TEST_CANONICALIZE_NAME("~", "~", "/somewhere"); |
461 | - TEST_CANONICALIZE_NAME("~/vanish", "~", "/somewhere"); |
462 | - TEST_CANONICALIZE_NAME("~/fs", "~/sf", "/somewhere/sf"); |
463 | + TEST_CANONICALIZE_NAME("~", "~", "/somewhere") |
464 | + TEST_CANONICALIZE_NAME("~/vanish", "~", "/somewhere") |
465 | + TEST_CANONICALIZE_NAME("~/fs", "~/sf", "/somewhere/sf") |
466 | |
467 | // ~ anywhere other than at the start of a path does not get expanded |
468 | |
469 | - TEST_CANONICALIZE_NAME("/opt/~", "path", "/opt/~/path"); |
470 | - TEST_CANONICALIZE_NAME("/opt/~/the", "path", "/opt/~/the/path"); |
471 | + TEST_CANONICALIZE_NAME("/opt/~", "path", "/opt/~/path") |
472 | + TEST_CANONICALIZE_NAME("/opt/~/the", "path", "/opt/~/the/path") |
473 | |
474 | - TEST_CANONICALIZE_NAME("/opt", "path/~", "/opt/path/~"); |
475 | - TEST_CANONICALIZE_NAME("/opt", "path/~/here", "/opt/path/~/here"); |
476 | + TEST_CANONICALIZE_NAME("/opt", "path/~", "/opt/path/~") |
477 | + TEST_CANONICALIZE_NAME("/opt", "path/~/here", "/opt/path/~/here") |
478 | |
479 | // ~ as part of a root-path spec segment name does not get expanded |
480 | |
481 | - TEST_CANONICALIZE_NAME("~a", "path", cwd + "/~a/path"); |
482 | - TEST_CANONICALIZE_NAME("a~", "path", cwd + "/a~/path"); |
483 | - |
484 | - TEST_CANONICALIZE_NAME("/opt/~a", "path", "/opt/~a/path"); |
485 | - TEST_CANONICALIZE_NAME("/opt/a~", "path", "/opt/a~/path"); |
486 | - |
487 | - TEST_CANONICALIZE_NAME("~a/b", "path", cwd + "/~a/b/path"); |
488 | - TEST_CANONICALIZE_NAME("a~/b", "path", cwd + "/a~/b/path"); |
489 | - |
490 | - TEST_CANONICALIZE_NAME("/opt/~the/test", "path", "/opt/~the/test/path"); |
491 | - TEST_CANONICALIZE_NAME("/opt/the~/test", "path", "/opt/the~/test/path"); |
492 | + TEST_CANONICALIZE_NAME("~a", "path", cwd + "/~a/path") |
493 | + TEST_CANONICALIZE_NAME("a~", "path", cwd + "/a~/path") |
494 | + |
495 | + TEST_CANONICALIZE_NAME("/opt/~a", "path", "/opt/~a/path") |
496 | + TEST_CANONICALIZE_NAME("/opt/a~", "path", "/opt/a~/path") |
497 | + |
498 | + TEST_CANONICALIZE_NAME("~a/b", "path", cwd + "/~a/b/path") |
499 | + TEST_CANONICALIZE_NAME("a~/b", "path", cwd + "/a~/b/path") |
500 | + |
501 | + TEST_CANONICALIZE_NAME("/opt/~the/test", "path", "/opt/~the/test/path") |
502 | + TEST_CANONICALIZE_NAME("/opt/the~/test", "path", "/opt/the~/test/path") |
503 | |
504 | // ~ as part of a path spec segment name does not get expanded |
505 | |
506 | - TEST_CANONICALIZE_NAME("/opt", "~path", "/opt/~path"); |
507 | - TEST_CANONICALIZE_NAME("/opt", "path~", "/opt/path~"); |
508 | - |
509 | - TEST_CANONICALIZE_NAME("/opt", "some/~path", "/opt/some/~path"); |
510 | - TEST_CANONICALIZE_NAME("/opt", "some/path~", "/opt/some/path~"); |
511 | - |
512 | - TEST_CANONICALIZE_NAME("/opt", "~path/here", "/opt/~path/here"); |
513 | - TEST_CANONICALIZE_NAME("/opt", "path~/here", "/opt/path~/here"); |
514 | - |
515 | - TEST_CANONICALIZE_NAME("/opt", "a/~path/here", "/opt/a/~path/here"); |
516 | - TEST_CANONICALIZE_NAME("/opt", "a/path~/here", "/opt/a/path~/here"); |
517 | + TEST_CANONICALIZE_NAME("/opt", "~path", "/opt/~path") |
518 | + TEST_CANONICALIZE_NAME("/opt", "path~", "/opt/path~") |
519 | + |
520 | + TEST_CANONICALIZE_NAME("/opt", "some/~path", "/opt/some/~path") |
521 | + TEST_CANONICALIZE_NAME("/opt", "some/path~", "/opt/some/path~") |
522 | + |
523 | + TEST_CANONICALIZE_NAME("/opt", "~path/here", "/opt/~path/here") |
524 | + TEST_CANONICALIZE_NAME("/opt", "path~/here", "/opt/path~/here") |
525 | + |
526 | + TEST_CANONICALIZE_NAME("/opt", "a/~path/here", "/opt/a/~path/here") |
527 | + TEST_CANONICALIZE_NAME("/opt", "a/path~/here", "/opt/a/path~/here") |
528 | } |
529 | #endif |
530 | BOOST_AUTO_TEST_SUITE_END() |
531 | |
532 | === modified file 'src/logic/map_objects/bob.cc' |
533 | --- src/logic/map_objects/bob.cc 2019-02-27 17:19:00 +0000 |
534 | +++ src/logic/map_objects/bob.cc 2019-04-10 16:40:56 +0000 |
535 | @@ -903,9 +903,9 @@ |
536 | |
537 | /// Give debug information. |
538 | void Bob::log_general_info(const EditorGameBase& egbase) const { |
539 | - FORMAT_WARNINGS_OFF; |
540 | + FORMAT_WARNINGS_OFF |
541 | molog("Owner: %p\n", owner_); |
542 | - FORMAT_WARNINGS_ON; |
543 | + FORMAT_WARNINGS_ON |
544 | molog("Postition: (%i, %i)\n", position_.x, position_.y); |
545 | molog("ActID: %i\n", actid_); |
546 | molog("ActScheduled: %s\n", actscheduled_ ? "true" : "false"); |
547 | @@ -929,9 +929,9 @@ |
548 | molog("* ivar2: %i\n", stack_[i].ivar2); |
549 | molog("* ivar3: %i\n", stack_[i].ivar3); |
550 | |
551 | - FORMAT_WARNINGS_OFF; |
552 | + FORMAT_WARNINGS_OFF |
553 | molog("* object pointer: %p\n", stack_[i].objvar1.get(egbase)); |
554 | - FORMAT_WARNINGS_ON; |
555 | + FORMAT_WARNINGS_ON |
556 | molog("* svar1: %s\n", stack_[i].svar1.c_str()); |
557 | |
558 | molog("* coords: (%i, %i)\n", stack_[i].coords.x, stack_[i].coords.y); |
559 | @@ -939,9 +939,9 @@ |
560 | for (Direction dir = FIRST_DIRECTION; dir <= LAST_DIRECTION; ++dir) { |
561 | molog(" %d", stack_[i].diranims.get_animation(dir)); |
562 | } |
563 | - FORMAT_WARNINGS_OFF; |
564 | + FORMAT_WARNINGS_OFF |
565 | molog("\n* path: %p\n", stack_[i].path); |
566 | - FORMAT_WARNINGS_ON; |
567 | + FORMAT_WARNINGS_ON |
568 | if (stack_[i].path) { |
569 | const Path& path = *stack_[i].path; |
570 | molog("** Path length: %" PRIuS "\n", path.get_nsteps()); |
571 | @@ -953,10 +953,10 @@ |
572 | molog("* (%i, %i)\n", coords.x, coords.y); |
573 | } |
574 | } |
575 | - FORMAT_WARNINGS_OFF; |
576 | + FORMAT_WARNINGS_OFF |
577 | molog("* route: %p\n", stack_[i].route); |
578 | molog("* program: %p\n", stack_[i].route); |
579 | - FORMAT_WARNINGS_ON; |
580 | + FORMAT_WARNINGS_ON |
581 | } |
582 | } |
583 | |
584 | |
585 | === modified file 'src/logic/map_objects/immovable.cc' |
586 | --- src/logic/map_objects/immovable.cc 2019-02-27 17:19:00 +0000 |
587 | +++ src/logic/map_objects/immovable.cc 2019-04-10 16:40:56 +0000 |
588 | @@ -1337,14 +1337,14 @@ |
589 | void PlayerImmovable::log_general_info(const EditorGameBase& egbase) const { |
590 | BaseImmovable::log_general_info(egbase); |
591 | |
592 | - FORMAT_WARNINGS_OFF; |
593 | + FORMAT_WARNINGS_OFF |
594 | molog("this: %p\n", this); |
595 | molog("owner_: %p\n", owner_); |
596 | - FORMAT_WARNINGS_ON; |
597 | + FORMAT_WARNINGS_ON |
598 | molog("player_number: %i\n", owner_->player_number()); |
599 | - FORMAT_WARNINGS_OFF; |
600 | + FORMAT_WARNINGS_OFF |
601 | molog("economy_: %p\n", economy_); |
602 | - FORMAT_WARNINGS_ON; |
603 | + FORMAT_WARNINGS_ON |
604 | } |
605 | |
606 | constexpr uint8_t kCurrentPacketVersionPlayerImmovable = 1; |
607 | |
608 | === modified file 'src/logic/map_objects/tribes/building.cc' |
609 | --- src/logic/map_objects/tribes/building.cc 2019-02-28 12:22:36 +0000 |
610 | +++ src/logic/map_objects/tribes/building.cc 2019-04-10 16:40:56 +0000 |
611 | @@ -681,9 +681,9 @@ |
612 | PlayerImmovable::log_general_info(egbase); |
613 | |
614 | molog("position: (%i, %i)\n", position_.x, position_.y); |
615 | - FORMAT_WARNINGS_OFF; |
616 | + FORMAT_WARNINGS_OFF |
617 | molog("flag: %p\n", flag_); |
618 | - FORMAT_WARNINGS_ON; |
619 | + FORMAT_WARNINGS_ON |
620 | molog("* position: (%i, %i)\n", flag_->get_position().x, flag_->get_position().y); |
621 | |
622 | molog("anim: %s\n", descr().get_animation_name(anim_).c_str()); |
623 | @@ -692,9 +692,9 @@ |
624 | molog("leave_time: %i\n", leave_time_); |
625 | |
626 | molog("leave_queue.size(): %" PRIuS "\n", leave_queue_.size()); |
627 | - FORMAT_WARNINGS_OFF; |
628 | + FORMAT_WARNINGS_OFF |
629 | molog("leave_allow.get(): %p\n", leave_allow_.get(egbase)); |
630 | - FORMAT_WARNINGS_ON; |
631 | + FORMAT_WARNINGS_ON |
632 | } |
633 | |
634 | void Building::add_worker(Worker& worker) { |
635 | |
636 | === modified file 'src/logic/map_objects/tribes/production_program.cc' |
637 | --- src/logic/map_objects/tribes/production_program.cc 2019-02-23 11:00:49 +0000 |
638 | +++ src/logic/map_objects/tribes/production_program.cc 2019-04-10 16:40:56 +0000 |
639 | @@ -133,7 +133,7 @@ |
640 | char const* const type_name = next_word(parameters, reached_end); |
641 | const DescriptionIndex& wareindex = tribes.ware_index(type_name); |
642 | if (tribes.ware_exists(wareindex)) { |
643 | - for (int i = 0; i < static_cast<int>(tribes.nrtribes()); ++i) { |
644 | + for (size_t i = 0; i < tribes.nrtribes(); ++i) { |
645 | const TribeDescr& tribe_descr = *tribes.get_tribe_descr(i); |
646 | if (tribe_descr.has_ware(wareindex)) { |
647 | tribes.set_ware_type_has_demand_check(wareindex, tribe_descr.name()); |
648 | @@ -142,7 +142,7 @@ |
649 | return new ProductionProgram::ActReturn::EconomyNeedsWare(wareindex); |
650 | } else if (tribes.worker_exists(tribes.worker_index(type_name))) { |
651 | const DescriptionIndex& workerindex = tribes.worker_index(type_name); |
652 | - for (int i = 0; i < static_cast<int>(tribes.nrtribes()); ++i) { |
653 | + for (size_t i = 0; i < tribes.nrtribes(); ++i) { |
654 | const TribeDescr* tribe_descr = tribes.get_tribe_descr(i); |
655 | if (tribe_descr->has_worker(workerindex)) { |
656 | tribes.set_worker_type_has_demand_check(workerindex); |
657 | @@ -462,13 +462,13 @@ |
658 | const Tribes& tribes) { |
659 | try { |
660 | if (match(parameters, "failed")) |
661 | - result_ = Failed; |
662 | + result_ = ProgramResult::kFailed; |
663 | else if (match(parameters, "completed")) |
664 | - result_ = Completed; |
665 | + result_ = ProgramResult::kCompleted; |
666 | else if (match(parameters, "skipped")) |
667 | - result_ = Skipped; |
668 | + result_ = ProgramResult::kSkipped; |
669 | else if (match(parameters, "no_stats")) |
670 | - result_ = None; |
671 | + result_ = ProgramResult::kNone; |
672 | else |
673 | throw GameDataError("expected %s but found \"%s\"", |
674 | "{\"failed\"|\"completed\"|\"skipped\"|\"no_stats\"}", parameters); |
675 | @@ -539,22 +539,33 @@ |
676 | i18n::localize_list(condition_list, i18n::ConcatenateWith::AND); |
677 | |
678 | std::string result_string; |
679 | - if (result_ == Failed) { |
680 | + switch (result_) { |
681 | + case ProgramResult::kFailed: { |
682 | /** TRANSLATORS: "Did not start working because the economy needs the ware ‘%s’" */ |
683 | result_string = (boost::format(_("Did not start %1$s because %2$s")) % |
684 | ps.top_state().program->descname() % condition_string) |
685 | .str(); |
686 | - } else if (result_ == Completed) { |
687 | + } break; |
688 | + case ProgramResult::kCompleted: { |
689 | /** TRANSLATORS: "Completed working because the economy needs the ware ‘%s’" */ |
690 | result_string = (boost::format(_("Completed %1$s because %2$s")) % |
691 | ps.top_state().program->descname() % condition_string) |
692 | .str(); |
693 | - } else { |
694 | + } break; |
695 | + case ProgramResult::kSkipped: { |
696 | /** TRANSLATORS: "Skipped working because the economy needs the ware ‘%s’" */ |
697 | result_string = (boost::format(_("Skipped %1$s because %2$s")) % |
698 | ps.top_state().program->descname() % condition_string) |
699 | .str(); |
700 | - } |
701 | + } break; |
702 | + case ProgramResult::kNone: { |
703 | + // TODO(GunChleoc): Same as skipped - is this on purpose? |
704 | + result_string = (boost::format(_("Skipped %1$s because %2$s")) % |
705 | + ps.top_state().program->descname() % condition_string) |
706 | + .str(); |
707 | + } |
708 | + } |
709 | + |
710 | ps.set_production_result(result_string); |
711 | } |
712 | return ps.program_end(game, result_); |
713 | @@ -562,9 +573,9 @@ |
714 | |
715 | ProductionProgram::ActCall::ActCall(char* parameters, const ProductionSiteDescr& descr) { |
716 | // Initialize with default handling methods. |
717 | - handling_methods_[Failed - 1] = Continue; |
718 | - handling_methods_[Completed - 1] = Continue; |
719 | - handling_methods_[Skipped - 1] = Continue; |
720 | + handling_methods_[program_result_index(ProgramResult::kFailed)] = ProgramResultHandlingMethod::kContinue; |
721 | + handling_methods_[program_result_index(ProgramResult::kCompleted)] = ProgramResultHandlingMethod::kContinue; |
722 | + handling_methods_[program_result_index(ProgramResult::kSkipped)] = ProgramResultHandlingMethod::kContinue; |
723 | |
724 | try { |
725 | bool reached_end; |
726 | @@ -586,34 +597,34 @@ |
727 | |
728 | ProgramResult result_to_set_method_for; |
729 | if (match_force_skip(parameters, "failure")) { |
730 | - if (handling_methods_[Failed - 1] != Continue) |
731 | + if (handling_methods_[program_result_index(ProgramResult::kFailed)] != ProgramResultHandlingMethod::kContinue) |
732 | throw GameDataError("%s handling method already defined", "failure"); |
733 | - result_to_set_method_for = Failed; |
734 | + result_to_set_method_for = ProgramResult::kFailed; |
735 | } else if (match_force_skip(parameters, "completion")) { |
736 | - if (handling_methods_[Completed - 1] != Continue) |
737 | + if (handling_methods_[program_result_index(ProgramResult::kCompleted)] != ProgramResultHandlingMethod::kContinue) |
738 | throw GameDataError("%s handling method already defined", "completion"); |
739 | - result_to_set_method_for = Completed; |
740 | + result_to_set_method_for = ProgramResult::kCompleted; |
741 | } else if (match_force_skip(parameters, "skip")) { |
742 | - if (handling_methods_[Skipped - 1] != Continue) |
743 | + if (handling_methods_[program_result_index(ProgramResult::kSkipped)] != ProgramResultHandlingMethod::kContinue) |
744 | throw GameDataError("%s handling method already defined", "skip"); |
745 | - result_to_set_method_for = Skipped; |
746 | + result_to_set_method_for = ProgramResult::kSkipped; |
747 | } else |
748 | throw GameDataError( |
749 | "expected %s but found \"%s\"", "{\"failure\"|\"completion\"|\"skip\"}", parameters); |
750 | |
751 | ProgramResultHandlingMethod handling_method; |
752 | if (match(parameters, "fail")) |
753 | - handling_method = Fail; |
754 | + handling_method = ProgramResultHandlingMethod::kFail; |
755 | else if (match(parameters, "complete")) |
756 | - handling_method = Complete; |
757 | + handling_method = ProgramResultHandlingMethod::kComplete; |
758 | else if (match(parameters, "skip")) |
759 | - handling_method = Skip; |
760 | + handling_method = ProgramResultHandlingMethod::kSkip; |
761 | else if (match(parameters, "repeat")) |
762 | - handling_method = Repeat; |
763 | + handling_method = ProgramResultHandlingMethod::kRepeat; |
764 | else |
765 | throw GameDataError("expected %s but found \"%s\"", |
766 | "{\"fail\"|\"complete\"|\"skip\"|\"repeat\"}", parameters); |
767 | - handling_methods_[result_to_set_method_for - 1] = handling_method; |
768 | + handling_methods_[program_result_index(result_to_set_method_for)] = handling_method; |
769 | reached_end = !*parameters; |
770 | } |
771 | } catch (const WException& e) { |
772 | @@ -622,21 +633,21 @@ |
773 | } |
774 | |
775 | void ProductionProgram::ActCall::execute(Game& game, ProductionSite& ps) const { |
776 | - ProgramResult const program_result = static_cast<ProgramResult>(ps.top_state().phase); |
777 | + ProgramResult const program_result = ps.top_state().phase; |
778 | |
779 | - if (program_result == None) { // The program has not yet been called. |
780 | + if (program_result == ProgramResult::kNone) { // The program has not yet been called. |
781 | return ps.program_start(game, program_->name()); |
782 | } |
783 | |
784 | - switch (handling_methods_[program_result - 1]) { |
785 | - case Fail: |
786 | - case Complete: |
787 | - case Skip: |
788 | - return ps.program_end(game, None); |
789 | - case Continue: |
790 | + switch (handling_methods_[program_result_index(program_result)]) { |
791 | + case ProgramResultHandlingMethod::kFail: |
792 | + case ProgramResultHandlingMethod::kComplete: |
793 | + case ProgramResultHandlingMethod::kSkip: |
794 | + return ps.program_end(game, ProgramResult::kNone); |
795 | + case ProgramResultHandlingMethod::kContinue: |
796 | return ps.program_step(game); |
797 | - case Repeat: |
798 | - ps.top_state().phase = None; |
799 | + case ProgramResultHandlingMethod::kRepeat: |
800 | + ps.top_state().phase = ProgramResult::kNone; |
801 | ps.program_timer_ = true; |
802 | ps.program_time_ = ps.schedule_act(game, 10); |
803 | break; |
804 | @@ -687,9 +698,9 @@ |
805 | ProductionSite& psite, |
806 | Worker& worker) const { |
807 | ProductionSite::State& state = psite.top_state(); |
808 | - if (state.phase == 0) { |
809 | + if (state.phase == ProgramResult::kNone) { |
810 | worker.start_task_program(game, program()); |
811 | - ++state.phase; |
812 | + state.phase = ProgramResult::kFailed; |
813 | return true; |
814 | } else { |
815 | psite.program_step(game); |
816 | @@ -700,7 +711,7 @@ |
817 | void ProductionProgram::ActCallWorker::building_work_failed(Game& game, |
818 | ProductionSite& psite, |
819 | Worker&) const { |
820 | - psite.program_end(game, Failed); |
821 | + psite.program_end(game, ProgramResult::kFailed); |
822 | } |
823 | |
824 | ProductionProgram::ActSleep::ActSleep(char* parameters) { |
825 | @@ -719,7 +730,7 @@ |
826 | } |
827 | |
828 | void ProductionProgram::ActSleep::execute(Game& game, ProductionSite& ps) const { |
829 | - return ps.program_step(game, duration_ ? duration_ : ps.top_state().phase); |
830 | + return ps.program_step(game, duration_ ? duration_ : 0, ps.top_state().phase); |
831 | } |
832 | |
833 | ProductionProgram::ActCheckMap::ActCheckMap(char* parameters) { |
834 | @@ -743,7 +754,7 @@ |
835 | return ps.program_step(game, 0); |
836 | } else { |
837 | ps.set_production_result(_("No use for ships on this map!")); |
838 | - return ps.program_end(game, Failed); |
839 | + return ps.program_end(game, ProgramResult::kFailed); |
840 | } |
841 | } |
842 | default: |
843 | @@ -777,7 +788,7 @@ |
844 | |
845 | void ProductionProgram::ActAnimate::execute(Game& game, ProductionSite& ps) const { |
846 | ps.start_animation(game, id_); |
847 | - return ps.program_step(game, duration_ ? duration_ : ps.top_state().phase); |
848 | + return ps.program_step(game, duration_ ? duration_ : 0, ps.top_state().phase); |
849 | } |
850 | |
851 | ProductionProgram::ActConsume::ActConsume(char* parameters, |
852 | @@ -900,7 +911,7 @@ |
853 | .str(); |
854 | |
855 | ps.set_production_result(result_string); |
856 | - return ps.program_end(game, Failed); |
857 | + return ps.program_end(game, ProgramResult::kFailed); |
858 | } else { // we fulfilled all consumption requirements |
859 | for (size_t i = 0; i < inputqueues.size(); ++i) { |
860 | if (uint8_t const q = consumption_quantities[i]) { |
861 | @@ -1182,7 +1193,7 @@ |
862 | if (digged_percentage < max_) { |
863 | // mine can produce normally |
864 | if (totalres == 0) |
865 | - return ps.program_end(game, Failed); |
866 | + return ps.program_end(game, ProgramResult::kFailed); |
867 | |
868 | // second pass through nodes |
869 | assert(totalchance); |
870 | @@ -1210,7 +1221,7 @@ |
871 | } |
872 | |
873 | if (pick >= 0) { |
874 | - return ps.program_end(game, Failed); |
875 | + return ps.program_end(game, ProgramResult::kFailed); |
876 | } |
877 | |
878 | } else { |
879 | @@ -1233,7 +1244,7 @@ |
880 | if (training_ >= game.logic_rand() % 100) { |
881 | ps.train_workers(game); |
882 | } |
883 | - return ps.program_end(game, Failed); |
884 | + return ps.program_end(game, ProgramResult::kFailed); |
885 | } |
886 | } |
887 | |
888 | @@ -1278,7 +1289,7 @@ |
889 | const std::vector<Soldier*> soldiers = ctrl->present_soldiers(); |
890 | if (soldiers.empty()) { |
891 | ps.set_production_result(_("No soldier to train!")); |
892 | - return ps.program_end(game, Skipped); |
893 | + return ps.program_end(game, ProgramResult::kSkipped); |
894 | } |
895 | ps.molog(" Checking soldier (%u) level %d)\n", static_cast<unsigned int>(attribute), |
896 | static_cast<unsigned int>(level)); |
897 | @@ -1287,7 +1298,7 @@ |
898 | for (std::vector<Soldier*>::const_iterator it = soldiers.begin();; ++it) { |
899 | if (it == soldiers_end) { |
900 | ps.set_production_result(_("No soldier found for this training level!")); |
901 | - return ps.program_end(game, Skipped); |
902 | + return ps.program_end(game, ProgramResult::kSkipped); |
903 | } |
904 | if (attribute == TrainingAttribute::kHealth) { |
905 | if ((*it)->get_health_level() == level) |
906 | @@ -1354,7 +1365,6 @@ |
907 | |
908 | void ProductionProgram::ActTrain::execute(Game& game, ProductionSite& ps) const { |
909 | const SoldierControl* ctrl = ps.soldier_control(); |
910 | - ; |
911 | const std::vector<Soldier*> soldiers = ctrl->present_soldiers(); |
912 | const std::vector<Soldier*>::const_iterator soldiers_end = soldiers.end(); |
913 | std::vector<Soldier*>::const_iterator it = soldiers.begin(); |
914 | @@ -1365,7 +1375,7 @@ |
915 | for (;; ++it) { |
916 | if (it == soldiers_end) { |
917 | ps.set_production_result(_("No soldier found for this training level!")); |
918 | - return ps.program_end(game, Skipped); |
919 | + return ps.program_end(game, ProgramResult::kSkipped); |
920 | } |
921 | if (attribute == TrainingAttribute::kHealth) { |
922 | if ((*it)->get_health_level() == level) |
923 | @@ -1481,7 +1491,7 @@ |
924 | } |
925 | |
926 | if (available_resource == INVALID_INDEX) { |
927 | - psite.program_end(game, Failed); |
928 | + psite.program_end(game, ProgramResult::kFailed); |
929 | return; |
930 | } |
931 | |
932 | @@ -1534,14 +1544,14 @@ |
933 | } |
934 | |
935 | psite.molog("construct: no object or buildable field\n"); |
936 | - psite.program_end(game, Failed); |
937 | + psite.program_end(game, ProgramResult::kFailed); |
938 | } |
939 | |
940 | bool ProductionProgram::ActConstruct::get_building_work(Game& game, |
941 | ProductionSite& psite, |
942 | Worker& worker) const { |
943 | ProductionSite::State& state = psite.top_state(); |
944 | - if (state.phase >= 1) { |
945 | + if (state.phase > ProgramResult::kNone) { |
946 | psite.program_step(game); |
947 | return false; |
948 | } |
949 | @@ -1554,7 +1564,7 @@ |
950 | if (construction) { |
951 | if (!construction->construct_remaining_buildcost(game, &remaining)) { |
952 | psite.molog("construct: immovable %u not under construction", construction->serial()); |
953 | - psite.program_end(game, Failed); |
954 | + psite.program_end(game, ProgramResult::kFailed); |
955 | return false; |
956 | } |
957 | } else { |
958 | @@ -1571,7 +1581,7 @@ |
959 | } |
960 | |
961 | if (!wq) { |
962 | - psite.program_end(game, Failed); |
963 | + psite.program_end(game, ProgramResult::kFailed); |
964 | return false; |
965 | } |
966 | |
967 | @@ -1587,14 +1597,14 @@ |
968 | worker.top_state().objvar1 = construction; |
969 | worker.top_state().coords = state.coord; |
970 | |
971 | - state.phase = 1; |
972 | + state.phase = ProgramResult::kFailed; |
973 | return true; |
974 | } |
975 | |
976 | void ProductionProgram::ActConstruct::building_work_failed(Game& game, |
977 | ProductionSite& psite, |
978 | Worker&) const { |
979 | - psite.program_end(game, Failed); |
980 | + psite.program_end(game, ProgramResult::kFailed); |
981 | } |
982 | |
983 | ProductionProgram::ProductionProgram(const std::string& init_name, |
984 | |
985 | === modified file 'src/logic/map_objects/tribes/productionsite.cc' |
986 | --- src/logic/map_objects/tribes/productionsite.cc 2019-02-23 11:00:49 +0000 |
987 | +++ src/logic/map_objects/tribes/productionsite.cc 2019-04-10 16:40:56 +0000 |
988 | @@ -682,7 +682,7 @@ |
989 | |
990 | if (!can_start_working()) { |
991 | while (!stack_.empty()) |
992 | - program_end(game, Failed); |
993 | + program_end(game, ProgramResult::kFailed); |
994 | } else { |
995 | if (stack_.empty()) { |
996 | working_positions_[0].worker->update_task_buildingwork(game); |
997 | @@ -691,7 +691,7 @@ |
998 | |
999 | State& state = top_state(); |
1000 | if (state.program->size() <= state.ip) |
1001 | - return program_end(game, Completed); |
1002 | + return program_end(game, ProgramResult::kCompleted); |
1003 | |
1004 | if (anim_ != descr().get_animation(default_anim_)) { |
1005 | // Restart idle animation, which is the default |
1006 | @@ -720,7 +720,7 @@ |
1007 | // new productions cycle. Otherwise it can lead to consumption |
1008 | // of input wares without producing anything |
1009 | if (is_stopped_ && state.ip == 0) { |
1010 | - program_end(game, Failed); |
1011 | + program_end(game, ProgramResult::kFailed); |
1012 | program_timer_ = true; |
1013 | program_time_ = schedule_act(game, 20000); |
1014 | } else |
1015 | @@ -874,7 +874,7 @@ |
1016 | /** |
1017 | * Advance the program to the next step. |
1018 | */ |
1019 | -void ProductionSite::program_step(Game& game, uint32_t const delay, uint32_t const phase) { |
1020 | +void ProductionSite::program_step(Game& game, uint32_t const delay, ProgramResult const phase) { |
1021 | State& state = top_state(); |
1022 | ++state.ip; |
1023 | state.phase = phase; |
1024 | @@ -890,7 +890,7 @@ |
1025 | |
1026 | state.program = descr().get_program(program_name); |
1027 | state.ip = 0; |
1028 | - state.phase = 0; |
1029 | + state.phase = ProgramResult::kNone; |
1030 | |
1031 | stack_.push_back(state); |
1032 | |
1033 | @@ -918,17 +918,18 @@ |
1034 | const std::string& program_name = top_state().program->name(); |
1035 | |
1036 | stack_.pop_back(); |
1037 | - if (!stack_.empty()) |
1038 | + if (!stack_.empty()) { |
1039 | top_state().phase = result; |
1040 | + } |
1041 | |
1042 | switch (result) { |
1043 | - case Failed: |
1044 | + case ProgramResult::kFailed: |
1045 | statistics_.erase(statistics_.begin(), statistics_.begin() + 1); |
1046 | statistics_.push_back(false); |
1047 | calc_statistics(); |
1048 | crude_percent_ = crude_percent_ * 8 / 10; |
1049 | break; |
1050 | - case Completed: |
1051 | + case ProgramResult::kCompleted: |
1052 | skipped_programs_.erase(program_name); |
1053 | statistics_.erase(statistics_.begin(), statistics_.begin() + 1); |
1054 | statistics_.push_back(true); |
1055 | @@ -936,11 +937,11 @@ |
1056 | crude_percent_ = crude_percent_ * 8 / 10 + 1000000 * 2 / 10; |
1057 | calc_statistics(); |
1058 | break; |
1059 | - case Skipped: |
1060 | + case ProgramResult::kSkipped: |
1061 | skipped_programs_[program_name] = game.get_gametime(); |
1062 | crude_percent_ = crude_percent_ * 98 / 100; |
1063 | break; |
1064 | - case None: |
1065 | + case ProgramResult::kNone: |
1066 | skipped_programs_.erase(program_name); |
1067 | break; |
1068 | } |
1069 | |
1070 | === modified file 'src/logic/map_objects/tribes/productionsite.h' |
1071 | --- src/logic/map_objects/tribes/productionsite.h 2019-02-23 11:00:49 +0000 |
1072 | +++ src/logic/map_objects/tribes/productionsite.h 2019-04-10 16:40:56 +0000 |
1073 | @@ -243,7 +243,7 @@ |
1074 | struct State { |
1075 | const ProductionProgram* program; ///< currently running program |
1076 | size_t ip; ///< instruction pointer |
1077 | - uint32_t phase; ///< micro-step index (instruction dependent) |
1078 | + ProgramResult phase; ///< micro-step index (instruction dependent) |
1079 | uint32_t flags; ///< pfXXX flags |
1080 | |
1081 | /** |
1082 | @@ -254,7 +254,7 @@ |
1083 | Coords coord; |
1084 | /*@}*/ |
1085 | |
1086 | - State() : program(nullptr), ip(0), phase(0), flags(0), coord(Coords::null()) { |
1087 | + State() : program(nullptr), ip(0), phase(ProgramResult::kNone), flags(0), coord(Coords::null()) { |
1088 | } |
1089 | }; |
1090 | |
1091 | @@ -282,7 +282,7 @@ |
1092 | /// how long it should take to mine, given the particular circumstances, |
1093 | /// and pass the result to the following animation command, to set the |
1094 | /// duration. |
1095 | - void program_step(Game&, uint32_t delay = 10, uint32_t phase = 0); |
1096 | + void program_step(Game&, uint32_t delay = 10, ProgramResult phase = ProgramResult::kNone); |
1097 | |
1098 | void program_start(Game&, const std::string& program_name); |
1099 | virtual void program_end(Game&, ProgramResult); |
1100 | |
1101 | === modified file 'src/logic/map_objects/tribes/program_result.h' |
1102 | --- src/logic/map_objects/tribes/program_result.h 2019-02-23 11:00:49 +0000 |
1103 | +++ src/logic/map_objects/tribes/program_result.h 2019-04-10 16:40:56 +0000 |
1104 | @@ -20,10 +20,26 @@ |
1105 | #ifndef WL_LOGIC_MAP_OBJECTS_TRIBES_PROGRAM_RESULT_H |
1106 | #define WL_LOGIC_MAP_OBJECTS_TRIBES_PROGRAM_RESULT_H |
1107 | |
1108 | +#include "base/macros.h" |
1109 | + |
1110 | namespace Widelands { |
1111 | -// Don't change this values, they are used as hardcoded array indices |
1112 | -enum ProgramResult { None = 0, Failed = 1, Completed = 2, Skipped = 3 }; |
1113 | -enum ProgramResultHandlingMethod { Fail, Complete, Skip, Continue, Repeat }; |
1114 | +// Don't change these values, they are used as hardcoded array indices |
1115 | +enum class ProgramResult { kNone = 0, kFailed = 1, kCompleted = 2, kSkipped = 3 }; |
1116 | +inline int program_result_index(ProgramResult result) { |
1117 | + switch (result) { |
1118 | + case ProgramResult::kFailed: |
1119 | + return 0; |
1120 | + case ProgramResult::kCompleted: |
1121 | + return 1; |
1122 | + case ProgramResult::kSkipped: |
1123 | + return 2; |
1124 | + case ProgramResult::kNone: |
1125 | + NEVER_HERE(); |
1126 | + } |
1127 | + return 0; |
1128 | +} |
1129 | + |
1130 | +enum class ProgramResultHandlingMethod { kFail, kComplete, kSkip, kContinue, kRepeat }; |
1131 | } // namespace Widelands |
1132 | |
1133 | #endif // end of include guard: WL_LOGIC_MAP_OBJECTS_TRIBES_PROGRAM_RESULT_H |
1134 | |
1135 | === modified file 'src/logic/map_objects/tribes/trainingsite.cc' |
1136 | --- src/logic/map_objects/tribes/trainingsite.cc 2019-02-23 11:00:49 +0000 |
1137 | +++ src/logic/map_objects/tribes/trainingsite.cc 2019-04-10 16:40:56 +0000 |
1138 | @@ -270,7 +270,7 @@ |
1139 | soldier_request_(nullptr), |
1140 | capacity_(descr().get_max_number_of_soldiers()), |
1141 | build_heroes_(false), |
1142 | - result_(Failed) { |
1143 | + result_(ProgramResult::kFailed) { |
1144 | set_soldier_control(&soldier_control_); |
1145 | |
1146 | // Initialize this in the constructor so that loading code may |
1147 | @@ -543,7 +543,7 @@ |
1148 | bool leftover_soldiers_check = true; |
1149 | |
1150 | if (current_upgrade_) { |
1151 | - if (result_ == Completed) { |
1152 | + if (result_ == ProgramResult::kCompleted) { |
1153 | drop_unupgradable_soldiers(game); |
1154 | leftover_soldiers_check = false; |
1155 | current_upgrade_->lastsuccess = true; |
1156 | |
1157 | === modified file 'src/logic/map_objects/tribes/tribe_descr.cc' |
1158 | --- src/logic/map_objects/tribes/tribe_descr.cc 2019-03-24 12:06:43 +0000 |
1159 | +++ src/logic/map_objects/tribes/tribe_descr.cc 2019-04-10 16:40:56 +0000 |
1160 | @@ -174,7 +174,7 @@ |
1161 | throw GameDataError("Tribe has no indicators for resource %s.", resource.c_str()); |
1162 | } |
1163 | resource_indicators_[resource] = resis; |
1164 | - }; |
1165 | + } |
1166 | |
1167 | ship_names_ = table.get_table("ship_names")->array_entries<std::string>(); |
1168 | |
1169 | |
1170 | === modified file 'src/logic/map_objects/tribes/worker.cc' |
1171 | --- src/logic/map_objects/tribes/worker.cc 2019-03-17 10:30:24 +0000 |
1172 | +++ src/logic/map_objects/tribes/worker.cc 2019-04-10 16:40:56 +0000 |
1173 | @@ -1060,34 +1060,34 @@ |
1174 | Bob::log_general_info(egbase); |
1175 | |
1176 | if (upcast(PlayerImmovable, loc, location_.get(egbase))) { |
1177 | - FORMAT_WARNINGS_OFF; |
1178 | + FORMAT_WARNINGS_OFF |
1179 | molog("* Owner: (%p)\n", &loc->owner()); |
1180 | - FORMAT_WARNINGS_ON; |
1181 | + FORMAT_WARNINGS_ON |
1182 | molog("** Owner (plrnr): %i\n", loc->owner().player_number()); |
1183 | - FORMAT_WARNINGS_OFF; |
1184 | + FORMAT_WARNINGS_OFF |
1185 | molog("* Economy: %p\n", loc->get_economy()); |
1186 | - FORMAT_WARNINGS_ON; |
1187 | + FORMAT_WARNINGS_ON |
1188 | } |
1189 | |
1190 | PlayerImmovable* imm = location_.get(egbase); |
1191 | molog("location: %u\n", imm ? imm->serial() : 0); |
1192 | - FORMAT_WARNINGS_OFF; |
1193 | + FORMAT_WARNINGS_OFF |
1194 | molog("Economy: %p\n", economy_); |
1195 | molog("transfer: %p\n", transfer_); |
1196 | - FORMAT_WARNINGS_ON; |
1197 | + FORMAT_WARNINGS_ON |
1198 | |
1199 | if (upcast(WareInstance, ware, carried_ware_.get(egbase))) { |
1200 | molog("* carried_ware->get_ware() (id): %i\n", ware->descr_index()); |
1201 | - FORMAT_WARNINGS_OFF; |
1202 | + FORMAT_WARNINGS_OFF |
1203 | molog("* carried_ware->get_economy() (): %p\n", ware->get_economy()); |
1204 | - FORMAT_WARNINGS_ON; |
1205 | + FORMAT_WARNINGS_ON |
1206 | } |
1207 | |
1208 | molog("current_exp: %i / %i\n", current_exp_, descr().get_needed_experience()); |
1209 | |
1210 | - FORMAT_WARNINGS_OFF; |
1211 | + FORMAT_WARNINGS_OFF |
1212 | molog("supply: %p\n", supply_); |
1213 | - FORMAT_WARNINGS_ON; |
1214 | + FORMAT_WARNINGS_ON |
1215 | } |
1216 | |
1217 | /** |
1218 | |
1219 | === modified file 'src/logic/map_objects/world/terrain_description.h' |
1220 | --- src/logic/map_objects/world/terrain_description.h 2019-02-23 11:00:49 +0000 |
1221 | +++ src/logic/map_objects/world/terrain_description.h 2019-04-10 16:40:56 +0000 |
1222 | @@ -43,7 +43,7 @@ |
1223 | |
1224 | class TerrainDescription { |
1225 | public: |
1226 | - enum Is { |
1227 | + enum class Is { |
1228 | kArable = 0, |
1229 | kWalkable = 1, |
1230 | kWater = 2, |
1231 | @@ -149,6 +149,14 @@ |
1232 | DISALLOW_COPY_AND_ASSIGN(TerrainDescription); |
1233 | }; |
1234 | |
1235 | +inline TerrainDescription::Is operator|(TerrainDescription::Is left, TerrainDescription::Is right) { |
1236 | + return TerrainDescription::Is(static_cast<int>(left) | static_cast<int>(right)); |
1237 | +} |
1238 | +inline int operator&(TerrainDescription::Is left, TerrainDescription::Is right) { |
1239 | + return static_cast<int>(left) & static_cast<int>(right); |
1240 | +} |
1241 | + |
1242 | + |
1243 | } // namespace Widelands |
1244 | |
1245 | #endif // end of include guard: WL_LOGIC_MAP_OBJECTS_WORLD_TERRAIN_DESCRIPTION_H |
1246 | |
1247 | === modified file 'src/logic/mapdifferenceregion.h' |
1248 | --- src/logic/mapdifferenceregion.h 2019-02-23 11:00:49 +0000 |
1249 | +++ src/logic/mapdifferenceregion.h 2019-04-10 16:40:56 +0000 |
1250 | @@ -48,12 +48,12 @@ |
1251 | map.neighbour_function(area_, &area_); \ |
1252 | break; |
1253 | |
1254 | - DIRECTION_CASE(WALK_NW, get_tln); |
1255 | - DIRECTION_CASE(WALK_NE, get_trn); |
1256 | - DIRECTION_CASE(WALK_E, get_rn); |
1257 | - DIRECTION_CASE(WALK_SE, get_brn); |
1258 | - DIRECTION_CASE(WALK_SW, get_bln); |
1259 | - DIRECTION_CASE(WALK_W, get_ln); |
1260 | + DIRECTION_CASE(WALK_NW, get_tln) |
1261 | + DIRECTION_CASE(WALK_NE, get_trn) |
1262 | + DIRECTION_CASE(WALK_E, get_rn) |
1263 | + DIRECTION_CASE(WALK_SE, get_brn) |
1264 | + DIRECTION_CASE(WALK_SW, get_bln) |
1265 | + DIRECTION_CASE(WALK_W, get_ln) |
1266 | #undef DIRECTION_CASE |
1267 | } |
1268 | --direction; |
1269 | |
1270 | === modified file 'src/logic/maphollowregion.cc' |
1271 | --- src/logic/maphollowregion.cc 2019-02-23 11:00:49 +0000 |
1272 | +++ src/logic/maphollowregion.cc 2019-04-10 16:40:56 +0000 |
1273 | @@ -24,7 +24,7 @@ |
1274 | template <> |
1275 | MapHollowRegion<Area<>>::MapHollowRegion(const Map& map, const HollowArea<Area<>>& hollow_area) |
1276 | : hollow_area_(hollow_area), |
1277 | - phase_(Top), |
1278 | + phase_(Phase::kTop), |
1279 | delta_radius_(hollow_area.radius - hollow_area.hole_radius), |
1280 | row_(0), |
1281 | rowwidth_(hollow_area.radius + 1), |
1282 | @@ -37,12 +37,13 @@ |
1283 | } |
1284 | |
1285 | template <> bool MapHollowRegion<Area<>>::advance(const Map& map) { |
1286 | - if (phase_ == None) |
1287 | + if (phase_ == Phase::kNone) { |
1288 | return false; |
1289 | + } |
1290 | ++rowpos_; |
1291 | if (rowpos_ < rowwidth_) { |
1292 | map.get_rn(hollow_area_, &hollow_area_); |
1293 | - if ((phase_ & (Upper | Lower)) && rowpos_ == delta_radius_) { |
1294 | + if ((phase_ & (Phase::kUpper | Phase::kLower)) && rowpos_ == delta_radius_) { |
1295 | // Jump over the hole. |
1296 | const uint32_t holewidth = rowwidth_ - 2 * delta_radius_; |
1297 | for (uint32_t i = 0; i < holewidth; ++i) |
1298 | @@ -51,27 +52,29 @@ |
1299 | } |
1300 | } else { |
1301 | ++row_; |
1302 | - if (phase_ == Top && row_ == delta_radius_) |
1303 | - phase_ = Upper; |
1304 | + if (phase_ == Phase::kTop && row_ == delta_radius_) { |
1305 | + phase_ = Phase::kUpper; |
1306 | + } |
1307 | |
1308 | // If we completed the widest, center line, switch into lower mode |
1309 | // There are radius_+1 lines in the upper "half", because the upper |
1310 | // half includes the center line. |
1311 | - else if (phase_ == Upper && row_ > hollow_area_.radius) { |
1312 | + else if (phase_ == Phase::kUpper && row_ > hollow_area_.radius) { |
1313 | row_ = 1; |
1314 | - phase_ = Lower; |
1315 | + phase_ = Phase::kLower; |
1316 | } |
1317 | |
1318 | - if (phase_ & (Top | Upper)) { |
1319 | + if (phase_ & (Phase::kTop | Phase::kUpper)) { |
1320 | map.get_bln(left_, &hollow_area_); |
1321 | ++rowwidth_; |
1322 | } else { |
1323 | |
1324 | if (row_ > hollow_area_.radius) { |
1325 | - phase_ = None; |
1326 | + phase_ = Phase::kNone; |
1327 | return true; // early out |
1328 | - } else if (phase_ == Lower && row_ > hollow_area_.hole_radius) |
1329 | - phase_ = Bottom; |
1330 | + } else if (phase_ == Phase::kLower && row_ > hollow_area_.hole_radius) { |
1331 | + phase_ = Phase::kBottom; |
1332 | + } |
1333 | |
1334 | map.get_brn(left_, &hollow_area_); |
1335 | --rowwidth_; |
1336 | |
1337 | === modified file 'src/logic/maphollowregion.h' |
1338 | --- src/logic/maphollowregion.h 2019-02-23 11:00:49 +0000 |
1339 | +++ src/logic/maphollowregion.h 2019-04-10 16:40:56 +0000 |
1340 | @@ -55,15 +55,15 @@ |
1341 | */ |
1342 | bool advance(const Map&); |
1343 | |
1344 | + enum class Phase { |
1345 | + kNone = 0, // not initialized or completed |
1346 | + kTop = 1, // above the hole |
1347 | + kUpper = 2, // upper half |
1348 | + kLower = 4, // lower half |
1349 | + kBottom = 8, // below the hole |
1350 | + }; |
1351 | + |
1352 | private: |
1353 | - enum Phase { |
1354 | - None = 0, // not initialized or completed |
1355 | - Top = 1, // above the hole |
1356 | - Upper = 2, // upper half |
1357 | - Lower = 4, // lower half |
1358 | - Bottom = 8, // below the hole |
1359 | - }; |
1360 | - |
1361 | HollowArea<AreaType> hollow_area_; |
1362 | Phase phase_; |
1363 | const uint32_t delta_radius_; |
1364 | @@ -77,6 +77,14 @@ |
1365 | template <> |
1366 | MapHollowRegion<Area<>>::MapHollowRegion(const Map& map, const HollowArea<Area<>>& hollow_area); |
1367 | template <> bool MapHollowRegion<Area<>>::advance(const Map& map); |
1368 | + |
1369 | +// A bunch of operators that turn MapHollowRegion<Area<>>::Phase into a bitwise combinable class. |
1370 | +inline MapHollowRegion<Area<>>::Phase operator|(MapHollowRegion<Area<>>::Phase left, MapHollowRegion<Area<>>::Phase right) { |
1371 | + return MapHollowRegion<Area<>>::Phase(static_cast<int>(left) | static_cast<int>(right)); |
1372 | +} |
1373 | +inline int operator&(MapHollowRegion<Area<>>::Phase left, MapHollowRegion<Area<>>::Phase right) { |
1374 | + return static_cast<int>(left) & static_cast<int>(right); |
1375 | +} |
1376 | } // namespace Widelands |
1377 | |
1378 | #endif // end of include guard: WL_LOGIC_MAPHOLLOWREGION_H |
1379 | |
1380 | === modified file 'src/logic/maptriangleregion.cc' |
1381 | --- src/logic/maptriangleregion.cc 2019-02-23 11:00:49 +0000 |
1382 | +++ src/logic/maptriangleregion.cc 2019-04-10 16:40:56 +0000 |
1383 | @@ -36,18 +36,18 @@ |
1384 | remaining_rows_in_lower_phase_ = (area.radius - 1) / 2; |
1385 | if (radius_is_odd_) { |
1386 | map.get_trn(area.node, &area.node); |
1387 | - phase_ = Top; |
1388 | + phase_ = Phase::kTop; |
1389 | row_length_ = area.radius + 2; |
1390 | remaining_in_row_ = radius_plus_1 / 2; |
1391 | area.t = TriangleIndex::D; |
1392 | } else { |
1393 | - phase_ = Upper; |
1394 | + phase_ = Phase::kUpper; |
1395 | remaining_in_row_ = row_length_ = radius_plus_1; |
1396 | area.t = TriangleIndex::R; |
1397 | } |
1398 | } else { |
1399 | assert(area.radius == 0); |
1400 | - phase_ = Bottom; |
1401 | + phase_ = Phase::kBottom; |
1402 | remaining_in_row_ = 0; |
1403 | area.t = TriangleIndex::R; |
1404 | } |
1405 | @@ -57,12 +57,12 @@ |
1406 | if (radius_is_odd_) { |
1407 | map.get_ln(area.node, &area.node); |
1408 | left_ = area.node; |
1409 | - phase_ = Upper; |
1410 | + phase_ = Phase::kUpper; |
1411 | remaining_in_row_ = row_length_ = area.radius + 2; |
1412 | area.t = TriangleIndex::R; |
1413 | } else { |
1414 | map.get_bln(area.node, &left_); |
1415 | - phase_ = Top; |
1416 | + phase_ = Phase::kTop; |
1417 | row_length_ = area.radius + 3; |
1418 | remaining_in_row_ = half_radius_rounded_down + (0 < area.radius); |
1419 | area.t = TriangleIndex::D; |
1420 | @@ -77,17 +77,17 @@ |
1421 | return false; |
1422 | --remaining_in_row_; |
1423 | switch (phase_) { |
1424 | - case Top: |
1425 | + case Phase::kTop: |
1426 | if (remaining_in_row_) |
1427 | map.get_rn(location_.node, &location_.node); |
1428 | else if (remaining_rows_in_upper_phase_) { |
1429 | - phase_ = Upper; |
1430 | + phase_ = Phase::kUpper; |
1431 | remaining_in_row_ = row_length_; |
1432 | assert(remaining_in_row_); |
1433 | location_ = TCoords<>(left_, location_.t); |
1434 | } |
1435 | break; |
1436 | - case Upper: |
1437 | + case Phase::kUpper: |
1438 | if (remaining_in_row_) { |
1439 | if (location_.t == TriangleIndex::D) |
1440 | location_.t = TriangleIndex::R; |
1441 | @@ -99,11 +99,11 @@ |
1442 | left_ = map.bl_n(left_); |
1443 | } else { |
1444 | if (remaining_rows_in_lower_phase_) { |
1445 | - phase_ = Lower; |
1446 | + phase_ = Phase::kLower; |
1447 | assert(row_length_ >= 2); |
1448 | row_length_ -= 2; |
1449 | } else if (location_.t == TriangleIndex::R) { |
1450 | - phase_ = Bottom; |
1451 | + phase_ = Phase::kBottom; |
1452 | row_length_ /= 2; |
1453 | } else |
1454 | return false; |
1455 | @@ -113,7 +113,7 @@ |
1456 | location_ = TCoords<>(left_, location_.t); |
1457 | } |
1458 | break; |
1459 | - case Lower: |
1460 | + case Phase::kLower: |
1461 | if (remaining_in_row_) { |
1462 | if (location_.t == TriangleIndex::D) |
1463 | location_.t = TriangleIndex::R; |
1464 | @@ -125,14 +125,14 @@ |
1465 | remaining_in_row_ = row_length_ -= 2; |
1466 | left_ = map.br_n(left_); |
1467 | } else if (location_.t == TriangleIndex::R) { |
1468 | - phase_ = Bottom; |
1469 | + phase_ = Phase::kBottom; |
1470 | remaining_in_row_ = row_length_ / 2; |
1471 | left_ = map.br_n(left_); |
1472 | } |
1473 | location_ = TCoords<>(left_, location_.t); |
1474 | } |
1475 | break; |
1476 | - case Bottom: |
1477 | + case Phase::kBottom: |
1478 | if (remaining_in_row_) |
1479 | map.get_rn(location_.node, &location_.node); |
1480 | break; |
1481 | @@ -156,17 +156,17 @@ |
1482 | remaining_rows_in_lower_phase_ = (area.radius - 1) / 2; |
1483 | if (radius_is_odd_) { |
1484 | map.get_trn(area.node, &area.node); |
1485 | - phase_ = Top; |
1486 | + phase_ = Phase::kTop; |
1487 | row_length_ = area.radius + 2; |
1488 | remaining_in_row_ = radius_plus_1 / 2; |
1489 | area.t = TriangleIndex::D; |
1490 | } else { |
1491 | - phase_ = Upper; |
1492 | + phase_ = Phase::kUpper; |
1493 | remaining_in_row_ = row_length_ = radius_plus_1; |
1494 | area.t = TriangleIndex::R; |
1495 | } |
1496 | } else { |
1497 | - phase_ = Bottom; |
1498 | + phase_ = Phase::kBottom; |
1499 | remaining_in_row_ = 0; |
1500 | area.t = TriangleIndex::R; |
1501 | } |
1502 | @@ -176,12 +176,12 @@ |
1503 | if (radius_is_odd_) { |
1504 | map.get_ln(area.node, &area.node); |
1505 | left_ = area.node; |
1506 | - phase_ = Upper; |
1507 | + phase_ = Phase::kUpper; |
1508 | remaining_in_row_ = row_length_ = area.radius + 2; |
1509 | area.t = TriangleIndex::R; |
1510 | } else { |
1511 | map.get_bln(area.node, &left_); |
1512 | - phase_ = Top; |
1513 | + phase_ = Phase::kTop; |
1514 | row_length_ = area.radius + 3; |
1515 | remaining_in_row_ = half_radius_rounded_down + (0 < area.radius); |
1516 | area.t = TriangleIndex::D; |
1517 | @@ -197,17 +197,17 @@ |
1518 | return false; |
1519 | --remaining_in_row_; |
1520 | switch (phase_) { |
1521 | - case Top: |
1522 | + case Phase::kTop: |
1523 | if (remaining_in_row_) |
1524 | map.get_rn(location_.node, &location_.node); |
1525 | else if (remaining_rows_in_upper_phase_) { |
1526 | - phase_ = Upper; |
1527 | + phase_ = Phase::kUpper; |
1528 | remaining_in_row_ = row_length_; |
1529 | assert(remaining_in_row_); |
1530 | location_ = TCoords<FCoords>(left_, location_.t); |
1531 | } |
1532 | break; |
1533 | - case Upper: |
1534 | + case Phase::kUpper: |
1535 | if (remaining_in_row_) { |
1536 | if (location_.t == TriangleIndex::D) |
1537 | location_.t = TriangleIndex::R; |
1538 | @@ -219,11 +219,11 @@ |
1539 | left_ = map.bl_n(left_); |
1540 | } else { |
1541 | if (remaining_rows_in_lower_phase_) { |
1542 | - phase_ = Lower; |
1543 | + phase_ = Phase::kLower; |
1544 | assert(row_length_ >= 2); |
1545 | row_length_ -= 2; |
1546 | } else if (location_.t == TriangleIndex::R) { |
1547 | - phase_ = Bottom; |
1548 | + phase_ = Phase::kBottom; |
1549 | row_length_ /= 2; |
1550 | } else |
1551 | return false; |
1552 | @@ -233,7 +233,7 @@ |
1553 | location_ = TCoords<FCoords>(left_, location_.t); |
1554 | } |
1555 | break; |
1556 | - case Lower: |
1557 | + case Phase::kLower: |
1558 | if (remaining_in_row_) { |
1559 | if (location_.t == TriangleIndex::D) |
1560 | location_.t = TriangleIndex::R; |
1561 | @@ -245,14 +245,14 @@ |
1562 | remaining_in_row_ = row_length_ -= 2; |
1563 | left_ = map.br_n(left_); |
1564 | } else if (location_.t == TriangleIndex::R) { |
1565 | - phase_ = Bottom; |
1566 | + phase_ = Phase::kBottom; |
1567 | remaining_in_row_ = row_length_ / 2; |
1568 | left_ = map.br_n(left_); |
1569 | } |
1570 | location_ = TCoords<FCoords>(left_, location_.t); |
1571 | } |
1572 | break; |
1573 | - case Bottom: |
1574 | + case Phase::kBottom: |
1575 | if (remaining_in_row_) |
1576 | map.get_rn(location_.node, &location_.node); |
1577 | break; |
1578 | |
1579 | === modified file 'src/logic/maptriangleregion.h' |
1580 | --- src/logic/maptriangleregion.h 2019-02-23 11:00:49 +0000 |
1581 | +++ src/logic/maptriangleregion.h 2019-04-10 16:40:56 +0000 |
1582 | @@ -114,7 +114,7 @@ |
1583 | |
1584 | private: |
1585 | const bool radius_is_odd_ = false; |
1586 | - enum { Top, Upper, Lower, Bottom } phase_ = Top; |
1587 | + enum class Phase { kTop, kUpper, kLower, kBottom } phase_ = Phase::kTop; |
1588 | uint16_t remaining_rows_in_upper_phase_ = 0U; |
1589 | uint16_t remaining_rows_in_lower_phase_ = 0U; |
1590 | uint16_t row_length_, remaining_in_row_ = 0U; |
1591 | |
1592 | === modified file 'src/logic/player.cc' |
1593 | --- src/logic/player.cc 2019-03-09 08:58:52 +0000 |
1594 | +++ src/logic/player.cc 2019-04-10 16:40:56 +0000 |
1595 | @@ -329,8 +329,8 @@ |
1596 | } |
1597 | |
1598 | if (g_options.pull_section("global").get_bool("sound_at_message", true)) { |
1599 | - MAYBE_PLAY(Message::Type::kEconomySiteOccupied, "military/site_occupied"); |
1600 | - MAYBE_PLAY(Message::Type::kWarfareUnderAttack, "military/under_attack"); |
1601 | + MAYBE_PLAY(Message::Type::kEconomySiteOccupied, "military/site_occupied") |
1602 | + MAYBE_PLAY(Message::Type::kWarfareUnderAttack, "military/under_attack") |
1603 | Notifications::publish(NoteSound("message", 200, PRIO_ALWAYS_PLAY)); |
1604 | } |
1605 | } |
1606 | |
1607 | === modified file 'src/map_io/map_buildingdata_packet.cc' |
1608 | --- src/map_io/map_buildingdata_packet.cc 2019-02-23 11:00:49 +0000 |
1609 | +++ src/map_io/map_buildingdata_packet.cc 2019-04-10 16:40:56 +0000 |
1610 | @@ -666,7 +666,7 @@ |
1611 | |
1612 | productionsite.stack_[i].program = productionsite.descr().get_program(program_name); |
1613 | productionsite.stack_[i].ip = fr.signed_32(); |
1614 | - productionsite.stack_[i].phase = fr.signed_32(); |
1615 | + productionsite.stack_[i].phase = static_cast<ProgramResult>(fr.signed_32()); |
1616 | productionsite.stack_[i].flags = fr.unsigned_32(); |
1617 | |
1618 | uint32_t serial = fr.unsigned_32(); |
1619 | @@ -1135,7 +1135,8 @@ |
1620 | for (uint16_t i = 0; i < program_size; ++i) { |
1621 | fw.string(productionsite.stack_[i].program->name()); |
1622 | fw.signed_32(productionsite.stack_[i].ip); |
1623 | - fw.signed_32(productionsite.stack_[i].phase); |
1624 | + // TODO(GunChleoc): If we ever change this packet, we can have an uint8 here. |
1625 | + fw.signed_32(static_cast<int>(productionsite.stack_[i].phase)); |
1626 | fw.unsigned_32(productionsite.stack_[i].flags); |
1627 | fw.unsigned_32(mos.get_object_file_index_or_zero(productionsite.stack_[i].objvar.get(game))); |
1628 | write_coords_32(&fw, productionsite.stack_[i].coord); |
1629 | |
1630 | === modified file 'src/map_io/map_players_view_packet.cc' |
1631 | --- src/map_io/map_players_view_packet.cc 2019-02-23 11:00:49 +0000 |
1632 | +++ src/map_io/map_players_view_packet.cc 2019-04-10 16:40:56 +0000 |
1633 | @@ -434,47 +434,47 @@ |
1634 | OPEN_INPUT_FILE_NEW_VERSION(FileRead, node_immovable_kinds_file, |
1635 | node_immovable_kinds_filename, node_immovable_kinds_file_version, |
1636 | NODE_IMMOVABLE_KINDS_FILENAME_TEMPLATE, |
1637 | - kCurrentPacketVersionImmovableKinds); |
1638 | + kCurrentPacketVersionImmovableKinds) |
1639 | |
1640 | OPEN_INPUT_FILE_NEW_VERSION(FileRead, node_immovables_file, node_immovables_filename, |
1641 | node_immovables_file_version, NODE_IMMOVABLES_FILENAME_TEMPLATE, |
1642 | - kCurrentPacketVersionImmovables); |
1643 | + kCurrentPacketVersionImmovables) |
1644 | |
1645 | OPEN_INPUT_FILE_NEW_VERSION(FileRead, roads_file, roads_filename, road_file_version, |
1646 | - ROADS_FILENAME_TEMPLATE, kCurrentPacketVersionRoads); |
1647 | + ROADS_FILENAME_TEMPLATE, kCurrentPacketVersionRoads) |
1648 | |
1649 | OPEN_INPUT_FILE_NEW_VERSION(FileRead, terrains_file, terrains_filename, terrains_file_version, |
1650 | - TERRAINS_FILENAME_TEMPLATE, kCurrentPacketVersionTerrains); |
1651 | + TERRAINS_FILENAME_TEMPLATE, kCurrentPacketVersionTerrains) |
1652 | |
1653 | OPEN_INPUT_FILE_NEW_VERSION( |
1654 | FileRead, triangle_immovable_kinds_file, triangle_immovable_kinds_filename, |
1655 | triangle_immovable_kinds_file_version, TRIANGLE_IMMOVABLE_KINDS_FILENAME_TEMPLATE, |
1656 | - kCurrentPacketVersionImmovableKinds); |
1657 | + kCurrentPacketVersionImmovableKinds) |
1658 | |
1659 | OPEN_INPUT_FILE_NEW_VERSION(FileRead, triangle_immovables_file, triangle_immovables_filename, |
1660 | triangle_immovables_file_version, |
1661 | TRIANGLE_IMMOVABLES_FILENAME_TEMPLATE, |
1662 | - kCurrentPacketVersionImmovables); |
1663 | + kCurrentPacketVersionImmovables) |
1664 | |
1665 | OPEN_INPUT_FILE(FileRead, owners_file, owners_filename, OWNERS_FILENAME_TEMPLATE, |
1666 | - kCurrentPacketVersionOwners); |
1667 | + kCurrentPacketVersionOwners) |
1668 | |
1669 | OPEN_INPUT_FILE_NEW_VERSION(FileRead, surveys_file, surveys_filename, surveys_file_version, |
1670 | - SURVEYS_FILENAME_TEMPLATE, kCurrentPacketVersionSurveys); |
1671 | + SURVEYS_FILENAME_TEMPLATE, kCurrentPacketVersionSurveys) |
1672 | |
1673 | OPEN_INPUT_FILE_NEW_VERSION(FileRead, survey_amounts_file, survey_amounts_filename, |
1674 | survey_amounts_file_version, SURVEY_AMOUNTS_FILENAME_TEMPLATE, |
1675 | - kCurrentPacketVersionSurveyAmounts); |
1676 | + kCurrentPacketVersionSurveyAmounts) |
1677 | |
1678 | OPEN_INPUT_FILE(FileRead, survey_times_file, survey_times_filename, |
1679 | - SURVEY_TIMES_FILENAME_TEMPLATE, kCurrentPacketVersionSurveyTimes); |
1680 | + SURVEY_TIMES_FILENAME_TEMPLATE, kCurrentPacketVersionSurveyTimes) |
1681 | |
1682 | OPEN_INPUT_FILE_NEW_VERSION(FileRead, border_file, border_filename, border_file_version, |
1683 | - BORDER_FILENAME_TEMPLATE, kCurrentPacketVersionBorder); |
1684 | + BORDER_FILENAME_TEMPLATE, kCurrentPacketVersionBorder) |
1685 | |
1686 | OPEN_INPUT_FILE_NEW_VERSION_SILENT(FileRead, hidden_file, hidden_filename, |
1687 | hidden_file_version, HIDDEN_FILENAME_TEMPLATE, |
1688 | - kCurrentPacketVersionHidden); |
1689 | + kCurrentPacketVersionHidden) |
1690 | |
1691 | for (FCoords first_in_row(Coords(0, 0), &first_field); first_in_row.y < mapheight; |
1692 | ++first_in_row.y, first_in_row.field += mapwidth) { |
1693 | @@ -801,19 +801,19 @@ |
1694 | hidden_file_version, kCurrentPacketVersionHidden); |
1695 | } |
1696 | |
1697 | - CHECK_TRAILING_BYTES(unseen_times_file, unseen_times_filename); |
1698 | - CHECK_TRAILING_BYTES(node_immovable_kinds_file, node_immovable_kinds_filename); |
1699 | - CHECK_TRAILING_BYTES(node_immovables_file, node_immovables_filename); |
1700 | - CHECK_TRAILING_BYTES(roads_file, roads_filename); |
1701 | - CHECK_TRAILING_BYTES(terrains_file, terrains_filename); |
1702 | - CHECK_TRAILING_BYTES(triangle_immovable_kinds_file, triangle_immovable_kinds_filename); |
1703 | - CHECK_TRAILING_BYTES(triangle_immovables_file, triangle_immovables_filename); |
1704 | - CHECK_TRAILING_BYTES(owners_file, owners_filename); |
1705 | - CHECK_TRAILING_BYTES(surveys_file, surveys_filename); |
1706 | - CHECK_TRAILING_BYTES(survey_amounts_file, survey_amounts_filename); |
1707 | - CHECK_TRAILING_BYTES(survey_times_file, survey_times_filename); |
1708 | - CHECK_TRAILING_BYTES(border_file, border_filename); |
1709 | - CHECK_TRAILING_BYTES(hidden_file, hidden_filename); |
1710 | + CHECK_TRAILING_BYTES(unseen_times_file, unseen_times_filename) |
1711 | + CHECK_TRAILING_BYTES(node_immovable_kinds_file, node_immovable_kinds_filename) |
1712 | + CHECK_TRAILING_BYTES(node_immovables_file, node_immovables_filename) |
1713 | + CHECK_TRAILING_BYTES(roads_file, roads_filename) |
1714 | + CHECK_TRAILING_BYTES(terrains_file, terrains_filename) |
1715 | + CHECK_TRAILING_BYTES(triangle_immovable_kinds_file, triangle_immovable_kinds_filename) |
1716 | + CHECK_TRAILING_BYTES(triangle_immovables_file, triangle_immovables_filename) |
1717 | + CHECK_TRAILING_BYTES(owners_file, owners_filename) |
1718 | + CHECK_TRAILING_BYTES(surveys_file, surveys_filename) |
1719 | + CHECK_TRAILING_BYTES(survey_amounts_file, survey_amounts_filename) |
1720 | + CHECK_TRAILING_BYTES(survey_times_file, survey_times_filename) |
1721 | + CHECK_TRAILING_BYTES(border_file, border_filename) |
1722 | + CHECK_TRAILING_BYTES(hidden_file, hidden_filename) |
1723 | } |
1724 | } |
1725 | |
1726 | @@ -1011,38 +1011,38 @@ |
1727 | fs.ensure_directory_exists( |
1728 | (boost::format(DIRNAME_TEMPLATE) % static_cast<unsigned int>(plnum)).str()); |
1729 | |
1730 | - WRITE(unseen_times_file, UNSEEN_TIMES_FILENAME_TEMPLATE, kCurrentPacketVersionUnseenTimes); |
1731 | + WRITE(unseen_times_file, UNSEEN_TIMES_FILENAME_TEMPLATE, kCurrentPacketVersionUnseenTimes) |
1732 | |
1733 | WRITE(node_immovable_kinds_file, NODE_IMMOVABLE_KINDS_FILENAME_TEMPLATE, |
1734 | - kCurrentPacketVersionImmovableKinds); |
1735 | + kCurrentPacketVersionImmovableKinds) |
1736 | |
1737 | WRITE( |
1738 | - node_immovables_file, NODE_IMMOVABLES_FILENAME_TEMPLATE, kCurrentPacketVersionImmovables); |
1739 | - |
1740 | - WRITE(roads_file, ROADS_FILENAME_TEMPLATE, kCurrentPacketVersionRoads); |
1741 | - |
1742 | - WRITE(terrains_file, TERRAINS_FILENAME_TEMPLATE, kCurrentPacketVersionTerrains); |
1743 | + node_immovables_file, NODE_IMMOVABLES_FILENAME_TEMPLATE, kCurrentPacketVersionImmovables) |
1744 | + |
1745 | + WRITE(roads_file, ROADS_FILENAME_TEMPLATE, kCurrentPacketVersionRoads) |
1746 | + |
1747 | + WRITE(terrains_file, TERRAINS_FILENAME_TEMPLATE, kCurrentPacketVersionTerrains) |
1748 | |
1749 | WRITE(triangle_immovable_kinds_file, TRIANGLE_IMMOVABLE_KINDS_FILENAME_TEMPLATE, |
1750 | - kCurrentPacketVersionImmovableKinds); |
1751 | + kCurrentPacketVersionImmovableKinds) |
1752 | |
1753 | WRITE(triangle_immovables_file, TRIANGLE_IMMOVABLES_FILENAME_TEMPLATE, |
1754 | - kCurrentPacketVersionImmovables); |
1755 | - |
1756 | - WRITE(owners_file, OWNERS_FILENAME_TEMPLATE, kCurrentPacketVersionOwners); |
1757 | - |
1758 | - WRITE(surveys_file, SURVEYS_FILENAME_TEMPLATE, kCurrentPacketVersionSurveys); |
1759 | + kCurrentPacketVersionImmovables) |
1760 | + |
1761 | + WRITE(owners_file, OWNERS_FILENAME_TEMPLATE, kCurrentPacketVersionOwners) |
1762 | + |
1763 | + WRITE(surveys_file, SURVEYS_FILENAME_TEMPLATE, kCurrentPacketVersionSurveys) |
1764 | |
1765 | WRITE( |
1766 | - survey_amounts_file, SURVEY_AMOUNTS_FILENAME_TEMPLATE, kCurrentPacketVersionSurveyAmounts); |
1767 | - |
1768 | - WRITE(survey_times_file, SURVEY_TIMES_FILENAME_TEMPLATE, kCurrentPacketVersionSurveyTimes); |
1769 | - |
1770 | - WRITE(hidden_file, HIDDEN_FILENAME_TEMPLATE, kCurrentPacketVersionHidden); |
1771 | - |
1772 | - WRITE(vision_file, VISION_FILENAME_TEMPLATE, kCurrentPacketVersionVision); |
1773 | - |
1774 | - WRITE(border_file, BORDER_FILENAME_TEMPLATE, kCurrentPacketVersionBorder); |
1775 | + survey_amounts_file, SURVEY_AMOUNTS_FILENAME_TEMPLATE, kCurrentPacketVersionSurveyAmounts) |
1776 | + |
1777 | + WRITE(survey_times_file, SURVEY_TIMES_FILENAME_TEMPLATE, kCurrentPacketVersionSurveyTimes) |
1778 | + |
1779 | + WRITE(hidden_file, HIDDEN_FILENAME_TEMPLATE, kCurrentPacketVersionHidden) |
1780 | + |
1781 | + WRITE(vision_file, VISION_FILENAME_TEMPLATE, kCurrentPacketVersionVision) |
1782 | + |
1783 | + WRITE(border_file, BORDER_FILENAME_TEMPLATE, kCurrentPacketVersionBorder) |
1784 | } |
1785 | } |
1786 | } // namespace Widelands |
1787 | |
1788 | === modified file 'src/map_io/s2map.cc' |
1789 | --- src/map_io/s2map.cc 2019-02-23 11:00:49 +0000 |
1790 | +++ src/map_io/s2map.cc 2019-04-10 16:40:56 +0000 |
1791 | @@ -704,7 +704,7 @@ |
1792 | res = ""; |
1793 | amount = 0; |
1794 | break; |
1795 | - }; |
1796 | + } |
1797 | |
1798 | Widelands::DescriptionIndex nres = 0; |
1799 | if (*res) { |
1800 | |
1801 | === modified file 'src/scripting/lua_bases.cc' |
1802 | --- src/scripting/lua_bases.cc 2019-02-23 11:00:49 +0000 |
1803 | +++ src/scripting/lua_bases.cc 2019-04-10 16:40:56 +0000 |
1804 | @@ -572,7 +572,7 @@ |
1805 | PERS_UINT32("player", player_number_); |
1806 | } |
1807 | void LuaPlayerBase::__unpersist(lua_State* L) { |
1808 | - UNPERS_UINT32("player", player_number_); |
1809 | + UNPERS_UINT32("player", player_number_) |
1810 | } |
1811 | |
1812 | /* |
1813 | |
1814 | === modified file 'src/scripting/lua_game.cc' |
1815 | --- src/scripting/lua_game.cc 2019-03-09 08:58:52 +0000 |
1816 | +++ src/scripting/lua_game.cc 2019-04-10 16:40:56 +0000 |
1817 | @@ -435,10 +435,10 @@ |
1818 | lua_pop(L, 1); |
1819 | |
1820 | if (lua_gettop(L) == 4) { |
1821 | - CHECK_UINT(posx); |
1822 | - CHECK_UINT(posy); |
1823 | - CHECK_UINT(w); |
1824 | - CHECK_UINT(h); |
1825 | + CHECK_UINT(posx) |
1826 | + CHECK_UINT(posy) |
1827 | + CHECK_UINT(w) |
1828 | + CHECK_UINT(h) |
1829 | |
1830 | // If a field has been defined, read the coordinates to jump to. |
1831 | lua_getfield(L, 4, "field"); |
1832 | @@ -959,7 +959,7 @@ |
1833 | PERS_STRING("name", name_); |
1834 | } |
1835 | void LuaObjective::__unpersist(lua_State* L) { |
1836 | - UNPERS_STRING("name", name_); |
1837 | + UNPERS_STRING("name", name_) |
1838 | } |
1839 | |
1840 | /* |
1841 | @@ -1126,9 +1126,9 @@ |
1842 | PERS_UINT32("msg_idx", get_mos(L)->message_savers[player_number_ - 1][message_id_].value()); |
1843 | } |
1844 | void LuaMessage::__unpersist(lua_State* L) { |
1845 | - UNPERS_UINT32("player", player_number_); |
1846 | + UNPERS_UINT32("player", player_number_) |
1847 | uint32_t midx = 0; |
1848 | - UNPERS_UINT32("msg_idx", midx); |
1849 | + UNPERS_UINT32("msg_idx", midx) |
1850 | message_id_ = MessageId(midx); |
1851 | } |
1852 | |
1853 | |
1854 | === modified file 'src/scripting/lua_map.cc' |
1855 | --- src/scripting/lua_map.cc 2019-04-07 05:46:13 +0000 |
1856 | +++ src/scripting/lua_map.cc 2019-04-10 16:40:56 +0000 |
1857 | @@ -545,10 +545,10 @@ |
1858 | lua_pushuint32(L, idx); \ |
1859 | lua_pushuint32(L, i.first.name); \ |
1860 | lua_rawset(L, -3); |
1861 | - PUSHLEVEL(1, health); |
1862 | - PUSHLEVEL(2, attack); |
1863 | - PUSHLEVEL(3, defense); |
1864 | - PUSHLEVEL(4, evade); |
1865 | + PUSHLEVEL(1, health) |
1866 | + PUSHLEVEL(2, attack) |
1867 | + PUSHLEVEL(3, defense) |
1868 | + PUSHLEVEL(4, evade) |
1869 | #undef PUSHLEVEL |
1870 | |
1871 | lua_pushuint32(L, i.second); |
1872 | @@ -1539,7 +1539,7 @@ |
1873 | |
1874 | void LuaTribeDescription::__unpersist(lua_State* L) { |
1875 | std::string name; |
1876 | - UNPERS_STRING("name", name); |
1877 | + UNPERS_STRING("name", name) |
1878 | const Tribes& tribes = get_egbase(L).tribes(); |
1879 | DescriptionIndex idx = tribes.safe_tribe_index(name); |
1880 | set_description_pointer(tribes.get_tribe_descr(idx)); |
1881 | @@ -1993,7 +1993,7 @@ |
1882 | |
1883 | void LuaImmovableDescription::__unpersist(lua_State* L) { |
1884 | std::string name; |
1885 | - UNPERS_STRING("name", name); |
1886 | + UNPERS_STRING("name", name) |
1887 | const World& world = get_egbase(L).world(); |
1888 | DescriptionIndex idx = world.get_immovable_index(name); |
1889 | if (idx != INVALID_INDEX) { |
1890 | @@ -2215,7 +2215,7 @@ |
1891 | |
1892 | void LuaBuildingDescription::__unpersist(lua_State* L) { |
1893 | std::string name; |
1894 | - UNPERS_STRING("name", name); |
1895 | + UNPERS_STRING("name", name) |
1896 | const Tribes& tribes = get_egbase(L).tribes(); |
1897 | DescriptionIndex idx = tribes.safe_building_index(name.c_str()); |
1898 | set_description_pointer(tribes.get_building_descr(idx)); |
1899 | @@ -3070,7 +3070,7 @@ |
1900 | |
1901 | void LuaWareDescription::__unpersist(lua_State* L) { |
1902 | std::string name; |
1903 | - UNPERS_STRING("name", name); |
1904 | + UNPERS_STRING("name", name) |
1905 | const Tribes& tribes = get_egbase(L).tribes(); |
1906 | DescriptionIndex idx = tribes.safe_ware_index(name.c_str()); |
1907 | set_description_pointer(tribes.get_ware_descr(idx)); |
1908 | @@ -3188,7 +3188,7 @@ |
1909 | |
1910 | void LuaWorkerDescription::__unpersist(lua_State* L) { |
1911 | std::string name; |
1912 | - UNPERS_STRING("name", name); |
1913 | + UNPERS_STRING("name", name) |
1914 | const Tribes& tribes = get_egbase(L).tribes(); |
1915 | DescriptionIndex idx = tribes.safe_worker_index(name.c_str()); |
1916 | set_description_pointer(tribes.get_worker_descr(idx)); |
1917 | @@ -3469,7 +3469,7 @@ |
1918 | |
1919 | void LuaResourceDescription::__unpersist(lua_State* L) { |
1920 | std::string name; |
1921 | - UNPERS_STRING("name", name); |
1922 | + UNPERS_STRING("name", name) |
1923 | const World& world = get_egbase(L).world(); |
1924 | const ResourceDescription* descr = world.get_resource(world.safe_resource_index(name.c_str())); |
1925 | set_description_pointer(descr); |
1926 | @@ -3590,7 +3590,7 @@ |
1927 | |
1928 | void LuaTerrainDescription::__unpersist(lua_State* L) { |
1929 | std::string name; |
1930 | - UNPERS_STRING("name", name); |
1931 | + UNPERS_STRING("name", name) |
1932 | set_description_pointer(get_egbase(L).world().terrain_descr(name)); |
1933 | } |
1934 | |
1935 | @@ -3776,8 +3776,8 @@ |
1936 | void LuaEconomy::__unpersist(lua_State* L) { |
1937 | Widelands::PlayerNumber player_number; |
1938 | Widelands::Serial economy_serial; |
1939 | - UNPERS_UINT32("player", player_number); |
1940 | - UNPERS_UINT32("economy", economy_serial); |
1941 | + UNPERS_UINT32("player", player_number) |
1942 | + UNPERS_UINT32("economy", economy_serial) |
1943 | const Widelands::Player& player = get_egbase(L).player(player_number); |
1944 | set_economy_pointer(player.get_economy(economy_serial)); |
1945 | } |
1946 | @@ -3929,7 +3929,7 @@ |
1947 | } |
1948 | void LuaMapObject::__unpersist(lua_State* L) { |
1949 | uint32_t idx; |
1950 | - UNPERS_UINT32("file_index", idx); |
1951 | + UNPERS_UINT32("file_index", idx) |
1952 | |
1953 | if (!idx) |
1954 | ptr_ = nullptr; |
1955 | @@ -6179,8 +6179,8 @@ |
1956 | } |
1957 | |
1958 | void LuaField::__unpersist(lua_State* L) { |
1959 | - UNPERS_INT32("x", coords_.x); |
1960 | - UNPERS_INT32("y", coords_.y); |
1961 | + UNPERS_INT32("x", coords_.x) |
1962 | + UNPERS_INT32("y", coords_.y) |
1963 | } |
1964 | |
1965 | /* |
1966 | @@ -6727,7 +6727,7 @@ |
1967 | } |
1968 | |
1969 | void LuaPlayerSlot::__unpersist(lua_State* L) { |
1970 | - UNPERS_UINT32("player", player_number_); |
1971 | + UNPERS_UINT32("player", player_number_) |
1972 | } |
1973 | |
1974 | /* |
1975 | |
1976 | === modified file 'src/sound/sound_handler.cc' |
1977 | --- src/sound/sound_handler.cc 2019-02-23 11:00:49 +0000 |
1978 | +++ src/sound/sound_handler.cc 2019-04-10 16:40:56 +0000 |
1979 | @@ -112,7 +112,7 @@ |
1980 | nosound_ = true; |
1981 | } |
1982 | |
1983 | - SDL_MIXER_VERSION(&sdl_version); |
1984 | + SDL_MIXER_VERSION(&sdl_version) |
1985 | log("SDL_mixer version: %d.%d.%d\n", static_cast<unsigned int>(sdl_version.major), |
1986 | static_cast<unsigned int>(sdl_version.minor), static_cast<unsigned int>(sdl_version.patch)); |
1987 | |
1988 | |
1989 | === modified file 'src/ui_basic/box.cc' |
1990 | --- src/ui_basic/box.cc 2019-02-23 11:00:49 +0000 |
1991 | +++ src/ui_basic/box.cc 2019-04-10 16:40:56 +0000 |
1992 | @@ -423,6 +423,6 @@ |
1993 | |
1994 | case Item::ItemSpace: |
1995 | break; // no need to do anything |
1996 | - }; |
1997 | + } |
1998 | } |
1999 | } // namespace UI |
2000 | |
2001 | === modified file 'src/ui_basic/editbox.cc' |
2002 | --- src/ui_basic/editbox.cc 2019-02-23 11:00:49 +0000 |
2003 | +++ src/ui_basic/editbox.cc 2019-04-10 16:40:56 +0000 |
2004 | @@ -208,7 +208,7 @@ |
2005 | case SDLK_DELETE: |
2006 | if (m_->caret < m_->text.size()) { |
2007 | while ((m_->text[++m_->caret] & 0xc0) == 0x80) { |
2008 | - }; |
2009 | + } |
2010 | // Now fallthrough to handle it like Backspace |
2011 | } else { |
2012 | return true; |
2013 | @@ -232,7 +232,7 @@ |
2014 | case SDLK_LEFT: |
2015 | if (m_->caret > 0) { |
2016 | while ((m_->text[--m_->caret] & 0xc0) == 0x80) { |
2017 | - }; |
2018 | + } |
2019 | if (code.mod & (KMOD_LCTRL | KMOD_RCTRL)) |
2020 | for (uint32_t new_caret = m_->caret;; m_->caret = new_caret) |
2021 | if (0 == new_caret || isspace(m_->text[--new_caret])) |
2022 | @@ -250,7 +250,8 @@ |
2023 | case SDLK_RIGHT: |
2024 | if (m_->caret < m_->text.size()) { |
2025 | while ((m_->text[++m_->caret] & 0xc0) == 0x80) { |
2026 | - }; |
2027 | + // We're just advancing the caret |
2028 | + } |
2029 | if (code.mod & (KMOD_LCTRL | KMOD_RCTRL)) |
2030 | for (uint32_t new_caret = m_->caret;; ++new_caret) |
2031 | if (new_caret == m_->text.size() || isspace(m_->text[new_caret - 1])) { |
2032 | |
2033 | === modified file 'src/ui_basic/unique_window.h' |
2034 | --- src/ui_basic/unique_window.h 2019-02-23 11:00:49 +0000 |
2035 | +++ src/ui_basic/unique_window.h 2019-04-10 16:40:56 +0000 |
2036 | @@ -55,9 +55,6 @@ |
2037 | int32_t x, y; |
2038 | bool valid_pos; |
2039 | |
2040 | - Registry(const Registry&) = default; |
2041 | - Registry& operator=(const Registry&) = default; |
2042 | - |
2043 | Registry() : window(nullptr), x(0), y(0), valid_pos(false) { |
2044 | } |
2045 | ~Registry(); |
2046 | |
2047 | === modified file 'src/ui_fsmenu/main.cc' |
2048 | --- src/ui_fsmenu/main.cc 2019-02-23 11:00:49 +0000 |
2049 | +++ src/ui_fsmenu/main.cc 2019-04-10 16:40:56 +0000 |
2050 | @@ -114,7 +114,7 @@ |
2051 | } |
2052 | |
2053 | void FullscreenMenuMain::clicked_ok() { |
2054 | - ; // do nothing |
2055 | + // do nothing |
2056 | } |
2057 | |
2058 | void FullscreenMenuMain::layout() { |
2059 | |
2060 | === modified file 'src/ui_fsmenu/netsetup_lan.cc' |
2061 | --- src/ui_fsmenu/netsetup_lan.cc 2019-02-23 11:00:49 +0000 |
2062 | +++ src/ui_fsmenu/netsetup_lan.cc 2019-04-10 16:40:56 +0000 |
2063 | @@ -207,7 +207,7 @@ |
2064 | /** TRANSLATORS: The state of a LAN game can be open, closed or unknown */ |
2065 | er.set_string(2, pgettext("game_state", "Unknown")); |
2066 | break; |
2067 | - }; |
2068 | + } |
2069 | } |
2070 | |
2071 | void FullscreenMenuNetSetupLAN::game_opened(const NetOpenGame* game) { |
2072 | |
2073 | === modified file 'src/wui/interactive_player.cc' |
2074 | --- src/wui/interactive_player.cc 2019-03-01 04:29:12 +0000 |
2075 | +++ src/wui/interactive_player.cc 2019-04-10 16:40:56 +0000 |
2076 | @@ -68,7 +68,7 @@ |
2077 | const Widelands::Player::Field& pf) { |
2078 | if (pf.vision == 0) { |
2079 | return 0.; |
2080 | - }; |
2081 | + } |
2082 | |
2083 | uint32_t brightness = 144 + fcoords.field->get_brightness(); |
2084 | brightness = std::min<uint32_t>(255, (brightness * 255) / 160); |
Continuous integration builds have changed state:
Travis build 4702. State: passed. Details: https:/ /travis- ci.org/ widelands/ widelands/ builds/ 517666765. /ci.appveyor. com/project/ widelands- dev/widelands/ build/_ widelands_ dev_widelands_ bug_1823612_ llvm8_build_ errors- 4488.
Appveyor build 4488. State: success. Details: https:/