Merge lp:~widelands-dev/widelands/bug-1823612-llvm8-build-errors into lp:widelands

Proposed by GunChleoc
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
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.

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

Continuous integration builds have changed state:

Travis build 4702. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/517666765.
Appveyor build 4488. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_bug_1823612_llvm8_build_errors-4488.

Revision history for this message
GunChleoc (gunchleoc) wrote :

This is ready for review now, targeted at Build 20.

review: Needs Resubmitting
Revision history for this message
hessenfarmer (stephan-lutz) wrote :

Found at least one questionable change in ai code see inline.
needs intensive testing of programs especially for the mines

Revision history for this message
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....

Revision history for this message
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?

Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 4706. State: errored. Details: https://travis-ci.org/widelands/widelands/builds/517922834.
Appveyor build 4492. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_bug_1823612_llvm8_build_errors-4492.

Revision history for this message
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?

Revision history for this message
TiborB (tiborb95) wrote :

@Gun, I am not sure whom you are asking, but still I left the comment in the code....

Revision history for this message
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.

Revision history for this message
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.

Revision history for this message
TiborB (tiborb95) wrote :

@hessenfarmer - the bug is too much as no real harm is done here, todo in the code would be enough....

Revision history for this message
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.

Revision history for this message
hessenfarmer (stephan-lutz) wrote :

ok thanks for the explanation.
did some playtesting. Found no anomalies.

review: Approve (test)
Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 4709. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/518396046.
Appveyor build 4495. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_bug_1823612_llvm8_build_errors-4495.

Revision history for this message
GunChleoc (gunchleoc) wrote :

Thanks!

Let's have it.

@bunnybot merge

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/ai/ai_help_structs.cc'
--- src/ai/ai_help_structs.cc 2019-02-23 11:00:49 +0000
+++ src/ai/ai_help_structs.cc 2019-04-10 16:40:56 +0000
@@ -1148,12 +1148,12 @@
1148 if (this_player_team != mytn) {1148 if (this_player_team != mytn) {
1149 log("%2d: Team changed %d -> %d\n", pn, this_player_team, mytn);1149 log("%2d: Team changed %d -> %d\n", pn, this_player_team, mytn);
1150 this_player_team = mytn;1150 this_player_team = mytn;
1151 };1151 }
1152 if (all_stats[opn].team_number != pltn) {1152 if (all_stats[opn].team_number != pltn) {
1153 log("%2d: Team changed for player %d: %d -> %d\n", pn, opn, all_stats[opn].team_number,1153 log("%2d: Team changed for player %d: %d -> %d\n", pn, opn, all_stats[opn].team_number,
1154 pltn);1154 pltn);
1155 all_stats[opn].team_number = pltn;1155 all_stats[opn].team_number = pltn;
1156 };1156 }
1157 }1157 }
1158}1158}
11591159
@@ -1248,7 +1248,7 @@
1248uint32_t PlayersStrengths::get_player_power(Widelands::PlayerNumber pn) {1248uint32_t PlayersStrengths::get_player_power(Widelands::PlayerNumber pn) {
1249 if (all_stats.count(pn) > 0) {1249 if (all_stats.count(pn) > 0) {
1250 return all_stats[pn].players_power;1250 return all_stats[pn].players_power;
1251 };1251 }
1252 return 0;1252 return 0;
1253}1253}
12541254
@@ -1256,7 +1256,7 @@
1256uint32_t PlayersStrengths::get_player_land(Widelands::PlayerNumber pn) {1256uint32_t PlayersStrengths::get_player_land(Widelands::PlayerNumber pn) {
1257 if (all_stats.count(pn) > 0) {1257 if (all_stats.count(pn) > 0) {
1258 return all_stats[pn].players_land;1258 return all_stats[pn].players_land;
1259 };1259 }
1260 return 0;1260 return 0;
1261}1261}
12621262
12631263
=== modified file 'src/ai/defaultai.cc'
--- src/ai/defaultai.cc 2019-03-24 13:13:34 +0000
+++ src/ai/defaultai.cc 2019-04-10 16:40:56 +0000
@@ -327,7 +327,7 @@
327 case SchedulerTaskId::kRoadCheck:327 case SchedulerTaskId::kRoadCheck:
328 if (check_economies()) { // is a must328 if (check_economies()) { // is a must
329 return;329 return;
330 };330 }
331 set_taskpool_task_time(gametime + 1000, SchedulerTaskId::kRoadCheck);331 set_taskpool_task_time(gametime + 1000, SchedulerTaskId::kRoadCheck);
332 // testing 5 roads332 // testing 5 roads
333 {333 {
@@ -337,7 +337,7 @@
337 if (improve_roads(gametime)) {337 if (improve_roads(gametime)) {
338 // if significant change takes place do not go on338 // if significant change takes place do not go on
339 break;339 break;
340 };340 }
341 }341 }
342 }342 }
343 break;343 break;
@@ -380,7 +380,7 @@
380 if (check_productionsites(gametime)) {380 if (check_productionsites(gametime)) {
381 // if significant change takes place do not go on381 // if significant change takes place do not go on
382 break;382 break;
383 };383 }
384 }384 }
385 }385 }
386 break;386 break;
@@ -413,7 +413,7 @@
413 if (check_mines_(gametime)) {413 if (check_mines_(gametime)) {
414 // if significant change takes place do not go on414 // if significant change takes place do not go on
415 break;415 break;
416 };416 }
417 }417 }
418 }418 }
419 break;419 break;
@@ -460,7 +460,7 @@
460 if (get_land_owner(game().map(), coords) == player_number()) {460 if (get_land_owner(game().map(), coords) == player_number()) {
461 ++conquered_wh;461 ++conquered_wh;
462 }462 }
463 };463 }
464 if (!basic_economy_established) {464 if (!basic_economy_established) {
465 assert(!persistent_data->remaining_basic_buildings.empty());465 assert(!persistent_data->remaining_basic_buildings.empty());
466 log("%2d: Basic economy not achieved, %" PRIuS " building(s) missing, f.e.: %s\n",466 log("%2d: Basic economy not achieved, %" PRIuS " building(s) missing, f.e.: %s\n",
@@ -3078,7 +3078,6 @@
3078 (bf->military_in_constr_nearby + bf->military_unstationed) <3078 (bf->military_in_constr_nearby + bf->military_unstationed) <
3079 concurent_ms_in_constr_no_enemy) {3079 concurent_ms_in_constr_no_enemy) {
3080 // it will conquer new buildable spots for buildings or mines3080 // it will conquer new buildable spots for buildings or mines
3081 ;
3082 } else if (bf->defense_msite_allowed &&3081 } else if (bf->defense_msite_allowed &&
3083 (bf->military_in_constr_nearby + bf->military_unstationed) <3082 (bf->military_in_constr_nearby + bf->military_unstationed) <
3084 concurent_ms_in_constr_enemy_nearby) {3083 concurent_ms_in_constr_enemy_nearby) {
@@ -3514,15 +3513,15 @@
3514 if (!has_building && flag.nr_of_roads() == 1) {3513 if (!has_building && flag.nr_of_roads() == 1) {
3515 return false;3514 return false;
3516 } else if (is_warehouse && flag.nr_of_roads() <= 3) {3515 } else if (is_warehouse && flag.nr_of_roads() <= 3) {
3517 ;3516 // Do nothing
3518 } else if (needs_warehouse) {3517 } else if (needs_warehouse) {
3519 ;3518 // Do nothing
3520 } else if (flag.current_wares() > 5) {3519 } else if (flag.current_wares() > 5) {
3521 ;3520 // Do nothing
3522 } else if (has_building && std::rand() % 3 == 0) {3521 } else if (has_building && std::rand() % 3 == 0) {
3523 ;3522 // Do nothing
3524 } else if (std::rand() % 10 == 0) {3523 } else if (std::rand() % 10 == 0) {
3525 ;3524 // Do nothing
3526 } else {3525 } else {
3527 return false;3526 return false;
3528 }3527 }
@@ -3753,8 +3752,6 @@
3753 // if we are within grace time, it is OK, just go on3752 // if we are within grace time, it is OK, just go on
3754 if (eco->dismantle_grace_time > gametime &&3753 if (eco->dismantle_grace_time > gametime &&
3755 eco->dismantle_grace_time != std::numeric_limits<uint32_t>::max()) {3754 eco->dismantle_grace_time != std::numeric_limits<uint32_t>::max()) {
3756 ;
3757
3758 // if grace time is not set, this is probably first time without a warehouse and we must3755 // if grace time is not set, this is probably first time without a warehouse and we must
3759 // set it3756 // set it
3760 } else if (eco->dismantle_grace_time == std::numeric_limits<uint32_t>::max()) {3757 } else if (eco->dismantle_grace_time == std::numeric_limits<uint32_t>::max()) {
@@ -5458,10 +5455,11 @@
5458 inputs[14] = (bo.current_stats - 50) / 10;5455 inputs[14] = (bo.current_stats - 50) / 10;
5459 inputs[15] = management_data.get_military_number_at(123) / 10;5456 inputs[15] = management_data.get_military_number_at(123) / 10;
5460 inputs[16] = 0;5457 inputs[16] = 0;
5461 inputs[17] = (inputs_on_stock) ? 0 : -2;5458 // TODO(GunChleoc): This is overwritten below due to a typo
5459 // inputs[17] = (inputs_on_stock) ? 0 : -2;
5462 inputs[18] = (suppliers_exist) ? 0 : -3;5460 inputs[18] = (suppliers_exist) ? 0 : -3;
5463 ;
5464 inputs[17] = (inputs_on_stock) ? 0 : -4;5461 inputs[17] = (inputs_on_stock) ? 0 : -4;
5462 // Nothing on inputs[19]
5465 inputs[20] =5463 inputs[20] =
5466 (mines_per_type[bo.mines].in_construction + mines_per_type[bo.mines].finished == 1) ?5464 (mines_per_type[bo.mines].in_construction + mines_per_type[bo.mines].finished == 1) ?
5467 3 :5465 3 :
@@ -6060,7 +6058,7 @@
6060 // 2. in new flags to be processed yet6058 // 2. in new flags to be processed yet
6061 if (remove_from_dqueue<Widelands::Flag>(new_flags, flag)) {6059 if (remove_from_dqueue<Widelands::Flag>(new_flags, flag)) {
6062 return;6060 return;
6063 };6061 }
60646062
6065 // 3. Or in neither of them6063 // 3. Or in neither of them
6066 } else if (upcast(Road const, road, &pi)) {6064 } else if (upcast(Road const, road, &pi)) {
@@ -6152,7 +6150,7 @@
6152 // (used when testing possible port location)6150 // (used when testing possible port location)
6153 if (f->nodecaps() & BUILDCAPS_MINE) {6151 if (f->nodecaps() & BUILDCAPS_MINE) {
6154 mineable_fields_count += 1;6152 mineable_fields_count += 1;
6155 };6153 }
61566154
6157 // add neighbours to a queue (duplicates are no problem)6155 // add neighbours to a queue (duplicates are no problem)
6158 // to relieve AI/CPU we skip every second field in each direction6156 // to relieve AI/CPU we skip every second field in each direction
61596157
=== modified file 'src/ai/defaultai_warfare.cc'
--- src/ai/defaultai_warfare.cc 2019-02-23 11:00:49 +0000
+++ src/ai/defaultai_warfare.cc 2019-04-10 16:40:56 +0000
@@ -266,7 +266,6 @@
266 inputs[3] = (is_warehouse) ? 2 : 0;266 inputs[3] = (is_warehouse) ? 2 : 0;
267 inputs[4] = (site->second.attack_soldiers_competency > 15) ? 2 : 0;267 inputs[4] = (site->second.attack_soldiers_competency > 15) ? 2 : 0;
268 inputs[5] = (site->second.attack_soldiers_competency > 25) ? 4 : 0;268 inputs[5] = (site->second.attack_soldiers_competency > 25) ? 4 : 0;
269 ;
270 inputs[6] =269 inputs[6] =
271 (2 * site->second.defenders_strength > 3 * site->second.attack_soldiers_strength) ?270 (2 * site->second.defenders_strength > 3 * site->second.attack_soldiers_strength) ?
272 2 :271 2 :
273272
=== modified file 'src/economy/economy.cc'
--- src/economy/economy.cc 2019-02-23 11:00:49 +0000
+++ src/economy/economy.cc 2019-04-10 16:40:56 +0000
@@ -434,9 +434,9 @@
434 RequestList::iterator const it = std::find(requests_.begin(), requests_.end(), &req);434 RequestList::iterator const it = std::find(requests_.begin(), requests_.end(), &req);
435435
436 if (it == requests_.end()) {436 if (it == requests_.end()) {
437 FORMAT_WARNINGS_OFF;437 FORMAT_WARNINGS_OFF
438 log("WARNING: remove_request(%p) not in list\n", &req);438 log("WARNING: remove_request(%p) not in list\n", &req);
439 FORMAT_WARNINGS_ON;439 FORMAT_WARNINGS_ON
440 return;440 return;
441 }441 }
442442
443443
=== modified file 'src/economy/ware_instance.cc'
--- src/economy/ware_instance.cc 2019-02-23 11:00:49 +0000
+++ src/economy/ware_instance.cc 2019-04-10 16:40:56 +0000
@@ -187,9 +187,9 @@
187187
188WareInstance::~WareInstance() {188WareInstance::~WareInstance() {
189 if (supply_) {189 if (supply_) {
190 FORMAT_WARNINGS_OFF;190 FORMAT_WARNINGS_OFF
191 molog("Ware %u still has supply %p\n", descr_index_, supply_);191 molog("Ware %u still has supply %p\n", descr_index_, supply_);
192 FORMAT_WARNINGS_ON;192 FORMAT_WARNINGS_ON
193 delete supply_;193 delete supply_;
194 }194 }
195}195}
196196
=== modified file 'src/editor/tools/info_tool.cc'
--- src/editor/tools/info_tool.cc 2019-02-23 11:00:49 +0000
+++ src/editor/tools/info_tool.cc 2019-04-10 16:40:56 +0000
@@ -74,7 +74,7 @@
74 } break;74 } break;
75 default:75 default:
76 break;76 break;
77 };77 }
7878
79 if (caps & Widelands::BUILDCAPS_FLAG) {79 if (caps & Widelands::BUILDCAPS_FLAG) {
80 /** TRANSLATORS: Editor terrain property: space for a flag */80 /** TRANSLATORS: Editor terrain property: space for a flag */
8181
=== modified file 'src/editor/ui_menus/tool_menu.cc'
--- src/editor/ui_menus/tool_menu.cc 2019-02-23 11:00:49 +0000
+++ src/editor/ui_menus/tool_menu.cc 2019-04-10 16:40:56 +0000
@@ -56,15 +56,15 @@
56 this, pos, g_gr->images().get("images/wui/editor/editor_menu_tool_" pic ".png"), tooltip); \56 this, pos, g_gr->images().get("images/wui/editor/editor_menu_tool_" pic ".png"), tooltip); \
57 pos.x += width + spacing;57 pos.x += width + spacing;
5858
59 ADD_BUTTON("change_height", _("Change height"));59 ADD_BUTTON("change_height", _("Change height"))
60 ADD_BUTTON("noise_height", _("Random height"));60 ADD_BUTTON("noise_height", _("Random height"))
61 ADD_BUTTON("set_terrain", _("Terrain"));61 ADD_BUTTON("set_terrain", _("Terrain"))
62 ADD_BUTTON("place_immovable", _("Immovables"));62 ADD_BUTTON("place_immovable", _("Immovables"))
63 ADD_BUTTON("place_bob", _("Animals"));63 ADD_BUTTON("place_bob", _("Animals"))
64 ADD_BUTTON("change_resources", _("Resources"));64 ADD_BUTTON("change_resources", _("Resources"))
65 ADD_BUTTON("set_port_space", _("Set port space"));65 ADD_BUTTON("set_port_space", _("Set port space"))
66 ADD_BUTTON("set_origin", _("Set the position that will have the coordinates (0, 0). This will "66 ADD_BUTTON("set_origin", _("Set the position that will have the coordinates (0, 0). This will "
67 "be the top-left corner of a generated minimap."));67 "be the top-left corner of a generated minimap."))
6868
69 set_inner_size(offs.x + (width + spacing) * num_tools, offs.y + (height + spacing));69 set_inner_size(offs.x + (width + spacing) * num_tools, offs.y + (height + spacing));
7070
7171
=== modified file 'src/graphic/gl/initialize.cc'
--- src/graphic/gl/initialize.cc 2019-02-23 22:42:03 +0000
+++ src/graphic/gl/initialize.cc 2019-04-10 16:40:56 +0000
@@ -101,17 +101,17 @@
101 glbinding::setAfterCallback([](const glbinding::FunctionCall& call) {101 glbinding::setAfterCallback([](const glbinding::FunctionCall& call) {
102 log("%s(", call.function->name());102 log("%s(", call.function->name());
103 for (size_t i = 0; i < call.parameters.size(); ++i) {103 for (size_t i = 0; i < call.parameters.size(); ++i) {
104 FORMAT_WARNINGS_OFF;104 FORMAT_WARNINGS_OFF
105 log("%p", call.parameters[i].get());105 log("%p", call.parameters[i].get());
106 FORMAT_WARNINGS_ON;106 FORMAT_WARNINGS_ON
107 if (i < call.parameters.size() - 1)107 if (i < call.parameters.size() - 1)
108 log(", ");108 log(", ");
109 }109 }
110 log(")");110 log(")");
111 if (call.returnValue) {111 if (call.returnValue) {
112 FORMAT_WARNINGS_OFF;112 FORMAT_WARNINGS_OFF
113 log(" -> %p", call.returnValue.get());113 log(" -> %p", call.returnValue.get());
114 FORMAT_WARNINGS_ON;114 FORMAT_WARNINGS_ON
115 }115 }
116 const auto error = glGetError();116 const auto error = glGetError();
117 log(" [%s]\n", gl_error_to_string(error));117 log(" [%s]\n", gl_error_to_string(error));
@@ -151,26 +151,26 @@
151151
152 LOG_SDL_GL_ATTRIBUTE(SDL_GL_RED_SIZE)152 LOG_SDL_GL_ATTRIBUTE(SDL_GL_RED_SIZE)
153 LOG_SDL_GL_ATTRIBUTE(SDL_GL_GREEN_SIZE)153 LOG_SDL_GL_ATTRIBUTE(SDL_GL_GREEN_SIZE)
154 LOG_SDL_GL_ATTRIBUTE(SDL_GL_BLUE_SIZE);154 LOG_SDL_GL_ATTRIBUTE(SDL_GL_BLUE_SIZE)
155 LOG_SDL_GL_ATTRIBUTE(SDL_GL_ALPHA_SIZE);155 LOG_SDL_GL_ATTRIBUTE(SDL_GL_ALPHA_SIZE)
156 LOG_SDL_GL_ATTRIBUTE(SDL_GL_BUFFER_SIZE);156 LOG_SDL_GL_ATTRIBUTE(SDL_GL_BUFFER_SIZE)
157 LOG_SDL_GL_ATTRIBUTE(SDL_GL_DOUBLEBUFFER);157 LOG_SDL_GL_ATTRIBUTE(SDL_GL_DOUBLEBUFFER)
158 LOG_SDL_GL_ATTRIBUTE(SDL_GL_DEPTH_SIZE);158 LOG_SDL_GL_ATTRIBUTE(SDL_GL_DEPTH_SIZE)
159 LOG_SDL_GL_ATTRIBUTE(SDL_GL_STENCIL_SIZE);159 LOG_SDL_GL_ATTRIBUTE(SDL_GL_STENCIL_SIZE)
160 LOG_SDL_GL_ATTRIBUTE(SDL_GL_ACCUM_RED_SIZE);160 LOG_SDL_GL_ATTRIBUTE(SDL_GL_ACCUM_RED_SIZE)
161 LOG_SDL_GL_ATTRIBUTE(SDL_GL_ACCUM_GREEN_SIZE);161 LOG_SDL_GL_ATTRIBUTE(SDL_GL_ACCUM_GREEN_SIZE)
162 LOG_SDL_GL_ATTRIBUTE(SDL_GL_ACCUM_BLUE_SIZE);162 LOG_SDL_GL_ATTRIBUTE(SDL_GL_ACCUM_BLUE_SIZE)
163 LOG_SDL_GL_ATTRIBUTE(SDL_GL_ACCUM_ALPHA_SIZE);163 LOG_SDL_GL_ATTRIBUTE(SDL_GL_ACCUM_ALPHA_SIZE)
164 LOG_SDL_GL_ATTRIBUTE(SDL_GL_STEREO);164 LOG_SDL_GL_ATTRIBUTE(SDL_GL_STEREO)
165 LOG_SDL_GL_ATTRIBUTE(SDL_GL_MULTISAMPLEBUFFERS);165 LOG_SDL_GL_ATTRIBUTE(SDL_GL_MULTISAMPLEBUFFERS)
166 LOG_SDL_GL_ATTRIBUTE(SDL_GL_MULTISAMPLESAMPLES);166 LOG_SDL_GL_ATTRIBUTE(SDL_GL_MULTISAMPLESAMPLES)
167 LOG_SDL_GL_ATTRIBUTE(SDL_GL_ACCELERATED_VISUAL);167 LOG_SDL_GL_ATTRIBUTE(SDL_GL_ACCELERATED_VISUAL)
168 LOG_SDL_GL_ATTRIBUTE(SDL_GL_CONTEXT_MAJOR_VERSION);168 LOG_SDL_GL_ATTRIBUTE(SDL_GL_CONTEXT_MAJOR_VERSION)
169 LOG_SDL_GL_ATTRIBUTE(SDL_GL_CONTEXT_MINOR_VERSION);169 LOG_SDL_GL_ATTRIBUTE(SDL_GL_CONTEXT_MINOR_VERSION)
170 LOG_SDL_GL_ATTRIBUTE(SDL_GL_CONTEXT_FLAGS);170 LOG_SDL_GL_ATTRIBUTE(SDL_GL_CONTEXT_FLAGS)
171 LOG_SDL_GL_ATTRIBUTE(SDL_GL_CONTEXT_PROFILE_MASK);171 LOG_SDL_GL_ATTRIBUTE(SDL_GL_CONTEXT_PROFILE_MASK)
172 LOG_SDL_GL_ATTRIBUTE(SDL_GL_SHARE_WITH_CURRENT_CONTEXT);172 LOG_SDL_GL_ATTRIBUTE(SDL_GL_SHARE_WITH_CURRENT_CONTEXT)
173 LOG_SDL_GL_ATTRIBUTE(SDL_GL_FRAMEBUFFER_SRGB_CAPABLE);173 LOG_SDL_GL_ATTRIBUTE(SDL_GL_FRAMEBUFFER_SRGB_CAPABLE)
174#undef LOG_SDL_GL_ATTRIBUTE174#undef LOG_SDL_GL_ATTRIBUTE
175175
176 GLboolean glBool;176 GLboolean glBool;
177177
=== modified file 'src/graphic/gl/utils.cc'
--- src/graphic/gl/utils.cc 2017-11-28 17:29:49 +0000
+++ src/graphic/gl/utils.cc 2019-04-10 16:40:56 +0000
@@ -57,7 +57,7 @@
57} // namespace57} // namespace
5858
59const char* gl_error_to_string(const GLenum err) {59const char* gl_error_to_string(const GLenum err) {
60 CLANG_DIAG_OFF("-Wswitch-enum");60 CLANG_DIAG_OFF("-Wswitch-enum")
61#define LOG(a) \61#define LOG(a) \
62 case a: \62 case a: \
63 return #a63 return #a
@@ -74,7 +74,7 @@
74 break;74 break;
75 }75 }
76#undef LOG76#undef LOG
77 CLANG_DIAG_ON("-Wswitch-enum");77 CLANG_DIAG_ON("-Wswitch-enum")
78 return "unknown";78 return "unknown";
79}79}
8080
8181
=== modified file 'src/io/filesystem/test/test_filesystem.cc'
--- src/io/filesystem/test/test_filesystem.cc 2019-02-23 11:00:49 +0000
+++ src/io/filesystem/test/test_filesystem.cc 2019-04-10 16:40:56 +0000
@@ -65,66 +65,66 @@
6565
66 // RealFSImpl is constructed with a root directory...66 // RealFSImpl is constructed with a root directory...
6767
68 TEST_CANONICALIZE_NAME("", "path", cwd + "/path");68 TEST_CANONICALIZE_NAME("", "path", cwd + "/path")
69 TEST_CANONICALIZE_NAME(".", "path", cwd + "/path");69 TEST_CANONICALIZE_NAME(".", "path", cwd + "/path")
7070
71 TEST_CANONICALIZE_NAME("/home", "path", "/home/path");71 TEST_CANONICALIZE_NAME("/home", "path", "/home/path")
72 TEST_CANONICALIZE_NAME("/opt", "path", "/opt/path");72 TEST_CANONICALIZE_NAME("/opt", "path", "/opt/path")
73 TEST_CANONICALIZE_NAME("/opt/test", "path", "/opt/test/path");73 TEST_CANONICALIZE_NAME("/opt/test", "path", "/opt/test/path")
74 TEST_CANONICALIZE_NAME("/opt", "some/path", "/opt/some/path");74 TEST_CANONICALIZE_NAME("/opt", "some/path", "/opt/some/path")
7575
76 // single dot is removed (root path)...76 // single dot is removed (root path)...
7777
78 TEST_CANONICALIZE_NAME("./home/me", "path", cwd + "/home/me/path");78 TEST_CANONICALIZE_NAME("./home/me", "path", cwd + "/home/me/path")
79 TEST_CANONICALIZE_NAME("/home/./you", "path", "/home/you/path");79 TEST_CANONICALIZE_NAME("/home/./you", "path", "/home/you/path")
80 TEST_CANONICALIZE_NAME("/home/us/.", "path", "/home/us/path");80 TEST_CANONICALIZE_NAME("/home/us/.", "path", "/home/us/path")
8181
82 // single dot is removed (file path)...82 // single dot is removed (file path)...
8383
84 TEST_CANONICALIZE_NAME("/opt", "./no/where", "/opt/no/where");84 TEST_CANONICALIZE_NAME("/opt", "./no/where", "/opt/no/where")
85 TEST_CANONICALIZE_NAME("/opt", "some/./where", "/opt/some/where");85 TEST_CANONICALIZE_NAME("/opt", "some/./where", "/opt/some/where")
86 TEST_CANONICALIZE_NAME("/opt", "any/where/.", "/opt/any/where");86 TEST_CANONICALIZE_NAME("/opt", "any/where/.", "/opt/any/where")
8787
88 // empty path nodes are removed (root path)...88 // empty path nodes are removed (root path)...
8989
90 TEST_CANONICALIZE_NAME("//usr/empty", "path", "/usr/empty/path");90 TEST_CANONICALIZE_NAME("//usr/empty", "path", "/usr/empty/path")
91 TEST_CANONICALIZE_NAME("/usr//empty", "path", "/usr/empty/path");91 TEST_CANONICALIZE_NAME("/usr//empty", "path", "/usr/empty/path")
92 TEST_CANONICALIZE_NAME("/usr/empty/", "path", "/usr/empty/path");92 TEST_CANONICALIZE_NAME("/usr/empty/", "path", "/usr/empty/path")
93 TEST_CANONICALIZE_NAME("/usr/empty//", "path", "/usr/empty/path");93 TEST_CANONICALIZE_NAME("/usr/empty//", "path", "/usr/empty/path")
9494
95 // empty path nodes are removed (file path)...95 // empty path nodes are removed (file path)...
9696
97 TEST_CANONICALIZE_NAME("/usr", "/empty/path", "/usr/empty/path");97 TEST_CANONICALIZE_NAME("/usr", "/empty/path", "/usr/empty/path")
98 TEST_CANONICALIZE_NAME("/usr", "//empty/path", "/usr/empty/path");98 TEST_CANONICALIZE_NAME("/usr", "//empty/path", "/usr/empty/path")
99 TEST_CANONICALIZE_NAME("/usr", "empty//path", "/usr/empty/path");99 TEST_CANONICALIZE_NAME("/usr", "empty//path", "/usr/empty/path")
100 TEST_CANONICALIZE_NAME("/usr", "empty/path/", "/usr/empty/path");100 TEST_CANONICALIZE_NAME("/usr", "empty/path/", "/usr/empty/path")
101 TEST_CANONICALIZE_NAME("/usr", "empty/path//", "/usr/empty/path");101 TEST_CANONICALIZE_NAME("/usr", "empty/path//", "/usr/empty/path")
102102
103 // '..' moves up a directory in the path (root path)...103 // '..' moves up a directory in the path (root path)...
104104
105 TEST_CANONICALIZE_NAME("/usr/../home", "path", "/home/path");105 TEST_CANONICALIZE_NAME("/usr/../home", "path", "/home/path")
106 TEST_CANONICALIZE_NAME("/usr/../../home", "path", "/home/path");106 TEST_CANONICALIZE_NAME("/usr/../../home", "path", "/home/path")
107 TEST_CANONICALIZE_NAME("/usr/test/..", "path", "/usr/path");107 TEST_CANONICALIZE_NAME("/usr/test/..", "path", "/usr/path")
108 TEST_CANONICALIZE_NAME("/usr/one/../two/..", "path", "/usr/path");108 TEST_CANONICALIZE_NAME("/usr/one/../two/..", "path", "/usr/path")
109 TEST_CANONICALIZE_NAME("/usr/one/../a/b/..", "path", "/usr/a/path");109 TEST_CANONICALIZE_NAME("/usr/one/../a/b/..", "path", "/usr/a/path")
110110
111 // '..' moves up a directory in the path (file path)...111 // '..' moves up a directory in the path (file path)...
112112
113 TEST_CANONICALIZE_NAME("/home/test", "../path", "/home/path");113 TEST_CANONICALIZE_NAME("/home/test", "../path", "/home/path")
114 TEST_CANONICALIZE_NAME("/home/test", "../../path", "/path");114 TEST_CANONICALIZE_NAME("/home/test", "../../path", "/path")
115 TEST_CANONICALIZE_NAME("/home/test", "../../../path", "/path");115 TEST_CANONICALIZE_NAME("/home/test", "../../../path", "/path")
116116
117 TEST_CANONICALIZE_NAME("/home/test", "path/..", "/home/test");117 TEST_CANONICALIZE_NAME("/home/test", "path/..", "/home/test")
118 TEST_CANONICALIZE_NAME("/home/test", "path/../..", "/home");118 TEST_CANONICALIZE_NAME("/home/test", "path/../..", "/home")
119119
120 TEST_CANONICALIZE_NAME("/home/test", "path/../one", "/home/test/one");120 TEST_CANONICALIZE_NAME("/home/test", "path/../one", "/home/test/one")
121 TEST_CANONICALIZE_NAME("/home/test", "path/../../one", "/home/one");121 TEST_CANONICALIZE_NAME("/home/test", "path/../../one", "/home/one")
122 TEST_CANONICALIZE_NAME("/home/test", "path/../../../one", "/one");122 TEST_CANONICALIZE_NAME("/home/test", "path/../../../one", "/one")
123 TEST_CANONICALIZE_NAME("/home/test", "path/../../../../one", "/one");123 TEST_CANONICALIZE_NAME("/home/test", "path/../../../../one", "/one")
124124
125 // ...but not a '..' coming from two different strings...125 // ...but not a '..' coming from two different strings...
126126
127 TEST_CANONICALIZE_NAME("/home/test/.", "./path", "/home/test/path");127 TEST_CANONICALIZE_NAME("/home/test/.", "./path", "/home/test/path")
128128
129#ifdef _WIN32129#ifdef _WIN32
130 // Check drive letter handling.130 // Check drive letter handling.
@@ -140,53 +140,53 @@
140 setenv("HOME", "/my/home", 1);140 setenv("HOME", "/my/home", 1);
141 std::string cwd = RealFSImpl("").get_working_directory();141 std::string cwd = RealFSImpl("").get_working_directory();
142142
143 TEST_CANONICALIZE_NAME("~", "path", "/my/home/path");143 TEST_CANONICALIZE_NAME("~", "path", "/my/home/path")
144 TEST_CANONICALIZE_NAME("~/test", "path", "/my/home/test/path");144 TEST_CANONICALIZE_NAME("~/test", "path", "/my/home/test/path")
145145
146 setenv("HOME", "/somewhere", 1);146 setenv("HOME", "/somewhere", 1);
147 TEST_CANONICALIZE_NAME("~", "path", "/somewhere/path");147 TEST_CANONICALIZE_NAME("~", "path", "/somewhere/path")
148148
149 // ~ at the start of the path overrides the root149 // ~ at the start of the path overrides the root
150150
151 TEST_CANONICALIZE_NAME("~", "~", "/somewhere");151 TEST_CANONICALIZE_NAME("~", "~", "/somewhere")
152 TEST_CANONICALIZE_NAME("~/vanish", "~", "/somewhere");152 TEST_CANONICALIZE_NAME("~/vanish", "~", "/somewhere")
153 TEST_CANONICALIZE_NAME("~/fs", "~/sf", "/somewhere/sf");153 TEST_CANONICALIZE_NAME("~/fs", "~/sf", "/somewhere/sf")
154154
155 // ~ anywhere other than at the start of a path does not get expanded155 // ~ anywhere other than at the start of a path does not get expanded
156156
157 TEST_CANONICALIZE_NAME("/opt/~", "path", "/opt/~/path");157 TEST_CANONICALIZE_NAME("/opt/~", "path", "/opt/~/path")
158 TEST_CANONICALIZE_NAME("/opt/~/the", "path", "/opt/~/the/path");158 TEST_CANONICALIZE_NAME("/opt/~/the", "path", "/opt/~/the/path")
159159
160 TEST_CANONICALIZE_NAME("/opt", "path/~", "/opt/path/~");160 TEST_CANONICALIZE_NAME("/opt", "path/~", "/opt/path/~")
161 TEST_CANONICALIZE_NAME("/opt", "path/~/here", "/opt/path/~/here");161 TEST_CANONICALIZE_NAME("/opt", "path/~/here", "/opt/path/~/here")
162162
163 // ~ as part of a root-path spec segment name does not get expanded163 // ~ as part of a root-path spec segment name does not get expanded
164164
165 TEST_CANONICALIZE_NAME("~a", "path", cwd + "/~a/path");165 TEST_CANONICALIZE_NAME("~a", "path", cwd + "/~a/path")
166 TEST_CANONICALIZE_NAME("a~", "path", cwd + "/a~/path");166 TEST_CANONICALIZE_NAME("a~", "path", cwd + "/a~/path")
167167
168 TEST_CANONICALIZE_NAME("/opt/~a", "path", "/opt/~a/path");168 TEST_CANONICALIZE_NAME("/opt/~a", "path", "/opt/~a/path")
169 TEST_CANONICALIZE_NAME("/opt/a~", "path", "/opt/a~/path");169 TEST_CANONICALIZE_NAME("/opt/a~", "path", "/opt/a~/path")
170170
171 TEST_CANONICALIZE_NAME("~a/b", "path", cwd + "/~a/b/path");171 TEST_CANONICALIZE_NAME("~a/b", "path", cwd + "/~a/b/path")
172 TEST_CANONICALIZE_NAME("a~/b", "path", cwd + "/a~/b/path");172 TEST_CANONICALIZE_NAME("a~/b", "path", cwd + "/a~/b/path")
173173
174 TEST_CANONICALIZE_NAME("/opt/~the/test", "path", "/opt/~the/test/path");174 TEST_CANONICALIZE_NAME("/opt/~the/test", "path", "/opt/~the/test/path")
175 TEST_CANONICALIZE_NAME("/opt/the~/test", "path", "/opt/the~/test/path");175 TEST_CANONICALIZE_NAME("/opt/the~/test", "path", "/opt/the~/test/path")
176176
177 // ~ as part of a path spec segment name does not get expanded177 // ~ as part of a path spec segment name does not get expanded
178178
179 TEST_CANONICALIZE_NAME("/opt", "~path", "/opt/~path");179 TEST_CANONICALIZE_NAME("/opt", "~path", "/opt/~path")
180 TEST_CANONICALIZE_NAME("/opt", "path~", "/opt/path~");180 TEST_CANONICALIZE_NAME("/opt", "path~", "/opt/path~")
181181
182 TEST_CANONICALIZE_NAME("/opt", "some/~path", "/opt/some/~path");182 TEST_CANONICALIZE_NAME("/opt", "some/~path", "/opt/some/~path")
183 TEST_CANONICALIZE_NAME("/opt", "some/path~", "/opt/some/path~");183 TEST_CANONICALIZE_NAME("/opt", "some/path~", "/opt/some/path~")
184184
185 TEST_CANONICALIZE_NAME("/opt", "~path/here", "/opt/~path/here");185 TEST_CANONICALIZE_NAME("/opt", "~path/here", "/opt/~path/here")
186 TEST_CANONICALIZE_NAME("/opt", "path~/here", "/opt/path~/here");186 TEST_CANONICALIZE_NAME("/opt", "path~/here", "/opt/path~/here")
187187
188 TEST_CANONICALIZE_NAME("/opt", "a/~path/here", "/opt/a/~path/here");188 TEST_CANONICALIZE_NAME("/opt", "a/~path/here", "/opt/a/~path/here")
189 TEST_CANONICALIZE_NAME("/opt", "a/path~/here", "/opt/a/path~/here");189 TEST_CANONICALIZE_NAME("/opt", "a/path~/here", "/opt/a/path~/here")
190}190}
191#endif191#endif
192BOOST_AUTO_TEST_SUITE_END()192BOOST_AUTO_TEST_SUITE_END()
193193
=== modified file 'src/logic/map_objects/bob.cc'
--- src/logic/map_objects/bob.cc 2019-02-27 17:19:00 +0000
+++ src/logic/map_objects/bob.cc 2019-04-10 16:40:56 +0000
@@ -903,9 +903,9 @@
903903
904/// Give debug information.904/// Give debug information.
905void Bob::log_general_info(const EditorGameBase& egbase) const {905void Bob::log_general_info(const EditorGameBase& egbase) const {
906 FORMAT_WARNINGS_OFF;906 FORMAT_WARNINGS_OFF
907 molog("Owner: %p\n", owner_);907 molog("Owner: %p\n", owner_);
908 FORMAT_WARNINGS_ON;908 FORMAT_WARNINGS_ON
909 molog("Postition: (%i, %i)\n", position_.x, position_.y);909 molog("Postition: (%i, %i)\n", position_.x, position_.y);
910 molog("ActID: %i\n", actid_);910 molog("ActID: %i\n", actid_);
911 molog("ActScheduled: %s\n", actscheduled_ ? "true" : "false");911 molog("ActScheduled: %s\n", actscheduled_ ? "true" : "false");
@@ -929,9 +929,9 @@
929 molog("* ivar2: %i\n", stack_[i].ivar2);929 molog("* ivar2: %i\n", stack_[i].ivar2);
930 molog("* ivar3: %i\n", stack_[i].ivar3);930 molog("* ivar3: %i\n", stack_[i].ivar3);
931931
932 FORMAT_WARNINGS_OFF;932 FORMAT_WARNINGS_OFF
933 molog("* object pointer: %p\n", stack_[i].objvar1.get(egbase));933 molog("* object pointer: %p\n", stack_[i].objvar1.get(egbase));
934 FORMAT_WARNINGS_ON;934 FORMAT_WARNINGS_ON
935 molog("* svar1: %s\n", stack_[i].svar1.c_str());935 molog("* svar1: %s\n", stack_[i].svar1.c_str());
936936
937 molog("* coords: (%i, %i)\n", stack_[i].coords.x, stack_[i].coords.y);937 molog("* coords: (%i, %i)\n", stack_[i].coords.x, stack_[i].coords.y);
@@ -939,9 +939,9 @@
939 for (Direction dir = FIRST_DIRECTION; dir <= LAST_DIRECTION; ++dir) {939 for (Direction dir = FIRST_DIRECTION; dir <= LAST_DIRECTION; ++dir) {
940 molog(" %d", stack_[i].diranims.get_animation(dir));940 molog(" %d", stack_[i].diranims.get_animation(dir));
941 }941 }
942 FORMAT_WARNINGS_OFF;942 FORMAT_WARNINGS_OFF
943 molog("\n* path: %p\n", stack_[i].path);943 molog("\n* path: %p\n", stack_[i].path);
944 FORMAT_WARNINGS_ON;944 FORMAT_WARNINGS_ON
945 if (stack_[i].path) {945 if (stack_[i].path) {
946 const Path& path = *stack_[i].path;946 const Path& path = *stack_[i].path;
947 molog("** Path length: %" PRIuS "\n", path.get_nsteps());947 molog("** Path length: %" PRIuS "\n", path.get_nsteps());
@@ -953,10 +953,10 @@
953 molog("* (%i, %i)\n", coords.x, coords.y);953 molog("* (%i, %i)\n", coords.x, coords.y);
954 }954 }
955 }955 }
956 FORMAT_WARNINGS_OFF;956 FORMAT_WARNINGS_OFF
957 molog("* route: %p\n", stack_[i].route);957 molog("* route: %p\n", stack_[i].route);
958 molog("* program: %p\n", stack_[i].route);958 molog("* program: %p\n", stack_[i].route);
959 FORMAT_WARNINGS_ON;959 FORMAT_WARNINGS_ON
960 }960 }
961}961}
962962
963963
=== modified file 'src/logic/map_objects/immovable.cc'
--- src/logic/map_objects/immovable.cc 2019-02-27 17:19:00 +0000
+++ src/logic/map_objects/immovable.cc 2019-04-10 16:40:56 +0000
@@ -1337,14 +1337,14 @@
1337void PlayerImmovable::log_general_info(const EditorGameBase& egbase) const {1337void PlayerImmovable::log_general_info(const EditorGameBase& egbase) const {
1338 BaseImmovable::log_general_info(egbase);1338 BaseImmovable::log_general_info(egbase);
13391339
1340 FORMAT_WARNINGS_OFF;1340 FORMAT_WARNINGS_OFF
1341 molog("this: %p\n", this);1341 molog("this: %p\n", this);
1342 molog("owner_: %p\n", owner_);1342 molog("owner_: %p\n", owner_);
1343 FORMAT_WARNINGS_ON;1343 FORMAT_WARNINGS_ON
1344 molog("player_number: %i\n", owner_->player_number());1344 molog("player_number: %i\n", owner_->player_number());
1345 FORMAT_WARNINGS_OFF;1345 FORMAT_WARNINGS_OFF
1346 molog("economy_: %p\n", economy_);1346 molog("economy_: %p\n", economy_);
1347 FORMAT_WARNINGS_ON;1347 FORMAT_WARNINGS_ON
1348}1348}
13491349
1350constexpr uint8_t kCurrentPacketVersionPlayerImmovable = 1;1350constexpr uint8_t kCurrentPacketVersionPlayerImmovable = 1;
13511351
=== modified file 'src/logic/map_objects/tribes/building.cc'
--- src/logic/map_objects/tribes/building.cc 2019-02-28 12:22:36 +0000
+++ src/logic/map_objects/tribes/building.cc 2019-04-10 16:40:56 +0000
@@ -681,9 +681,9 @@
681 PlayerImmovable::log_general_info(egbase);681 PlayerImmovable::log_general_info(egbase);
682682
683 molog("position: (%i, %i)\n", position_.x, position_.y);683 molog("position: (%i, %i)\n", position_.x, position_.y);
684 FORMAT_WARNINGS_OFF;684 FORMAT_WARNINGS_OFF
685 molog("flag: %p\n", flag_);685 molog("flag: %p\n", flag_);
686 FORMAT_WARNINGS_ON;686 FORMAT_WARNINGS_ON
687 molog("* position: (%i, %i)\n", flag_->get_position().x, flag_->get_position().y);687 molog("* position: (%i, %i)\n", flag_->get_position().x, flag_->get_position().y);
688688
689 molog("anim: %s\n", descr().get_animation_name(anim_).c_str());689 molog("anim: %s\n", descr().get_animation_name(anim_).c_str());
@@ -692,9 +692,9 @@
692 molog("leave_time: %i\n", leave_time_);692 molog("leave_time: %i\n", leave_time_);
693693
694 molog("leave_queue.size(): %" PRIuS "\n", leave_queue_.size());694 molog("leave_queue.size(): %" PRIuS "\n", leave_queue_.size());
695 FORMAT_WARNINGS_OFF;695 FORMAT_WARNINGS_OFF
696 molog("leave_allow.get(): %p\n", leave_allow_.get(egbase));696 molog("leave_allow.get(): %p\n", leave_allow_.get(egbase));
697 FORMAT_WARNINGS_ON;697 FORMAT_WARNINGS_ON
698}698}
699699
700void Building::add_worker(Worker& worker) {700void Building::add_worker(Worker& worker) {
701701
=== modified file 'src/logic/map_objects/tribes/production_program.cc'
--- src/logic/map_objects/tribes/production_program.cc 2019-02-23 11:00:49 +0000
+++ src/logic/map_objects/tribes/production_program.cc 2019-04-10 16:40:56 +0000
@@ -133,7 +133,7 @@
133 char const* const type_name = next_word(parameters, reached_end);133 char const* const type_name = next_word(parameters, reached_end);
134 const DescriptionIndex& wareindex = tribes.ware_index(type_name);134 const DescriptionIndex& wareindex = tribes.ware_index(type_name);
135 if (tribes.ware_exists(wareindex)) {135 if (tribes.ware_exists(wareindex)) {
136 for (int i = 0; i < static_cast<int>(tribes.nrtribes()); ++i) {136 for (size_t i = 0; i < tribes.nrtribes(); ++i) {
137 const TribeDescr& tribe_descr = *tribes.get_tribe_descr(i);137 const TribeDescr& tribe_descr = *tribes.get_tribe_descr(i);
138 if (tribe_descr.has_ware(wareindex)) {138 if (tribe_descr.has_ware(wareindex)) {
139 tribes.set_ware_type_has_demand_check(wareindex, tribe_descr.name());139 tribes.set_ware_type_has_demand_check(wareindex, tribe_descr.name());
@@ -142,7 +142,7 @@
142 return new ProductionProgram::ActReturn::EconomyNeedsWare(wareindex);142 return new ProductionProgram::ActReturn::EconomyNeedsWare(wareindex);
143 } else if (tribes.worker_exists(tribes.worker_index(type_name))) {143 } else if (tribes.worker_exists(tribes.worker_index(type_name))) {
144 const DescriptionIndex& workerindex = tribes.worker_index(type_name);144 const DescriptionIndex& workerindex = tribes.worker_index(type_name);
145 for (int i = 0; i < static_cast<int>(tribes.nrtribes()); ++i) {145 for (size_t i = 0; i < tribes.nrtribes(); ++i) {
146 const TribeDescr* tribe_descr = tribes.get_tribe_descr(i);146 const TribeDescr* tribe_descr = tribes.get_tribe_descr(i);
147 if (tribe_descr->has_worker(workerindex)) {147 if (tribe_descr->has_worker(workerindex)) {
148 tribes.set_worker_type_has_demand_check(workerindex);148 tribes.set_worker_type_has_demand_check(workerindex);
@@ -462,13 +462,13 @@
462 const Tribes& tribes) {462 const Tribes& tribes) {
463 try {463 try {
464 if (match(parameters, "failed"))464 if (match(parameters, "failed"))
465 result_ = Failed;465 result_ = ProgramResult::kFailed;
466 else if (match(parameters, "completed"))466 else if (match(parameters, "completed"))
467 result_ = Completed;467 result_ = ProgramResult::kCompleted;
468 else if (match(parameters, "skipped"))468 else if (match(parameters, "skipped"))
469 result_ = Skipped;469 result_ = ProgramResult::kSkipped;
470 else if (match(parameters, "no_stats"))470 else if (match(parameters, "no_stats"))
471 result_ = None;471 result_ = ProgramResult::kNone;
472 else472 else
473 throw GameDataError("expected %s but found \"%s\"",473 throw GameDataError("expected %s but found \"%s\"",
474 "{\"failed\"|\"completed\"|\"skipped\"|\"no_stats\"}", parameters);474 "{\"failed\"|\"completed\"|\"skipped\"|\"no_stats\"}", parameters);
@@ -539,22 +539,33 @@
539 i18n::localize_list(condition_list, i18n::ConcatenateWith::AND);539 i18n::localize_list(condition_list, i18n::ConcatenateWith::AND);
540540
541 std::string result_string;541 std::string result_string;
542 if (result_ == Failed) {542 switch (result_) {
543 case ProgramResult::kFailed: {
543 /** TRANSLATORS: "Did not start working because the economy needs the ware ‘%s’" */544 /** TRANSLATORS: "Did not start working because the economy needs the ware ‘%s’" */
544 result_string = (boost::format(_("Did not start %1$s because %2$s")) %545 result_string = (boost::format(_("Did not start %1$s because %2$s")) %
545 ps.top_state().program->descname() % condition_string)546 ps.top_state().program->descname() % condition_string)
546 .str();547 .str();
547 } else if (result_ == Completed) {548 } break;
549 case ProgramResult::kCompleted: {
548 /** TRANSLATORS: "Completed working because the economy needs the ware ‘%s’" */550 /** TRANSLATORS: "Completed working because the economy needs the ware ‘%s’" */
549 result_string = (boost::format(_("Completed %1$s because %2$s")) %551 result_string = (boost::format(_("Completed %1$s because %2$s")) %
550 ps.top_state().program->descname() % condition_string)552 ps.top_state().program->descname() % condition_string)
551 .str();553 .str();
552 } else {554 } break;
555 case ProgramResult::kSkipped: {
553 /** TRANSLATORS: "Skipped working because the economy needs the ware ‘%s’" */556 /** TRANSLATORS: "Skipped working because the economy needs the ware ‘%s’" */
554 result_string = (boost::format(_("Skipped %1$s because %2$s")) %557 result_string = (boost::format(_("Skipped %1$s because %2$s")) %
555 ps.top_state().program->descname() % condition_string)558 ps.top_state().program->descname() % condition_string)
556 .str();559 .str();
557 }560 } break;
561 case ProgramResult::kNone: {
562 // TODO(GunChleoc): Same as skipped - is this on purpose?
563 result_string = (boost::format(_("Skipped %1$s because %2$s")) %
564 ps.top_state().program->descname() % condition_string)
565 .str();
566 }
567 }
568
558 ps.set_production_result(result_string);569 ps.set_production_result(result_string);
559 }570 }
560 return ps.program_end(game, result_);571 return ps.program_end(game, result_);
@@ -562,9 +573,9 @@
562573
563ProductionProgram::ActCall::ActCall(char* parameters, const ProductionSiteDescr& descr) {574ProductionProgram::ActCall::ActCall(char* parameters, const ProductionSiteDescr& descr) {
564 // Initialize with default handling methods.575 // Initialize with default handling methods.
565 handling_methods_[Failed - 1] = Continue;576 handling_methods_[program_result_index(ProgramResult::kFailed)] = ProgramResultHandlingMethod::kContinue;
566 handling_methods_[Completed - 1] = Continue;577 handling_methods_[program_result_index(ProgramResult::kCompleted)] = ProgramResultHandlingMethod::kContinue;
567 handling_methods_[Skipped - 1] = Continue;578 handling_methods_[program_result_index(ProgramResult::kSkipped)] = ProgramResultHandlingMethod::kContinue;
568579
569 try {580 try {
570 bool reached_end;581 bool reached_end;
@@ -586,34 +597,34 @@
586597
587 ProgramResult result_to_set_method_for;598 ProgramResult result_to_set_method_for;
588 if (match_force_skip(parameters, "failure")) {599 if (match_force_skip(parameters, "failure")) {
589 if (handling_methods_[Failed - 1] != Continue)600 if (handling_methods_[program_result_index(ProgramResult::kFailed)] != ProgramResultHandlingMethod::kContinue)
590 throw GameDataError("%s handling method already defined", "failure");601 throw GameDataError("%s handling method already defined", "failure");
591 result_to_set_method_for = Failed;602 result_to_set_method_for = ProgramResult::kFailed;
592 } else if (match_force_skip(parameters, "completion")) {603 } else if (match_force_skip(parameters, "completion")) {
593 if (handling_methods_[Completed - 1] != Continue)604 if (handling_methods_[program_result_index(ProgramResult::kCompleted)] != ProgramResultHandlingMethod::kContinue)
594 throw GameDataError("%s handling method already defined", "completion");605 throw GameDataError("%s handling method already defined", "completion");
595 result_to_set_method_for = Completed;606 result_to_set_method_for = ProgramResult::kCompleted;
596 } else if (match_force_skip(parameters, "skip")) {607 } else if (match_force_skip(parameters, "skip")) {
597 if (handling_methods_[Skipped - 1] != Continue)608 if (handling_methods_[program_result_index(ProgramResult::kSkipped)] != ProgramResultHandlingMethod::kContinue)
598 throw GameDataError("%s handling method already defined", "skip");609 throw GameDataError("%s handling method already defined", "skip");
599 result_to_set_method_for = Skipped;610 result_to_set_method_for = ProgramResult::kSkipped;
600 } else611 } else
601 throw GameDataError(612 throw GameDataError(
602 "expected %s but found \"%s\"", "{\"failure\"|\"completion\"|\"skip\"}", parameters);613 "expected %s but found \"%s\"", "{\"failure\"|\"completion\"|\"skip\"}", parameters);
603614
604 ProgramResultHandlingMethod handling_method;615 ProgramResultHandlingMethod handling_method;
605 if (match(parameters, "fail"))616 if (match(parameters, "fail"))
606 handling_method = Fail;617 handling_method = ProgramResultHandlingMethod::kFail;
607 else if (match(parameters, "complete"))618 else if (match(parameters, "complete"))
608 handling_method = Complete;619 handling_method = ProgramResultHandlingMethod::kComplete;
609 else if (match(parameters, "skip"))620 else if (match(parameters, "skip"))
610 handling_method = Skip;621 handling_method = ProgramResultHandlingMethod::kSkip;
611 else if (match(parameters, "repeat"))622 else if (match(parameters, "repeat"))
612 handling_method = Repeat;623 handling_method = ProgramResultHandlingMethod::kRepeat;
613 else624 else
614 throw GameDataError("expected %s but found \"%s\"",625 throw GameDataError("expected %s but found \"%s\"",
615 "{\"fail\"|\"complete\"|\"skip\"|\"repeat\"}", parameters);626 "{\"fail\"|\"complete\"|\"skip\"|\"repeat\"}", parameters);
616 handling_methods_[result_to_set_method_for - 1] = handling_method;627 handling_methods_[program_result_index(result_to_set_method_for)] = handling_method;
617 reached_end = !*parameters;628 reached_end = !*parameters;
618 }629 }
619 } catch (const WException& e) {630 } catch (const WException& e) {
@@ -622,21 +633,21 @@
622}633}
623634
624void ProductionProgram::ActCall::execute(Game& game, ProductionSite& ps) const {635void ProductionProgram::ActCall::execute(Game& game, ProductionSite& ps) const {
625 ProgramResult const program_result = static_cast<ProgramResult>(ps.top_state().phase);636 ProgramResult const program_result = ps.top_state().phase;
626637
627 if (program_result == None) { // The program has not yet been called.638 if (program_result == ProgramResult::kNone) { // The program has not yet been called.
628 return ps.program_start(game, program_->name());639 return ps.program_start(game, program_->name());
629 }640 }
630641
631 switch (handling_methods_[program_result - 1]) {642 switch (handling_methods_[program_result_index(program_result)]) {
632 case Fail:643 case ProgramResultHandlingMethod::kFail:
633 case Complete:644 case ProgramResultHandlingMethod::kComplete:
634 case Skip:645 case ProgramResultHandlingMethod::kSkip:
635 return ps.program_end(game, None);646 return ps.program_end(game, ProgramResult::kNone);
636 case Continue:647 case ProgramResultHandlingMethod::kContinue:
637 return ps.program_step(game);648 return ps.program_step(game);
638 case Repeat:649 case ProgramResultHandlingMethod::kRepeat:
639 ps.top_state().phase = None;650 ps.top_state().phase = ProgramResult::kNone;
640 ps.program_timer_ = true;651 ps.program_timer_ = true;
641 ps.program_time_ = ps.schedule_act(game, 10);652 ps.program_time_ = ps.schedule_act(game, 10);
642 break;653 break;
@@ -687,9 +698,9 @@
687 ProductionSite& psite,698 ProductionSite& psite,
688 Worker& worker) const {699 Worker& worker) const {
689 ProductionSite::State& state = psite.top_state();700 ProductionSite::State& state = psite.top_state();
690 if (state.phase == 0) {701 if (state.phase == ProgramResult::kNone) {
691 worker.start_task_program(game, program());702 worker.start_task_program(game, program());
692 ++state.phase;703 state.phase = ProgramResult::kFailed;
693 return true;704 return true;
694 } else {705 } else {
695 psite.program_step(game);706 psite.program_step(game);
@@ -700,7 +711,7 @@
700void ProductionProgram::ActCallWorker::building_work_failed(Game& game,711void ProductionProgram::ActCallWorker::building_work_failed(Game& game,
701 ProductionSite& psite,712 ProductionSite& psite,
702 Worker&) const {713 Worker&) const {
703 psite.program_end(game, Failed);714 psite.program_end(game, ProgramResult::kFailed);
704}715}
705716
706ProductionProgram::ActSleep::ActSleep(char* parameters) {717ProductionProgram::ActSleep::ActSleep(char* parameters) {
@@ -719,7 +730,7 @@
719}730}
720731
721void ProductionProgram::ActSleep::execute(Game& game, ProductionSite& ps) const {732void ProductionProgram::ActSleep::execute(Game& game, ProductionSite& ps) const {
722 return ps.program_step(game, duration_ ? duration_ : ps.top_state().phase);733 return ps.program_step(game, duration_ ? duration_ : 0, ps.top_state().phase);
723}734}
724735
725ProductionProgram::ActCheckMap::ActCheckMap(char* parameters) {736ProductionProgram::ActCheckMap::ActCheckMap(char* parameters) {
@@ -743,7 +754,7 @@
743 return ps.program_step(game, 0);754 return ps.program_step(game, 0);
744 } else {755 } else {
745 ps.set_production_result(_("No use for ships on this map!"));756 ps.set_production_result(_("No use for ships on this map!"));
746 return ps.program_end(game, Failed);757 return ps.program_end(game, ProgramResult::kFailed);
747 }758 }
748 }759 }
749 default:760 default:
@@ -777,7 +788,7 @@
777788
778void ProductionProgram::ActAnimate::execute(Game& game, ProductionSite& ps) const {789void ProductionProgram::ActAnimate::execute(Game& game, ProductionSite& ps) const {
779 ps.start_animation(game, id_);790 ps.start_animation(game, id_);
780 return ps.program_step(game, duration_ ? duration_ : ps.top_state().phase);791 return ps.program_step(game, duration_ ? duration_ : 0, ps.top_state().phase);
781}792}
782793
783ProductionProgram::ActConsume::ActConsume(char* parameters,794ProductionProgram::ActConsume::ActConsume(char* parameters,
@@ -900,7 +911,7 @@
900 .str();911 .str();
901912
902 ps.set_production_result(result_string);913 ps.set_production_result(result_string);
903 return ps.program_end(game, Failed);914 return ps.program_end(game, ProgramResult::kFailed);
904 } else { // we fulfilled all consumption requirements915 } else { // we fulfilled all consumption requirements
905 for (size_t i = 0; i < inputqueues.size(); ++i) {916 for (size_t i = 0; i < inputqueues.size(); ++i) {
906 if (uint8_t const q = consumption_quantities[i]) {917 if (uint8_t const q = consumption_quantities[i]) {
@@ -1182,7 +1193,7 @@
1182 if (digged_percentage < max_) {1193 if (digged_percentage < max_) {
1183 // mine can produce normally1194 // mine can produce normally
1184 if (totalres == 0)1195 if (totalres == 0)
1185 return ps.program_end(game, Failed);1196 return ps.program_end(game, ProgramResult::kFailed);
11861197
1187 // second pass through nodes1198 // second pass through nodes
1188 assert(totalchance);1199 assert(totalchance);
@@ -1210,7 +1221,7 @@
1210 }1221 }
12111222
1212 if (pick >= 0) {1223 if (pick >= 0) {
1213 return ps.program_end(game, Failed);1224 return ps.program_end(game, ProgramResult::kFailed);
1214 }1225 }
12151226
1216 } else {1227 } else {
@@ -1233,7 +1244,7 @@
1233 if (training_ >= game.logic_rand() % 100) {1244 if (training_ >= game.logic_rand() % 100) {
1234 ps.train_workers(game);1245 ps.train_workers(game);
1235 }1246 }
1236 return ps.program_end(game, Failed);1247 return ps.program_end(game, ProgramResult::kFailed);
1237 }1248 }
1238 }1249 }
12391250
@@ -1278,7 +1289,7 @@
1278 const std::vector<Soldier*> soldiers = ctrl->present_soldiers();1289 const std::vector<Soldier*> soldiers = ctrl->present_soldiers();
1279 if (soldiers.empty()) {1290 if (soldiers.empty()) {
1280 ps.set_production_result(_("No soldier to train!"));1291 ps.set_production_result(_("No soldier to train!"));
1281 return ps.program_end(game, Skipped);1292 return ps.program_end(game, ProgramResult::kSkipped);
1282 }1293 }
1283 ps.molog(" Checking soldier (%u) level %d)\n", static_cast<unsigned int>(attribute),1294 ps.molog(" Checking soldier (%u) level %d)\n", static_cast<unsigned int>(attribute),
1284 static_cast<unsigned int>(level));1295 static_cast<unsigned int>(level));
@@ -1287,7 +1298,7 @@
1287 for (std::vector<Soldier*>::const_iterator it = soldiers.begin();; ++it) {1298 for (std::vector<Soldier*>::const_iterator it = soldiers.begin();; ++it) {
1288 if (it == soldiers_end) {1299 if (it == soldiers_end) {
1289 ps.set_production_result(_("No soldier found for this training level!"));1300 ps.set_production_result(_("No soldier found for this training level!"));
1290 return ps.program_end(game, Skipped);1301 return ps.program_end(game, ProgramResult::kSkipped);
1291 }1302 }
1292 if (attribute == TrainingAttribute::kHealth) {1303 if (attribute == TrainingAttribute::kHealth) {
1293 if ((*it)->get_health_level() == level)1304 if ((*it)->get_health_level() == level)
@@ -1354,7 +1365,6 @@
13541365
1355void ProductionProgram::ActTrain::execute(Game& game, ProductionSite& ps) const {1366void ProductionProgram::ActTrain::execute(Game& game, ProductionSite& ps) const {
1356 const SoldierControl* ctrl = ps.soldier_control();1367 const SoldierControl* ctrl = ps.soldier_control();
1357 ;
1358 const std::vector<Soldier*> soldiers = ctrl->present_soldiers();1368 const std::vector<Soldier*> soldiers = ctrl->present_soldiers();
1359 const std::vector<Soldier*>::const_iterator soldiers_end = soldiers.end();1369 const std::vector<Soldier*>::const_iterator soldiers_end = soldiers.end();
1360 std::vector<Soldier*>::const_iterator it = soldiers.begin();1370 std::vector<Soldier*>::const_iterator it = soldiers.begin();
@@ -1365,7 +1375,7 @@
1365 for (;; ++it) {1375 for (;; ++it) {
1366 if (it == soldiers_end) {1376 if (it == soldiers_end) {
1367 ps.set_production_result(_("No soldier found for this training level!"));1377 ps.set_production_result(_("No soldier found for this training level!"));
1368 return ps.program_end(game, Skipped);1378 return ps.program_end(game, ProgramResult::kSkipped);
1369 }1379 }
1370 if (attribute == TrainingAttribute::kHealth) {1380 if (attribute == TrainingAttribute::kHealth) {
1371 if ((*it)->get_health_level() == level)1381 if ((*it)->get_health_level() == level)
@@ -1481,7 +1491,7 @@
1481 }1491 }
14821492
1483 if (available_resource == INVALID_INDEX) {1493 if (available_resource == INVALID_INDEX) {
1484 psite.program_end(game, Failed);1494 psite.program_end(game, ProgramResult::kFailed);
1485 return;1495 return;
1486 }1496 }
14871497
@@ -1534,14 +1544,14 @@
1534 }1544 }
15351545
1536 psite.molog("construct: no object or buildable field\n");1546 psite.molog("construct: no object or buildable field\n");
1537 psite.program_end(game, Failed);1547 psite.program_end(game, ProgramResult::kFailed);
1538}1548}
15391549
1540bool ProductionProgram::ActConstruct::get_building_work(Game& game,1550bool ProductionProgram::ActConstruct::get_building_work(Game& game,
1541 ProductionSite& psite,1551 ProductionSite& psite,
1542 Worker& worker) const {1552 Worker& worker) const {
1543 ProductionSite::State& state = psite.top_state();1553 ProductionSite::State& state = psite.top_state();
1544 if (state.phase >= 1) {1554 if (state.phase > ProgramResult::kNone) {
1545 psite.program_step(game);1555 psite.program_step(game);
1546 return false;1556 return false;
1547 }1557 }
@@ -1554,7 +1564,7 @@
1554 if (construction) {1564 if (construction) {
1555 if (!construction->construct_remaining_buildcost(game, &remaining)) {1565 if (!construction->construct_remaining_buildcost(game, &remaining)) {
1556 psite.molog("construct: immovable %u not under construction", construction->serial());1566 psite.molog("construct: immovable %u not under construction", construction->serial());
1557 psite.program_end(game, Failed);1567 psite.program_end(game, ProgramResult::kFailed);
1558 return false;1568 return false;
1559 }1569 }
1560 } else {1570 } else {
@@ -1571,7 +1581,7 @@
1571 }1581 }
15721582
1573 if (!wq) {1583 if (!wq) {
1574 psite.program_end(game, Failed);1584 psite.program_end(game, ProgramResult::kFailed);
1575 return false;1585 return false;
1576 }1586 }
15771587
@@ -1587,14 +1597,14 @@
1587 worker.top_state().objvar1 = construction;1597 worker.top_state().objvar1 = construction;
1588 worker.top_state().coords = state.coord;1598 worker.top_state().coords = state.coord;
15891599
1590 state.phase = 1;1600 state.phase = ProgramResult::kFailed;
1591 return true;1601 return true;
1592}1602}
15931603
1594void ProductionProgram::ActConstruct::building_work_failed(Game& game,1604void ProductionProgram::ActConstruct::building_work_failed(Game& game,
1595 ProductionSite& psite,1605 ProductionSite& psite,
1596 Worker&) const {1606 Worker&) const {
1597 psite.program_end(game, Failed);1607 psite.program_end(game, ProgramResult::kFailed);
1598}1608}
15991609
1600ProductionProgram::ProductionProgram(const std::string& init_name,1610ProductionProgram::ProductionProgram(const std::string& init_name,
16011611
=== modified file 'src/logic/map_objects/tribes/productionsite.cc'
--- src/logic/map_objects/tribes/productionsite.cc 2019-02-23 11:00:49 +0000
+++ src/logic/map_objects/tribes/productionsite.cc 2019-04-10 16:40:56 +0000
@@ -682,7 +682,7 @@
682682
683 if (!can_start_working()) {683 if (!can_start_working()) {
684 while (!stack_.empty())684 while (!stack_.empty())
685 program_end(game, Failed);685 program_end(game, ProgramResult::kFailed);
686 } else {686 } else {
687 if (stack_.empty()) {687 if (stack_.empty()) {
688 working_positions_[0].worker->update_task_buildingwork(game);688 working_positions_[0].worker->update_task_buildingwork(game);
@@ -691,7 +691,7 @@
691691
692 State& state = top_state();692 State& state = top_state();
693 if (state.program->size() <= state.ip)693 if (state.program->size() <= state.ip)
694 return program_end(game, Completed);694 return program_end(game, ProgramResult::kCompleted);
695695
696 if (anim_ != descr().get_animation(default_anim_)) {696 if (anim_ != descr().get_animation(default_anim_)) {
697 // Restart idle animation, which is the default697 // Restart idle animation, which is the default
@@ -720,7 +720,7 @@
720 // new productions cycle. Otherwise it can lead to consumption720 // new productions cycle. Otherwise it can lead to consumption
721 // of input wares without producing anything721 // of input wares without producing anything
722 if (is_stopped_ && state.ip == 0) {722 if (is_stopped_ && state.ip == 0) {
723 program_end(game, Failed);723 program_end(game, ProgramResult::kFailed);
724 program_timer_ = true;724 program_timer_ = true;
725 program_time_ = schedule_act(game, 20000);725 program_time_ = schedule_act(game, 20000);
726 } else726 } else
@@ -874,7 +874,7 @@
874/**874/**
875 * Advance the program to the next step.875 * Advance the program to the next step.
876 */876 */
877void ProductionSite::program_step(Game& game, uint32_t const delay, uint32_t const phase) {877void ProductionSite::program_step(Game& game, uint32_t const delay, ProgramResult const phase) {
878 State& state = top_state();878 State& state = top_state();
879 ++state.ip;879 ++state.ip;
880 state.phase = phase;880 state.phase = phase;
@@ -890,7 +890,7 @@
890890
891 state.program = descr().get_program(program_name);891 state.program = descr().get_program(program_name);
892 state.ip = 0;892 state.ip = 0;
893 state.phase = 0;893 state.phase = ProgramResult::kNone;
894894
895 stack_.push_back(state);895 stack_.push_back(state);
896896
@@ -918,17 +918,18 @@
918 const std::string& program_name = top_state().program->name();918 const std::string& program_name = top_state().program->name();
919919
920 stack_.pop_back();920 stack_.pop_back();
921 if (!stack_.empty())921 if (!stack_.empty()) {
922 top_state().phase = result;922 top_state().phase = result;
923 }
923924
924 switch (result) {925 switch (result) {
925 case Failed:926 case ProgramResult::kFailed:
926 statistics_.erase(statistics_.begin(), statistics_.begin() + 1);927 statistics_.erase(statistics_.begin(), statistics_.begin() + 1);
927 statistics_.push_back(false);928 statistics_.push_back(false);
928 calc_statistics();929 calc_statistics();
929 crude_percent_ = crude_percent_ * 8 / 10;930 crude_percent_ = crude_percent_ * 8 / 10;
930 break;931 break;
931 case Completed:932 case ProgramResult::kCompleted:
932 skipped_programs_.erase(program_name);933 skipped_programs_.erase(program_name);
933 statistics_.erase(statistics_.begin(), statistics_.begin() + 1);934 statistics_.erase(statistics_.begin(), statistics_.begin() + 1);
934 statistics_.push_back(true);935 statistics_.push_back(true);
@@ -936,11 +937,11 @@
936 crude_percent_ = crude_percent_ * 8 / 10 + 1000000 * 2 / 10;937 crude_percent_ = crude_percent_ * 8 / 10 + 1000000 * 2 / 10;
937 calc_statistics();938 calc_statistics();
938 break;939 break;
939 case Skipped:940 case ProgramResult::kSkipped:
940 skipped_programs_[program_name] = game.get_gametime();941 skipped_programs_[program_name] = game.get_gametime();
941 crude_percent_ = crude_percent_ * 98 / 100;942 crude_percent_ = crude_percent_ * 98 / 100;
942 break;943 break;
943 case None:944 case ProgramResult::kNone:
944 skipped_programs_.erase(program_name);945 skipped_programs_.erase(program_name);
945 break;946 break;
946 }947 }
947948
=== modified file 'src/logic/map_objects/tribes/productionsite.h'
--- src/logic/map_objects/tribes/productionsite.h 2019-02-23 11:00:49 +0000
+++ src/logic/map_objects/tribes/productionsite.h 2019-04-10 16:40:56 +0000
@@ -243,7 +243,7 @@
243 struct State {243 struct State {
244 const ProductionProgram* program; ///< currently running program244 const ProductionProgram* program; ///< currently running program
245 size_t ip; ///< instruction pointer245 size_t ip; ///< instruction pointer
246 uint32_t phase; ///< micro-step index (instruction dependent)246 ProgramResult phase; ///< micro-step index (instruction dependent)
247 uint32_t flags; ///< pfXXX flags247 uint32_t flags; ///< pfXXX flags
248248
249 /**249 /**
@@ -254,7 +254,7 @@
254 Coords coord;254 Coords coord;
255 /*@}*/255 /*@}*/
256256
257 State() : program(nullptr), ip(0), phase(0), flags(0), coord(Coords::null()) {257 State() : program(nullptr), ip(0), phase(ProgramResult::kNone), flags(0), coord(Coords::null()) {
258 }258 }
259 };259 };
260260
@@ -282,7 +282,7 @@
282 /// how long it should take to mine, given the particular circumstances,282 /// how long it should take to mine, given the particular circumstances,
283 /// and pass the result to the following animation command, to set the283 /// and pass the result to the following animation command, to set the
284 /// duration.284 /// duration.
285 void program_step(Game&, uint32_t delay = 10, uint32_t phase = 0);285 void program_step(Game&, uint32_t delay = 10, ProgramResult phase = ProgramResult::kNone);
286286
287 void program_start(Game&, const std::string& program_name);287 void program_start(Game&, const std::string& program_name);
288 virtual void program_end(Game&, ProgramResult);288 virtual void program_end(Game&, ProgramResult);
289289
=== modified file 'src/logic/map_objects/tribes/program_result.h'
--- src/logic/map_objects/tribes/program_result.h 2019-02-23 11:00:49 +0000
+++ src/logic/map_objects/tribes/program_result.h 2019-04-10 16:40:56 +0000
@@ -20,10 +20,26 @@
20#ifndef WL_LOGIC_MAP_OBJECTS_TRIBES_PROGRAM_RESULT_H20#ifndef WL_LOGIC_MAP_OBJECTS_TRIBES_PROGRAM_RESULT_H
21#define WL_LOGIC_MAP_OBJECTS_TRIBES_PROGRAM_RESULT_H21#define WL_LOGIC_MAP_OBJECTS_TRIBES_PROGRAM_RESULT_H
2222
23#include "base/macros.h"
24
23namespace Widelands {25namespace Widelands {
24// Don't change this values, they are used as hardcoded array indices26// Don't change these values, they are used as hardcoded array indices
25enum ProgramResult { None = 0, Failed = 1, Completed = 2, Skipped = 3 };27enum class ProgramResult { kNone = 0, kFailed = 1, kCompleted = 2, kSkipped = 3 };
26enum ProgramResultHandlingMethod { Fail, Complete, Skip, Continue, Repeat };28inline int program_result_index(ProgramResult result) {
29 switch (result) {
30 case ProgramResult::kFailed:
31 return 0;
32 case ProgramResult::kCompleted:
33 return 1;
34 case ProgramResult::kSkipped:
35 return 2;
36 case ProgramResult::kNone:
37 NEVER_HERE();
38 }
39 return 0;
40}
41
42enum class ProgramResultHandlingMethod { kFail, kComplete, kSkip, kContinue, kRepeat };
27} // namespace Widelands43} // namespace Widelands
2844
29#endif // end of include guard: WL_LOGIC_MAP_OBJECTS_TRIBES_PROGRAM_RESULT_H45#endif // end of include guard: WL_LOGIC_MAP_OBJECTS_TRIBES_PROGRAM_RESULT_H
3046
=== modified file 'src/logic/map_objects/tribes/trainingsite.cc'
--- src/logic/map_objects/tribes/trainingsite.cc 2019-02-23 11:00:49 +0000
+++ src/logic/map_objects/tribes/trainingsite.cc 2019-04-10 16:40:56 +0000
@@ -270,7 +270,7 @@
270 soldier_request_(nullptr),270 soldier_request_(nullptr),
271 capacity_(descr().get_max_number_of_soldiers()),271 capacity_(descr().get_max_number_of_soldiers()),
272 build_heroes_(false),272 build_heroes_(false),
273 result_(Failed) {273 result_(ProgramResult::kFailed) {
274 set_soldier_control(&soldier_control_);274 set_soldier_control(&soldier_control_);
275275
276 // Initialize this in the constructor so that loading code may276 // Initialize this in the constructor so that loading code may
@@ -543,7 +543,7 @@
543 bool leftover_soldiers_check = true;543 bool leftover_soldiers_check = true;
544544
545 if (current_upgrade_) {545 if (current_upgrade_) {
546 if (result_ == Completed) {546 if (result_ == ProgramResult::kCompleted) {
547 drop_unupgradable_soldiers(game);547 drop_unupgradable_soldiers(game);
548 leftover_soldiers_check = false;548 leftover_soldiers_check = false;
549 current_upgrade_->lastsuccess = true;549 current_upgrade_->lastsuccess = true;
550550
=== modified file 'src/logic/map_objects/tribes/tribe_descr.cc'
--- src/logic/map_objects/tribes/tribe_descr.cc 2019-03-24 12:06:43 +0000
+++ src/logic/map_objects/tribes/tribe_descr.cc 2019-04-10 16:40:56 +0000
@@ -174,7 +174,7 @@
174 throw GameDataError("Tribe has no indicators for resource %s.", resource.c_str());174 throw GameDataError("Tribe has no indicators for resource %s.", resource.c_str());
175 }175 }
176 resource_indicators_[resource] = resis;176 resource_indicators_[resource] = resis;
177 };177 }
178178
179 ship_names_ = table.get_table("ship_names")->array_entries<std::string>();179 ship_names_ = table.get_table("ship_names")->array_entries<std::string>();
180180
181181
=== modified file 'src/logic/map_objects/tribes/worker.cc'
--- src/logic/map_objects/tribes/worker.cc 2019-03-17 10:30:24 +0000
+++ src/logic/map_objects/tribes/worker.cc 2019-04-10 16:40:56 +0000
@@ -1060,34 +1060,34 @@
1060 Bob::log_general_info(egbase);1060 Bob::log_general_info(egbase);
10611061
1062 if (upcast(PlayerImmovable, loc, location_.get(egbase))) {1062 if (upcast(PlayerImmovable, loc, location_.get(egbase))) {
1063 FORMAT_WARNINGS_OFF;1063 FORMAT_WARNINGS_OFF
1064 molog("* Owner: (%p)\n", &loc->owner());1064 molog("* Owner: (%p)\n", &loc->owner());
1065 FORMAT_WARNINGS_ON;1065 FORMAT_WARNINGS_ON
1066 molog("** Owner (plrnr): %i\n", loc->owner().player_number());1066 molog("** Owner (plrnr): %i\n", loc->owner().player_number());
1067 FORMAT_WARNINGS_OFF;1067 FORMAT_WARNINGS_OFF
1068 molog("* Economy: %p\n", loc->get_economy());1068 molog("* Economy: %p\n", loc->get_economy());
1069 FORMAT_WARNINGS_ON;1069 FORMAT_WARNINGS_ON
1070 }1070 }
10711071
1072 PlayerImmovable* imm = location_.get(egbase);1072 PlayerImmovable* imm = location_.get(egbase);
1073 molog("location: %u\n", imm ? imm->serial() : 0);1073 molog("location: %u\n", imm ? imm->serial() : 0);
1074 FORMAT_WARNINGS_OFF;1074 FORMAT_WARNINGS_OFF
1075 molog("Economy: %p\n", economy_);1075 molog("Economy: %p\n", economy_);
1076 molog("transfer: %p\n", transfer_);1076 molog("transfer: %p\n", transfer_);
1077 FORMAT_WARNINGS_ON;1077 FORMAT_WARNINGS_ON
10781078
1079 if (upcast(WareInstance, ware, carried_ware_.get(egbase))) {1079 if (upcast(WareInstance, ware, carried_ware_.get(egbase))) {
1080 molog("* carried_ware->get_ware() (id): %i\n", ware->descr_index());1080 molog("* carried_ware->get_ware() (id): %i\n", ware->descr_index());
1081 FORMAT_WARNINGS_OFF;1081 FORMAT_WARNINGS_OFF
1082 molog("* carried_ware->get_economy() (): %p\n", ware->get_economy());1082 molog("* carried_ware->get_economy() (): %p\n", ware->get_economy());
1083 FORMAT_WARNINGS_ON;1083 FORMAT_WARNINGS_ON
1084 }1084 }
10851085
1086 molog("current_exp: %i / %i\n", current_exp_, descr().get_needed_experience());1086 molog("current_exp: %i / %i\n", current_exp_, descr().get_needed_experience());
10871087
1088 FORMAT_WARNINGS_OFF;1088 FORMAT_WARNINGS_OFF
1089 molog("supply: %p\n", supply_);1089 molog("supply: %p\n", supply_);
1090 FORMAT_WARNINGS_ON;1090 FORMAT_WARNINGS_ON
1091}1091}
10921092
1093/**1093/**
10941094
=== modified file 'src/logic/map_objects/world/terrain_description.h'
--- src/logic/map_objects/world/terrain_description.h 2019-02-23 11:00:49 +0000
+++ src/logic/map_objects/world/terrain_description.h 2019-04-10 16:40:56 +0000
@@ -43,7 +43,7 @@
4343
44class TerrainDescription {44class TerrainDescription {
45public:45public:
46 enum Is {46 enum class Is {
47 kArable = 0,47 kArable = 0,
48 kWalkable = 1,48 kWalkable = 1,
49 kWater = 2,49 kWater = 2,
@@ -149,6 +149,14 @@
149 DISALLOW_COPY_AND_ASSIGN(TerrainDescription);149 DISALLOW_COPY_AND_ASSIGN(TerrainDescription);
150};150};
151151
152inline TerrainDescription::Is operator|(TerrainDescription::Is left, TerrainDescription::Is right) {
153 return TerrainDescription::Is(static_cast<int>(left) | static_cast<int>(right));
154}
155inline int operator&(TerrainDescription::Is left, TerrainDescription::Is right) {
156 return static_cast<int>(left) & static_cast<int>(right);
157}
158
159
152} // namespace Widelands160} // namespace Widelands
153161
154#endif // end of include guard: WL_LOGIC_MAP_OBJECTS_WORLD_TERRAIN_DESCRIPTION_H162#endif // end of include guard: WL_LOGIC_MAP_OBJECTS_WORLD_TERRAIN_DESCRIPTION_H
155163
=== modified file 'src/logic/mapdifferenceregion.h'
--- src/logic/mapdifferenceregion.h 2019-02-23 11:00:49 +0000
+++ src/logic/mapdifferenceregion.h 2019-04-10 16:40:56 +0000
@@ -48,12 +48,12 @@
48 map.neighbour_function(area_, &area_); \48 map.neighbour_function(area_, &area_); \
49 break;49 break;
5050
51 DIRECTION_CASE(WALK_NW, get_tln);51 DIRECTION_CASE(WALK_NW, get_tln)
52 DIRECTION_CASE(WALK_NE, get_trn);52 DIRECTION_CASE(WALK_NE, get_trn)
53 DIRECTION_CASE(WALK_E, get_rn);53 DIRECTION_CASE(WALK_E, get_rn)
54 DIRECTION_CASE(WALK_SE, get_brn);54 DIRECTION_CASE(WALK_SE, get_brn)
55 DIRECTION_CASE(WALK_SW, get_bln);55 DIRECTION_CASE(WALK_SW, get_bln)
56 DIRECTION_CASE(WALK_W, get_ln);56 DIRECTION_CASE(WALK_W, get_ln)
57#undef DIRECTION_CASE57#undef DIRECTION_CASE
58 }58 }
59 --direction;59 --direction;
6060
=== modified file 'src/logic/maphollowregion.cc'
--- src/logic/maphollowregion.cc 2019-02-23 11:00:49 +0000
+++ src/logic/maphollowregion.cc 2019-04-10 16:40:56 +0000
@@ -24,7 +24,7 @@
24template <>24template <>
25MapHollowRegion<Area<>>::MapHollowRegion(const Map& map, const HollowArea<Area<>>& hollow_area)25MapHollowRegion<Area<>>::MapHollowRegion(const Map& map, const HollowArea<Area<>>& hollow_area)
26 : hollow_area_(hollow_area),26 : hollow_area_(hollow_area),
27 phase_(Top),27 phase_(Phase::kTop),
28 delta_radius_(hollow_area.radius - hollow_area.hole_radius),28 delta_radius_(hollow_area.radius - hollow_area.hole_radius),
29 row_(0),29 row_(0),
30 rowwidth_(hollow_area.radius + 1),30 rowwidth_(hollow_area.radius + 1),
@@ -37,12 +37,13 @@
37}37}
3838
39template <> bool MapHollowRegion<Area<>>::advance(const Map& map) {39template <> bool MapHollowRegion<Area<>>::advance(const Map& map) {
40 if (phase_ == None)40 if (phase_ == Phase::kNone) {
41 return false;41 return false;
42 }
42 ++rowpos_;43 ++rowpos_;
43 if (rowpos_ < rowwidth_) {44 if (rowpos_ < rowwidth_) {
44 map.get_rn(hollow_area_, &hollow_area_);45 map.get_rn(hollow_area_, &hollow_area_);
45 if ((phase_ & (Upper | Lower)) && rowpos_ == delta_radius_) {46 if ((phase_ & (Phase::kUpper | Phase::kLower)) && rowpos_ == delta_radius_) {
46 // Jump over the hole.47 // Jump over the hole.
47 const uint32_t holewidth = rowwidth_ - 2 * delta_radius_;48 const uint32_t holewidth = rowwidth_ - 2 * delta_radius_;
48 for (uint32_t i = 0; i < holewidth; ++i)49 for (uint32_t i = 0; i < holewidth; ++i)
@@ -51,27 +52,29 @@
51 }52 }
52 } else {53 } else {
53 ++row_;54 ++row_;
54 if (phase_ == Top && row_ == delta_radius_)55 if (phase_ == Phase::kTop && row_ == delta_radius_) {
55 phase_ = Upper;56 phase_ = Phase::kUpper;
57 }
5658
57 // If we completed the widest, center line, switch into lower mode59 // If we completed the widest, center line, switch into lower mode
58 // There are radius_+1 lines in the upper "half", because the upper60 // There are radius_+1 lines in the upper "half", because the upper
59 // half includes the center line.61 // half includes the center line.
60 else if (phase_ == Upper && row_ > hollow_area_.radius) {62 else if (phase_ == Phase::kUpper && row_ > hollow_area_.radius) {
61 row_ = 1;63 row_ = 1;
62 phase_ = Lower;64 phase_ = Phase::kLower;
63 }65 }
6466
65 if (phase_ & (Top | Upper)) {67 if (phase_ & (Phase::kTop | Phase::kUpper)) {
66 map.get_bln(left_, &hollow_area_);68 map.get_bln(left_, &hollow_area_);
67 ++rowwidth_;69 ++rowwidth_;
68 } else {70 } else {
6971
70 if (row_ > hollow_area_.radius) {72 if (row_ > hollow_area_.radius) {
71 phase_ = None;73 phase_ = Phase::kNone;
72 return true; // early out74 return true; // early out
73 } else if (phase_ == Lower && row_ > hollow_area_.hole_radius)75 } else if (phase_ == Phase::kLower && row_ > hollow_area_.hole_radius) {
74 phase_ = Bottom;76 phase_ = Phase::kBottom;
77 }
7578
76 map.get_brn(left_, &hollow_area_);79 map.get_brn(left_, &hollow_area_);
77 --rowwidth_;80 --rowwidth_;
7881
=== modified file 'src/logic/maphollowregion.h'
--- src/logic/maphollowregion.h 2019-02-23 11:00:49 +0000
+++ src/logic/maphollowregion.h 2019-04-10 16:40:56 +0000
@@ -55,15 +55,15 @@
55 */55 */
56 bool advance(const Map&);56 bool advance(const Map&);
5757
58 enum class Phase {
59 kNone = 0, // not initialized or completed
60 kTop = 1, // above the hole
61 kUpper = 2, // upper half
62 kLower = 4, // lower half
63 kBottom = 8, // below the hole
64 };
65
58private:66private:
59 enum Phase {
60 None = 0, // not initialized or completed
61 Top = 1, // above the hole
62 Upper = 2, // upper half
63 Lower = 4, // lower half
64 Bottom = 8, // below the hole
65 };
66
67 HollowArea<AreaType> hollow_area_;67 HollowArea<AreaType> hollow_area_;
68 Phase phase_;68 Phase phase_;
69 const uint32_t delta_radius_;69 const uint32_t delta_radius_;
@@ -77,6 +77,14 @@
77template <>77template <>
78MapHollowRegion<Area<>>::MapHollowRegion(const Map& map, const HollowArea<Area<>>& hollow_area);78MapHollowRegion<Area<>>::MapHollowRegion(const Map& map, const HollowArea<Area<>>& hollow_area);
79template <> bool MapHollowRegion<Area<>>::advance(const Map& map);79template <> bool MapHollowRegion<Area<>>::advance(const Map& map);
80
81// A bunch of operators that turn MapHollowRegion<Area<>>::Phase into a bitwise combinable class.
82inline MapHollowRegion<Area<>>::Phase operator|(MapHollowRegion<Area<>>::Phase left, MapHollowRegion<Area<>>::Phase right) {
83 return MapHollowRegion<Area<>>::Phase(static_cast<int>(left) | static_cast<int>(right));
84}
85inline int operator&(MapHollowRegion<Area<>>::Phase left, MapHollowRegion<Area<>>::Phase right) {
86 return static_cast<int>(left) & static_cast<int>(right);
87}
80} // namespace Widelands88} // namespace Widelands
8189
82#endif // end of include guard: WL_LOGIC_MAPHOLLOWREGION_H90#endif // end of include guard: WL_LOGIC_MAPHOLLOWREGION_H
8391
=== modified file 'src/logic/maptriangleregion.cc'
--- src/logic/maptriangleregion.cc 2019-02-23 11:00:49 +0000
+++ src/logic/maptriangleregion.cc 2019-04-10 16:40:56 +0000
@@ -36,18 +36,18 @@
36 remaining_rows_in_lower_phase_ = (area.radius - 1) / 2;36 remaining_rows_in_lower_phase_ = (area.radius - 1) / 2;
37 if (radius_is_odd_) {37 if (radius_is_odd_) {
38 map.get_trn(area.node, &area.node);38 map.get_trn(area.node, &area.node);
39 phase_ = Top;39 phase_ = Phase::kTop;
40 row_length_ = area.radius + 2;40 row_length_ = area.radius + 2;
41 remaining_in_row_ = radius_plus_1 / 2;41 remaining_in_row_ = radius_plus_1 / 2;
42 area.t = TriangleIndex::D;42 area.t = TriangleIndex::D;
43 } else {43 } else {
44 phase_ = Upper;44 phase_ = Phase::kUpper;
45 remaining_in_row_ = row_length_ = radius_plus_1;45 remaining_in_row_ = row_length_ = radius_plus_1;
46 area.t = TriangleIndex::R;46 area.t = TriangleIndex::R;
47 }47 }
48 } else {48 } else {
49 assert(area.radius == 0);49 assert(area.radius == 0);
50 phase_ = Bottom;50 phase_ = Phase::kBottom;
51 remaining_in_row_ = 0;51 remaining_in_row_ = 0;
52 area.t = TriangleIndex::R;52 area.t = TriangleIndex::R;
53 }53 }
@@ -57,12 +57,12 @@
57 if (radius_is_odd_) {57 if (radius_is_odd_) {
58 map.get_ln(area.node, &area.node);58 map.get_ln(area.node, &area.node);
59 left_ = area.node;59 left_ = area.node;
60 phase_ = Upper;60 phase_ = Phase::kUpper;
61 remaining_in_row_ = row_length_ = area.radius + 2;61 remaining_in_row_ = row_length_ = area.radius + 2;
62 area.t = TriangleIndex::R;62 area.t = TriangleIndex::R;
63 } else {63 } else {
64 map.get_bln(area.node, &left_);64 map.get_bln(area.node, &left_);
65 phase_ = Top;65 phase_ = Phase::kTop;
66 row_length_ = area.radius + 3;66 row_length_ = area.radius + 3;
67 remaining_in_row_ = half_radius_rounded_down + (0 < area.radius);67 remaining_in_row_ = half_radius_rounded_down + (0 < area.radius);
68 area.t = TriangleIndex::D;68 area.t = TriangleIndex::D;
@@ -77,17 +77,17 @@
77 return false;77 return false;
78 --remaining_in_row_;78 --remaining_in_row_;
79 switch (phase_) {79 switch (phase_) {
80 case Top:80 case Phase::kTop:
81 if (remaining_in_row_)81 if (remaining_in_row_)
82 map.get_rn(location_.node, &location_.node);82 map.get_rn(location_.node, &location_.node);
83 else if (remaining_rows_in_upper_phase_) {83 else if (remaining_rows_in_upper_phase_) {
84 phase_ = Upper;84 phase_ = Phase::kUpper;
85 remaining_in_row_ = row_length_;85 remaining_in_row_ = row_length_;
86 assert(remaining_in_row_);86 assert(remaining_in_row_);
87 location_ = TCoords<>(left_, location_.t);87 location_ = TCoords<>(left_, location_.t);
88 }88 }
89 break;89 break;
90 case Upper:90 case Phase::kUpper:
91 if (remaining_in_row_) {91 if (remaining_in_row_) {
92 if (location_.t == TriangleIndex::D)92 if (location_.t == TriangleIndex::D)
93 location_.t = TriangleIndex::R;93 location_.t = TriangleIndex::R;
@@ -99,11 +99,11 @@
99 left_ = map.bl_n(left_);99 left_ = map.bl_n(left_);
100 } else {100 } else {
101 if (remaining_rows_in_lower_phase_) {101 if (remaining_rows_in_lower_phase_) {
102 phase_ = Lower;102 phase_ = Phase::kLower;
103 assert(row_length_ >= 2);103 assert(row_length_ >= 2);
104 row_length_ -= 2;104 row_length_ -= 2;
105 } else if (location_.t == TriangleIndex::R) {105 } else if (location_.t == TriangleIndex::R) {
106 phase_ = Bottom;106 phase_ = Phase::kBottom;
107 row_length_ /= 2;107 row_length_ /= 2;
108 } else108 } else
109 return false;109 return false;
@@ -113,7 +113,7 @@
113 location_ = TCoords<>(left_, location_.t);113 location_ = TCoords<>(left_, location_.t);
114 }114 }
115 break;115 break;
116 case Lower:116 case Phase::kLower:
117 if (remaining_in_row_) {117 if (remaining_in_row_) {
118 if (location_.t == TriangleIndex::D)118 if (location_.t == TriangleIndex::D)
119 location_.t = TriangleIndex::R;119 location_.t = TriangleIndex::R;
@@ -125,14 +125,14 @@
125 remaining_in_row_ = row_length_ -= 2;125 remaining_in_row_ = row_length_ -= 2;
126 left_ = map.br_n(left_);126 left_ = map.br_n(left_);
127 } else if (location_.t == TriangleIndex::R) {127 } else if (location_.t == TriangleIndex::R) {
128 phase_ = Bottom;128 phase_ = Phase::kBottom;
129 remaining_in_row_ = row_length_ / 2;129 remaining_in_row_ = row_length_ / 2;
130 left_ = map.br_n(left_);130 left_ = map.br_n(left_);
131 }131 }
132 location_ = TCoords<>(left_, location_.t);132 location_ = TCoords<>(left_, location_.t);
133 }133 }
134 break;134 break;
135 case Bottom:135 case Phase::kBottom:
136 if (remaining_in_row_)136 if (remaining_in_row_)
137 map.get_rn(location_.node, &location_.node);137 map.get_rn(location_.node, &location_.node);
138 break;138 break;
@@ -156,17 +156,17 @@
156 remaining_rows_in_lower_phase_ = (area.radius - 1) / 2;156 remaining_rows_in_lower_phase_ = (area.radius - 1) / 2;
157 if (radius_is_odd_) {157 if (radius_is_odd_) {
158 map.get_trn(area.node, &area.node);158 map.get_trn(area.node, &area.node);
159 phase_ = Top;159 phase_ = Phase::kTop;
160 row_length_ = area.radius + 2;160 row_length_ = area.radius + 2;
161 remaining_in_row_ = radius_plus_1 / 2;161 remaining_in_row_ = radius_plus_1 / 2;
162 area.t = TriangleIndex::D;162 area.t = TriangleIndex::D;
163 } else {163 } else {
164 phase_ = Upper;164 phase_ = Phase::kUpper;
165 remaining_in_row_ = row_length_ = radius_plus_1;165 remaining_in_row_ = row_length_ = radius_plus_1;
166 area.t = TriangleIndex::R;166 area.t = TriangleIndex::R;
167 }167 }
168 } else {168 } else {
169 phase_ = Bottom;169 phase_ = Phase::kBottom;
170 remaining_in_row_ = 0;170 remaining_in_row_ = 0;
171 area.t = TriangleIndex::R;171 area.t = TriangleIndex::R;
172 }172 }
@@ -176,12 +176,12 @@
176 if (radius_is_odd_) {176 if (radius_is_odd_) {
177 map.get_ln(area.node, &area.node);177 map.get_ln(area.node, &area.node);
178 left_ = area.node;178 left_ = area.node;
179 phase_ = Upper;179 phase_ = Phase::kUpper;
180 remaining_in_row_ = row_length_ = area.radius + 2;180 remaining_in_row_ = row_length_ = area.radius + 2;
181 area.t = TriangleIndex::R;181 area.t = TriangleIndex::R;
182 } else {182 } else {
183 map.get_bln(area.node, &left_);183 map.get_bln(area.node, &left_);
184 phase_ = Top;184 phase_ = Phase::kTop;
185 row_length_ = area.radius + 3;185 row_length_ = area.radius + 3;
186 remaining_in_row_ = half_radius_rounded_down + (0 < area.radius);186 remaining_in_row_ = half_radius_rounded_down + (0 < area.radius);
187 area.t = TriangleIndex::D;187 area.t = TriangleIndex::D;
@@ -197,17 +197,17 @@
197 return false;197 return false;
198 --remaining_in_row_;198 --remaining_in_row_;
199 switch (phase_) {199 switch (phase_) {
200 case Top:200 case Phase::kTop:
201 if (remaining_in_row_)201 if (remaining_in_row_)
202 map.get_rn(location_.node, &location_.node);202 map.get_rn(location_.node, &location_.node);
203 else if (remaining_rows_in_upper_phase_) {203 else if (remaining_rows_in_upper_phase_) {
204 phase_ = Upper;204 phase_ = Phase::kUpper;
205 remaining_in_row_ = row_length_;205 remaining_in_row_ = row_length_;
206 assert(remaining_in_row_);206 assert(remaining_in_row_);
207 location_ = TCoords<FCoords>(left_, location_.t);207 location_ = TCoords<FCoords>(left_, location_.t);
208 }208 }
209 break;209 break;
210 case Upper:210 case Phase::kUpper:
211 if (remaining_in_row_) {211 if (remaining_in_row_) {
212 if (location_.t == TriangleIndex::D)212 if (location_.t == TriangleIndex::D)
213 location_.t = TriangleIndex::R;213 location_.t = TriangleIndex::R;
@@ -219,11 +219,11 @@
219 left_ = map.bl_n(left_);219 left_ = map.bl_n(left_);
220 } else {220 } else {
221 if (remaining_rows_in_lower_phase_) {221 if (remaining_rows_in_lower_phase_) {
222 phase_ = Lower;222 phase_ = Phase::kLower;
223 assert(row_length_ >= 2);223 assert(row_length_ >= 2);
224 row_length_ -= 2;224 row_length_ -= 2;
225 } else if (location_.t == TriangleIndex::R) {225 } else if (location_.t == TriangleIndex::R) {
226 phase_ = Bottom;226 phase_ = Phase::kBottom;
227 row_length_ /= 2;227 row_length_ /= 2;
228 } else228 } else
229 return false;229 return false;
@@ -233,7 +233,7 @@
233 location_ = TCoords<FCoords>(left_, location_.t);233 location_ = TCoords<FCoords>(left_, location_.t);
234 }234 }
235 break;235 break;
236 case Lower:236 case Phase::kLower:
237 if (remaining_in_row_) {237 if (remaining_in_row_) {
238 if (location_.t == TriangleIndex::D)238 if (location_.t == TriangleIndex::D)
239 location_.t = TriangleIndex::R;239 location_.t = TriangleIndex::R;
@@ -245,14 +245,14 @@
245 remaining_in_row_ = row_length_ -= 2;245 remaining_in_row_ = row_length_ -= 2;
246 left_ = map.br_n(left_);246 left_ = map.br_n(left_);
247 } else if (location_.t == TriangleIndex::R) {247 } else if (location_.t == TriangleIndex::R) {
248 phase_ = Bottom;248 phase_ = Phase::kBottom;
249 remaining_in_row_ = row_length_ / 2;249 remaining_in_row_ = row_length_ / 2;
250 left_ = map.br_n(left_);250 left_ = map.br_n(left_);
251 }251 }
252 location_ = TCoords<FCoords>(left_, location_.t);252 location_ = TCoords<FCoords>(left_, location_.t);
253 }253 }
254 break;254 break;
255 case Bottom:255 case Phase::kBottom:
256 if (remaining_in_row_)256 if (remaining_in_row_)
257 map.get_rn(location_.node, &location_.node);257 map.get_rn(location_.node, &location_.node);
258 break;258 break;
259259
=== modified file 'src/logic/maptriangleregion.h'
--- src/logic/maptriangleregion.h 2019-02-23 11:00:49 +0000
+++ src/logic/maptriangleregion.h 2019-04-10 16:40:56 +0000
@@ -114,7 +114,7 @@
114114
115private:115private:
116 const bool radius_is_odd_ = false;116 const bool radius_is_odd_ = false;
117 enum { Top, Upper, Lower, Bottom } phase_ = Top;117 enum class Phase { kTop, kUpper, kLower, kBottom } phase_ = Phase::kTop;
118 uint16_t remaining_rows_in_upper_phase_ = 0U;118 uint16_t remaining_rows_in_upper_phase_ = 0U;
119 uint16_t remaining_rows_in_lower_phase_ = 0U;119 uint16_t remaining_rows_in_lower_phase_ = 0U;
120 uint16_t row_length_, remaining_in_row_ = 0U;120 uint16_t row_length_, remaining_in_row_ = 0U;
121121
=== modified file 'src/logic/player.cc'
--- src/logic/player.cc 2019-03-09 08:58:52 +0000
+++ src/logic/player.cc 2019-04-10 16:40:56 +0000
@@ -329,8 +329,8 @@
329 }329 }
330330
331 if (g_options.pull_section("global").get_bool("sound_at_message", true)) {331 if (g_options.pull_section("global").get_bool("sound_at_message", true)) {
332 MAYBE_PLAY(Message::Type::kEconomySiteOccupied, "military/site_occupied");332 MAYBE_PLAY(Message::Type::kEconomySiteOccupied, "military/site_occupied")
333 MAYBE_PLAY(Message::Type::kWarfareUnderAttack, "military/under_attack");333 MAYBE_PLAY(Message::Type::kWarfareUnderAttack, "military/under_attack")
334 Notifications::publish(NoteSound("message", 200, PRIO_ALWAYS_PLAY));334 Notifications::publish(NoteSound("message", 200, PRIO_ALWAYS_PLAY));
335 }335 }
336}336}
337337
=== modified file 'src/map_io/map_buildingdata_packet.cc'
--- src/map_io/map_buildingdata_packet.cc 2019-02-23 11:00:49 +0000
+++ src/map_io/map_buildingdata_packet.cc 2019-04-10 16:40:56 +0000
@@ -666,7 +666,7 @@
666666
667 productionsite.stack_[i].program = productionsite.descr().get_program(program_name);667 productionsite.stack_[i].program = productionsite.descr().get_program(program_name);
668 productionsite.stack_[i].ip = fr.signed_32();668 productionsite.stack_[i].ip = fr.signed_32();
669 productionsite.stack_[i].phase = fr.signed_32();669 productionsite.stack_[i].phase = static_cast<ProgramResult>(fr.signed_32());
670 productionsite.stack_[i].flags = fr.unsigned_32();670 productionsite.stack_[i].flags = fr.unsigned_32();
671671
672 uint32_t serial = fr.unsigned_32();672 uint32_t serial = fr.unsigned_32();
@@ -1135,7 +1135,8 @@
1135 for (uint16_t i = 0; i < program_size; ++i) {1135 for (uint16_t i = 0; i < program_size; ++i) {
1136 fw.string(productionsite.stack_[i].program->name());1136 fw.string(productionsite.stack_[i].program->name());
1137 fw.signed_32(productionsite.stack_[i].ip);1137 fw.signed_32(productionsite.stack_[i].ip);
1138 fw.signed_32(productionsite.stack_[i].phase);1138 // TODO(GunChleoc): If we ever change this packet, we can have an uint8 here.
1139 fw.signed_32(static_cast<int>(productionsite.stack_[i].phase));
1139 fw.unsigned_32(productionsite.stack_[i].flags);1140 fw.unsigned_32(productionsite.stack_[i].flags);
1140 fw.unsigned_32(mos.get_object_file_index_or_zero(productionsite.stack_[i].objvar.get(game)));1141 fw.unsigned_32(mos.get_object_file_index_or_zero(productionsite.stack_[i].objvar.get(game)));
1141 write_coords_32(&fw, productionsite.stack_[i].coord);1142 write_coords_32(&fw, productionsite.stack_[i].coord);
11421143
=== modified file 'src/map_io/map_players_view_packet.cc'
--- src/map_io/map_players_view_packet.cc 2019-02-23 11:00:49 +0000
+++ src/map_io/map_players_view_packet.cc 2019-04-10 16:40:56 +0000
@@ -434,47 +434,47 @@
434 OPEN_INPUT_FILE_NEW_VERSION(FileRead, node_immovable_kinds_file,434 OPEN_INPUT_FILE_NEW_VERSION(FileRead, node_immovable_kinds_file,
435 node_immovable_kinds_filename, node_immovable_kinds_file_version,435 node_immovable_kinds_filename, node_immovable_kinds_file_version,
436 NODE_IMMOVABLE_KINDS_FILENAME_TEMPLATE,436 NODE_IMMOVABLE_KINDS_FILENAME_TEMPLATE,
437 kCurrentPacketVersionImmovableKinds);437 kCurrentPacketVersionImmovableKinds)
438438
439 OPEN_INPUT_FILE_NEW_VERSION(FileRead, node_immovables_file, node_immovables_filename,439 OPEN_INPUT_FILE_NEW_VERSION(FileRead, node_immovables_file, node_immovables_filename,
440 node_immovables_file_version, NODE_IMMOVABLES_FILENAME_TEMPLATE,440 node_immovables_file_version, NODE_IMMOVABLES_FILENAME_TEMPLATE,
441 kCurrentPacketVersionImmovables);441 kCurrentPacketVersionImmovables)
442442
443 OPEN_INPUT_FILE_NEW_VERSION(FileRead, roads_file, roads_filename, road_file_version,443 OPEN_INPUT_FILE_NEW_VERSION(FileRead, roads_file, roads_filename, road_file_version,
444 ROADS_FILENAME_TEMPLATE, kCurrentPacketVersionRoads);444 ROADS_FILENAME_TEMPLATE, kCurrentPacketVersionRoads)
445445
446 OPEN_INPUT_FILE_NEW_VERSION(FileRead, terrains_file, terrains_filename, terrains_file_version,446 OPEN_INPUT_FILE_NEW_VERSION(FileRead, terrains_file, terrains_filename, terrains_file_version,
447 TERRAINS_FILENAME_TEMPLATE, kCurrentPacketVersionTerrains);447 TERRAINS_FILENAME_TEMPLATE, kCurrentPacketVersionTerrains)
448448
449 OPEN_INPUT_FILE_NEW_VERSION(449 OPEN_INPUT_FILE_NEW_VERSION(
450 FileRead, triangle_immovable_kinds_file, triangle_immovable_kinds_filename,450 FileRead, triangle_immovable_kinds_file, triangle_immovable_kinds_filename,
451 triangle_immovable_kinds_file_version, TRIANGLE_IMMOVABLE_KINDS_FILENAME_TEMPLATE,451 triangle_immovable_kinds_file_version, TRIANGLE_IMMOVABLE_KINDS_FILENAME_TEMPLATE,
452 kCurrentPacketVersionImmovableKinds);452 kCurrentPacketVersionImmovableKinds)
453453
454 OPEN_INPUT_FILE_NEW_VERSION(FileRead, triangle_immovables_file, triangle_immovables_filename,454 OPEN_INPUT_FILE_NEW_VERSION(FileRead, triangle_immovables_file, triangle_immovables_filename,
455 triangle_immovables_file_version,455 triangle_immovables_file_version,
456 TRIANGLE_IMMOVABLES_FILENAME_TEMPLATE,456 TRIANGLE_IMMOVABLES_FILENAME_TEMPLATE,
457 kCurrentPacketVersionImmovables);457 kCurrentPacketVersionImmovables)
458458
459 OPEN_INPUT_FILE(FileRead, owners_file, owners_filename, OWNERS_FILENAME_TEMPLATE,459 OPEN_INPUT_FILE(FileRead, owners_file, owners_filename, OWNERS_FILENAME_TEMPLATE,
460 kCurrentPacketVersionOwners);460 kCurrentPacketVersionOwners)
461461
462 OPEN_INPUT_FILE_NEW_VERSION(FileRead, surveys_file, surveys_filename, surveys_file_version,462 OPEN_INPUT_FILE_NEW_VERSION(FileRead, surveys_file, surveys_filename, surveys_file_version,
463 SURVEYS_FILENAME_TEMPLATE, kCurrentPacketVersionSurveys);463 SURVEYS_FILENAME_TEMPLATE, kCurrentPacketVersionSurveys)
464464
465 OPEN_INPUT_FILE_NEW_VERSION(FileRead, survey_amounts_file, survey_amounts_filename,465 OPEN_INPUT_FILE_NEW_VERSION(FileRead, survey_amounts_file, survey_amounts_filename,
466 survey_amounts_file_version, SURVEY_AMOUNTS_FILENAME_TEMPLATE,466 survey_amounts_file_version, SURVEY_AMOUNTS_FILENAME_TEMPLATE,
467 kCurrentPacketVersionSurveyAmounts);467 kCurrentPacketVersionSurveyAmounts)
468468
469 OPEN_INPUT_FILE(FileRead, survey_times_file, survey_times_filename,469 OPEN_INPUT_FILE(FileRead, survey_times_file, survey_times_filename,
470 SURVEY_TIMES_FILENAME_TEMPLATE, kCurrentPacketVersionSurveyTimes);470 SURVEY_TIMES_FILENAME_TEMPLATE, kCurrentPacketVersionSurveyTimes)
471471
472 OPEN_INPUT_FILE_NEW_VERSION(FileRead, border_file, border_filename, border_file_version,472 OPEN_INPUT_FILE_NEW_VERSION(FileRead, border_file, border_filename, border_file_version,
473 BORDER_FILENAME_TEMPLATE, kCurrentPacketVersionBorder);473 BORDER_FILENAME_TEMPLATE, kCurrentPacketVersionBorder)
474474
475 OPEN_INPUT_FILE_NEW_VERSION_SILENT(FileRead, hidden_file, hidden_filename,475 OPEN_INPUT_FILE_NEW_VERSION_SILENT(FileRead, hidden_file, hidden_filename,
476 hidden_file_version, HIDDEN_FILENAME_TEMPLATE,476 hidden_file_version, HIDDEN_FILENAME_TEMPLATE,
477 kCurrentPacketVersionHidden);477 kCurrentPacketVersionHidden)
478478
479 for (FCoords first_in_row(Coords(0, 0), &first_field); first_in_row.y < mapheight;479 for (FCoords first_in_row(Coords(0, 0), &first_field); first_in_row.y < mapheight;
480 ++first_in_row.y, first_in_row.field += mapwidth) {480 ++first_in_row.y, first_in_row.field += mapwidth) {
@@ -801,19 +801,19 @@
801 hidden_file_version, kCurrentPacketVersionHidden);801 hidden_file_version, kCurrentPacketVersionHidden);
802 }802 }
803803
804 CHECK_TRAILING_BYTES(unseen_times_file, unseen_times_filename);804 CHECK_TRAILING_BYTES(unseen_times_file, unseen_times_filename)
805 CHECK_TRAILING_BYTES(node_immovable_kinds_file, node_immovable_kinds_filename);805 CHECK_TRAILING_BYTES(node_immovable_kinds_file, node_immovable_kinds_filename)
806 CHECK_TRAILING_BYTES(node_immovables_file, node_immovables_filename);806 CHECK_TRAILING_BYTES(node_immovables_file, node_immovables_filename)
807 CHECK_TRAILING_BYTES(roads_file, roads_filename);807 CHECK_TRAILING_BYTES(roads_file, roads_filename)
808 CHECK_TRAILING_BYTES(terrains_file, terrains_filename);808 CHECK_TRAILING_BYTES(terrains_file, terrains_filename)
809 CHECK_TRAILING_BYTES(triangle_immovable_kinds_file, triangle_immovable_kinds_filename);809 CHECK_TRAILING_BYTES(triangle_immovable_kinds_file, triangle_immovable_kinds_filename)
810 CHECK_TRAILING_BYTES(triangle_immovables_file, triangle_immovables_filename);810 CHECK_TRAILING_BYTES(triangle_immovables_file, triangle_immovables_filename)
811 CHECK_TRAILING_BYTES(owners_file, owners_filename);811 CHECK_TRAILING_BYTES(owners_file, owners_filename)
812 CHECK_TRAILING_BYTES(surveys_file, surveys_filename);812 CHECK_TRAILING_BYTES(surveys_file, surveys_filename)
813 CHECK_TRAILING_BYTES(survey_amounts_file, survey_amounts_filename);813 CHECK_TRAILING_BYTES(survey_amounts_file, survey_amounts_filename)
814 CHECK_TRAILING_BYTES(survey_times_file, survey_times_filename);814 CHECK_TRAILING_BYTES(survey_times_file, survey_times_filename)
815 CHECK_TRAILING_BYTES(border_file, border_filename);815 CHECK_TRAILING_BYTES(border_file, border_filename)
816 CHECK_TRAILING_BYTES(hidden_file, hidden_filename);816 CHECK_TRAILING_BYTES(hidden_file, hidden_filename)
817 }817 }
818}818}
819819
@@ -1011,38 +1011,38 @@
1011 fs.ensure_directory_exists(1011 fs.ensure_directory_exists(
1012 (boost::format(DIRNAME_TEMPLATE) % static_cast<unsigned int>(plnum)).str());1012 (boost::format(DIRNAME_TEMPLATE) % static_cast<unsigned int>(plnum)).str());
10131013
1014 WRITE(unseen_times_file, UNSEEN_TIMES_FILENAME_TEMPLATE, kCurrentPacketVersionUnseenTimes);1014 WRITE(unseen_times_file, UNSEEN_TIMES_FILENAME_TEMPLATE, kCurrentPacketVersionUnseenTimes)
10151015
1016 WRITE(node_immovable_kinds_file, NODE_IMMOVABLE_KINDS_FILENAME_TEMPLATE,1016 WRITE(node_immovable_kinds_file, NODE_IMMOVABLE_KINDS_FILENAME_TEMPLATE,
1017 kCurrentPacketVersionImmovableKinds);1017 kCurrentPacketVersionImmovableKinds)
10181018
1019 WRITE(1019 WRITE(
1020 node_immovables_file, NODE_IMMOVABLES_FILENAME_TEMPLATE, kCurrentPacketVersionImmovables);1020 node_immovables_file, NODE_IMMOVABLES_FILENAME_TEMPLATE, kCurrentPacketVersionImmovables)
10211021
1022 WRITE(roads_file, ROADS_FILENAME_TEMPLATE, kCurrentPacketVersionRoads);1022 WRITE(roads_file, ROADS_FILENAME_TEMPLATE, kCurrentPacketVersionRoads)
10231023
1024 WRITE(terrains_file, TERRAINS_FILENAME_TEMPLATE, kCurrentPacketVersionTerrains);1024 WRITE(terrains_file, TERRAINS_FILENAME_TEMPLATE, kCurrentPacketVersionTerrains)
10251025
1026 WRITE(triangle_immovable_kinds_file, TRIANGLE_IMMOVABLE_KINDS_FILENAME_TEMPLATE,1026 WRITE(triangle_immovable_kinds_file, TRIANGLE_IMMOVABLE_KINDS_FILENAME_TEMPLATE,
1027 kCurrentPacketVersionImmovableKinds);1027 kCurrentPacketVersionImmovableKinds)
10281028
1029 WRITE(triangle_immovables_file, TRIANGLE_IMMOVABLES_FILENAME_TEMPLATE,1029 WRITE(triangle_immovables_file, TRIANGLE_IMMOVABLES_FILENAME_TEMPLATE,
1030 kCurrentPacketVersionImmovables);1030 kCurrentPacketVersionImmovables)
10311031
1032 WRITE(owners_file, OWNERS_FILENAME_TEMPLATE, kCurrentPacketVersionOwners);1032 WRITE(owners_file, OWNERS_FILENAME_TEMPLATE, kCurrentPacketVersionOwners)
10331033
1034 WRITE(surveys_file, SURVEYS_FILENAME_TEMPLATE, kCurrentPacketVersionSurveys);1034 WRITE(surveys_file, SURVEYS_FILENAME_TEMPLATE, kCurrentPacketVersionSurveys)
10351035
1036 WRITE(1036 WRITE(
1037 survey_amounts_file, SURVEY_AMOUNTS_FILENAME_TEMPLATE, kCurrentPacketVersionSurveyAmounts);1037 survey_amounts_file, SURVEY_AMOUNTS_FILENAME_TEMPLATE, kCurrentPacketVersionSurveyAmounts)
10381038
1039 WRITE(survey_times_file, SURVEY_TIMES_FILENAME_TEMPLATE, kCurrentPacketVersionSurveyTimes);1039 WRITE(survey_times_file, SURVEY_TIMES_FILENAME_TEMPLATE, kCurrentPacketVersionSurveyTimes)
10401040
1041 WRITE(hidden_file, HIDDEN_FILENAME_TEMPLATE, kCurrentPacketVersionHidden);1041 WRITE(hidden_file, HIDDEN_FILENAME_TEMPLATE, kCurrentPacketVersionHidden)
10421042
1043 WRITE(vision_file, VISION_FILENAME_TEMPLATE, kCurrentPacketVersionVision);1043 WRITE(vision_file, VISION_FILENAME_TEMPLATE, kCurrentPacketVersionVision)
10441044
1045 WRITE(border_file, BORDER_FILENAME_TEMPLATE, kCurrentPacketVersionBorder);1045 WRITE(border_file, BORDER_FILENAME_TEMPLATE, kCurrentPacketVersionBorder)
1046 }1046 }
1047}1047}
1048} // namespace Widelands1048} // namespace Widelands
10491049
=== modified file 'src/map_io/s2map.cc'
--- src/map_io/s2map.cc 2019-02-23 11:00:49 +0000
+++ src/map_io/s2map.cc 2019-04-10 16:40:56 +0000
@@ -704,7 +704,7 @@
704 res = "";704 res = "";
705 amount = 0;705 amount = 0;
706 break;706 break;
707 };707 }
708708
709 Widelands::DescriptionIndex nres = 0;709 Widelands::DescriptionIndex nres = 0;
710 if (*res) {710 if (*res) {
711711
=== modified file 'src/scripting/lua_bases.cc'
--- src/scripting/lua_bases.cc 2019-02-23 11:00:49 +0000
+++ src/scripting/lua_bases.cc 2019-04-10 16:40:56 +0000
@@ -572,7 +572,7 @@
572 PERS_UINT32("player", player_number_);572 PERS_UINT32("player", player_number_);
573}573}
574void LuaPlayerBase::__unpersist(lua_State* L) {574void LuaPlayerBase::__unpersist(lua_State* L) {
575 UNPERS_UINT32("player", player_number_);575 UNPERS_UINT32("player", player_number_)
576}576}
577577
578/*578/*
579579
=== modified file 'src/scripting/lua_game.cc'
--- src/scripting/lua_game.cc 2019-03-09 08:58:52 +0000
+++ src/scripting/lua_game.cc 2019-04-10 16:40:56 +0000
@@ -435,10 +435,10 @@
435 lua_pop(L, 1);435 lua_pop(L, 1);
436436
437 if (lua_gettop(L) == 4) {437 if (lua_gettop(L) == 4) {
438 CHECK_UINT(posx);438 CHECK_UINT(posx)
439 CHECK_UINT(posy);439 CHECK_UINT(posy)
440 CHECK_UINT(w);440 CHECK_UINT(w)
441 CHECK_UINT(h);441 CHECK_UINT(h)
442442
443 // If a field has been defined, read the coordinates to jump to.443 // If a field has been defined, read the coordinates to jump to.
444 lua_getfield(L, 4, "field");444 lua_getfield(L, 4, "field");
@@ -959,7 +959,7 @@
959 PERS_STRING("name", name_);959 PERS_STRING("name", name_);
960}960}
961void LuaObjective::__unpersist(lua_State* L) {961void LuaObjective::__unpersist(lua_State* L) {
962 UNPERS_STRING("name", name_);962 UNPERS_STRING("name", name_)
963}963}
964964
965/*965/*
@@ -1126,9 +1126,9 @@
1126 PERS_UINT32("msg_idx", get_mos(L)->message_savers[player_number_ - 1][message_id_].value());1126 PERS_UINT32("msg_idx", get_mos(L)->message_savers[player_number_ - 1][message_id_].value());
1127}1127}
1128void LuaMessage::__unpersist(lua_State* L) {1128void LuaMessage::__unpersist(lua_State* L) {
1129 UNPERS_UINT32("player", player_number_);1129 UNPERS_UINT32("player", player_number_)
1130 uint32_t midx = 0;1130 uint32_t midx = 0;
1131 UNPERS_UINT32("msg_idx", midx);1131 UNPERS_UINT32("msg_idx", midx)
1132 message_id_ = MessageId(midx);1132 message_id_ = MessageId(midx);
1133}1133}
11341134
11351135
=== modified file 'src/scripting/lua_map.cc'
--- src/scripting/lua_map.cc 2019-04-07 05:46:13 +0000
+++ src/scripting/lua_map.cc 2019-04-10 16:40:56 +0000
@@ -545,10 +545,10 @@
545 lua_pushuint32(L, idx); \545 lua_pushuint32(L, idx); \
546 lua_pushuint32(L, i.first.name); \546 lua_pushuint32(L, i.first.name); \
547 lua_rawset(L, -3);547 lua_rawset(L, -3);
548 PUSHLEVEL(1, health);548 PUSHLEVEL(1, health)
549 PUSHLEVEL(2, attack);549 PUSHLEVEL(2, attack)
550 PUSHLEVEL(3, defense);550 PUSHLEVEL(3, defense)
551 PUSHLEVEL(4, evade);551 PUSHLEVEL(4, evade)
552#undef PUSHLEVEL552#undef PUSHLEVEL
553553
554 lua_pushuint32(L, i.second);554 lua_pushuint32(L, i.second);
@@ -1539,7 +1539,7 @@
15391539
1540void LuaTribeDescription::__unpersist(lua_State* L) {1540void LuaTribeDescription::__unpersist(lua_State* L) {
1541 std::string name;1541 std::string name;
1542 UNPERS_STRING("name", name);1542 UNPERS_STRING("name", name)
1543 const Tribes& tribes = get_egbase(L).tribes();1543 const Tribes& tribes = get_egbase(L).tribes();
1544 DescriptionIndex idx = tribes.safe_tribe_index(name);1544 DescriptionIndex idx = tribes.safe_tribe_index(name);
1545 set_description_pointer(tribes.get_tribe_descr(idx));1545 set_description_pointer(tribes.get_tribe_descr(idx));
@@ -1993,7 +1993,7 @@
19931993
1994void LuaImmovableDescription::__unpersist(lua_State* L) {1994void LuaImmovableDescription::__unpersist(lua_State* L) {
1995 std::string name;1995 std::string name;
1996 UNPERS_STRING("name", name);1996 UNPERS_STRING("name", name)
1997 const World& world = get_egbase(L).world();1997 const World& world = get_egbase(L).world();
1998 DescriptionIndex idx = world.get_immovable_index(name);1998 DescriptionIndex idx = world.get_immovable_index(name);
1999 if (idx != INVALID_INDEX) {1999 if (idx != INVALID_INDEX) {
@@ -2215,7 +2215,7 @@
22152215
2216void LuaBuildingDescription::__unpersist(lua_State* L) {2216void LuaBuildingDescription::__unpersist(lua_State* L) {
2217 std::string name;2217 std::string name;
2218 UNPERS_STRING("name", name);2218 UNPERS_STRING("name", name)
2219 const Tribes& tribes = get_egbase(L).tribes();2219 const Tribes& tribes = get_egbase(L).tribes();
2220 DescriptionIndex idx = tribes.safe_building_index(name.c_str());2220 DescriptionIndex idx = tribes.safe_building_index(name.c_str());
2221 set_description_pointer(tribes.get_building_descr(idx));2221 set_description_pointer(tribes.get_building_descr(idx));
@@ -3070,7 +3070,7 @@
30703070
3071void LuaWareDescription::__unpersist(lua_State* L) {3071void LuaWareDescription::__unpersist(lua_State* L) {
3072 std::string name;3072 std::string name;
3073 UNPERS_STRING("name", name);3073 UNPERS_STRING("name", name)
3074 const Tribes& tribes = get_egbase(L).tribes();3074 const Tribes& tribes = get_egbase(L).tribes();
3075 DescriptionIndex idx = tribes.safe_ware_index(name.c_str());3075 DescriptionIndex idx = tribes.safe_ware_index(name.c_str());
3076 set_description_pointer(tribes.get_ware_descr(idx));3076 set_description_pointer(tribes.get_ware_descr(idx));
@@ -3188,7 +3188,7 @@
31883188
3189void LuaWorkerDescription::__unpersist(lua_State* L) {3189void LuaWorkerDescription::__unpersist(lua_State* L) {
3190 std::string name;3190 std::string name;
3191 UNPERS_STRING("name", name);3191 UNPERS_STRING("name", name)
3192 const Tribes& tribes = get_egbase(L).tribes();3192 const Tribes& tribes = get_egbase(L).tribes();
3193 DescriptionIndex idx = tribes.safe_worker_index(name.c_str());3193 DescriptionIndex idx = tribes.safe_worker_index(name.c_str());
3194 set_description_pointer(tribes.get_worker_descr(idx));3194 set_description_pointer(tribes.get_worker_descr(idx));
@@ -3469,7 +3469,7 @@
34693469
3470void LuaResourceDescription::__unpersist(lua_State* L) {3470void LuaResourceDescription::__unpersist(lua_State* L) {
3471 std::string name;3471 std::string name;
3472 UNPERS_STRING("name", name);3472 UNPERS_STRING("name", name)
3473 const World& world = get_egbase(L).world();3473 const World& world = get_egbase(L).world();
3474 const ResourceDescription* descr = world.get_resource(world.safe_resource_index(name.c_str()));3474 const ResourceDescription* descr = world.get_resource(world.safe_resource_index(name.c_str()));
3475 set_description_pointer(descr);3475 set_description_pointer(descr);
@@ -3590,7 +3590,7 @@
35903590
3591void LuaTerrainDescription::__unpersist(lua_State* L) {3591void LuaTerrainDescription::__unpersist(lua_State* L) {
3592 std::string name;3592 std::string name;
3593 UNPERS_STRING("name", name);3593 UNPERS_STRING("name", name)
3594 set_description_pointer(get_egbase(L).world().terrain_descr(name));3594 set_description_pointer(get_egbase(L).world().terrain_descr(name));
3595}3595}
35963596
@@ -3776,8 +3776,8 @@
3776void LuaEconomy::__unpersist(lua_State* L) {3776void LuaEconomy::__unpersist(lua_State* L) {
3777 Widelands::PlayerNumber player_number;3777 Widelands::PlayerNumber player_number;
3778 Widelands::Serial economy_serial;3778 Widelands::Serial economy_serial;
3779 UNPERS_UINT32("player", player_number);3779 UNPERS_UINT32("player", player_number)
3780 UNPERS_UINT32("economy", economy_serial);3780 UNPERS_UINT32("economy", economy_serial)
3781 const Widelands::Player& player = get_egbase(L).player(player_number);3781 const Widelands::Player& player = get_egbase(L).player(player_number);
3782 set_economy_pointer(player.get_economy(economy_serial));3782 set_economy_pointer(player.get_economy(economy_serial));
3783}3783}
@@ -3929,7 +3929,7 @@
3929}3929}
3930void LuaMapObject::__unpersist(lua_State* L) {3930void LuaMapObject::__unpersist(lua_State* L) {
3931 uint32_t idx;3931 uint32_t idx;
3932 UNPERS_UINT32("file_index", idx);3932 UNPERS_UINT32("file_index", idx)
39333933
3934 if (!idx)3934 if (!idx)
3935 ptr_ = nullptr;3935 ptr_ = nullptr;
@@ -6179,8 +6179,8 @@
6179}6179}
61806180
6181void LuaField::__unpersist(lua_State* L) {6181void LuaField::__unpersist(lua_State* L) {
6182 UNPERS_INT32("x", coords_.x);6182 UNPERS_INT32("x", coords_.x)
6183 UNPERS_INT32("y", coords_.y);6183 UNPERS_INT32("y", coords_.y)
6184}6184}
61856185
6186/*6186/*
@@ -6727,7 +6727,7 @@
6727}6727}
67286728
6729void LuaPlayerSlot::__unpersist(lua_State* L) {6729void LuaPlayerSlot::__unpersist(lua_State* L) {
6730 UNPERS_UINT32("player", player_number_);6730 UNPERS_UINT32("player", player_number_)
6731}6731}
67326732
6733/*6733/*
67346734
=== modified file 'src/sound/sound_handler.cc'
--- src/sound/sound_handler.cc 2019-02-23 11:00:49 +0000
+++ src/sound/sound_handler.cc 2019-04-10 16:40:56 +0000
@@ -112,7 +112,7 @@
112 nosound_ = true;112 nosound_ = true;
113 }113 }
114114
115 SDL_MIXER_VERSION(&sdl_version);115 SDL_MIXER_VERSION(&sdl_version)
116 log("SDL_mixer version: %d.%d.%d\n", static_cast<unsigned int>(sdl_version.major),116 log("SDL_mixer version: %d.%d.%d\n", static_cast<unsigned int>(sdl_version.major),
117 static_cast<unsigned int>(sdl_version.minor), static_cast<unsigned int>(sdl_version.patch));117 static_cast<unsigned int>(sdl_version.minor), static_cast<unsigned int>(sdl_version.patch));
118118
119119
=== modified file 'src/ui_basic/box.cc'
--- src/ui_basic/box.cc 2019-02-23 11:00:49 +0000
+++ src/ui_basic/box.cc 2019-04-10 16:40:56 +0000
@@ -423,6 +423,6 @@
423423
424 case Item::ItemSpace:424 case Item::ItemSpace:
425 break; // no need to do anything425 break; // no need to do anything
426 };426 }
427}427}
428} // namespace UI428} // namespace UI
429429
=== modified file 'src/ui_basic/editbox.cc'
--- src/ui_basic/editbox.cc 2019-02-23 11:00:49 +0000
+++ src/ui_basic/editbox.cc 2019-04-10 16:40:56 +0000
@@ -208,7 +208,7 @@
208 case SDLK_DELETE:208 case SDLK_DELETE:
209 if (m_->caret < m_->text.size()) {209 if (m_->caret < m_->text.size()) {
210 while ((m_->text[++m_->caret] & 0xc0) == 0x80) {210 while ((m_->text[++m_->caret] & 0xc0) == 0x80) {
211 };211 }
212 // Now fallthrough to handle it like Backspace212 // Now fallthrough to handle it like Backspace
213 } else {213 } else {
214 return true;214 return true;
@@ -232,7 +232,7 @@
232 case SDLK_LEFT:232 case SDLK_LEFT:
233 if (m_->caret > 0) {233 if (m_->caret > 0) {
234 while ((m_->text[--m_->caret] & 0xc0) == 0x80) {234 while ((m_->text[--m_->caret] & 0xc0) == 0x80) {
235 };235 }
236 if (code.mod & (KMOD_LCTRL | KMOD_RCTRL))236 if (code.mod & (KMOD_LCTRL | KMOD_RCTRL))
237 for (uint32_t new_caret = m_->caret;; m_->caret = new_caret)237 for (uint32_t new_caret = m_->caret;; m_->caret = new_caret)
238 if (0 == new_caret || isspace(m_->text[--new_caret]))238 if (0 == new_caret || isspace(m_->text[--new_caret]))
@@ -250,7 +250,8 @@
250 case SDLK_RIGHT:250 case SDLK_RIGHT:
251 if (m_->caret < m_->text.size()) {251 if (m_->caret < m_->text.size()) {
252 while ((m_->text[++m_->caret] & 0xc0) == 0x80) {252 while ((m_->text[++m_->caret] & 0xc0) == 0x80) {
253 };253 // We're just advancing the caret
254 }
254 if (code.mod & (KMOD_LCTRL | KMOD_RCTRL))255 if (code.mod & (KMOD_LCTRL | KMOD_RCTRL))
255 for (uint32_t new_caret = m_->caret;; ++new_caret)256 for (uint32_t new_caret = m_->caret;; ++new_caret)
256 if (new_caret == m_->text.size() || isspace(m_->text[new_caret - 1])) {257 if (new_caret == m_->text.size() || isspace(m_->text[new_caret - 1])) {
257258
=== modified file 'src/ui_basic/unique_window.h'
--- src/ui_basic/unique_window.h 2019-02-23 11:00:49 +0000
+++ src/ui_basic/unique_window.h 2019-04-10 16:40:56 +0000
@@ -55,9 +55,6 @@
55 int32_t x, y;55 int32_t x, y;
56 bool valid_pos;56 bool valid_pos;
5757
58 Registry(const Registry&) = default;
59 Registry& operator=(const Registry&) = default;
60
61 Registry() : window(nullptr), x(0), y(0), valid_pos(false) {58 Registry() : window(nullptr), x(0), y(0), valid_pos(false) {
62 }59 }
63 ~Registry();60 ~Registry();
6461
=== modified file 'src/ui_fsmenu/main.cc'
--- src/ui_fsmenu/main.cc 2019-02-23 11:00:49 +0000
+++ src/ui_fsmenu/main.cc 2019-04-10 16:40:56 +0000
@@ -114,7 +114,7 @@
114}114}
115115
116void FullscreenMenuMain::clicked_ok() {116void FullscreenMenuMain::clicked_ok() {
117 ; // do nothing117 // do nothing
118}118}
119119
120void FullscreenMenuMain::layout() {120void FullscreenMenuMain::layout() {
121121
=== modified file 'src/ui_fsmenu/netsetup_lan.cc'
--- src/ui_fsmenu/netsetup_lan.cc 2019-02-23 11:00:49 +0000
+++ src/ui_fsmenu/netsetup_lan.cc 2019-04-10 16:40:56 +0000
@@ -207,7 +207,7 @@
207 /** TRANSLATORS: The state of a LAN game can be open, closed or unknown */207 /** TRANSLATORS: The state of a LAN game can be open, closed or unknown */
208 er.set_string(2, pgettext("game_state", "Unknown"));208 er.set_string(2, pgettext("game_state", "Unknown"));
209 break;209 break;
210 };210 }
211}211}
212212
213void FullscreenMenuNetSetupLAN::game_opened(const NetOpenGame* game) {213void FullscreenMenuNetSetupLAN::game_opened(const NetOpenGame* game) {
214214
=== modified file 'src/wui/interactive_player.cc'
--- src/wui/interactive_player.cc 2019-03-01 04:29:12 +0000
+++ src/wui/interactive_player.cc 2019-04-10 16:40:56 +0000
@@ -68,7 +68,7 @@
68 const Widelands::Player::Field& pf) {68 const Widelands::Player::Field& pf) {
69 if (pf.vision == 0) {69 if (pf.vision == 0) {
70 return 0.;70 return 0.;
71 };71 }
7272
73 uint32_t brightness = 144 + fcoords.field->get_brightness();73 uint32_t brightness = 144 + fcoords.field->get_brightness();
74 brightness = std::min<uint32_t>(255, (brightness * 255) / 160);74 brightness = std::min<uint32_t>(255, (brightness * 255) / 160);

Subscribers

People subscribed via source and target branches

to status/vote changes: