Merge lp:~widelands-dev/widelands/bug-1343302 into lp:widelands

Proposed by GunChleoc
Status: Merged
Merged at revision: 7129
Proposed branch: lp:~widelands-dev/widelands/bug-1343302
Merge into: lp:widelands
Diff against target: 6513 lines (+846/-840)
156 files modified
src/ai/ai_help_structs.cc (+3/-3)
src/ai/defaultai.cc (+99/-98)
src/base/md5.h (+1/-1)
src/base/point.cc (+2/-2)
src/economy/cmd_call_economy_balance.cc (+1/-1)
src/economy/economy.cc (+4/-4)
src/economy/economy_data_packet.cc (+1/-1)
src/economy/flag.cc (+3/-3)
src/economy/flag.h (+2/-2)
src/economy/fleet.cc (+1/-1)
src/economy/idleworkersupply.cc (+1/-1)
src/economy/request.cc (+8/-8)
src/economy/road.cc (+9/-9)
src/economy/transfer.cc (+1/-1)
src/economy/ware_instance.cc (+1/-1)
src/economy/wares_queue.cc (+1/-1)
src/editor/editorinteractive.cc (+4/-4)
src/editor/map_generator.cc (+4/-4)
src/editor/tools/editor_history.cc (+3/-3)
src/editor/tools/editor_increase_resources_tool.cc (+3/-3)
src/editor/tools/editor_place_bob_tool.cc (+2/-2)
src/editor/tools/editor_place_immovable_tool.cc (+4/-4)
src/editor/tools/editor_set_resources_tool.cc (+2/-2)
src/editor/tools/editor_set_terrain_tool.cc (+4/-4)
src/editor/ui_menus/categorized_item_selection_menu.h (+2/-2)
src/editor/ui_menus/editor_main_menu_load_map.cc (+4/-4)
src/editor/ui_menus/editor_main_menu_save_map.cc (+10/-10)
src/editor/ui_menus/editor_player_menu.cc (+3/-3)
src/editor/ui_menus/editor_player_menu_allowed_buildings_menu.cc (+1/-1)
src/editor/ui_menus/editor_tool_place_bob_options_menu.cc (+2/-2)
src/game_io/game_interactive_player_data_packet.cc (+1/-1)
src/game_io/game_map_data_packet.cc (+1/-1)
src/game_io/game_player_economies_data_packet.cc (+1/-1)
src/game_io/game_player_info_data_packet.cc (+2/-2)
src/graphic/animation.cc (+3/-3)
src/graphic/color.cc (+1/-1)
src/graphic/font_handler.cc (+1/-1)
src/graphic/graphic.cc (+5/-5)
src/graphic/image_transformations.cc (+1/-1)
src/graphic/render/gl_surface_texture.cc (+7/-7)
src/graphic/render/minimaprenderer.cc (+5/-5)
src/graphic/render/terrain_sdl.h (+5/-5)
src/graphic/rendertarget.cc (+1/-1)
src/graphic/text/rt_parse.cc (+4/-4)
src/graphic/text/sdl_ttf_font.cc (+1/-1)
src/graphic/text/test/render_richtext.cc (+1/-1)
src/graphic/text/textstream.cc (+3/-3)
src/graphic/text_parser.cc (+1/-1)
src/io/fileread.cc (+2/-2)
src/io/filesystem/disk_filesystem.cc (+5/-5)
src/io/filesystem/filesystem.cc (+1/-1)
src/io/filesystem/layered_filesystem.cc (+11/-11)
src/io/filesystem/zip_filesystem.cc (+1/-1)
src/io/filewrite.cc (+1/-1)
src/logic/battle.cc (+8/-8)
src/logic/bill_of_materials.h (+1/-1)
src/logic/bob.cc (+3/-3)
src/logic/buildcost.cc (+1/-1)
src/logic/building.cc (+8/-8)
src/logic/checkstep.cc (+6/-6)
src/logic/cmd_queue.cc (+1/-1)
src/logic/constructionsite.cc (+2/-2)
src/logic/dismantlesite.cc (+3/-3)
src/logic/editor_game_base.cc (+7/-7)
src/logic/game.cc (+5/-5)
src/logic/game_controller.h (+1/-1)
src/logic/immovable.cc (+19/-19)
src/logic/map.cc (+7/-7)
src/logic/mapdifferenceregion.cc (+4/-4)
src/logic/mapdifferenceregion.h (+4/-4)
src/logic/maphollowregion.cc (+4/-4)
src/logic/maptriangleregion.cc (+2/-2)
src/logic/militarysite.cc (+6/-6)
src/logic/player.cc (+24/-24)
src/logic/playercommand.cc (+9/-9)
src/logic/production_program.cc (+51/-51)
src/logic/productionsite.cc (+7/-7)
src/logic/requirements.cc (+3/-3)
src/logic/single_player_game_settings_provider.cc (+2/-2)
src/logic/soldier.cc (+20/-20)
src/logic/trainingsite.cc (+1/-1)
src/logic/tribe.cc (+3/-3)
src/logic/warehouse.cc (+4/-4)
src/logic/warelist.h (+1/-1)
src/logic/widelands.h (+9/-9)
src/logic/widelands_geometry.cc (+3/-3)
src/logic/widelands_geometry.h (+8/-8)
src/logic/widelands_geometry_io.cc (+2/-2)
src/logic/worker.cc (+14/-14)
src/logic/worker.h (+1/-1)
src/map_io/s2map.cc (+5/-5)
src/map_io/widelands_map_building_data_packet.cc (+1/-1)
src/map_io/widelands_map_buildingdata_data_packet.cc (+10/-10)
src/map_io/widelands_map_extradata_data_packet.cc (+1/-1)
src/map_io/widelands_map_flagdata_data_packet.cc (+4/-4)
src/map_io/widelands_map_players_messages_data_packet.cc (+5/-5)
src/map_io/widelands_map_players_view_data_packet.cc (+10/-10)
src/map_io/widelands_map_road_data_packet.cc (+1/-1)
src/map_io/widelands_map_roaddata_data_packet.cc (+10/-10)
src/map_io/widelands_map_saver.cc (+1/-1)
src/map_io/widelands_map_scripting_data_packet.cc (+1/-1)
src/network/internet_gaming.cc (+1/-1)
src/network/nethost.cc (+5/-5)
src/network/network.cc (+1/-1)
src/profile/profile.cc (+10/-10)
src/scripting/c_utils.cc (+5/-5)
src/scripting/lua_bases.cc (+11/-11)
src/scripting/lua_game.cc (+8/-8)
src/scripting/lua_globals.cc (+2/-2)
src/scripting/lua_map.cc (+3/-3)
src/scripting/lua_table.h (+1/-1)
src/scripting/lua_ui.cc (+3/-3)
src/scripting/scripting.cc (+1/-1)
src/sound/sound_handler.cc (+6/-6)
src/ui_basic/button.cc (+7/-7)
src/ui_basic/checkbox.cc (+6/-6)
src/ui_basic/editbox.cc (+3/-3)
src/ui_basic/listselect.cc (+5/-5)
src/ui_basic/multilineeditbox.cc (+1/-1)
src/ui_basic/multilinetextarea.cc (+1/-1)
src/ui_basic/panel.cc (+19/-19)
src/ui_basic/progresswindow.cc (+1/-1)
src/ui_basic/slider.cc (+16/-16)
src/ui_basic/table.cc (+4/-4)
src/ui_basic/unique_window.cc (+1/-1)
src/ui_basic/window.cc (+27/-27)
src/ui_fsmenu/editor_mapselect.cc (+4/-4)
src/ui_fsmenu/internet_lobby.cc (+1/-1)
src/ui_fsmenu/intro.cc (+1/-1)
src/ui_fsmenu/launch_spg.cc (+2/-2)
src/ui_fsmenu/mapselect.cc (+5/-5)
src/ui_fsmenu/netsetup_lan.cc (+1/-1)
src/ui_fsmenu/options.cc (+5/-5)
src/wlapplication.cc (+9/-9)
src/wui/actionconfirm.cc (+17/-17)
src/wui/building_statistics_menu.cc (+11/-11)
src/wui/buildingwindow.cc (+9/-9)
src/wui/chat_msg_layout.cc (+2/-2)
src/wui/encyclopedia_window.cc (+2/-2)
src/wui/fieldaction.cc (+11/-11)
src/wui/game_main_menu.cc (+2/-2)
src/wui/game_message_menu.cc (+2/-2)
src/wui/game_objectives_menu.cc (+3/-3)
src/wui/game_options_sound_menu.cc (+6/-6)
src/wui/general_statistics_menu.cc (+1/-1)
src/wui/interactive_base.cc (+21/-16)
src/wui/interactive_player.cc (+2/-2)
src/wui/mapview.cc (+3/-3)
src/wui/mapviewpixelfunctions.cc (+1/-1)
src/wui/overlay_manager.cc (+10/-10)
src/wui/plot_area.cc (+1/-1)
src/wui/productionsitewindow.cc (+2/-2)
src/wui/shipwindow.cc (+2/-2)
src/wui/transport_ui.cc (+2/-2)
src/wui/waresdisplay.cc (+1/-1)
src/wui/waresqueuedisplay.cc (+5/-5)
To merge this branch: bzr merge lp:~widelands-dev/widelands/bug-1343302
Reviewer Review Type Date Requested Status
SirVer Approve
GunChleoc Needs Resubmitting
Review via email: mp+227432@code.launchpad.net

Description of the change

The codecheck rule still needs fixing, which is beyond my skills. At the moment, it seriously overgenerates. So, I left some NOCOM comments:

# NOCOM(#GunChleoc) this rule does not exclude string literals, e.g. _(" or ")
# NOCOM(#GunChleoc) this rule does not exclude RST comments or // inline comments added after code
# NOCOM(#GunChleoc) this rule is always triggered twice

The code itself is cleaned up and ready to merge.

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

Awesome!

I have a bunch of comments about the rule itself, I did not look over the rest of the code yet.

review: Needs Fixing
Revision history for this message
GunChleoc (gunchleoc) wrote :

I have moved the codecheck rule into a new branch, so we can get this code in faster.

review: Needs Resubmitting
Revision history for this message
SirVer (sirver) :
review: Approve

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 2014-07-14 10:45:44 +0000
+++ src/ai/ai_help_structs.cc 2014-07-25 13:46:28 +0000
@@ -28,8 +28,8 @@
2828
29bool FindNodeWithFlagOrRoad::accept(const Map&, FCoords fc) const {29bool FindNodeWithFlagOrRoad::accept(const Map&, FCoords fc) const {
30 if (upcast(PlayerImmovable const, pimm, fc.field->get_immovable()))30 if (upcast(PlayerImmovable const, pimm, fc.field->get_immovable()))
31 return pimm->get_economy() != economy and(dynamic_cast<Flag const*>(pimm)31 return pimm->get_economy() != economy && (dynamic_cast<Flag const*>(pimm)
32 or(dynamic_cast<Road const*>(pimm) &&32 || (dynamic_cast<Road const*>(pimm) &&
33 (fc.field->nodecaps() & BUILDCAPS_FLAG)));33 (fc.field->nodecaps() & BUILDCAPS_FLAG)));
34 return false;34 return false;
35}35}
@@ -53,7 +53,7 @@
53 if (dynamic_cast<Flag const*>(imm))53 if (dynamic_cast<Flag const*>(imm))
54 return true;54 return true;
5555
56 if (not dynamic_cast<Road const*>(imm) || !(endcaps & BUILDCAPS_FLAG))56 if (!dynamic_cast<Road const*>(imm) || !(endcaps & BUILDCAPS_FLAG))
57 return false;57 return false;
58 }58 }
5959
6060
=== modified file 'src/ai/defaultai.cc'
--- src/ai/defaultai.cc 2014-07-23 15:58:57 +0000
+++ src/ai/defaultai.cc 2014-07-25 13:46:28 +0000
@@ -114,17 +114,17 @@
114}114}
115115
116DefaultAI::~DefaultAI() {116DefaultAI::~DefaultAI() {
117 while (not buildable_fields.empty()) {117 while (!buildable_fields.empty()) {
118 delete buildable_fields.back();118 delete buildable_fields.back();
119 buildable_fields.pop_back();119 buildable_fields.pop_back();
120 }120 }
121121
122 while (not mineable_fields.empty()) {122 while (!mineable_fields.empty()) {
123 delete mineable_fields.back();123 delete mineable_fields.back();
124 mineable_fields.pop_back();124 mineable_fields.pop_back();
125 }125 }
126126
127 while (not economies.empty()) {127 while (!economies.empty()) {
128 delete economies.back();128 delete economies.back();
129 economies.pop_back();129 economies.pop_back();
130 }130 }
@@ -314,7 +314,7 @@
314 bo.prod_build_material_ = bh.prod_build_material();314 bo.prod_build_material_ = bh.prod_build_material();
315315
316 // here we identify hunters316 // here we identify hunters
317 if (bo.outputs_.size() == 1 and tribe_->safe_ware_index("meat") == bo.outputs_.at(0)) {317 if (bo.outputs_.size() == 1 && tribe_->safe_ware_index("meat") == bo.outputs_.at(0)) {
318 bo.is_hunter_ = true;318 bo.is_hunter_ = true;
319 } else319 } else
320 bo.is_hunter_ = false;320 bo.is_hunter_ = false;
@@ -364,7 +364,7 @@
364 if (upcast(PlayerImmovable, imm, f.field->get_immovable()))364 if (upcast(PlayerImmovable, imm, f.field->get_immovable()))
365365
366 // Guard by a set - immovables might be on several nodes at once.366 // Guard by a set - immovables might be on several nodes at once.
367 if (&imm->owner() == player_ and not found_immovables.count(imm)) {367 if (&imm->owner() == player_ && !found_immovables.count(imm)) {
368 found_immovables.insert(imm);368 found_immovables.insert(imm);
369 gain_immovable(*imm);369 gain_immovable(*imm);
370 }370 }
@@ -379,7 +379,7 @@
379 * milliseconds if the area the computer owns is big.379 * milliseconds if the area the computer owns is big.
380 */380 */
381void DefaultAI::update_all_buildable_fields(const int32_t gametime) {381void DefaultAI::update_all_buildable_fields(const int32_t gametime) {
382 while (not buildable_fields.empty() and buildable_fields.front()->next_update_due_ <= gametime) {382 while (!buildable_fields.empty() && buildable_fields.front()->next_update_due_ <= gametime) {
383 BuildableField& bf = *buildable_fields.front();383 BuildableField& bf = *buildable_fields.front();
384384
385 // check whether we lost ownership of the node385 // check whether we lost ownership of the node
@@ -411,7 +411,7 @@
411 * milliseconds if the area the computer owns is big.411 * milliseconds if the area the computer owns is big.
412 */412 */
413void DefaultAI::update_all_mineable_fields(const int32_t gametime) {413void DefaultAI::update_all_mineable_fields(const int32_t gametime) {
414 while (not mineable_fields.empty() and mineable_fields.front()->next_update_due_ <= gametime) {414 while (!mineable_fields.empty() && mineable_fields.front()->next_update_due_ <= gametime) {
415 MineableField* mf = mineable_fields.front();415 MineableField* mf = mineable_fields.front();
416416
417 // check whether we lost ownership of the node417 // check whether we lost ownership of the node
@@ -493,7 +493,7 @@
493 }493 }
494494
495 // to save some CPU495 // to save some CPU
496 if (mines_.size() > 8 and game().get_gametime() % 3 > 0)496 if (mines_.size() > 8 && game().get_gametime() % 3 > 0)
497 field.unowned_mines_pots_nearby_ = 0;497 field.unowned_mines_pots_nearby_ = 0;
498 else498 else
499 field.unowned_mines_pots_nearby_ = map.find_fields(499 field.unowned_mines_pots_nearby_ = map.find_fields(
@@ -534,7 +534,7 @@
534 }534 }
535535
536 // counting fields with fish536 // counting fields with fish
537 if (field.water_nearby_ > 0 and game().get_gametime() % 10 == 0) {537 if (field.water_nearby_ > 0 && game().get_gametime() % 10 == 0) {
538 map.find_fields(Area<FCoords>(field.coords, 6),538 map.find_fields(Area<FCoords>(field.coords, 6),
539 &resource_list,539 &resource_list,
540 FindNodeResource(world.get_resource("fish")));540 FindNodeResource(world.get_resource("fish")));
@@ -553,7 +553,7 @@
553553
554 if (BaseImmovable const* const imm = fse.field->get_immovable())554 if (BaseImmovable const* const imm = fse.field->get_immovable())
555 if (dynamic_cast<Flag const*>(imm)555 if (dynamic_cast<Flag const*>(imm)
556 or(dynamic_cast<Road const*>(imm) && (fse.field->nodecaps() & BUILDCAPS_FLAG)))556 || (dynamic_cast<Road const*>(imm) && (fse.field->nodecaps() & BUILDCAPS_FLAG)))
557 field.preferred_ = true;557 field.preferred_ = true;
558558
559 for (uint32_t i = 0; i < immovables.size(); ++i) {559 for (uint32_t i = 0; i < immovables.size(); ++i) {
@@ -654,7 +654,7 @@
654 const int32_t radius = militarysite->descr().get_conquers() + 4;654 const int32_t radius = militarysite->descr().get_conquers() + 4;
655 const int32_t v = radius - dist;655 const int32_t v = radius - dist;
656656
657 if (v > 0 and dist > 0) {657 if (v > 0 && dist > 0) {
658658
659 field.military_capacity_ += militarysite->maxSoldierCapacity();659 field.military_capacity_ += militarysite->maxSoldierCapacity();
660 field.military_presence_ += militarysite->stationedSoldiers().size();660 field.military_presence_ += militarysite->stationedSoldiers().size();
@@ -685,7 +685,7 @@
685685
686 if (BaseImmovable const* const imm = fse.field->get_immovable())686 if (BaseImmovable const* const imm = fse.field->get_immovable())
687 if (dynamic_cast<Flag const*>(imm)687 if (dynamic_cast<Flag const*>(imm)
688 or(dynamic_cast<Road const*>(imm) && (fse.field->nodecaps() & BUILDCAPS_FLAG)))688 || (dynamic_cast<Road const*>(imm) && (fse.field->nodecaps() & BUILDCAPS_FLAG)))
689 field.preferred_ = true;689 field.preferred_ = true;
690690
691 container_iterate_const(std::vector<ImmovableFound>, immovables, i) {691 container_iterate_const(std::vector<ImmovableFound>, immovables, i) {
@@ -802,7 +802,7 @@
802802
803 if ((militarysites.size() * 2 + 20) <803 if ((militarysites.size() * 2 + 20) <
804 productionsites.size()804 productionsites.size()
805 or spots<(3 + (static_cast<int32_t>(productionsites.size()) / 5))or num_constructionsites_>(805 || spots<(3 + (static_cast<int32_t>(productionsites.size()) / 5)) || num_constructionsites_>(
806 (militarysites.size() + productionsites.size()) / 2)) {806 (militarysites.size() + productionsites.size()) / 2)) {
807 new_buildings_stop_ = true;807 new_buildings_stop_ = true;
808 }808 }
@@ -865,8 +865,9 @@
865 if (!bf->reachable)865 if (!bf->reachable)
866 continue;866 continue;
867867
868 // add randomnes and ease AI
868 if (time(nullptr) % 5 == 0)869 if (time(nullptr) % 5 == 0)
869 continue; // add randomnes and ease AI870 continue;
870871
871 // Continue if field is blocked at the moment872 // Continue if field is blocked at the moment
872 field_blocked = false;873 field_blocked = false;
@@ -902,7 +903,7 @@
902 if (bo.unoccupied_)903 if (bo.unoccupied_)
903 continue;904 continue;
904905
905 if (not(bo.type == BuildingObserver::MILITARYSITE) and bo.cnt_under_construction_ >= 2)906 if (!(bo.type == BuildingObserver::MILITARYSITE) && bo.cnt_under_construction_ >= 2)
906 continue;907 continue;
907908
908 // so we are going to seriously evaluate this building on this field,909 // so we are going to seriously evaluate this building on this field,
@@ -948,7 +949,7 @@
948 if (bo.type == BuildingObserver::PRODUCTIONSITE) {949 if (bo.type == BuildingObserver::PRODUCTIONSITE) {
949950
950 // exclude spots on border951 // exclude spots on border
951 if (bf->near_border_ and not bo.need_trees_ and not bo.need_stones_)952 if (bf->near_border_ && !bo.need_trees_ && !bo.need_stones_)
952 continue;953 continue;
953954
954 // this can be only a well (as by now)955 // this can be only a well (as by now)
@@ -958,7 +959,7 @@
958959
959 if (bo.cnt_under_construction_ + bo.unoccupied_ > 0)960 if (bo.cnt_under_construction_ + bo.unoccupied_ > 0)
960 continue;961 continue;
961 if ((bo.cnt_built_ + bo.unoccupied_) > 0 and gametime < kBaseInfrastructureTime)962 if ((bo.cnt_built_ + bo.unoccupied_) > 0 && gametime < kBaseInfrastructureTime)
962 continue;963 continue;
963 if (new_buildings_stop_)964 if (new_buildings_stop_)
964 continue;965 continue;
@@ -1023,13 +1024,13 @@
10231024
1024 // production hint (f.e. associate forester with logs)1025 // production hint (f.e. associate forester with logs)
10251026
1026 if (bo.need_water_ and bf->water_nearby_ < 5) // probably some of them needs water1027 if (bo.need_water_ && bf->water_nearby_ < 5) // probably some of them needs water
1027 continue;1028 continue;
10281029
1029 if (bo.plants_trees_) { // RANGERS1030 if (bo.plants_trees_) { // RANGERS
10301031
1031 // if there are too many trees nearby1032 // if there are too many trees nearby
1032 if (bf->trees_nearby_ > 25 and bo.total_count() >= 2)1033 if (bf->trees_nearby_ > 25 && bo.total_count() >= 2)
1033 continue;1034 continue;
10341035
1035 // sometimes all area is blocked by trees so this is to prevent this1036 // sometimes all area is blocked by trees so this is to prevent this
@@ -1058,8 +1059,8 @@
1058 else if (bo.total_count() < bo.cnt_target_)1059 else if (bo.total_count() < bo.cnt_target_)
1059 prio += 30 + bf->producers_nearby_.at(bo.production_hint_) * 5;1060 prio += 30 + bf->producers_nearby_.at(bo.production_hint_) * 5;
10601061
1061 } else if (gametime > kBaseInfrastructureTime and not1062 } else if (gametime > kBaseInfrastructureTime &&
1062 new_buildings_stop_) { // gamekeepers or so1063 !new_buildings_stop_) { // gamekeepers or so
1063 if (bo.stocklevel_time < game().get_gametime() - 5 * 1000) {1064 if (bo.stocklevel_time < game().get_gametime() - 5 * 1000) {
1064 bo.stocklevel_ =1065 bo.stocklevel_ =
1065 get_stocklevel_by_hint(static_cast<size_t>(bo.production_hint_));1066 get_stocklevel_by_hint(static_cast<size_t>(bo.production_hint_));
@@ -1077,7 +1078,7 @@
1077 prio += bf->producers_nearby_.at(bo.production_hint_) * 10;1078 prio += bf->producers_nearby_.at(bo.production_hint_) * 10;
1078 prio += recalc_with_border_range(*bf, prio);1079 prio += recalc_with_border_range(*bf, prio);
10791080
1080 } else if (bo.stocklevel_ < 50 and not new_buildings_stop_) {1081 } else if (bo.stocklevel_ < 50 && !new_buildings_stop_) {
1081 prio += bf->producers_nearby_.at(bo.production_hint_) * 5;1082 prio += bf->producers_nearby_.at(bo.production_hint_) * 5;
1082 prio += recalc_with_border_range(*bf, prio); // only for not wood producers_1083 prio += recalc_with_border_range(*bf, prio); // only for not wood producers_
1083 } else1084 } else
@@ -1086,11 +1087,11 @@
10861087
1087 if (prio <= 0)1088 if (prio <= 0)
1088 continue;1089 continue;
1089 } else if (bo.recruitment_ and gametime >1090 } else if (bo.recruitment_ && gametime >
1090 kBaseInfrastructureTime and not new_buildings_stop_) {1091 kBaseInfrastructureTime && !new_buildings_stop_) {
1091 // this will depend on number of mines_ and productionsites1092 // this will depend on number of mines_ and productionsites
1092 if (static_cast<int32_t>((productionsites.size() + mines_.size()) / 30) >1093 if (static_cast<int32_t>((productionsites.size() + mines_.size()) / 30) >
1093 bo.total_count() and bo.cnt_under_construction_ ==1094 bo.total_count() && bo.cnt_under_construction_ ==
1094 0)1095 0)
1095 prio = 4 + bulgarian_constant;1096 prio = 4 + bulgarian_constant;
1096 } else { // finally normal productionsites1097 } else { // finally normal productionsites
@@ -1101,36 +1102,36 @@
1101 continue;1102 continue;
11021103
1103 // if hunter and too little critters nearby skipping1104 // if hunter and too little critters nearby skipping
1104 if (bo.is_hunter_ and bf->critters_nearby_ < 5)1105 if (bo.is_hunter_ && bf->critters_nearby_ < 5)
1105 continue;1106 continue;
1106 // similarly for fishers1107 // similarly for fishers
1107 if (bo.need_water_ and bf->fish_nearby_ <= 1)1108 if (bo.need_water_ && bf->fish_nearby_ <= 1)
1108 continue;1109 continue;
11091110
1110 // first eliminate buildings needing water if there is short supplies1111 // first eliminate buildings needing water if there is short supplies
1111 if (bo.need_water_ and bf->water_nearby_ < 4)1112 if (bo.need_water_ && bf->water_nearby_ < 4)
1112 continue;1113 continue;
11131114
1114 if (bo.is_basic_ and bo.total_count() == 0)1115 if (bo.is_basic_ && bo.total_count() == 0)
1115 prio = 150 + max_preciousness;1116 prio = 150 + max_preciousness;
1116 else if (bo.is_food_basic_ and game().get_gametime() >1117 else if (bo.is_food_basic_ && game().get_gametime() >
1117 kPrimaryFoodStartTime and bo.total_count() ==1118 kPrimaryFoodStartTime && bo.total_count() ==
1118 0) {1119 0) {
1119 prio = 40 + max_preciousness;1120 prio = 40 + max_preciousness;
1120 } else if (game().get_gametime() <1121 } else if (game().get_gametime() <
1121 kBaseInfrastructureTime or1122 kBaseInfrastructureTime ||
1122 new_buildings_stop_) // leave 15 minutes for basic infrastructure only1123 new_buildings_stop_) // leave 15 minutes for basic infrastructure only
1123 continue;1124 continue;
1124 else if ((bo.is_basic_ and bo.total_count() <=1125 else if ((bo.is_basic_ && bo.total_count() <=
1125 1)or(output_is_needed and bo.total_count() == 0))1126 1) || (output_is_needed && bo.total_count() == 0))
1126 prio = 80 + max_preciousness;1127 prio = 80 + max_preciousness;
1127 else if (bo.inputs_.size() == 0) {1128 else if (bo.inputs_.size() == 0) {
1128 bo.cnt_target_ =1129 bo.cnt_target_ =
1129 1 + static_cast<int32_t>(mines_.size() + productionsites.size()) / 8;1130 1 + static_cast<int32_t>(mines_.size() + productionsites.size()) / 8;
11301131
1131 if (bo.cnt_built_ >1132 if (bo.cnt_built_ >
1132 bo.cnt_target_ and not(1133 bo.cnt_target_ &&
1133 bo.space_consumer_ or bo.is_food_basic_)) // spaceconsumers_ and basic_s1134 !(bo.space_consumer_ || bo.is_food_basic_)) // spaceconsumers_ and basic_s
1134 // can be built more then target1135 // can be built more then target
1135 continue;1136 continue;
11361137
@@ -1145,7 +1146,7 @@
1145 if (bo.space_consumer_) // need to consider trees nearby1146 if (bo.space_consumer_) // need to consider trees nearby
1146 prio += 20 - (bf->trees_nearby_ / 3);1147 prio += 20 - (bf->trees_nearby_ / 3);
11471148
1148 if (not bo.space_consumer_)1149 if (!bo.space_consumer_)
1149 prio -= bf->producers_nearby_.at(bo.outputs_.at(0)) *1150 prio -= bf->producers_nearby_.at(bo.outputs_.at(0)) *
1150 20; // leave some free space between them1151 20; // leave some free space between them
11511152
@@ -1172,18 +1173,18 @@
1172 // to have two buildings from everything (intended for upgradeable buildings)1173 // to have two buildings from everything (intended for upgradeable buildings)
1173 // but I do not know how to identify such buildings1174 // but I do not know how to identify such buildings
1174 if (bo.cnt_built_ == 11175 if (bo.cnt_built_ == 1
1175 and game().get_gametime() > 60 * 60 * 10001176 && game().get_gametime() > 60 * 60 * 1000
1176 and bo.desc->enhancement() != INVALID_INDEX1177 && bo.desc->enhancement() != INVALID_INDEX
1177 and !mines_.empty())1178 && !mines_.empty())
1178 {1179 {
1179 prio = max_preciousness + bulgarian_constant;1180 prio = max_preciousness + bulgarian_constant;
1180 }1181 }
1181 // if output is needed and there are no idle buildings1182 // if output is needed and there are no idle buildings
1182 else if (output_is_needed) {1183 else if (output_is_needed) {
1183 if (bo.cnt_built_ > 0 and bo.current_stats_ > 80) {1184 if (bo.cnt_built_ > 0 && bo.current_stats_ > 80) {
1184 prio = max_preciousness + bulgarian_constant + 30;1185 prio = max_preciousness + bulgarian_constant + 30;
11851186
1186 } else if (bo.cnt_built_ > 0 and bo.current_stats_ > 55) {1187 } else if (bo.cnt_built_ > 0 && bo.current_stats_ > 55) {
1187 prio = max_preciousness + bulgarian_constant;1188 prio = max_preciousness + bulgarian_constant;
11881189
1189 }1190 }
@@ -1208,22 +1209,22 @@
1208 } // production sites done1209 } // production sites done
1209 else if (bo.type == BuildingObserver::MILITARYSITE) {1210 else if (bo.type == BuildingObserver::MILITARYSITE) {
12101211
1211 if (new_military_buildings_stop and not bf->enemy_nearby_)1212 if (new_military_buildings_stop && !bf->enemy_nearby_)
1212 continue;1213 continue;
12131214
1214 if (near_enemy_b_buildings_stop and bf->enemy_nearby_)1215 if (near_enemy_b_buildings_stop && bf->enemy_nearby_)
1215 continue;1216 continue;
12161217
1217 if (bf->enemy_nearby_ and bo.fighting_type_)1218 if (bf->enemy_nearby_ && bo.fighting_type_)
1218 ; // it is ok, go on1219 ; // it is ok, go on
1219 else if (bf->unowned_mines_pots_nearby_ >1220 else if (bf->unowned_mines_pots_nearby_ >
1220 0 and(bo.mountain_conqueror_ or bo.expansion_type_))1221 0 && (bo.mountain_conqueror_ || bo.expansion_type_))
1221 ; // it is ok, go on1222 ; // it is ok, go on
1222 else if (bf->unowned_land_nearby_ and bo.expansion_type_) {1223 else if (bf->unowned_land_nearby_ && bo.expansion_type_) {
1223 // decreasing probability for big buidlings1224 // decreasing probability for big buidlings
1224 if (bo.desc->get_size() == 2 and gametime % 5 >= 1)1225 if (bo.desc->get_size() == 2 && gametime % 5 >= 1)
1225 continue;1226 continue;
1226 if (bo.desc->get_size() == 3 and gametime % 15 >= 1)1227 if (bo.desc->get_size() == 3 && gametime % 15 >= 1)
1227 continue;1228 continue;
1228 }1229 }
1229 // it is ok, go on1230 // it is ok, go on
@@ -1231,7 +1232,7 @@
1231 continue; // the building is not suitable for situation1232 continue; // the building is not suitable for situation
12321233
1233 if (bo.desc->get_size() ==1234 if (bo.desc->get_size() ==
1234 3 and game().get_gametime() <1235 3 && game().get_gametime() <
1235 15 * 60 * 1000) // do not built fortresses in first half of hour of game1236 15 * 60 * 1000) // do not built fortresses in first half of hour of game
1236 continue;1237 continue;
12371238
@@ -1239,7 +1240,7 @@
1239 continue;1240 continue;
12401241
1241 // not to build so many military buildings nearby1242 // not to build so many military buildings nearby
1242 if (!bf->enemy_nearby_ and bf->military_in_constr_nearby_ > 0)1243 if (!bf->enemy_nearby_ && bf->military_in_constr_nearby_ > 0)
1243 continue;1244 continue;
12441245
1245 // here is to consider unowned potential mines1246 // here is to consider unowned potential mines
@@ -1257,7 +1258,7 @@
1257 if (bo.desc->get_size() < maxsize)1258 if (bo.desc->get_size() < maxsize)
1258 prio = prio - 5; // penalty1259 prio = prio - 5; // penalty
12591260
1260 if (bf->enemy_nearby_ and bf->military_capacity_ < 12) {1261 if (bf->enemy_nearby_ && bf->military_capacity_ < 12) {
1261 prio += 100;1262 prio += 100;
1262 }1263 }
12631264
@@ -1272,7 +1273,7 @@
1272 // chance for a warehouses (containing waiting soldiers or wares1273 // chance for a warehouses (containing waiting soldiers or wares
1273 // needed for soldier training) near the frontier.1274 // needed for soldier training) near the frontier.
1274 if ((static_cast<int32_t>(productionsites.size() + mines_.size())) / 35 >1275 if ((static_cast<int32_t>(productionsites.size() + mines_.size())) / 35 >
1275 static_cast<int32_t>(numof_warehouses_) and bo.cnt_under_construction_ ==1276 static_cast<int32_t>(numof_warehouses_) && bo.cnt_under_construction_ ==
1276 0)1277 0)
1277 prio = 13;1278 prio = 13;
12781279
@@ -1290,7 +1291,7 @@
12901291
1291 // build after 20 production sites and then after each 50 production site1292 // build after 20 production sites and then after each 50 production site
1292 if (static_cast<int32_t>((productionsites.size() + 30) / 50) >1293 if (static_cast<int32_t>((productionsites.size() + 30) / 50) >
1293 bo.total_count() and bo.cnt_under_construction_ ==1294 bo.total_count() && bo.cnt_under_construction_ ==
1294 0)1295 0)
1295 prio = 4;1296 prio = 4;
12961297
@@ -1329,7 +1330,7 @@
1329 for (uint32_t i = 0; i < buildings_.size() && productionsites.size() > 8; ++i) {1330 for (uint32_t i = 0; i < buildings_.size() && productionsites.size() > 8; ++i) {
1330 BuildingObserver& bo = buildings_.at(i);1331 BuildingObserver& bo = buildings_.at(i);
13311332
1332 if (not bo.mines_marble_ and gametime <1333 if (!bo.mines_marble_ && gametime <
1333 kBaseInfrastructureTime) // allow only stone mines_ in early stages of game1334 kBaseInfrastructureTime) // allow only stone mines_ in early stages of game
1334 continue;1335 continue;
13351336
@@ -1352,7 +1353,7 @@
1352 }1353 }
13531354
1354 // Only try to build mines_ that produce needed wares.1355 // Only try to build mines_ that produce needed wares.
1355 if (((bo.cnt_built_ - bo.unoccupied_) > 0 and bo.current_stats_ < 20)or bo.stocklevel_ >1356 if (((bo.cnt_built_ - bo.unoccupied_) > 0 && bo.current_stats_ < 20) || bo.stocklevel_ >
1356 40 + static_cast<uint32_t>(bo.mines_marble_) * 30) {1357 40 + static_cast<uint32_t>(bo.mines_marble_) * 30) {
13571358
1358 continue;1359 continue;
@@ -1430,7 +1431,7 @@
1430 blocked_fields.push_back(blocked);1431 blocked_fields.push_back(blocked);
14311432
1432 // if space consumer we block also nearby fields1433 // if space consumer we block also nearby fields
1433 if (best_building->space_consumer_ and not best_building->plants_trees_) {1434 if (best_building->space_consumer_ && !best_building->plants_trees_) {
1434 Map& map = game().map();1435 Map& map = game().map();
14351436
1436 MapRegion<Area<FCoords>> mr(map, Area<FCoords>(map.get_fcoords(proposed_coords), 3));1437 MapRegion<Area<FCoords>> mr(map, Area<FCoords>(map.get_fcoords(proposed_coords), 3));
@@ -1441,7 +1442,7 @@
1441 } while (mr.advance(map));1442 } while (mr.advance(map));
1442 }1443 }
14431444
1444 if (not(best_building->type == BuildingObserver::MILITARYSITE))1445 if (!(best_building->type == BuildingObserver::MILITARYSITE))
1445 best_building->construction_decision_time_ = gametime;1446 best_building->construction_decision_time_ = gametime;
1446 else // very ugly hack here1447 else // very ugly hack here
1447 best_building->construction_decision_time_ = gametime - kBuildingMinInterval / 2;1448 best_building->construction_decision_time_ = gametime - kBuildingMinInterval / 2;
@@ -1508,7 +1509,7 @@
15081509
1509 // If the economy consists of just one constructionsite, and the defaultAI1510 // If the economy consists of just one constructionsite, and the defaultAI
1510 // failed more than 4 times to connect, we remove the constructionsite1511 // failed more than 4 times to connect, we remove the constructionsite
1511 if (eo_to_connect->failed_connection_tries > 3 and eo_to_connect->flags.size() == 1) {1512 if (eo_to_connect->failed_connection_tries > 3 && eo_to_connect->flags.size() == 1) {
1512 Building* bld = eo_to_connect->flags.front()->get_building();1513 Building* bld = eo_to_connect->flags.front()->get_building();
15131514
1514 if (bld) {1515 if (bld) {
@@ -1732,7 +1733,7 @@
1732 Path& path = *new Path();1733 Path& path = *new Path();
17331734
1734 if (map.findpath(flag.get_position(), nf.flag->get_position(), 0, path, check) >=1735 if (map.findpath(flag.get_position(), nf.flag->get_position(), 0, path, check) >=
1735 0 and static_cast<int32_t>(2 * path.get_nsteps() + 2) < nf.cost_) {1736 0 && static_cast<int32_t>(2 * path.get_nsteps() + 2) < nf.cost_) {
1736 game().send_player_build_road(player_number(), path);1737 game().send_player_build_road(player_number(), path);
1737 return true;1738 return true;
1738 }1739 }
@@ -1855,7 +1856,7 @@
1855 // Wells handling1856 // Wells handling
1856 if (site.bo->mines_water_) {1857 if (site.bo->mines_water_) {
1857 if (site.unoccupied_till_ + 6 * 60 * 1000 < game().get_gametime()1858 if (site.unoccupied_till_ + 6 * 60 * 1000 < game().get_gametime()
1858 and site.site->get_statistics_percent() ==1859 && site.site->get_statistics_percent() ==
1859 0) {1860 0) {
1860 site.bo->last_dismantle_time_ = game().get_gametime();1861 site.bo->last_dismantle_time_ = game().get_gametime();
1861 flags_to_be_removed.push_back(site.site->base_flag().get_position());1862 flags_to_be_removed.push_back(site.site->base_flag().get_position());
@@ -1882,7 +1883,7 @@
1882 }1883 }
18831884
1884 if (site.unoccupied_till_ + 6 * 60 * 1000 < game().get_gametime()1885 if (site.unoccupied_till_ + 6 * 60 * 1000 < game().get_gametime()
1885 and site.site->get_statistics_percent() ==1886 && site.site->get_statistics_percent() ==
1886 0) {1887 0) {
1887 // it is possible that there are stones but quary is not able to mine them1888 // it is possible that there are stones but quary is not able to mine them
1888 site.bo->last_dismantle_time_ = game().get_gametime();1889 site.bo->last_dismantle_time_ = game().get_gametime();
@@ -1897,13 +1898,13 @@
18971898
1898 // All other SPACE_CONSUMERS without input and above target_count1899 // All other SPACE_CONSUMERS without input and above target_count
1899 if (site.bo->inputs_.empty() // does not consume anything1900 if (site.bo->inputs_.empty() // does not consume anything
1900 and site.bo->production_hint_ ==1901 && site.bo->production_hint_ ==
1901 -1 // not a renewing building (forester...)1902 -1 // not a renewing building (forester...)
1902 and site.unoccupied_till_ +1903 && site.unoccupied_till_ +
1903 10 * 60 * 1000 <1904 10 * 60 * 1000 <
1904 game().get_gametime() // > 10 minutes old1905 game().get_gametime() // > 10 minutes old
1905 and site.site->can_start_working() // building is occupied1906 && site.site->can_start_working() // building is occupied
1906 and site.bo->space_consumer_ and not site.bo->plants_trees_) {1907 && site.bo->space_consumer_ && !site.bo->plants_trees_) {
19071908
1908 // if we have more buildings then target1909 // if we have more buildings then target
1909 if (site.bo->cnt_built_ > site.bo->cnt_target_) {1910 if (site.bo->cnt_built_ > site.bo->cnt_target_) {
@@ -1913,7 +1914,7 @@
1913 }1914 }
19141915
1915 if (site.site->get_statistics_percent()<1916 if (site.site->get_statistics_percent()<
1916 30 and site.bo->stocklevel_> 100) { // production stats == 0%1917 30 && site.bo->stocklevel_> 100) { // production stats == 0%
1917 site.bo->last_dismantle_time_ = game().get_gametime();1918 site.bo->last_dismantle_time_ = game().get_gametime();
1918 flags_to_be_removed.push_back(site.site->base_flag().get_position());1919 flags_to_be_removed.push_back(site.site->base_flag().get_position());
1919 game().send_player_dismantle(*site.site);1920 game().send_player_dismantle(*site.site);
@@ -1933,10 +1934,10 @@
1933 }1934 }
19341935
1935 // buildings with inputs_, checking if we can a dismantle some due to low performance1936 // buildings with inputs_, checking if we can a dismantle some due to low performance
1936 if (!site.bo->inputs_.empty() and(site.bo->cnt_built_ - site.bo->unoccupied_) >=1937 if (!site.bo->inputs_.empty() && (site.bo->cnt_built_ - site.bo->unoccupied_) >=
1937 3 and site.site->can_start_working() and site.site->get_statistics_percent() <1938 3 && site.site->can_start_working() && site.site->get_statistics_percent() <
1938 20 and // statistics for the building1939 20 && // statistics for the building
1939 site.bo->current_stats_<30 and // overall statistics1940 site.bo->current_stats_<30 && // overall statistics
1940 (game().get_gametime() - site.unoccupied_till_)> 10 *1941 (game().get_gametime() - site.unoccupied_till_)> 10 *
1941 60 * 1000) {1942 60 * 1000) {
19421943
@@ -1951,10 +1952,10 @@
1951 // first if is only for log, second one is "executive"1952 // first if is only for log, second one is "executive"
19521953
1953 if (site.bo->inputs_.size() ==1954 if (site.bo->inputs_.size() ==
1954 0 and site.bo->production_hint_ <1955 0 && site.bo->production_hint_ <
1955 0 and site.site->can_start_working()1956 0 && site.site->can_start_working()
1956 and not site.bo->space_consumer_ and site.site->get_statistics_percent() <1957 && !site.bo->space_consumer_ && site.site->get_statistics_percent() <
1957 10 and((game().get_gametime() - site.built_time_) > 10 * 60 * 1000)) {1958 10 && ((game().get_gametime() - site.built_time_) > 10 * 60 * 1000)) {
19581959
1959 site.bo->last_dismantle_time_ = game().get_gametime();1960 site.bo->last_dismantle_time_ = game().get_gametime();
1960 flags_to_be_removed.push_back(site.site->base_flag().get_position());1961 flags_to_be_removed.push_back(site.site->base_flag().get_position());
@@ -1974,7 +1975,7 @@
1974 uint16_t score = site.bo->stocklevel_;1975 uint16_t score = site.bo->stocklevel_;
19751976
19761977
1977 if (score > 150 and site.bo->cnt_built_ > site.bo->cnt_target_) {1978 if (score > 150 && site.bo->cnt_built_ > site.bo->cnt_target_) {
19781979
1979 site.bo->last_dismantle_time_ = game().get_gametime();1980 site.bo->last_dismantle_time_ = game().get_gametime();
1980 flags_to_be_removed.push_back(site.site->base_flag().get_position());1981 flags_to_be_removed.push_back(site.site->base_flag().get_position());
@@ -1982,12 +1983,12 @@
1982 return true;1983 return true;
1983 }1984 }
19841985
1985 if (score > 70 and not site.site->is_stopped()) {1986 if (score > 70 && !site.site->is_stopped()) {
19861987
1987 game().send_player_start_stop_building(*site.site);1988 game().send_player_start_stop_building(*site.site);
1988 }1989 }
19891990
1990 if (score < 50 and site.site->is_stopped()) {1991 if (score < 50 && site.site->is_stopped()) {
19911992
1992 game().send_player_start_stop_building(*site.site);1993 game().send_player_start_stop_building(*site.site);
1993 }1994 }
@@ -2025,9 +2026,9 @@
2025 {2026 {
2026 // forcing first upgrade2027 // forcing first upgrade
2027 if ((en_bo.cnt_under_construction_ + en_bo.cnt_built_ + en_bo.unoccupied_) == 02028 if ((en_bo.cnt_under_construction_ + en_bo.cnt_built_ + en_bo.unoccupied_) == 0
2028 and(site.bo->cnt_built_ - site.bo->unoccupied_) >= 12029 && (site.bo->cnt_built_ - site.bo->unoccupied_) >= 1
2029 and(game().get_gametime() - site.unoccupied_till_) > 30 * 60 * 10002030 && (game().get_gametime() - site.unoccupied_till_) > 30 * 60 * 1000
2030 and !mines_.empty())2031 && !mines_.empty())
2031 {2032 {
2032 game().send_player_enhance_building(*site.site, enhancement);2033 game().send_player_enhance_building(*site.site, enhancement);
2033 return true;2034 return true;
@@ -2039,11 +2040,11 @@
2039 // now, let consider normal upgrade2040 // now, let consider normal upgrade
2040 // do not upgrade if candidate production % is too low2041 // do not upgrade if candidate production % is too low
2041 if ((en_bo.cnt_built_ - en_bo.unoccupied_) != 02042 if ((en_bo.cnt_built_ - en_bo.unoccupied_) != 0
2042 or(en_bo.cnt_under_construction_ + en_bo.unoccupied_) <= 02043 || (en_bo.cnt_under_construction_ + en_bo.unoccupied_) <= 0
2043 or en_bo.current_stats_ >= 50) {2044 || en_bo.current_stats_ >= 50) {
20442045
2045 if (en_bo.current_stats_ > 652046 if (en_bo.current_stats_ > 65
2046 and ((en_bo.current_stats_ - site.bo->current_stats_) + // priority for enhancement2047 && ((en_bo.current_stats_ - site.bo->current_stats_) + // priority for enhancement
2047 (en_bo.current_stats_ - 65)) > 0)2048 (en_bo.current_stats_ - 65)) > 0)
2048 {2049 {
2049 enbld = enhancement;2050 enbld = enhancement;
@@ -2085,7 +2086,7 @@
20852086
2086 // first get rid of mines that are missing workers for some time (5 minutes)2087 // first get rid of mines that are missing workers for some time (5 minutes)
2087 // released worker (if any) can be usefull elsewhere !2088 // released worker (if any) can be usefull elsewhere !
2088 if (site.built_time_ + 5 * 60 * 1000 < gametime and not site.site->can_start_working()) {2089 if (site.built_time_ + 5 * 60 * 1000 < gametime && !site.site->can_start_working()) {
2089 flags_to_be_removed.push_back(site.site->base_flag().get_position());2090 flags_to_be_removed.push_back(site.site->base_flag().get_position());
2090 game().send_player_dismantle(*site.site);2091 game().send_player_dismantle(*site.site);
2091 return true;2092 return true;
@@ -2123,7 +2124,7 @@
2123 if (en_bo.unoccupied_ + en_bo.cnt_under_construction_ <= 0)2124 if (en_bo.unoccupied_ + en_bo.cnt_under_construction_ <= 0)
2124 {2125 {
2125 // do not upgrade target building are not working properly (probably do not have food)2126 // do not upgrade target building are not working properly (probably do not have food)
2126 if (en_bo.cnt_built_ <= 0 and en_bo.current_stats_ >= 60)2127 if (en_bo.cnt_built_ <= 0 && en_bo.current_stats_ >= 60)
2127 {2128 {
2128 // do not build the same building so soon (kind of duplicity check)2129 // do not build the same building so soon (kind of duplicity check)
2129 if (gametime - en_bo.construction_decision_time_ >= kBuildingMinInterval)2130 if (gametime - en_bo.construction_decision_time_ >= kBuildingMinInterval)
@@ -2258,8 +2259,8 @@
2258 update_buildable_field(bf, vision, true);2259 update_buildable_field(bf, vision, true);
2259 const int32_t size_penalty = ms->get_size() - 1;2260 const int32_t size_penalty = ms->get_size() - 1;
22602261
2261 if (bf.military_capacity_ > 9 and bf.military_presence_ >2262 if (bf.military_capacity_ > 9 && bf.military_presence_ >
2262 3 and bf.military_loneliness_<160 and bf.military_stationed_>(2 + size_penalty)) {2263 3 && bf.military_loneliness_<160 && bf.military_stationed_>(2 + size_penalty)) {
22632264
2264 if (ms->get_playercaps() & Widelands::Building::PCap_Dismantle) {2265 if (ms->get_playercaps() & Widelands::Building::PCap_Dismantle) {
2265 flags_to_be_removed.push_back(ms->base_flag().get_position());2266 flags_to_be_removed.push_back(ms->base_flag().get_position());
@@ -2315,7 +2316,7 @@
2315 // NOTE take care about the type of computer player_. The more2316 // NOTE take care about the type of computer player_. The more
2316 // NOTE aggressive a computer player_ is, the more important is2317 // NOTE aggressive a computer player_ is, the more important is
2317 // NOTE this check. So we add \var type as bonus.2318 // NOTE this check. So we add \var type as bonus.
2318 if (bf.enemy_nearby_ and prio > 0)2319 if (bf.enemy_nearby_ && prio > 0)
2319 prio /= (3 + type_);2320 prio /= (3 + type_);
23202321
2321 return prio;2322 return prio;
@@ -2380,7 +2381,7 @@
2380void DefaultAI::consider_productionsite_influence(BuildableField& field,2381void DefaultAI::consider_productionsite_influence(BuildableField& field,
2381 Coords coords,2382 Coords coords,
2382 const BuildingObserver& bo) {2383 const BuildingObserver& bo) {
2383 if (bo.space_consumer_ and game().map().calc_distance(coords, field.coords) < 4)2384 if (bo.space_consumer_ && game().map().calc_distance(coords, field.coords) < 4)
2384 ++field.space_consumers_nearby_;2385 ++field.space_consumers_nearby_;
23852386
2386 for (size_t i = 0; i < bo.inputs_.size(); ++i)2387 for (size_t i = 0; i < bo.inputs_.size(); ++i)
@@ -2627,7 +2628,7 @@
26272628
2628 }2629 }
26292630
2630 if (not any_attackable) {2631 if (!any_attackable) {
2631 next_attack_consideration_due_ = 120 * 1000 + (gametime % 30 + 2) * 1000 + gametime;2632 next_attack_consideration_due_ = 120 * 1000 + (gametime % 30 + 2) * 1000 + gametime;
2632 return false;2633 return false;
2633 }2634 }
@@ -2638,7 +2639,7 @@
2638 Map& map = game().map();2639 Map& map = game().map();
26392640
2640 uint16_t position = 0;2641 uint16_t position = 0;
2641 for (uint32_t i = 0; i < attempts && not any_attacked; ++i) {2642 for (uint32_t i = 0; i < attempts && !any_attacked; ++i) {
2642 position = (game().get_gametime() + (3 * i)) % militarysites.size();2643 position = (game().get_gametime() + (3 * i)) % militarysites.size();
26432644
2644 // picking random military sites2645 // picking random military sites
@@ -2661,7 +2662,7 @@
2661 // uint8_t retreat = ms->owner().get_retreat_percentage();2662 // uint8_t retreat = ms->owner().get_retreat_percentage();
26622663
2663 // skipping if based on "enemies nearby" there are probably no enemies nearby2664 // skipping if based on "enemies nearby" there are probably no enemies nearby
2664 if (not mso->enemies_nearby and gametime % 8 > 0) {2665 if (!mso->enemies_nearby && gametime % 8 > 0) {
2665 continue; // go on with next attempt2666 continue; // go on with next attempt
2666 }2667 }
26672668
@@ -2680,7 +2681,7 @@
26802681
2681 mso->enemies_nearby = true;2682 mso->enemies_nearby = true;
26822683
2683 if (not player_attackable[bld->owner().player_number() - 1]) {2684 if (!player_attackable[bld->owner().player_number() - 1]) {
2684 continue;2685 continue;
2685 }2686 }
26862687
26872688
=== modified file 'src/base/md5.h'
--- src/base/md5.h 2014-07-05 16:41:51 +0000
+++ src/base/md5.h 2014-07-25 13:46:28 +0000
@@ -52,7 +52,7 @@
52 return memcmp(data, o.data, sizeof(data)) == 0;52 return memcmp(data, o.data, sizeof(data)) == 0;
53 }53 }
5454
55 bool operator!= (const md5_checksum & o) const {return not (*this == o);}55 bool operator!= (const md5_checksum & o) const {return !(*this == o);}
56};56};
5757
58// Note that the implementation of MD5Checksum is basically just58// Note that the implementation of MD5Checksum is basically just
5959
=== modified file 'src/base/point.cc'
--- src/base/point.cc 2014-06-24 20:21:13 +0000
+++ src/base/point.cc 2014-07-25 13:46:28 +0000
@@ -30,10 +30,10 @@
30}30}
3131
32bool Point::operator == (const Point& other) const {32bool Point::operator == (const Point& other) const {
33 return x == other.x and y == other.y;33 return x == other.x && y == other.y;
34}34}
35bool Point::operator != (const Point& other) const {35bool Point::operator != (const Point& other) const {
36 return not(*this == other);36 return !(*this == other);
37}37}
3838
39Point Point::operator +(const Point& other) const {39Point Point::operator +(const Point& other) const {
4040
=== modified file 'src/economy/cmd_call_economy_balance.cc'
--- src/economy/cmd_call_economy_balance.cc 2014-06-01 18:00:48 +0000
+++ src/economy/cmd_call_economy_balance.cc 2014-07-25 13:46:28 +0000
@@ -68,7 +68,7 @@
68 GameLogicCommand::Read(fr, egbase, mol);68 GameLogicCommand::Read(fr, egbase, mol);
69 uint8_t const player_number = fr.Unsigned8();69 uint8_t const player_number = fr.Unsigned8();
70 if (Player * const player = egbase.get_player(player_number)) {70 if (Player * const player = egbase.get_player(player_number)) {
71 if (not fr.Unsigned8())71 if (!fr.Unsigned8())
72 throw wexception("0 is not allowed here");72 throw wexception("0 is not allowed here");
73 uint16_t const economy_number = fr.Unsigned16();73 uint16_t const economy_number = fr.Unsigned16();
74 if (economy_number < player->get_nr_economies())74 if (economy_number < player->get_nr_economies())
7575
=== modified file 'src/economy/economy.cc'
--- src/economy/economy.cc 2014-07-22 09:54:49 +0000
+++ src/economy/economy.cc 2014-07-25 13:46:28 +0000
@@ -130,7 +130,7 @@
130130
131 Economy * e = f1.get_economy();131 Economy * e = f1.get_economy();
132 // No economy in the editor.132 // No economy in the editor.
133 if (not e)133 if (!e)
134 return;134 return;
135135
136 e->m_split_checks.push_back(std::make_pair(OPtr<Flag>(&f1), OPtr<Flag>(&f2)));136 e->m_split_checks.push_back(std::make_pair(OPtr<Flag>(&f1), OPtr<Flag>(&f2)));
@@ -549,8 +549,8 @@
549 // window for *this where the options window for e is, to give the user549 // window for *this where the options window for e is, to give the user
550 // some continuity.550 // some continuity.
551 if551 if
552 (e.m_optionswindow_registry.window and552 (e.m_optionswindow_registry.window &&
553 not m_optionswindow_registry.window)553 !m_optionswindow_registry.window)
554 {554 {
555 m_optionswindow_registry.x = e.m_optionswindow_registry.x;555 m_optionswindow_registry.x = e.m_optionswindow_registry.x;
556 m_optionswindow_registry.y = e.m_optionswindow_registry.y;556 m_optionswindow_registry.y = e.m_optionswindow_registry.y;
@@ -841,7 +841,7 @@
841 // Requests for heroes should not trigger the creation of more rookies841 // Requests for heroes should not trigger the creation of more rookies
842 if (soldier_level_check)842 if (soldier_level_check)
843 {843 {
844 if (not (req.get_requirements().check(*m_soldier_prototype)))844 if (!(req.get_requirements().check(*m_soldier_prototype)))
845 continue;845 continue;
846 }846 }
847847
848848
=== modified file 'src/economy/economy_data_packet.cc'
--- src/economy/economy_data_packet.cc 2014-05-11 07:38:01 +0000
+++ src/economy/economy_data_packet.cc 2014-07-25 13:46:28 +0000
@@ -36,7 +36,7 @@
36 uint16_t const version = fr.Unsigned16();36 uint16_t const version = fr.Unsigned16();
3737
38 try {38 try {
39 if (1 <= version and version <= CURRENT_ECONOMY_VERSION) {39 if (1 <= version && version <= CURRENT_ECONOMY_VERSION) {
40 if (2 <= version)40 if (2 <= version)
41 try {41 try {
42 const Tribe_Descr & tribe = m_eco->owner().tribe();42 const Tribe_Descr & tribe = m_eco->owner().tribe();
4343
=== modified file 'src/economy/flag.cc'
--- src/economy/flag.cc 2014-07-14 14:40:42 +0000
+++ src/economy/flag.cc 2014-07-25 13:46:28 +0000
@@ -80,7 +80,7 @@
80 auto should_be_deleted = [&egbase, this](const OPtr<Worker>& r) {80 auto should_be_deleted = [&egbase, this](const OPtr<Worker>& r) {
81 Worker& worker = *r.get(egbase);81 Worker& worker = *r.get(egbase);
82 Bob::State const* const state = worker.get_state(Worker::taskWaitforcapacity);82 Bob::State const* const state = worker.get_state(Worker::taskWaitforcapacity);
83 if (not state) {83 if (!state) {
84 log("WARNING: worker %u is in the capacity wait queue of flag %u but "84 log("WARNING: worker %u is in the capacity wait queue of flag %u but "
85 "does not have a waitforcapacity task! Removing from queue.\n",85 "does not have a waitforcapacity task! Removing from queue.\n",
86 worker.serial(),86 worker.serial(),
@@ -138,7 +138,7 @@
138138
139 init(egbase);139 init(egbase);
140140
141 if (road and game)141 if (road && game)
142 road->postsplit(*game, *this);142 road->postsplit(*game, *this);
143}143}
144144
@@ -498,7 +498,7 @@
498 while (!m_capacity_wait.empty()) {498 while (!m_capacity_wait.empty()) {
499 Worker * const w = m_capacity_wait[0].get(game);499 Worker * const w = m_capacity_wait[0].get(game);
500 m_capacity_wait.erase(m_capacity_wait.begin());500 m_capacity_wait.erase(m_capacity_wait.begin());
501 if (w and w->wakeup_flag_capacity(game, *this))501 if (w && w->wakeup_flag_capacity(game, *this))
502 break;502 break;
503 }503 }
504}504}
505505
=== modified file 'src/economy/flag.h'
--- src/economy/flag.h 2014-07-14 14:40:42 +0000
+++ src/economy/flag.h 2014-07-25 13:46:28 +0000
@@ -86,8 +86,8 @@
8686
87 bool has_road() const {87 bool has_road() const {
88 return88 return
89 m_roads[0] or m_roads[1] or m_roads[2] or89 m_roads[0] or m_roads[1] || m_roads[2] ||
90 m_roads[3] or m_roads[4] or m_roads[5];90 m_roads[3] or m_roads[4] || m_roads[5];
91 }91 }
92 Road * get_road(uint8_t const dir) const {return m_roads[dir - 1];}92 Road * get_road(uint8_t const dir) const {return m_roads[dir - 1];}
93 uint8_t nr_of_roads() const;93 uint8_t nr_of_roads() const;
9494
=== modified file 'src/economy/fleet.cc'
--- src/economy/fleet.cc 2014-07-22 09:54:49 +0000
+++ src/economy/fleet.cc 2014-07-25 13:46:28 +0000
@@ -204,7 +204,7 @@
204 */204 */
205void Fleet::merge(Editor_Game_Base & egbase, Fleet * other)205void Fleet::merge(Editor_Game_Base & egbase, Fleet * other)
206{206{
207 if (m_ports.empty() and not other->m_ports.empty()) {207 if (m_ports.empty() && !other->m_ports.empty()) {
208 other->merge(egbase, this);208 other->merge(egbase, this);
209 return;209 return;
210 }210 }
211211
=== modified file 'src/economy/idleworkersupply.cc'
--- src/economy/idleworkersupply.cc 2014-07-14 20:09:27 +0000
+++ src/economy/idleworkersupply.cc 2014-07-25 13:46:28 +0000
@@ -94,7 +94,7 @@
94uint32_t IdleWorkerSupply::nr_supplies(const Game &, const Request & req) const94uint32_t IdleWorkerSupply::nr_supplies(const Game &, const Request & req) const
95{95{
96 assert96 assert
97 (req.get_type() != wwWORKER or97 (req.get_type() != wwWORKER ||
98 req.get_index() < m_worker.descr().tribe().get_nrworkers());98 req.get_index() < m_worker.descr().tribe().get_nrworkers());
99 if99 if
100 (req.get_type() == wwWORKER &&100 (req.get_type() == wwWORKER &&
101101
=== modified file 'src/economy/request.cc'
--- src/economy/request.cc 2014-07-14 10:45:44 +0000
+++ src/economy/request.cc 2014-07-25 13:46:28 +0000
@@ -68,13 +68,13 @@
68 m_required_interval(0),68 m_required_interval(0),
69 m_last_request_time(m_required_time)69 m_last_request_time(m_required_time)
70{70{
71 assert(m_type == wwWARE or m_type == wwWORKER);71 assert(m_type == wwWARE || m_type == wwWORKER);
72 if (w == wwWARE and _target.owner().tribe().get_nrwares() <= index)72 if (w == wwWARE && _target.owner().tribe().get_nrwares() <= index)
73 throw wexception73 throw wexception
74 ("creating ware request with index %u, but tribe has only %u "74 ("creating ware request with index %u, but tribe has only %u "
75 "ware types",75 "ware types",
76 index, _target.owner().tribe().get_nrwares ());76 index, _target.owner().tribe().get_nrwares ());
77 if (w == wwWORKER and _target.owner().tribe().get_nrworkers() <= index)77 if (w == wwWORKER && _target.owner().tribe().get_nrworkers() <= index)
78 throw wexception78 throw wexception
79 ("creating worker request with index %u, but tribe has only %u "79 ("creating worker request with index %u, but tribe has only %u "
80 "worker types",80 "worker types",
@@ -86,7 +86,7 @@
86Request::~Request()86Request::~Request()
87{87{
88 // Remove from the economy88 // Remove from the economy
89 if (is_open() and m_economy)89 if (is_open() && m_economy)
90 m_economy->remove_request(*this);90 m_economy->remove_request(*this);
9191
92 // Cancel all ongoing transfers92 // Cancel all ongoing transfers
@@ -184,10 +184,10 @@
184184
185 // Target and econmy should be set. Same is true for callback stuff.185 // Target and econmy should be set. Same is true for callback stuff.
186186
187 assert(m_type == wwWARE or m_type == wwWORKER);187 assert(m_type == wwWARE || m_type == wwWORKER);
188 const Tribe_Descr & tribe = m_target.owner().tribe();188 const Tribe_Descr & tribe = m_target.owner().tribe();
189 assert(m_type != wwWARE or m_index < tribe.get_nrwares ());189 assert(m_type != wwWARE || m_index < tribe.get_nrwares ());
190 assert(m_type != wwWORKER or m_index < tribe.get_nrworkers());190 assert(m_type != wwWORKER || m_index < tribe.get_nrworkers());
191 fw.CString191 fw.CString
192 (m_type == wwWARE ?192 (m_type == wwWARE ?
193 tribe.get_ware_descr (m_index)->name() :193 tribe.get_ware_descr (m_index)->name() :
@@ -230,7 +230,7 @@
230 (Editor_Game_Base & egbase, uint32_t const nr) const230 (Editor_Game_Base & egbase, uint32_t const nr) const
231{231{
232 if (m_count <= nr) {232 if (m_count <= nr) {
233 if (not(m_count == 1 and nr == 1)) {233 if (!(m_count == 1 && nr == 1)) {
234 log234 log
235 ("Request::get_base_required_time: WARNING nr = %u but count is %u, "235 ("Request::get_base_required_time: WARNING nr = %u but count is %u, "
236 "which is not allowed according to the comment for this function\n",236 "which is not allowed according to the comment for this function\n",
237237
=== modified file 'src/economy/road.cc'
--- src/economy/road.cc 2014-07-23 14:49:10 +0000
+++ src/economy/road.cc 2014-07-25 13:46:28 +0000
@@ -289,8 +289,8 @@
289 carrier->set_location (this);289 carrier->set_location (this);
290 carrier->update_task_road(*game);290 carrier->update_task_road(*game);
291 } else if291 } else if
292 (not i.current->carrier_request and292 (!i.current->carrier_request &&
293 (i.current->carrier_type == 1 or293 (i.current->carrier_type == 1 ||
294 m_type == Road_Busy))294 m_type == Road_Busy))
295 _request_carrier(*i.current);295 _request_carrier(*i.current);
296 }296 }
@@ -543,8 +543,8 @@
543 j.current->carrier = nullptr;543 j.current->carrier = nullptr;
544 container_iterate(SlotVector, newroad.m_carrier_slots, k)544 container_iterate(SlotVector, newroad.m_carrier_slots, k)
545 if545 if
546 (not k.current->carrier.get(game) and546 (!k.current->carrier.get(game) &&
547 not k.current->carrier_request and547 !k.current->carrier_request &&
548 k.current->carrier_type == j.current->carrier_type)548 k.current->carrier_type == j.current->carrier_type)
549 {549 {
550 k.current->carrier = &ref_cast<Carrier, Worker> (w);550 k.current->carrier = &ref_cast<Carrier, Worker> (w);
@@ -571,9 +571,9 @@
571 // work correctly571 // work correctly
572 container_iterate(SlotVector, m_carrier_slots, i)572 container_iterate(SlotVector, m_carrier_slots, i)
573 if573 if
574 (not i.current->carrier.get(game) and574 (!i.current->carrier.get(game) &&
575 not i.current->carrier_request and575 !i.current->carrier_request &&
576 (i.current->carrier_type == 1 or576 (i.current->carrier_type == 1 ||
577 m_type == Road_Busy))577 m_type == Road_Busy))
578 _request_carrier(*i.current);578 _request_carrier(*i.current);
579579
@@ -639,8 +639,8 @@
639 _mark_map(game);639 _mark_map(game);
640 container_iterate(SlotVector, m_carrier_slots, i)640 container_iterate(SlotVector, m_carrier_slots, i)
641 if641 if
642 (not i.current->carrier.get(game) and642 (!i.current->carrier.get(game) &&
643 not i.current->carrier_request and643 !i.current->carrier_request &&
644 i.current->carrier_type != 1)644 i.current->carrier_type != 1)
645 _request_carrier(*i.current);645 _request_carrier(*i.current);
646 }646 }
647647
=== modified file 'src/economy/transfer.cc'
--- src/economy/transfer.cc 2014-07-03 19:26:30 +0000
+++ src/economy/transfer.cc 2014-07-25 13:46:28 +0000
@@ -224,7 +224,7 @@
224 assert(&m_route.get_flag(m_game, 0) == location);224 assert(&m_route.get_flag(m_game, 0) == location);
225225
226 // special rule to get wares into buildings226 // special rule to get wares into buildings
227 if (m_ware and m_route.get_nrsteps() == 1)227 if (m_ware && m_route.get_nrsteps() == 1)
228 if (dynamic_cast<Building const *>(destination)) {228 if (dynamic_cast<Building const *>(destination)) {
229 assert(&m_route.get_flag(m_game, 1) == &destflag);229 assert(&m_route.get_flag(m_game, 1) == &destflag);
230230
231231
=== modified file 'src/economy/ware_instance.cc'
--- src/economy/ware_instance.cc 2014-07-23 14:49:10 +0000
+++ src/economy/ware_instance.cc 2014-07-25 13:46:28 +0000
@@ -230,7 +230,7 @@
230*/230*/
231void WareInstance::set_economy(Economy * const e)231void WareInstance::set_economy(Economy * const e)
232{232{
233 if (m_descr_index == INVALID_INDEX or m_economy == e)233 if (m_descr_index == INVALID_INDEX || m_economy == e)
234 return;234 return;
235235
236 if (m_economy)236 if (m_economy)
237237
=== modified file 'src/economy/wares_queue.cc'
--- src/economy/wares_queue.cc 2014-07-22 09:54:49 +0000
+++ src/economy/wares_queue.cc 2014-07-25 13:46:28 +0000
@@ -258,7 +258,7 @@
258{258{
259 uint16_t const packet_version = fr.Unsigned16();259 uint16_t const packet_version = fr.Unsigned16();
260 try {260 try {
261 if (packet_version == WARES_QUEUE_DATA_PACKET_VERSION or packet_version == 1) {261 if (packet_version == WARES_QUEUE_DATA_PACKET_VERSION || packet_version == 1) {
262 delete m_request;262 delete m_request;
263 m_ware = owner().tribe().ware_index(fr.CString ());263 m_ware = owner().tribe().ware_index(fr.CString ());
264 m_max_size = fr.Unsigned32();264 m_max_size = fr.Unsigned32();
265265
=== modified file 'src/editor/editorinteractive.cc'
--- src/editor/editorinteractive.cc 2014-07-22 09:54:49 +0000
+++ src/editor/editorinteractive.cc 2014-07-25 13:46:28 +0000
@@ -185,7 +185,7 @@
185 m_history.reset();185 m_history.reset();
186186
187 std::unique_ptr<Widelands::Map_Loader> ml(map.get_correct_loader(filename));187 std::unique_ptr<Widelands::Map_Loader> ml(map.get_correct_loader(filename));
188 if (not ml.get())188 if (!ml.get())
189 throw warning189 throw warning
190 (_("Unsupported format"),190 (_("Unsupported format"),
191 _("Widelands could not load the file \"%s\". The file format seems to be incompatible."),191 _("Widelands could not load the file \"%s\". The file format seems to be incompatible."),
@@ -300,7 +300,7 @@
300 tools.current().operates_on_triangles() ?300 tools.current().operates_on_triangles() ?
301 sel.triangle != get_sel_pos().triangle : sel.node != get_sel_pos().node;301 sel.triangle != get_sel_pos().triangle : sel.node != get_sel_pos().node;
302 Interactive_Base::set_sel_pos(sel);302 Interactive_Base::set_sel_pos(sel);
303 if (target_changed and m_left_mouse_button_is_down)303 if (target_changed && m_left_mouse_button_is_down)
304 map_clicked(true);304 map_clicked(true);
305}305}
306306
@@ -500,7 +500,7 @@
500500
501void Editor_Interactive::select_tool501void Editor_Interactive::select_tool
502(Editor_Tool & primary, Editor_Tool::Tool_Index const which) {502(Editor_Tool & primary, Editor_Tool::Tool_Index const which) {
503 if (which == Editor_Tool::First and & primary != tools.current_pointer) {503 if (which == Editor_Tool::First && & primary != tools.current_pointer) {
504 if (primary.has_size_one())504 if (primary.has_size_one())
505 set_sel_radius_and_update_menu(0);505 set_sel_radius_and_update_menu(0);
506 Widelands::Map & map = egbase().map();506 Widelands::Map & map = egbase().map();
@@ -548,7 +548,7 @@
548 references.end();548 references.end();
549 if (player) {549 if (player) {
550 for (; it < references_end; ++it)550 for (; it < references_end; ++it)
551 if (it->player == player and it->object == data) {551 if (it->player == player && it->object == data) {
552 references.erase(it);552 references.erase(it);
553 break;553 break;
554 }554 }
555555
=== modified file 'src/editor/map_generator.cc'
--- src/editor/map_generator.cc 2014-07-22 09:54:49 +0000
+++ src/editor/map_generator.cc 2014-07-25 13:46:28 +0000
@@ -80,7 +80,7 @@
8080
81 const MapGenBobCategory * bobCategory = landResource.getBobCategory(terrType);81 const MapGenBobCategory * bobCategory = landResource.getBobCategory(terrType);
8282
83 if (not bobCategory) // no bobs defined here...83 if (!bobCategory) // no bobs defined here...
84 return;84 return;
8585
86 uint32_t immovDens = landResource.getImmovableDensity();86 uint32_t immovDens = landResource.getImmovableDensity();
@@ -100,14 +100,14 @@
100100
101 // Set bob according to bob area101 // Set bob according to bob area
102102
103 if (set_immovable and (num = bobCategory->num_immovables()))103 if (set_immovable && (num = bobCategory->num_immovables()))
104 egbase_.create_immovable104 egbase_.create_immovable
105 (fc,105 (fc,
106 bobCategory->get_immovable106 bobCategory->get_immovable
107 (static_cast<size_t>(rng.rand() / (kMaxElevation / num))),107 (static_cast<size_t>(rng.rand() / (kMaxElevation / num))),
108 nullptr);108 nullptr);
109109
110 if (set_moveable and (num = bobCategory->num_critters()))110 if (set_moveable && (num = bobCategory->num_critters()))
111 egbase_.create_bob111 egbase_.create_bob
112 (fc,112 (fc,
113 egbase_.world().get_bob113 egbase_.world().get_bob
@@ -286,7 +286,7 @@
286 for (uint32_t x = 0; x < w; x += 16)286 for (uint32_t x = 0; x < w; x += 16)
287 for (uint32_t y = 0; y < h; y += 16) {287 for (uint32_t y = 0; y < h; y += 16) {
288 values[x + y * w] = rng.rand();288 values[x + y * w] = rng.rand();
289 if (x % 32 or y % 32) {289 if (x % 32 || y % 32) {
290 values[x + y * w] += kAverageElevation;290 values[x + y * w] += kAverageElevation;
291 values[x + y * w] /= 2;291 values[x + y * w] /= 2;
292 }292 }
293293
=== modified file 'src/editor/tools/editor_history.cc'
--- src/editor/tools/editor_history.cc 2014-03-01 17:09:07 +0000
+++ src/editor/tools/editor_history.cc 2014-07-25 13:46:28 +0000
@@ -38,7 +38,7 @@
3838
39Editor_Action_Args::~Editor_Action_Args()39Editor_Action_Args::~Editor_Action_Args()
40{40{
41 while (not draw_actions.empty()) {41 while (!draw_actions.empty()) {
42 delete draw_actions.back();42 delete draw_actions.back();
43 draw_actions.pop_back();43 draw_actions.pop_back();
44 }44 }
@@ -105,7 +105,7 @@
105 map, center, parent, tool.format_args(ind, parent));105 map, center, parent, tool.format_args(ind, parent));
106 if (draw && tool.is_unduable()) {106 if (draw && tool.is_unduable()) {
107 if107 if
108 (undo_stack.empty() or108 (undo_stack.empty() ||
109 undo_stack.front().tool.get_sel_impl() != std::string(m_draw_tool.get_sel_impl()))109 undo_stack.front().tool.get_sel_impl() != std::string(m_draw_tool.get_sel_impl()))
110 {110 {
111 Editor_Tool_Action da111 Editor_Tool_Action da
@@ -113,7 +113,7 @@
113 map, center, parent,113 map, center, parent,
114 m_draw_tool.format_args(Editor_Tool::First, parent));114 m_draw_tool.format_args(Editor_Tool::First, parent));
115115
116 if (not undo_stack.empty()) {116 if (!undo_stack.empty()) {
117 m_draw_tool.add_action(undo_stack.front(), *da.args);117 m_draw_tool.add_action(undo_stack.front(), *da.args);
118 undo_stack.pop_front();118 undo_stack.pop_front();
119 }119 }
120120
=== modified file 'src/editor/tools/editor_increase_resources_tool.cc'
--- src/editor/tools/editor_increase_resources_tool.cc 2014-06-05 05:40:53 +0000
+++ src/editor/tools/editor_increase_resources_tool.cc 2014-07-25 13:46:28 +0000
@@ -108,8 +108,8 @@
108 args.orgRes.push_back(mr.location().field->get_resources_amount());108 args.orgRes.push_back(mr.location().field->get_resources_amount());
109109
110 if110 if
111 ((res == args.cur_res or not mr.location().field->get_resources_amount())111 ((res == args.cur_res || !mr.location().field->get_resources_amount())
112 and112 &&
113 Editor_Change_Resource_Tool_Callback(mr.location(), map, world, args.cur_res))113 Editor_Change_Resource_Tool_Callback(mr.location(), map, world, args.cur_res))
114 {114 {
115 // Ok, we're doing something. First remove the current overlays.115 // Ok, we're doing something. First remove the current overlays.
@@ -119,7 +119,7 @@
119 (mr.location().field->get_resources_amount()));119 (mr.location().field->get_resources_amount()));
120 overlay_manager.remove_overlay(mr.location(), pic);120 overlay_manager.remove_overlay(mr.location(), pic);
121121
122 if (not amount) {122 if (!amount) {
123 mr.location().field->set_resources(0, 0);123 mr.location().field->set_resources(0, 0);
124 mr.location().field->set_starting_res_amount(0);124 mr.location().field->set_starting_res_amount(0);
125 } else {125 } else {
126126
=== modified file 'src/editor/tools/editor_place_bob_tool.cc'
--- src/editor/tools/editor_place_bob_tool.cc 2014-04-01 17:30:12 +0000
+++ src/editor/tools/editor_place_bob_tool.cc 2014-07-25 13:46:28 +0000
@@ -48,7 +48,7 @@
48 } while (mr.advance(map));48 } while (mr.advance(map));
49 }49 }
5050
51 if (not args.nbob_type.empty()) {51 if (!args.nbob_type.empty()) {
52 Widelands::Editor_Game_Base & egbase = parent.egbase();52 Widelands::Editor_Game_Base & egbase = parent.egbase();
53 Widelands::MapRegion<Widelands::Area<Widelands::FCoords> > mr53 Widelands::MapRegion<Widelands::Area<Widelands::FCoords> > mr
54 (map,54 (map,
@@ -75,7 +75,7 @@
75 Widelands::Node_and_Triangle<Widelands::Coords> center,75 Widelands::Node_and_Triangle<Widelands::Coords> center,
76 Editor_Interactive& parent,76 Editor_Interactive& parent,
77 Editor_Action_Args& args) {77 Editor_Action_Args& args) {
78 if (not args.nbob_type.empty()) {78 if (!args.nbob_type.empty()) {
79 Widelands::Editor_Game_Base & egbase = parent.egbase();79 Widelands::Editor_Game_Base & egbase = parent.egbase();
80 Widelands::MapRegion<Widelands::Area<Widelands::FCoords> > mr80 Widelands::MapRegion<Widelands::Area<Widelands::FCoords> > mr
81 (map,81 (map,
8282
=== modified file 'src/editor/tools/editor_place_immovable_tool.cc'
--- src/editor/tools/editor_place_immovable_tool.cc 2014-07-03 19:26:30 +0000
+++ src/editor/tools/editor_place_immovable_tool.cc 2014-07-25 13:46:28 +0000
@@ -38,7 +38,7 @@
38 Editor_Interactive& parent,38 Editor_Interactive& parent,
39 Editor_Action_Args& args) {39 Editor_Action_Args& args) {
40 const int32_t radius = args.sel_radius;40 const int32_t radius = args.sel_radius;
41 if (not get_nr_enabled())41 if (!get_nr_enabled())
42 return radius;42 return radius;
43 Widelands::Editor_Game_Base & egbase = parent.egbase();43 Widelands::Editor_Game_Base & egbase = parent.egbase();
44 if (args.oimmov_types.empty())44 if (args.oimmov_types.empty())
@@ -54,7 +54,7 @@
54 } while (mr.advance(map));54 } while (mr.advance(map));
55 }55 }
5656
57 if (not args.nimmov_types.empty())57 if (!args.nimmov_types.empty())
58 {58 {
59 Widelands::MapRegion<Widelands::Area<Widelands::FCoords> > mr59 Widelands::MapRegion<Widelands::Area<Widelands::FCoords> > mr
60 (map,60 (map,
@@ -63,8 +63,8 @@
63 std::list<int32_t>::iterator i = args.nimmov_types.begin();63 std::list<int32_t>::iterator i = args.nimmov_types.begin();
64 do {64 do {
65 if65 if
66 (not mr.location().field->get_immovable()66 (!mr.location().field->get_immovable()
67 and67 &&
68 (mr.location().field->nodecaps() & Widelands::MOVECAPS_WALK))68 (mr.location().field->nodecaps() & Widelands::MOVECAPS_WALK))
69 egbase.create_immovable(mr.location(), *i, nullptr);69 egbase.create_immovable(mr.location(), *i, nullptr);
70 ++i;70 ++i;
7171
=== modified file 'src/editor/tools/editor_set_resources_tool.cc'
--- src/editor/tools/editor_set_resources_tool.cc 2014-06-05 05:40:53 +0000
+++ src/editor/tools/editor_set_resources_tool.cc 2014-07-25 13:46:28 +0000
@@ -61,7 +61,7 @@
61 (world.get_resource(res)->get_editor_pic (mr.location().field->get_resources_amount()));61 (world.get_resource(res)->get_editor_pic (mr.location().field->get_resources_amount()));
62 overlay_manager.remove_overlay(mr.location(), pic);62 overlay_manager.remove_overlay(mr.location(), pic);
6363
64 if (not amount) {64 if (!amount) {
65 mr.location().field->set_resources(0, 0);65 mr.location().field->set_resources(0, 0);
66 mr.location().field->set_starting_res_amount(0);66 mr.location().field->set_starting_res_amount(0);
67 } else {67 } else {
@@ -105,7 +105,7 @@
105 (world.get_resource(res)->get_editor_pic(mr.location().field->get_resources_amount()));105 (world.get_resource(res)->get_editor_pic(mr.location().field->get_resources_amount()));
106 overlay_manager.remove_overlay(mr.location(), pic);106 overlay_manager.remove_overlay(mr.location(), pic);
107107
108 if (not amount) {108 if (!amount) {
109 mr.location().field->set_resources(0, 0);109 mr.location().field->set_resources(0, 0);
110 mr.location().field->set_starting_res_amount(0);110 mr.location().field->set_starting_res_amount(0);
111 } else {111 } else {
112112
=== modified file 'src/editor/tools/editor_set_terrain_tool.cc'
--- src/editor/tools/editor_set_terrain_tool.cc 2014-03-01 17:09:07 +0000
+++ src/editor/tools/editor_set_terrain_tool.cc 2014-07-25 13:46:28 +0000
@@ -31,7 +31,7 @@
31 Editor_Interactive& /* parent */,31 Editor_Interactive& /* parent */,
32 Editor_Action_Args& args) {32 Editor_Action_Args& args) {
33 assert33 assert
34 (center.triangle.t == TCoords<>::D or center.triangle.t == TCoords<>::R);34 (center.triangle.t == TCoords<>::D || center.triangle.t == TCoords<>::R);
35 uint16_t const radius = args.sel_radius;35 uint16_t const radius = args.sel_radius;
36 int32_t max = 0;36 int32_t max = 0;
3737
@@ -50,7 +50,7 @@
50 } while (mr.advance(map));50 } while (mr.advance(map));
51 }51 }
5252
53 if (not args.terrainType.empty()) {53 if (!args.terrainType.empty()) {
54 Widelands::MapTriangleRegion<TCoords<Widelands::FCoords> > mr54 Widelands::MapTriangleRegion<TCoords<Widelands::FCoords> > mr
55 (map, Widelands::Area<TCoords<Widelands::FCoords> >55 (map, Widelands::Area<TCoords<Widelands::FCoords> >
56 (TCoords<Widelands::FCoords>56 (TCoords<Widelands::FCoords>
@@ -74,9 +74,9 @@
74 Editor_Interactive& /* parent */,74 Editor_Interactive& /* parent */,
75 Editor_Action_Args& args) {75 Editor_Action_Args& args) {
76 assert76 assert
77 (center.triangle.t == TCoords<>::D or center.triangle.t == TCoords<>::R);77 (center.triangle.t == TCoords<>::D || center.triangle.t == TCoords<>::R);
78 uint16_t const radius = args.sel_radius;78 uint16_t const radius = args.sel_radius;
79 if (not args.terrainType.empty()) {79 if (!args.terrainType.empty()) {
80 int32_t max = 0;80 int32_t max = 0;
81 Widelands::MapTriangleRegion<TCoords<Widelands::FCoords> > mr81 Widelands::MapTriangleRegion<TCoords<Widelands::FCoords> > mr
82 (map,82 (map,
8383
=== modified file 'src/editor/ui_menus/categorized_item_selection_menu.h'
--- src/editor/ui_menus/categorized_item_selection_menu.h 2014-07-22 09:54:49 +0000
+++ src/editor/ui_menus/categorized_item_selection_menu.h 2014-07-25 13:46:28 +0000
@@ -145,10 +145,10 @@
145 // needs is the key state at the time the mouse was clicked. See the145 // needs is the key state at the time the mouse was clicked. See the
146 // usage comment for get_key_state.146 // usage comment for get_key_state.
147 const bool multiselect = get_key_state(SDLK_LCTRL) | get_key_state(SDLK_RCTRL);147 const bool multiselect = get_key_state(SDLK_LCTRL) | get_key_state(SDLK_RCTRL);
148 if (not t and(not multiselect or tool_->get_nr_enabled() == 1))148 if (!t and(!multiselect || tool_->get_nr_enabled() == 1))
149 checkboxes_[n]->set_state(true);149 checkboxes_[n]->set_state(true);
150 else {150 else {
151 if (not multiselect) {151 if (!multiselect) {
152 for (uint32_t i = 0; tool_->get_nr_enabled(); ++i)152 for (uint32_t i = 0; tool_->get_nr_enabled(); ++i)
153 tool_->enable(i, false);153 tool_->enable(i, false);
154 // disable all checkboxes154 // disable all checkboxes
155155
=== modified file 'src/editor/ui_menus/editor_main_menu_load_map.cc'
--- src/editor/ui_menus/editor_main_menu_load_map.cc 2014-06-21 10:24:12 +0000
+++ src/editor/ui_menus/editor_main_menu_load_map.cc 2014-07-25 13:46:28 +0000
@@ -220,10 +220,10 @@
220 {220 {
221 const char * const name = pname->c_str();221 const char * const name = pname->c_str();
222 if222 if
223 (strcmp(FileSystem::FS_Filename(name), ".") and223 (strcmp(FileSystem::FS_Filename(name), ".") &&
224 strcmp(FileSystem::FS_Filename(name), "..") and224 strcmp(FileSystem::FS_Filename(name), "..") &&
225 g_fs->IsDirectory(name) and225 g_fs->IsDirectory(name) &&
226 not WL_Map_Loader::is_widelands_map(name))226 !WL_Map_Loader::is_widelands_map(name))
227227
228 m_ls->add228 m_ls->add
229 (FileSystem::FS_Filename(name),229 (FileSystem::FS_Filename(name),
230230
=== modified file 'src/editor/ui_menus/editor_main_menu_save_map.cc'
--- src/editor/ui_menus/editor_main_menu_save_map.cc 2014-07-05 14:22:44 +0000
+++ src/editor/ui_menus/editor_main_menu_save_map.cc 2014-07-25 13:46:28 +0000
@@ -172,14 +172,14 @@
172 fill_list();172 fill_list();
173 } else { // Ok, save this map173 } else { // Ok, save this map
174 Widelands::Map & map = eia().egbase().map();174 Widelands::Map & map = eia().egbase().map();
175 if (not strcmp(map.get_name(), _("No Name"))) {175 if (!strcmp(map.get_name(), _("No Name"))) {
176 std::string::size_type const filename_size = filename.size();176 std::string::size_type const filename_size = filename.size();
177 map.set_name177 map.set_name
178 ((4 <= filename_size178 ((4 <= filename_size
179 and filename[filename_size - 1] == 'f'179 && filename[filename_size - 1] == 'f'
180 and filename[filename_size - 2] == 'm'180 && filename[filename_size - 2] == 'm'
181 and filename[filename_size - 3] == 'w'181 && filename[filename_size - 3] == 'w'
182 and filename[filename_size - 4] == '.'182 && filename[filename_size - 4] == '.'
183 ?183 ?
184 filename.substr(0, filename_size - 4) : filename)184 filename.substr(0, filename_size - 4) : filename)
185 .c_str());185 .c_str());
@@ -301,10 +301,10 @@
301 {301 {
302 const char * const name = pname->c_str();302 const char * const name = pname->c_str();
303 if303 if
304 (strcmp(FileSystem::FS_Filename(name), ".") and304 (strcmp(FileSystem::FS_Filename(name), ".") &&
305 strcmp(FileSystem::FS_Filename(name), "..") and305 strcmp(FileSystem::FS_Filename(name), "..") &&
306 g_fs->IsDirectory(name) and306 g_fs->IsDirectory(name) &&
307 not Widelands::WL_Map_Loader::is_widelands_map(name))307 !Widelands::WL_Map_Loader::is_widelands_map(name))
308308
309 m_ls->add309 m_ls->add
310 (FileSystem::FS_Filename(name),310 (FileSystem::FS_Filename(name),
@@ -379,7 +379,7 @@
379 % FileSystem::FS_Filename(filename.c_str())).str();379 % FileSystem::FS_Filename(filename.c_str())).str();
380 UI::WLMessageBox mbox380 UI::WLMessageBox mbox
381 (&eia(), _("Error Saving Map!"), s, UI::WLMessageBox::YESNO);381 (&eia(), _("Error Saving Map!"), s, UI::WLMessageBox::YESNO);
382 if (not mbox.run())382 if (!mbox.run())
383 return false;383 return false;
384384
385 g_fs->Unlink(complete_filename);385 g_fs->Unlink(complete_filename);
386386
=== modified file 'src/editor/ui_menus/editor_player_menu.cc'
--- src/editor/ui_menus/editor_player_menu.cc 2014-07-22 09:54:49 +0000
+++ src/editor/ui_menus/editor_player_menu.cc 2014-07-25 13:46:28 +0000
@@ -227,7 +227,7 @@
227 Widelands::Player_Number const nr_players = old_nr_players - 1;227 Widelands::Player_Number const nr_players = old_nr_players - 1;
228 assert(1 <= nr_players);228 assert(1 <= nr_players);
229229
230 if (not menu.is_player_tribe_referenced(old_nr_players)) {230 if (!menu.is_player_tribe_referenced(old_nr_players)) {
231 if (const Widelands::Coords sp = map.get_starting_pos(old_nr_players)) {231 if (const Widelands::Coords sp = map.get_starting_pos(old_nr_players)) {
232 // Remove starting position marker.232 // Remove starting position marker.
233 char picsname[] = "pics/editor_player_00_starting_pos.png";233 char picsname[] = "pics/editor_player_00_starting_pos.png";
@@ -309,7 +309,7 @@
309void Editor_Player_Menu::player_tribe_clicked(uint8_t n) {309void Editor_Player_Menu::player_tribe_clicked(uint8_t n) {
310 Editor_Interactive & menu =310 Editor_Interactive & menu =
311 ref_cast<Editor_Interactive, UI::Panel>(*get_parent());311 ref_cast<Editor_Interactive, UI::Panel>(*get_parent());
312 if (not menu.is_player_tribe_referenced(n + 1)) {312 if (!menu.is_player_tribe_referenced(n + 1)) {
313 std::string t = m_plr_set_tribes_buts[n]->get_title();313 std::string t = m_plr_set_tribes_buts[n]->get_title();
314 if (!Widelands::Tribe_Descr::exists_tribe(t))314 if (!Widelands::Tribe_Descr::exists_tribe(t))
315 throw wexception315 throw wexception
@@ -412,7 +412,7 @@
412 const Widelands::Player_Number player_number = p->player_number();412 const Widelands::Player_Number player_number = p->player_number();
413 const Widelands::Coords starting_pos = map.get_starting_pos(player_number);413 const Widelands::Coords starting_pos = map.get_starting_pos(player_number);
414 Widelands::BaseImmovable * const imm = map[starting_pos].get_immovable();414 Widelands::BaseImmovable * const imm = map[starting_pos].get_immovable();
415 if (not imm) {415 if (!imm) {
416 // place HQ416 // place HQ
417 const Widelands::Tribe_Descr & tribe = p->tribe();417 const Widelands::Tribe_Descr & tribe = p->tribe();
418 const Widelands::Building_Index idx =418 const Widelands::Building_Index idx =
419419
=== modified file 'src/editor/ui_menus/editor_player_menu_allowed_buildings_menu.cc'
--- src/editor/ui_menus/editor_player_menu_allowed_buildings_menu.cc 2014-07-20 13:00:05 +0000
+++ src/editor/ui_menus/editor_player_menu_allowed_buildings_menu.cc 2014-07-25 13:46:28 +0000
@@ -113,7 +113,7 @@
113 for (Building_Index i = 0; i < nr_buildings; ++i) {113 for (Building_Index i = 0; i < nr_buildings; ++i) {
114 const Widelands::Building_Descr & building =114 const Widelands::Building_Descr & building =
115 *tribe.get_building_descr(i);115 *tribe.get_building_descr(i);
116 if (not building.is_enhanced() and not building.is_buildable())116 if (!building.is_enhanced() && !building.is_buildable())
117 continue;117 continue;
118 (m_player.is_building_type_allowed(i) ? m_allowed : m_forbidden).add118 (m_player.is_building_type_allowed(i) ? m_allowed : m_forbidden).add
119 (building.descname().c_str(), i, building.get_icon());119 (building.descname().c_str(), i, building.get_icon());
120120
=== modified file 'src/editor/ui_menus/editor_tool_place_bob_options_menu.cc'
--- src/editor/ui_menus/editor_tool_place_bob_options_menu.cc 2014-07-22 09:54:49 +0000
+++ src/editor/ui_menus/editor_tool_place_bob_options_menu.cc 2014-07-25 13:46:28 +0000
@@ -125,12 +125,12 @@
125 // TODO(unknown) usage comment for get_key_state.125 // TODO(unknown) usage comment for get_key_state.
126 const bool multiselect =126 const bool multiselect =
127 get_key_state(SDLK_LCTRL) | get_key_state(SDLK_RCTRL);127 get_key_state(SDLK_LCTRL) | get_key_state(SDLK_RCTRL);
128 if (not t and (not multiselect or m_pit.get_nr_enabled() == 1)) {128 if (!t && (!multiselect || m_pit.get_nr_enabled() == 1)) {
129 m_checkboxes[n]->set_state(true);129 m_checkboxes[n]->set_state(true);
130 return;130 return;
131 }131 }
132132
133 if (not multiselect) {133 if (!multiselect) {
134 for (uint32_t i = 0; m_pit.get_nr_enabled(); ++i) m_pit.enable(i, false);134 for (uint32_t i = 0; m_pit.get_nr_enabled(); ++i) m_pit.enable(i, false);
135135
136 // disable all checkboxes136 // disable all checkboxes
137137
=== modified file 'src/game_io/game_interactive_player_data_packet.cc'
--- src/game_io/game_interactive_player_data_packet.cc 2014-05-11 07:38:01 +0000
+++ src/game_io/game_interactive_player_data_packet.cc 2014-07-25 13:46:28 +0000
@@ -47,7 +47,7 @@
47 throw game_data_error("Invalid player number: %i.", player_number);47 throw game_data_error("Invalid player number: %i.", player_number);
48 }48 }
4949
50 if (not game.get_player(player_number)) {50 if (!game.get_player(player_number)) {
51 // This happens if the player, that saved the game, was a spectator51 // This happens if the player, that saved the game, was a spectator
52 // and the slot for player 1 was not used in the game.52 // and the slot for player 1 was not used in the game.
53 // So now we try to create an InteractivePlayer object for another53 // So now we try to create an InteractivePlayer object for another
5454
=== modified file 'src/game_io/game_map_data_packet.cc'
--- src/game_io/game_map_data_packet.cc 2014-06-11 05:06:42 +0000
+++ src/game_io/game_map_data_packet.cc 2014-07-25 13:46:28 +0000
@@ -37,7 +37,7 @@
37void Game_Map_Data_Packet::Read37void Game_Map_Data_Packet::Read
38 (FileSystem & fs, Game & game, Map_Map_Object_Loader * const)38 (FileSystem & fs, Game & game, Map_Map_Object_Loader * const)
39{39{
40 if (not fs.FileExists("map") or not fs.IsDirectory("map"))40 if (!fs.FileExists("map") || !fs.IsDirectory("map"))
41 throw game_data_error("no map");41 throw game_data_error("no map");
4242
43 // Now Load the map as it would be a normal map saving.43 // Now Load the map as it would be a normal map saving.
4444
=== modified file 'src/game_io/game_player_economies_data_packet.cc'
--- src/game_io/game_player_economies_data_packet.cc 2014-07-03 19:26:30 +0000
+++ src/game_io/game_player_economies_data_packet.cc 2014-07-25 13:46:28 +0000
@@ -46,7 +46,7 @@
46 FileRead fr;46 FileRead fr;
47 fr.Open(fs, "binary/player_economies");47 fr.Open(fs, "binary/player_economies");
48 uint16_t const packet_version = fr.Unsigned16();48 uint16_t const packet_version = fr.Unsigned16();
49 if (3 <= packet_version and packet_version <= CURRENT_PACKET_VERSION) {49 if (3 <= packet_version && packet_version <= CURRENT_PACKET_VERSION) {
50 iterate_players_existing(p, nr_players, game, player)50 iterate_players_existing(p, nr_players, game, player)
51 try {51 try {
52 Player::Economies & economies = player->m_economies;52 Player::Economies & economies = player->m_economies;
5353
=== modified file 'src/game_io/game_player_info_data_packet.cc'
--- src/game_io/game_player_info_data_packet.cc 2014-07-05 14:22:44 +0000
+++ src/game_io/game_player_info_data_packet.cc 2014-07-25 13:46:28 +0000
@@ -40,7 +40,7 @@
40 FileRead fr;40 FileRead fr;
41 fr.Open(fs, "binary/player_info");41 fr.Open(fs, "binary/player_info");
42 uint16_t const packet_version = fr.Unsigned16();42 uint16_t const packet_version = fr.Unsigned16();
43 if (5 <= packet_version and packet_version <= CURRENT_PACKET_VERSION) {43 if (5 <= packet_version && packet_version <= CURRENT_PACKET_VERSION) {
44 uint32_t const max_players = fr.Unsigned16();44 uint32_t const max_players = fr.Unsigned16();
45 for (uint32_t i = 1; i < max_players + 1; ++i) {45 for (uint32_t i = 1; i < max_players + 1; ++i) {
46 game.remove_player(i);46 game.remove_player(i);
@@ -48,7 +48,7 @@
48 bool const see_all = fr.Unsigned8();48 bool const see_all = fr.Unsigned8();
4949
50 int32_t const plnum = fr.Unsigned8();50 int32_t const plnum = fr.Unsigned8();
51 if (plnum < 1 or MAX_PLAYERS < plnum)51 if (plnum < 1 || MAX_PLAYERS < plnum)
52 throw game_data_error52 throw game_data_error
53 ("player number (%i) is out of range (1 .. %u)",53 ("player number (%i) is out of range (1 .. %u)",
54 plnum, MAX_PLAYERS);54 plnum, MAX_PLAYERS);
5555
=== modified file 'src/graphic/animation.cc'
--- src/graphic/animation.cc 2014-07-22 09:54:49 +0000
+++ src/graphic/animation.cc 2014-07-25 13:46:28 +0000
@@ -272,7 +272,7 @@
272 if (image_files_.empty())272 if (image_files_.empty())
273 throw wexception("animation without pictures.");273 throw wexception("animation without pictures.");
274274
275 if (pc_mask_image_files_.size() and pc_mask_image_files_.size() != image_files_.size())275 if (pc_mask_image_files_.size() && pc_mask_image_files_.size() != image_files_.size())
276 throw wexception276 throw wexception
277 ("animation has %" PRIuS " frames but playercolor mask has %" PRIuS " frames",277 ("animation has %" PRIuS " frames but playercolor mask has %" PRIuS " frames",
278 image_files_.size(), pc_mask_image_files_.size());278 image_files_.size(), pc_mask_image_files_.size());
@@ -280,7 +280,7 @@
280 for (const std::string& filename : image_files_) {280 for (const std::string& filename : image_files_) {
281 const Image* image = g_gr->images().get(filename);281 const Image* image = g_gr->images().get(filename);
282 if (frames_.size() &&282 if (frames_.size() &&
283 (frames_[0]->width() != image->width() or frames_[0]->height() != image->height())) {283 (frames_[0]->width() != image->width() || frames_[0]->height() != image->height())) {
284 throw wexception("wrong size: (%u, %u), should be (%u, %u) like the first frame",284 throw wexception("wrong size: (%u, %u), should be (%u, %u) like the first frame",
285 image->width(),285 image->width(),
286 image->height(),286 image->height(),
@@ -294,7 +294,7 @@
294 // TODO(unknown) Do not load playercolor mask as opengl texture or use it as294 // TODO(unknown) Do not load playercolor mask as opengl texture or use it as
295 // opengl texture.295 // opengl texture.
296 const Image* pc_image = g_gr->images().get(filename);296 const Image* pc_image = g_gr->images().get(filename);
297 if (frames_[0]->width() != pc_image->width() or frames_[0]->height() != pc_image->height()) {297 if (frames_[0]->width() != pc_image->width() || frames_[0]->height() != pc_image->height()) {
298 // TODO(unknown): see bug #1324642298 // TODO(unknown): see bug #1324642
299 throw wexception("playercolor mask has wrong size: (%u, %u), should "299 throw wexception("playercolor mask has wrong size: (%u, %u), should "
300 "be (%u, %u) like the animation frame",300 "be (%u, %u) like the animation frame",
301301
=== modified file 'src/graphic/color.cc'
--- src/graphic/color.cc 2014-07-14 10:45:44 +0000
+++ src/graphic/color.cc 2014-07-25 13:46:28 +0000
@@ -34,7 +34,7 @@
34}34}
3535
36bool RGBColor::operator == (const RGBColor& other) const {36bool RGBColor::operator == (const RGBColor& other) const {
37 return r == other.r and g == other.g and b == other.b;37 return r == other.r && g == other.g && b == other.b;
38}38}
39bool RGBColor::operator != (const RGBColor& other) const {39bool RGBColor::operator != (const RGBColor& other) const {
40 return !(*this == other);40 return !(*this == other);
4141
=== modified file 'src/graphic/font_handler.cc'
--- src/graphic/font_handler.cc 2014-06-01 18:00:48 +0000
+++ src/graphic/font_handler.cc 2014-07-25 13:46:28 +0000
@@ -180,7 +180,7 @@
180 // Work around an Issue in SDL_TTF that dies when the surface180 // Work around an Issue in SDL_TTF that dies when the surface
181 // has zero width181 // has zero width
182 int width = 0;182 int width = 0;
183 if (TTF_SizeUTF8(font, lce.text.c_str(), &width, nullptr) < 0 or !width) {183 if (TTF_SizeUTF8(font, lce.text.c_str(), &width, nullptr) < 0 || !width) {
184 lce.width = 0;184 lce.width = 0;
185 lce.height = TTF_FontHeight(font);185 lce.height = TTF_FontHeight(font);
186 return;186 return;
187187
=== modified file 'src/graphic/graphic.cc'
--- src/graphic/graphic.cc 2014-07-22 09:54:49 +0000
+++ src/graphic/graphic.cc 2014-07-25 13:46:28 +0000
@@ -114,7 +114,7 @@
114 sdlsurface = SDL_SetVideoMode(w, h, 32, flags);114 sdlsurface = SDL_SetVideoMode(w, h, 32, flags);
115115
116 // If we tried opengl and it was not successful try without opengl116 // If we tried opengl and it was not successful try without opengl
117 if (!sdlsurface and opengl)117 if (!sdlsurface && opengl)
118 {118 {
119 log("Graphics: Could not set videomode: %s, trying without opengl\n", SDL_GetError());119 log("Graphics: Could not set videomode: %s, trying without opengl\n", SDL_GetError());
120 flags &= ~SDL_OPENGL;120 flags &= ~SDL_OPENGL;
@@ -138,7 +138,7 @@
138 // setting the videomode was successful. Print some information now138 // setting the videomode was successful. Print some information now
139 log("Graphics: Setting video mode was successful\n");139 log("Graphics: Setting video mode was successful\n");
140140
141 if (opengl and 0 != (sdlsurface->flags & SDL_GL_DOUBLEBUFFER))141 if (opengl && 0 != (sdlsurface->flags & SDL_GL_DOUBLEBUFFER))
142 log("Graphics: OPENGL DOUBLE BUFFERING ENABLED\n");142 log("Graphics: OPENGL DOUBLE BUFFERING ENABLED\n");
143 if (0 != (sdlsurface->flags & SDL_FULLSCREEN))143 if (0 != (sdlsurface->flags & SDL_FULLSCREEN))
144 log("Graphics: FULLSCREEN ENABLED\n");144 log("Graphics: FULLSCREEN ENABLED\n");
@@ -220,7 +220,7 @@
220220
221 // extensions will be valid if we ever succeeded in runnning glewInit.221 // extensions will be valid if we ever succeeded in runnning glewInit.
222 m_caps.gl.tex_power_of_two =222 m_caps.gl.tex_power_of_two =
223 (m_caps.gl.major_version < 2) and223 (m_caps.gl.major_version < 2) &&
224 (strstr(extensions, "GL_ARB_texture_non_power_of_two") == nullptr);224 (strstr(extensions, "GL_ARB_texture_non_power_of_two") == nullptr);
225 log("Graphics: OpenGL: Textures ");225 log("Graphics: OpenGL: Textures ");
226 log226 log
@@ -228,7 +228,7 @@
228 "may have any size\n");228 "may have any size\n");
229229
230 m_caps.gl.multitexture =230 m_caps.gl.multitexture =
231 ((strstr(extensions, "GL_ARB_multitexture") != nullptr) and231 ((strstr(extensions, "GL_ARB_multitexture") != nullptr) &&
232 (strstr(extensions, "GL_ARB_texture_env_combine") != nullptr));232 (strstr(extensions, "GL_ARB_texture_env_combine") != nullptr));
233 log("Graphics: OpenGL: Multitexture capabilities ");233 log("Graphics: OpenGL: Multitexture capabilities ");
234 log(m_caps.gl.multitexture ? "sufficient\n" : "insufficient, only basic terrain rendering possible\n");234 log(m_caps.gl.multitexture ? "sufficient\n" : "insufficient, only basic terrain rendering possible\n");
@@ -443,7 +443,7 @@
443 return;443 return;
444 }444 }
445445
446 if (force or m_update_fullscreen) {446 if (force || m_update_fullscreen) {
447 //flip defaults to SDL_UpdateRect(m_surface, 0, 0, 0, 0);447 //flip defaults to SDL_UpdateRect(m_surface, 0, 0, 0, 0);
448 SDL_Flip(m_sdl_screen);448 SDL_Flip(m_sdl_screen);
449 } else449 } else
450450
=== modified file 'src/graphic/image_transformations.cc'
--- src/graphic/image_transformations.cc 2014-07-14 10:45:44 +0000
+++ src/graphic/image_transformations.cc 2014-07-25 13:46:28 +0000
@@ -425,7 +425,7 @@
425}425}
426426
427const Image* resize(const Image* original, uint16_t w, uint16_t h) {427const Image* resize(const Image* original, uint16_t w, uint16_t h) {
428 if (original->width() == w and original->height() == h)428 if (original->width() == w && original->height() == h)
429 return original;429 return original;
430430
431 const string new_hash = (boost::format("%s:%i:%i") % original->hash() % w % h).str();431 const string new_hash = (boost::format("%s:%i:%i") % original->hash() % w % h).str();
432432
=== modified file 'src/graphic/render/gl_surface_texture.cc'
--- src/graphic/render/gl_surface_texture.cc 2014-06-25 05:42:44 +0000
+++ src/graphic/render/gl_surface_texture.cc 2014-07-25 13:46:28 +0000
@@ -85,9 +85,9 @@
85 uint8_t bpp = surface->format->BytesPerPixel;85 uint8_t bpp = surface->format->BytesPerPixel;
8686
87 if87 if
88 (surface->format->palette or (surface->format->colorkey > 0) or88 (surface->format->palette || (surface->format->colorkey > 0) ||
89 m_tex_w != static_cast<uint32_t>(surface->w) or89 m_tex_w != static_cast<uint32_t>(surface->w) ||
90 m_tex_h != static_cast<uint32_t>(surface->h) or90 m_tex_h != static_cast<uint32_t>(surface->h) ||
91 (bpp != 3 && bpp != 4))91 (bpp != 3 && bpp != 4))
92 {92 {
93 SDL_Surface * converted = SDL_CreateRGBSurface93 SDL_Surface * converted = SDL_CreateRGBSurface
@@ -109,7 +109,7 @@
109109
110 if (bpp == 4) {110 if (bpp == 4) {
111 if111 if
112 (fmt.Rmask == 0x000000ff and fmt.Gmask == 0x0000ff00 and112 (fmt.Rmask == 0x000000ff && fmt.Gmask == 0x0000ff00 &&
113 fmt.Bmask == 0x00ff0000)113 fmt.Bmask == 0x00ff0000)
114 {114 {
115 if (fmt.Amask == 0xff000000) {115 if (fmt.Amask == 0xff000000) {
@@ -121,7 +121,7 @@
121 glPixelTransferi(GL_ALPHA_BIAS, 1.0f);121 glPixelTransferi(GL_ALPHA_BIAS, 1.0f);
122 }122 }
123 } else if123 } else if
124 (fmt.Bmask == 0x000000ff and fmt.Gmask == 0x0000ff00 and124 (fmt.Bmask == 0x000000ff && fmt.Gmask == 0x0000ff00 &&
125 fmt.Rmask == 0x00ff0000)125 fmt.Rmask == 0x00ff0000)
126 {126 {
127 if (fmt.Amask == 0xff000000) {127 if (fmt.Amask == 0xff000000) {
@@ -136,12 +136,12 @@
136 throw wexception("OpenGL: Unknown pixel format");136 throw wexception("OpenGL: Unknown pixel format");
137 } else if (bpp == 3) {137 } else if (bpp == 3) {
138 if138 if
139 (fmt.Rmask == 0x000000ff and fmt.Gmask == 0x0000ff00 and139 (fmt.Rmask == 0x000000ff && fmt.Gmask == 0x0000ff00 &&
140 fmt.Bmask == 0x00ff0000)140 fmt.Bmask == 0x00ff0000)
141 {141 {
142 pixels_format = GL_RGB;142 pixels_format = GL_RGB;
143 } else if143 } else if
144 (fmt.Bmask == 0x000000ff and fmt.Gmask == 0x0000ff00 and144 (fmt.Bmask == 0x000000ff && fmt.Gmask == 0x0000ff00 &&
145 fmt.Rmask == 0x00ff0000)145 fmt.Rmask == 0x00ff0000)
146 {146 {
147 pixels_format = GL_BGR;147 pixels_format = GL_BGR;
148148
=== modified file 'src/graphic/render/minimaprenderer.cc'
--- src/graphic/render/minimaprenderer.cc 2014-07-22 09:54:49 +0000
+++ src/graphic/render/minimaprenderer.cc 2014-07-25 13:46:28 +0000
@@ -87,15 +87,15 @@
87 // * winterland -> orange87 // * winterland -> orange
8888
89 if (upcast(PlayerImmovable const, immovable, f.field->get_immovable())) {89 if (upcast(PlayerImmovable const, immovable, f.field->get_immovable())) {
90 if ((layers & MiniMapLayer::Road) and dynamic_cast<Road const *>(immovable)) {90 if ((layers & MiniMapLayer::Road) && dynamic_cast<Road const *>(immovable)) {
91 pixelcolor = blend_color(format, pixelcolor, 255, 255, 255);91 pixelcolor = blend_color(format, pixelcolor, 255, 255, 255);
92 }92 }
9393
94 if94 if
95 (((layers & MiniMapLayer::Flag) and dynamic_cast<Flag const *>(immovable))95 (((layers & MiniMapLayer::Flag) && dynamic_cast<Flag const *>(immovable))
96 or96 ||
97 ((layers & MiniMapLayer::Building)97 ((layers & MiniMapLayer::Building)
98 and98 &&
99 dynamic_cast<Widelands::Building const *>(immovable)))99 dynamic_cast<Widelands::Building const *>(immovable)))
100 {100 {
101 pixelcolor = SDL_MapRGB(&const_cast<SDL_PixelFormat&>(format), 255, 255, 255);101 pixelcolor = SDL_MapRGB(&const_cast<SDL_PixelFormat&>(format), 255, 255, 255);
@@ -187,7 +187,7 @@
187 uint32_t modx = pbottomright.x % 2;187 uint32_t modx = pbottomright.x % 2;
188 uint32_t mody = pbottomright.y % 2;188 uint32_t mody = pbottomright.y % 2;
189189
190 if (not player or player->see_all()) {190 if (!player || player->see_all()) {
191 for (uint32_t y = 0; y < surface_h; ++y) {191 for (uint32_t y = 0; y < surface_h; ++y) {
192 uint8_t * pix = pixels + y * pitch;192 uint8_t * pix = pixels + y * pitch;
193 Widelands::FCoords f193 Widelands::FCoords f
194194
=== modified file 'src/graphic/render/terrain_sdl.h'
--- src/graphic/render/terrain_sdl.h 2014-07-23 14:49:10 +0000
+++ src/graphic/render/terrain_sdl.h 2014-07-25 13:46:28 +0000
@@ -540,7 +540,7 @@
540 continue;540 continue;
541541
542 for (int32_t i = 0, y = (centery >> 16) - 2; i < 5; ++i, ++y)542 for (int32_t i = 0, y = (centery >> 16) - 2; i < 5; ++i, ++y)
543 if (0 < y and y < dsth)543 if (0 < y && y < dsth)
544 reinterpret_cast<T *>544 reinterpret_cast<T *>
545 (static_cast<uint8_t *>(dst.get_pixels()) + y * dst.get_pitch())545 (static_cast<uint8_t *>(dst.get_pixels()) + y * dst.get_pitch())
546 [x]546 [x]
@@ -567,7 +567,7 @@
567 continue;567 continue;
568568
569 for (int32_t i = 0, x = (centerx >> 16) - 2; i < 5; ++i, ++x)569 for (int32_t i = 0, x = (centerx >> 16) - 2; i < 5; ++i, ++x)
570 if (0 < x and x < dstw)570 if (0 < x && x < dstw)
571 reinterpret_cast<T *>571 reinterpret_cast<T *>
572 (static_cast<uint8_t *>(dst.get_pixels()) + y * dst.get_pitch())572 (static_cast<uint8_t *>(dst.get_pixels()) + y * dst.get_pitch())
573 [x]573 [x]
@@ -604,7 +604,7 @@
604 uint8_t road;604 uint8_t road;
605605
606 road = (roads >> Widelands::Road_East) & Widelands::Road_Mask;606 road = (roads >> Widelands::Road_East) & Widelands::Road_Mask;
607 if (-128 < f_vert.b or -128 < r_vert.b) {607 if (-128 < f_vert.b || -128 < r_vert.b) {
608 if (road) {608 if (road) {
609 switch (road) {609 switch (road) {
610 case Widelands::Road_Normal:610 case Widelands::Road_Normal:
@@ -623,7 +623,7 @@
623 }623 }
624624
625 road = (roads >> Widelands::Road_SouthEast) & Widelands::Road_Mask;625 road = (roads >> Widelands::Road_SouthEast) & Widelands::Road_Mask;
626 if (-128 < f_vert.b or -128 < br_vert.b) {626 if (-128 < f_vert.b || -128 < br_vert.b) {
627 if (road) {627 if (road) {
628 switch (road) {628 switch (road) {
629 case Widelands::Road_Normal:629 case Widelands::Road_Normal:
@@ -642,7 +642,7 @@
642 }642 }
643643
644 road = (roads >> Widelands::Road_SouthWest) & Widelands::Road_Mask;644 road = (roads >> Widelands::Road_SouthWest) & Widelands::Road_Mask;
645 if (-128 < f_vert.b or -128 < bl_vert.b) {645 if (-128 < f_vert.b || -128 < bl_vert.b) {
646 if (road) {646 if (road) {
647 switch (road) {647 switch (road) {
648 case Widelands::Road_Normal:648 case Widelands::Road_Normal:
649649
=== modified file 'src/graphic/rendertarget.cc'
--- src/graphic/rendertarget.cc 2014-07-23 14:49:10 +0000
+++ src/graphic/rendertarget.cc 2014-07-25 13:46:28 +0000
@@ -367,7 +367,7 @@
367 r.x += m_rect.x;367 r.x += m_rect.x;
368 r.y += m_rect.y;368 r.y += m_rect.y;
369369
370 return r.w and r.h;370 return r.w && r.h;
371}371}
372372
373/**373/**
374374
=== modified file 'src/graphic/text/rt_parse.cc'
--- src/graphic/text/rt_parse.cc 2014-07-14 10:45:44 +0000
+++ src/graphic/text/rt_parse.cc 2014-07-25 13:46:28 +0000
@@ -50,7 +50,7 @@
50}50}
5151
52bool Attr::get_bool() const {52bool Attr::get_bool() const {
53 if (m_value == "true" or m_value == "1" or m_value == "yes")53 if (m_value == "true" || m_value == "1" || m_value == "yes")
54 return true;54 return true;
55 return false;55 return false;
56}56}
@@ -132,13 +132,13 @@
132 TagConstraint tc = tcs[m_name];132 TagConstraint tc = tcs[m_name];
133133
134 for (;;) {134 for (;;) {
135 if (not tc.text_allowed)135 if (!tc.text_allowed)
136 ts.skip_ws();136 ts.skip_ws();
137137
138 size_t line = ts.line(), col = ts.col();138 size_t line = ts.line(), col = ts.col();
139 std::string text = ts.till_any("<");139 std::string text = ts.till_any("<");
140 if (text != "") {140 if (text != "") {
141 if (not tc.text_allowed)141 if (!tc.text_allowed)
142 throw SyntaxError_Impl(line, col, "no text, as only tags are allowed here", text, ts.peek(100));142 throw SyntaxError_Impl(line, col, "no text, as only tags are allowed here", text, ts.peek(100));
143 m_childs.push_back(new Child(text));143 m_childs.push_back(new Child(text));
144 }144 }
@@ -151,7 +151,7 @@
151 child->parse(ts, tcs, allowed_tags);151 child->parse(ts, tcs, allowed_tags);
152 if (!tc.allowed_childs.count(child->name()))152 if (!tc.allowed_childs.count(child->name()))
153 throw SyntaxError_Impl(line, col, "an allowed tag", child->name(), ts.peek(100, cpos));153 throw SyntaxError_Impl(line, col, "an allowed tag", child->name(), ts.peek(100, cpos));
154 if (!allowed_tags.empty() and !allowed_tags.count(child->name()))154 if (!allowed_tags.empty() && !allowed_tags.count(child->name()))
155 throw SyntaxError_Impl(line, col, "an allowed tag", child->name(), ts.peek(100, cpos));155 throw SyntaxError_Impl(line, col, "an allowed tag", child->name(), ts.peek(100, cpos));
156156
157 m_childs.push_back(new Child(child));157 m_childs.push_back(new Child(child));
158158
=== modified file 'src/graphic/text/sdl_ttf_font.cc'
--- src/graphic/text/sdl_ttf_font.cc 2014-07-14 10:45:44 +0000
+++ src/graphic/text/sdl_ttf_font.cc 2014-07-25 13:46:28 +0000
@@ -115,7 +115,7 @@
115 } else115 } else
116 text_surface = TTF_RenderUTF8_Blended(font_, txt.c_str(), sdlclr);116 text_surface = TTF_RenderUTF8_Blended(font_, txt.c_str(), sdlclr);
117117
118 if (not text_surface)118 if (!text_surface)
119 throw RenderError((format("Rendering '%s' gave the error: %s") % txt % TTF_GetError()).str());119 throw RenderError((format("Rendering '%s' gave the error: %s") % txt % TTF_GetError()).str());
120120
121 return *surface_cache->insert(hash, Surface::create(text_surface), true);121 return *surface_cache->insert(hash, Surface::create(text_surface), true);
122122
=== modified file 'src/graphic/text/test/render_richtext.cc'
--- src/graphic/text/test/render_richtext.cc 2014-07-01 07:12:55 +0000
+++ src/graphic/text/test/render_richtext.cc 2014-07-25 13:46:28 +0000
@@ -41,7 +41,7 @@
4141
42std::string read_stdin() {42std::string read_stdin() {
43 std::string txt;43 std::string txt;
44 while (not std::cin.eof()) {44 while (!std::cin.eof()) {
45 std::string line;45 std::string line;
46 getline(std::cin, line);46 getline(std::cin, line);
47 txt += line + "\n";47 txt += line + "\n";
4848
=== modified file 'src/graphic/text/textstream.cc'
--- src/graphic/text/textstream.cc 2013-07-26 20:19:36 +0000
+++ src/graphic/text/textstream.cc 2014-07-25 13:46:28 +0000
@@ -53,11 +53,11 @@
53 * r* means skip_ws starting from the back of the string53 * r* means skip_ws starting from the back of the string
54 */54 */
55void TextStream::skip_ws() {55void TextStream::skip_ws() {
56 while (m_i < m_end and isspace(m_t[m_i]))56 while (m_i < m_end && isspace(m_t[m_i]))
57 m_consume(1);57 m_consume(1);
58}58}
59void TextStream::rskip_ws() {59void TextStream::rskip_ws() {
60 while (m_i < m_end and isspace(m_t[m_end - 1]))60 while (m_i < m_end && isspace(m_t[m_end - 1]))
61 --m_end;61 --m_end;
62}62}
6363
@@ -133,7 +133,7 @@
133 */133 */
134string TextStream::parse_string() {134string TextStream::parse_string() {
135 string delim = peek(1);135 string delim = peek(1);
136 if (delim == "'" or delim == "\"") {136 if (delim == "'" || delim == "\"") {
137 m_consume(1);137 m_consume(1);
138 string rv = till_any(delim);138 string rv = till_any(delim);
139 m_consume(1);139 m_consume(1);
140140
=== modified file 'src/graphic/text_parser.cc'
--- src/graphic/text_parser.cc 2014-07-05 14:22:44 +0000
+++ src/graphic/text_parser.cc 2014-07-25 13:46:28 +0000
@@ -181,7 +181,7 @@
181 }181 }
182182
183 block.erase(0, block_start.size());183 block.erase(0, block_start.size());
184 if (block.size() and *block.begin() == ' ')184 if (block.size() && *block.begin() == ' ')
185 block.erase(0, 1);185 block.erase(0, 1);
186186
187 const std::string::size_type format_end_pos = block.find(format_end);187 const std::string::size_type format_end_pos = block.find(format_end);
188188
=== modified file 'src/io/fileread.cc'
--- src/io/fileread.cc 2014-06-18 14:23:22 +0000
+++ src/io/fileread.cc 2014-07-25 13:46:28 +0000
@@ -71,7 +71,7 @@
71size_t FileRead::Data(void* dst, size_t bufsize) {71size_t FileRead::Data(void* dst, size_t bufsize) {
72 assert(data_);72 assert(data_);
73 size_t read = 0;73 size_t read = 0;
74 for (; read < bufsize and filepos_ < length_; ++read, ++filepos_) {74 for (; read < bufsize && filepos_ < length_; ++read, ++filepos_) {
75 static_cast<char*>(dst)[read] = data_[filepos_];75 static_cast<char*>(dst)[read] = data_[filepos_];
76 }76 }
77 return read;77 return read;
@@ -114,7 +114,7 @@
114 if (EndOfFile())114 if (EndOfFile())
115 return nullptr;115 return nullptr;
116 char* result = data_ + filepos_;116 char* result = data_ + filepos_;
117 for (; data_[filepos_] and data_[filepos_] != '\n'; ++filepos_)117 for (; data_[filepos_] && data_[filepos_] != '\n'; ++filepos_)
118 if (data_[filepos_] == '\r') {118 if (data_[filepos_] == '\r') {
119 data_[filepos_] = '\0';119 data_[filepos_] = '\0';
120 ++filepos_;120 ++filepos_;
121121
=== modified file 'src/io/filesystem/disk_filesystem.cc'
--- src/io/filesystem/disk_filesystem.cc 2014-07-23 14:49:10 +0000
+++ src/io/filesystem/disk_filesystem.cc 2014-07-25 13:46:28 +0000
@@ -60,7 +60,7 @@
60 struct stat st;60 struct stat st;
6161
62 m_exists = (stat(c_str(), &st) != -1);62 m_exists = (stat(c_str(), &st) != -1);
63 m_isDirectory = m_exists and S_ISDIR(st.st_mode);63 m_isDirectory = m_exists && S_ISDIR(st.st_mode);
64 }64 }
65};65};
6666
@@ -291,7 +291,7 @@
291 it = dirname.find(m_filesep, it);291 it = dirname.find(m_filesep, it);
292292
293 FileSystemPath fspath(FS_CanonicalizeName(dirname.substr(0, it)));293 FileSystemPath fspath(FS_CanonicalizeName(dirname.substr(0, it)));
294 if (fspath.m_exists and !fspath.m_isDirectory)294 if (fspath.m_exists && !fspath.m_isDirectory)
295 throw wexception295 throw wexception
296 ("%s exists and is not a directory",296 ("%s exists and is not a directory",
297 dirname.substr(0, it).c_str());297 dirname.substr(0, it).c_str());
@@ -353,7 +353,7 @@
353353
354 try {354 try {
355 file = fopen(fullname.c_str(), "rb");355 file = fopen(fullname.c_str(), "rb");
356 if (not file)356 if (!file)
357 throw File_error("RealFSImpl::Load", fullname.c_str());357 throw File_error("RealFSImpl::Load", fullname.c_str());
358358
359 // determine the size of the file (rather quirky, but it doesn't require359 // determine the size of the file (rather quirky, but it doesn't require
@@ -374,7 +374,7 @@
374 // allocate a buffer and read the entire file into it374 // allocate a buffer and read the entire file into it
375 data = malloc(size + 1); // TODO(unknown) memory leak!375 data = malloc(size + 1); // TODO(unknown) memory leak!
376 int result = fread(data, size, 1, file);376 int result = fread(data, size, 1, file);
377 if (size and (result != 1)) {377 if (size && (result != 1)) {
378 throw wexception378 throw wexception
379 ("RealFSImpl::Load: read failed for %s (%s) with size %" PRIuS "",379 ("RealFSImpl::Load: read failed for %s (%s) with size %" PRIuS "",
380 fname.c_str(), fullname.c_str(), size);380 fname.c_str(), fullname.c_str(), size);
@@ -416,7 +416,7 @@
416 size_t const c = fwrite(data, length, 1, f);416 size_t const c = fwrite(data, length, 1, f);
417 fclose(f);417 fclose(f);
418418
419 if (length and c != 1) // data might be 0 blocks long419 if (length && c != 1) // data might be 0 blocks long
420 throw wexception420 throw wexception
421 ("Write to %s (%s) failed", fname.c_str(), fullname.c_str());421 ("Write to %s (%s) failed", fname.c_str(), fullname.c_str());
422}422}
423423
=== modified file 'src/io/filesystem/filesystem.cc'
--- src/io/filesystem/filesystem.cc 2014-07-23 14:49:10 +0000
+++ src/io/filesystem/filesystem.cc 2014-07-25 13:46:28 +0000
@@ -161,7 +161,7 @@
161 // their own "standards"?161 // their own "standards"?
162#define TRY_USE_AS_HOMEDIR(name) \162#define TRY_USE_AS_HOMEDIR(name) \
163 homedir = getenv(name); \163 homedir = getenv(name); \
164 if (homedir.size() and check_writeable_for_data(homedir.c_str())) \164 if (homedir.size() && check_writeable_for_data(homedir.c_str())) \
165 return homedir; \165 return homedir; \
166166
167 TRY_USE_AS_HOMEDIR("USERPROFILE");167 TRY_USE_AS_HOMEDIR("USERPROFILE");
168168
=== modified file 'src/io/filesystem/layered_filesystem.cc'
--- src/io/filesystem/layered_filesystem.cc 2014-07-23 14:49:10 +0000
+++ src/io/filesystem/layered_filesystem.cc 2014-07-25 13:46:28 +0000
@@ -103,7 +103,7 @@
103 * Returns true if the file can be found in at least one of the sub-filesystems103 * Returns true if the file can be found in at least one of the sub-filesystems
104 */104 */
105bool LayeredFileSystem::FileExists(const std::string & path) {105bool LayeredFileSystem::FileExists(const std::string & path) {
106 if (m_home and m_home->FileExists(path))106 if (m_home && m_home->FileExists(path))
107 return true;107 return true;
108 for (auto it = m_filesystems.rbegin(); it != m_filesystems.rend(); ++it)108 for (auto it = m_filesystems.rbegin(); it != m_filesystems.rend(); ++it)
109 if ((*it)->FileExists(path))109 if ((*it)->FileExists(path))
@@ -117,7 +117,7 @@
117 */117 */
118// TODO(unknown): What if it's a file in some and a dir in others?????118// TODO(unknown): What if it's a file in some and a dir in others?????
119bool LayeredFileSystem::IsDirectory(const std::string & path) {119bool LayeredFileSystem::IsDirectory(const std::string & path) {
120 if (m_home and m_home->IsDirectory(path))120 if (m_home && m_home->IsDirectory(path))
121 return true;121 return true;
122122
123 for (auto it = m_filesystems.rbegin(); it != m_filesystems.rend(); ++it)123 for (auto it = m_filesystems.rbegin(); it != m_filesystems.rend(); ++it)
@@ -153,7 +153,7 @@
153void LayeredFileSystem::Write153void LayeredFileSystem::Write
154 (const std::string & fname, void const * const data, int32_t const length)154 (const std::string & fname, void const * const data, int32_t const length)
155{155{
156 if (m_home and m_home->IsWritable())156 if (m_home && m_home->IsWritable())
157 return m_home->Write(fname, data, length);157 return m_home->Write(fname, data, length);
158158
159 for (auto it = m_filesystems.rbegin(); it != m_filesystems.rend(); ++it)159 for (auto it = m_filesystems.rbegin(); it != m_filesystems.rend(); ++it)
@@ -225,11 +225,11 @@
225 */225 */
226FileSystem * LayeredFileSystem::MakeSubFileSystem(const std::string & dirname)226FileSystem * LayeredFileSystem::MakeSubFileSystem(const std::string & dirname)
227{227{
228 if (m_home and m_home->IsWritable() and m_home->FileExists(dirname))228 if (m_home && m_home->IsWritable() && m_home->FileExists(dirname))
229 return m_home->MakeSubFileSystem(dirname);229 return m_home->MakeSubFileSystem(dirname);
230230
231 for (auto it = m_filesystems.rbegin(); it != m_filesystems.rend(); ++it)231 for (auto it = m_filesystems.rbegin(); it != m_filesystems.rend(); ++it)
232 if ((*it)->IsWritable() and (*it)->FileExists(dirname))232 if ((*it)->IsWritable() && (*it)->FileExists(dirname))
233 return (*it)->MakeSubFileSystem(dirname);233 return (*it)->MakeSubFileSystem(dirname);
234234
235 throw wexception("LayeredFileSystem: unable to create sub filesystem");235 throw wexception("LayeredFileSystem: unable to create sub filesystem");
@@ -240,11 +240,11 @@
240 */240 */
241FileSystem * LayeredFileSystem::CreateSubFileSystem(const std::string & dirname, Type const type)241FileSystem * LayeredFileSystem::CreateSubFileSystem(const std::string & dirname, Type const type)
242{242{
243 if (m_home and m_home->IsWritable() and not m_home->FileExists(dirname))243 if (m_home && m_home->IsWritable() && !m_home->FileExists(dirname))
244 return m_home->CreateSubFileSystem(dirname, type);244 return m_home->CreateSubFileSystem(dirname, type);
245245
246 for (auto it = m_filesystems.rbegin(); it != m_filesystems.rend(); ++it)246 for (auto it = m_filesystems.rbegin(); it != m_filesystems.rend(); ++it)
247 if ((*it)->IsWritable() and not (*it)->FileExists(dirname))247 if ((*it)->IsWritable() && !(*it)->FileExists(dirname))
248 return (*it)->CreateSubFileSystem(dirname, type);248 return (*it)->CreateSubFileSystem(dirname, type);
249249
250 throw wexception("LayeredFileSystem: unable to create sub filesystem");250 throw wexception("LayeredFileSystem: unable to create sub filesystem");
@@ -257,12 +257,12 @@
257 if (!FileExists(file))257 if (!FileExists(file))
258 return;258 return;
259259
260 if (m_home and m_home->IsWritable() and m_home->FileExists(file)) {260 if (m_home && m_home->IsWritable() && m_home->FileExists(file)) {
261 m_home->Unlink(file);261 m_home->Unlink(file);
262 return;262 return;
263 }263 }
264 for (auto it = m_filesystems.rbegin(); it != m_filesystems.rend(); ++it)264 for (auto it = m_filesystems.rbegin(); it != m_filesystems.rend(); ++it)
265 if ((*it)->IsWritable() and (*it)->FileExists(file)) {265 if ((*it)->IsWritable() && (*it)->FileExists(file)) {
266 (*it)->Unlink(file);266 (*it)->Unlink(file);
267 return;267 return;
268 }268 }
@@ -273,12 +273,12 @@
273{273{
274 if (!FileExists(old_name))274 if (!FileExists(old_name))
275 return;275 return;
276 if (m_home and m_home->IsWritable() and m_home->FileExists(old_name)) {276 if (m_home && m_home->IsWritable() && m_home->FileExists(old_name)) {
277 m_home->Rename(old_name, new_name);277 m_home->Rename(old_name, new_name);
278 return;278 return;
279 }279 }
280 for (auto it = m_filesystems.rbegin(); it != m_filesystems.rend(); ++it)280 for (auto it = m_filesystems.rbegin(); it != m_filesystems.rend(); ++it)
281 if ((*it)->IsWritable() and (*it)->FileExists(old_name)) {281 if ((*it)->IsWritable() && (*it)->FileExists(old_name)) {
282 (*it)->Rename(old_name, new_name);282 (*it)->Rename(old_name, new_name);
283 return;283 return;
284 }284 }
285285
=== modified file 'src/io/filesystem/zip_filesystem.cc'
--- src/io/filesystem/zip_filesystem.cc 2014-07-23 14:49:10 +0000
+++ src/io/filesystem/zip_filesystem.cc 2014-07-25 13:46:28 +0000
@@ -341,7 +341,7 @@
341 unzCloseCurrentFile(m_unzipfile);341 unzCloseCurrentFile(m_unzipfile);
342342
343 void * const result = malloc(totallen + 1);343 void * const result = malloc(totallen + 1);
344 if (not result)344 if (!result)
345 throw std::bad_alloc();345 throw std::bad_alloc();
346 unzOpenCurrentFile(m_unzipfile);346 unzOpenCurrentFile(m_unzipfile);
347 unzReadCurrentFile(m_unzipfile, result, totallen);347 unzReadCurrentFile(m_unzipfile, result, totallen);
348348
=== modified file 'src/io/filewrite.cc'
--- src/io/filewrite.cc 2014-07-14 10:45:44 +0000
+++ src/io/filewrite.cc 2014-07-25 13:46:28 +0000
@@ -55,7 +55,7 @@
55}55}
5656
57void FileWrite::Data(const void* const src, const size_t size, Pos const pos = Pos::Null()) {57void FileWrite::Data(const void* const src, const size_t size, Pos const pos = Pos::Null()) {
58 assert(data_ or not length_);58 assert(data_ || !length_);
5959
60 Pos i = pos;60 Pos i = pos;
61 if (pos.isNull()) {61 if (pos.isNull()) {
6262
=== modified file 'src/logic/battle.cc'
--- src/logic/battle.cc 2014-07-22 09:54:49 +0000
+++ src/logic/battle.cc 2014-07-25 13:46:28 +0000
@@ -68,7 +68,7 @@
68 }68 }
6969
70 // Ensures only live soldiers eganges in a battle70 // Ensures only live soldiers eganges in a battle
71 assert(First.get_current_hitpoints() and Second.get_current_hitpoints());71 assert(First.get_current_hitpoints() && Second.get_current_hitpoints());
7272
73 init(game);73 init(game);
74}74}
@@ -133,7 +133,7 @@
133133
134Soldier * Battle::opponent(Soldier& soldier)134Soldier * Battle::opponent(Soldier& soldier)
135{135{
136 assert(m_first == &soldier or m_second == &soldier);136 assert(m_first == &soldier || m_second == &soldier);
137 Soldier* other_soldier = m_first == &soldier ? m_second : m_first;137 Soldier* other_soldier = m_first == &soldier ? m_second : m_first;
138 return other_soldier;138 return other_soldier;
139}139}
@@ -148,7 +148,7 @@
148 // Identify what soldier is calling the routine148 // Identify what soldier is calling the routine
149 uint8_t const this_soldier_is = &soldier == m_first ? 1 : 2;149 uint8_t const this_soldier_is = &soldier == m_first ? 1 : 2;
150150
151 assert(m_first->getBattle() == this or m_second->getBattle() == this);151 assert(m_first->getBattle() == this || m_second->getBattle() == this);
152152
153 // Created this three 'states' of the battle:153 // Created this three 'states' of the battle:
154 // *First time entered, one enters :154 // *First time entered, one enters :
@@ -159,12 +159,12 @@
159 // roundFighted, reset m_readyflags159 // roundFighted, reset m_readyflags
160 bool const oneReadyToFight = (m_readyflags == 0);160 bool const oneReadyToFight = (m_readyflags == 0);
161 bool const roundFighted = (m_readyflags == 3);161 bool const roundFighted = (m_readyflags == 3);
162 bool const bothReadyToFight = ((this_soldier_is | m_readyflags) == 3) and162 bool const bothReadyToFight = ((this_soldier_is | m_readyflags) == 3) &&
163 (!roundFighted);163 (!roundFighted);
164 std::string what_anim;164 std::string what_anim;
165165
166 // Apply pending damage166 // Apply pending damage
167 if (m_damage and oneReadyToFight) {167 if (m_damage && oneReadyToFight) {
168 // Current attacker is last defender, so damage goes to current attacker168 // Current attacker is last defender, so damage goes to current attacker
169 if (m_first_strikes)169 if (m_first_strikes)
170 m_first ->damage(m_damage);170 m_first ->damage(m_damage);
@@ -183,7 +183,7 @@
183 return schedule_destroy(game);183 return schedule_destroy(game);
184 }184 }
185185
186 if (!m_first or !m_second)186 if (!m_first || !m_second)
187 return soldier.skip_act();187 return soldier.skip_act();
188188
189 // So both soldiers are alive; are we ready to trade the next blow?189 // So both soldiers are alive; are we ready to trade the next blow?
@@ -216,8 +216,8 @@
216 // Time for one of us to hurt the other. Which one is on turn is decided216 // Time for one of us to hurt the other. Which one is on turn is decided
217 // by calculateRound.217 // by calculateRound.
218 assert218 assert
219 ((m_readyflags == 1 and this_soldier_is == 2) or219 ((m_readyflags == 1 && this_soldier_is == 2) ||
220 (m_readyflags == 2 and this_soldier_is == 1));220 (m_readyflags == 2 && this_soldier_is == 1));
221221
222 // Both are now ready, mark flags, so our opponent can get new animation222 // Both are now ready, mark flags, so our opponent can get new animation
223 m_readyflags = 3;223 m_readyflags = 3;
224224
=== modified file 'src/logic/bill_of_materials.h'
--- src/logic/bill_of_materials.h 2014-07-05 16:41:51 +0000
+++ src/logic/bill_of_materials.h 2014-07-25 13:46:28 +0000
@@ -37,7 +37,7 @@
37 ++i; ++current; return *this;37 ++i; ++current; return *this;
38 }38 }
39 bool empty() const {return current == end;}39 bool empty() const {return current == end;}
40 operator bool() const {return not empty();}40 operator bool() const {return !empty();}
4141
42 uint8_t i;42 uint8_t i;
43 BillOfMaterials::const_iterator current;43 BillOfMaterials::const_iterator current;
4444
=== modified file 'src/logic/bob.cc'
--- src/logic/bob.cc 2014-07-15 10:02:22 +0000
+++ src/logic/bob.cc 2014-07-25 13:46:28 +0000
@@ -260,7 +260,7 @@
260 */260 */
261void Bob::push_task(Game & game, const Task & task, uint32_t const tdelta)261void Bob::push_task(Game & game, const Task & task, uint32_t const tdelta)
262{262{
263 assert(not task.unique or not get_state(task));263 assert(!task.unique || !get_state(task));
264 assert(m_in_act || m_stack.empty());264 assert(m_in_act || m_stack.empty());
265265
266 m_stack.push_back(State(&task));266 m_stack.push_back(State(&task));
@@ -707,7 +707,7 @@
707707
708 if708 if
709 (state.ivar2709 (state.ivar2
710 and710 &&
711 static_cast<Path::Step_Vector::size_type>(state.ivar1) + 1711 static_cast<Path::Step_Vector::size_type>(state.ivar1) + 1
712 ==712 ==
713 path->get_nsteps())713 path->get_nsteps())
@@ -891,7 +891,7 @@
891891
892 // Always call checkNodeBlocked, because it might communicate with other892 // Always call checkNodeBlocked, because it might communicate with other
893 // bobs (as is the case for soldiers on the battlefield).893 // bobs (as is the case for soldiers on the battlefield).
894 if (checkNodeBlocked(game, newnode, true) and !force)894 if (checkNodeBlocked(game, newnode, true) && !force)
895 return -2;895 return -2;
896896
897 // Move is go897 // Move is go
898898
=== modified file 'src/logic/buildcost.cc'
--- src/logic/buildcost.cc 2014-06-01 18:00:48 +0000
+++ src/logic/buildcost.cc 2014-07-25 13:46:28 +0000
@@ -38,7 +38,7 @@
38 ("a buildcost item of this ware type has already been "38 ("a buildcost item of this ware type has already been "
39 "defined");39 "defined");
40 int32_t const value = val->get_int();40 int32_t const value = val->get_int();
41 if (value < 1 or 255 < value)41 if (value < 1 || 255 < value)
42 throw wexception("count is out of range 1 .. 255");42 throw wexception("count is out of range 1 .. 255");
43 insert(std::pair<Ware_Index, uint8_t>(idx, value));43 insert(std::pair<Ware_Index, uint8_t>(idx, value));
44 } else44 } else
4545
=== modified file 'src/logic/building.cc'
--- src/logic/building.cc 2014-07-24 05:21:20 +0000
+++ src/logic/building.cc 2014-07-25 13:46:28 +0000
@@ -90,7 +90,7 @@
90 }90 }
9191
92 m_helptext_script = directory + "/help.lua";92 m_helptext_script = directory + "/help.lua";
93 if (not g_fs->FileExists(m_helptext_script))93 if (!g_fs->FileExists(m_helptext_script))
94 m_helptext_script = "";94 m_helptext_script = "";
9595
96 // Parse build options96 // Parse build options
@@ -293,7 +293,7 @@
293 }293 }
294294
295 Bob::State const* const state = worker.get_state(Worker::taskLeavebuilding);295 Bob::State const* const state = worker.get_state(Worker::taskLeavebuilding);
296 if (not state) {296 if (!state) {
297 log297 log
298 ("WARNING: worker %u is in the leave queue of building %u but "298 ("WARNING: worker %u is in the leave queue of building %u but "
299 "does not have a leavebuilding task! Removing from queue.\n",299 "does not have a leavebuilding task! Removing from queue.\n",
@@ -341,7 +341,7 @@
341 const Building_Descr & tmp_descr = descr();341 const Building_Descr & tmp_descr = descr();
342 if (tmp_descr.is_destructible()) {342 if (tmp_descr.is_destructible()) {
343 caps |= PCap_Bulldoze;343 caps |= PCap_Bulldoze;
344 if (tmp_descr.is_buildable() or tmp_descr.is_enhanced())344 if (tmp_descr.is_buildable() || tmp_descr.is_enhanced())
345 caps |= PCap_Dismantle;345 caps |= PCap_Dismantle;
346 }346 }
347 if (tmp_descr.enhancement() != INVALID_INDEX)347 if (tmp_descr.enhancement() != INVALID_INDEX)
@@ -388,7 +388,7 @@
388 map.get_brn(m_position, &neighb);388 map.get_brn(m_position, &neighb);
389 {389 {
390 Flag * flag = dynamic_cast<Flag *>(map.get_immovable(neighb));390 Flag * flag = dynamic_cast<Flag *>(map.get_immovable(neighb));
391 if (not flag)391 if (!flag)
392 flag =392 flag =
393 new Flag (egbase, owner(), neighb);393 new Flag (egbase, owner(), neighb);
394 m_flag = flag;394 m_flag = flag;
@@ -834,7 +834,7 @@
834834
835835
836void Building::add_worker(Worker & worker) {836void Building::add_worker(Worker & worker) {
837 if (not get_workers().size()) {837 if (!get_workers().size()) {
838 if (worker.descr().name() != "builder")838 if (worker.descr().name() != "builder")
839 set_seeing(true);839 set_seeing(true);
840 }840 }
@@ -845,7 +845,7 @@
845845
846void Building::remove_worker(Worker & worker) {846void Building::remove_worker(Worker & worker) {
847 PlayerImmovable::remove_worker(worker);847 PlayerImmovable::remove_worker(worker);
848 if (not get_workers().size())848 if (!get_workers().size())
849 set_seeing(false);849 set_seeing(false);
850 workers_changed();850 workers_changed();
851}851}
@@ -914,8 +914,8 @@
914 rt_description += img;914 rt_description += img;
915 {915 {
916 std::string::iterator it = rt_description.end() - 1;916 std::string::iterator it = rt_description.end() - 1;
917 for (; it != rt_description.begin() and *it != '?'; --it) {}917 for (; it != rt_description.begin() && *it != '?'; --it) {}
918 for (; *it == '?'; --it)918 for (; *it == '?'; --it)
919 *it = '0';919 *it = '0';
920 }920 }
921 rt_description += "><p font-size=14 font-face=DejaVuSerif>";921 rt_description += "><p font-size=14 font-face=DejaVuSerif>";
922922
=== modified file 'src/logic/checkstep.cc'
--- src/logic/checkstep.cc 2013-07-26 20:19:36 +0000
+++ src/logic/checkstep.cc 2014-07-25 13:46:28 +0000
@@ -168,11 +168,11 @@
168168
169 // Calculate cost and passability169 // Calculate cost and passability
170 if170 if
171 (not (endcaps & m_movecaps)171 (!(endcaps & m_movecaps)
172 and172 &&
173 not173 !
174 ((endcaps & MOVECAPS_WALK)174 ((endcaps & MOVECAPS_WALK)
175 and175 &&
176 (m_player.get_buildcaps(start) & m_movecaps & MOVECAPS_SWIM)))176 (m_player.get_buildcaps(start) & m_movecaps & MOVECAPS_SWIM)))
177 return false;177 return false;
178178
@@ -184,8 +184,8 @@
184184
185 return185 return
186 dynamic_cast<Flag const *>(imm)186 dynamic_cast<Flag const *>(imm)
187 or187 ||
188 (dynamic_cast<Road const *>(imm) and (endcaps & BUILDCAPS_FLAG));188 (dynamic_cast<Road const *>(imm) && (endcaps & BUILDCAPS_FLAG));
189 }189 }
190190
191 return true;191 return true;
192192
=== modified file 'src/logic/cmd_queue.cc'
--- src/logic/cmd_queue.cc 2014-07-23 14:49:10 +0000
+++ src/logic/cmd_queue.cc 2014-07-25 13:46:28 +0000
@@ -55,7 +55,7 @@
55// Note: Order of destruction of Items is not guaranteed55// Note: Order of destruction of Items is not guaranteed
56void Cmd_Queue::flush() {56void Cmd_Queue::flush() {
57 uint32_t cbucket = 0;57 uint32_t cbucket = 0;
58 while (m_ncmds and cbucket < CMD_QUEUE_BUCKET_SIZE) {58 while (m_ncmds && cbucket < CMD_QUEUE_BUCKET_SIZE) {
59 std::priority_queue<cmditem> & current_cmds = m_cmds[cbucket];59 std::priority_queue<cmditem> & current_cmds = m_cmds[cbucket];
6060
61 while (!current_cmds.empty()) {61 while (!current_cmds.empty()) {
6262
=== modified file 'src/logic/constructionsite.cc'
--- src/logic/constructionsite.cc 2014-07-22 09:54:49 +0000
+++ src/logic/constructionsite.cc 2014-07-25 13:46:28 +0000
@@ -204,7 +204,7 @@
204 if (m_work_completed >= m_work_steps)204 if (m_work_completed >= m_work_steps)
205 return false; // completed, so don't burn205 return false; // completed, so don't burn
206206
207 return m_work_completed or !m_old_buildings.empty();207 return m_work_completed || !m_old_buildings.empty();
208}208}
209209
210/*210/*
@@ -237,7 +237,7 @@
237 return true;237 return true;
238 }238 }
239239
240 if (not m_work_steps) // Happens for building without buildcost.240 if (!m_work_steps) // Happens for building without buildcost.
241 schedule_destroy(game); // Complete the building immediately.241 schedule_destroy(game); // Complete the building immediately.
242242
243 // Check if one step has completed243 // Check if one step has completed
244244
=== modified file 'src/logic/dismantlesite.cc'
--- src/logic/dismantlesite.cc 2014-07-15 07:44:14 +0000
+++ src/logic/dismantlesite.cc 2014-07-25 13:46:28 +0000
@@ -177,11 +177,11 @@
177 return true;177 return true;
178 }178 }
179179
180 if (not m_work_steps) // Happens for building without buildcost.180 if (!m_work_steps) // Happens for building without buildcost.
181 schedule_destroy(game); // Complete the building immediately.181 schedule_destroy(game); // Complete the building immediately.
182182
183 // Check if one step has completed183 // Check if one step has completed
184 if (static_cast<int32_t>(game.get_gametime() - m_work_steptime) >= 0 and m_working) {184 if (static_cast<int32_t>(game.get_gametime() - m_work_steptime) >= 0 && m_working) {
185 ++m_work_completed;185 ++m_work_completed;
186186
187 for (uint32_t i = 0; i < m_wares.size(); ++i) {187 for (uint32_t i = 0; i < m_wares.size(); ++i) {
@@ -217,7 +217,7 @@
217 worker.descr().get_right_walk_anims(false),217 worker.descr().get_right_walk_anims(false),
218 true);218 true);
219 worker.set_location(nullptr);219 worker.set_location(nullptr);
220 } else if (not m_working) {220 } else if (!m_working) {
221 m_work_steptime = game.get_gametime() + DISMANTLESITE_STEP_TIME;221 m_work_steptime = game.get_gametime() + DISMANTLESITE_STEP_TIME;
222 worker.start_task_idle222 worker.start_task_idle
223 (game, worker.descr().get_animation("work"), DISMANTLESITE_STEP_TIME);223 (game, worker.descr().get_animation("work"), DISMANTLESITE_STEP_TIME);
224224
=== modified file 'src/logic/editor_game_base.cc'
--- src/logic/editor_game_base.cc 2014-07-22 09:54:49 +0000
+++ src/logic/editor_game_base.cc 2014-07-25 13:46:28 +0000
@@ -70,7 +70,7 @@
70map_ (nullptr),70map_ (nullptr),
71lasttrackserial_ (0)71lasttrackserial_ (0)
72{72{
73 if (not lua_) // TODO(SirVer): this is sooo ugly, I can't say73 if (!lua_) // TODO(SirVer): this is sooo ugly, I can't say
74 lua_.reset(new LuaEditorInterface(this));74 lua_.reset(new LuaEditorInterface(this));
7575
76 g_sound_handler.egbase_ = this;76 g_sound_handler.egbase_ = this;
@@ -198,7 +198,7 @@
198void Editor_Game_Base::inform_players_about_immovable198void Editor_Game_Base::inform_players_about_immovable
199 (Map_Index const i, Map_Object_Descr const * const descr)199 (Map_Index const i, Map_Object_Descr const * const descr)
200{200{
201 if (not Road::IsRoadDescr(descr))201 if (!Road::IsRoadDescr(descr))
202 iterate_players_existing_const(plnum, MAX_PLAYERS, *this, p) {202 iterate_players_existing_const(plnum, MAX_PLAYERS, *this, p) {
203 Player::Field & player_field = p->m_fields[i];203 Player::Field & player_field = p->m_fields[i];
204 if (1 < player_field.vision) {204 if (1 < player_field.vision) {
@@ -249,7 +249,7 @@
249 if249 if
250 (pid <= MAX_PLAYERS250 (pid <= MAX_PLAYERS
251 ||251 ||
252 not dynamic_cast<const Game *>(this))252 !dynamic_cast<const Game *>(this))
253 { // if this is editor, load the tribe anyways253 { // if this is editor, load the tribe anyways
254 // the tribe is used, postload it254 // the tribe is used, postload it
255 tribes_[id]->postload(*this);255 tribes_[id]->postload(*this);
@@ -695,7 +695,7 @@
695 assert (player_area.player_number <= map().get_nrplayers());695 assert (player_area.player_number <= map().get_nrplayers());
696 assert (preferred_player <= map().get_nrplayers());696 assert (preferred_player <= map().get_nrplayers());
697 assert(preferred_player != player_area.player_number);697 assert(preferred_player != player_area.player_number);
698 assert(not conquer || not preferred_player);698 assert(!conquer || !preferred_player);
699 Player & conquering_player = player(player_area.player_number);699 Player & conquering_player = player(player_area.player_number);
700 MapRegion<Area<FCoords> > mr(map(), player_area);700 MapRegion<Area<FCoords> > mr(map(), player_area);
701 do {701 do {
@@ -709,12 +709,12 @@
709 // adds the influence709 // adds the influence
710 Military_Influence new_influence_modified = conquering_player.military_influence(index) +=710 Military_Influence new_influence_modified = conquering_player.military_influence(index) +=
711 influence;711 influence;
712 if (owner && not conquer_guarded_location_by_superior_influence)712 if (owner && !conquer_guarded_location_by_superior_influence)
713 new_influence_modified = 1;713 new_influence_modified = 1;
714 if (!owner || player(owner).military_influence(index) < new_influence_modified) {714 if (!owner || player(owner).military_influence(index) < new_influence_modified) {
715 change_field_owner(mr.location(), player_area.player_number);715 change_field_owner(mr.location(), player_area.player_number);
716 }716 }
717 } else if (not(conquering_player.military_influence(index) -= influence) &&717 } else if (!(conquering_player.military_influence(index) -= influence) &&
718 owner == player_area.player_number) {718 owner == player_area.player_number) {
719 // The player completely lost influence over the location, which he719 // The player completely lost influence over the location, which he
720 // owned. Now we must see if some other player has influence and if720 // owned. Now we must see if some other player has influence and if
@@ -772,7 +772,7 @@
772 PlayerImmovable & imm =772 PlayerImmovable & imm =
773 ref_cast<PlayerImmovable, BaseImmovable>(*i.current->object);773 ref_cast<PlayerImmovable, BaseImmovable>(*i.current->object);
774 if774 if
775 (not775 (!
776 m[i.current->coords].is_interior(imm.owner().player_number()))776 m[i.current->coords].is_interior(imm.owner().player_number()))
777 if777 if
778 (std::find(burnlist.begin(), burnlist.end(), &imm)778 (std::find(burnlist.begin(), burnlist.end(), &imm)
779779
=== modified file 'src/logic/game.cc'
--- src/logic/game.cc 2014-07-23 14:49:10 +0000
+++ src/logic/game.cc 2014-07-25 13:46:28 +0000
@@ -192,7 +192,7 @@
192 // this is to ensure we do not crash because of diskspace192 // this is to ensure we do not crash because of diskspace
193 // still this is only possibe to go from true->false193 // still this is only possibe to go from true->false
194 // still probally should not do this with an assert but with better checks194 // still probally should not do this with an assert but with better checks
195 assert(m_state == gs_notrunning || not wr);195 assert(m_state == gs_notrunning || !wr);
196196
197 m_writereplay = wr;197 m_writereplay = wr;
198}198}
@@ -478,7 +478,7 @@
478 } else {478 } else {
479 // Is a scenario!479 // Is a scenario!
480 iterate_players_existing_novar(p, nr_players, *this) {480 iterate_players_existing_novar(p, nr_players, *this) {
481 if (not map().get_starting_pos(p))481 if (!map().get_starting_pos(p))
482 throw warning482 throw warning
483 (_("Missing starting position"),483 (_("Missing starting position"),
484 _484 _
@@ -540,7 +540,7 @@
540 if (m_writereplay) {540 if (m_writereplay) {
541 log("Starting replay writer\n");541 log("Starting replay writer\n");
542542
543 assert(not m_replaywriter);543 assert(!m_replaywriter);
544 m_replaywriter = new ReplayWriter(*this, fname);544 m_replaywriter = new ReplayWriter(*this, fname);
545545
546 log("Replay writer has started\n");546 log("Replay writer has started\n");
@@ -626,7 +626,7 @@
626626
627/// (Only) called by the dedicated server, to end a game once all players left627/// (Only) called by the dedicated server, to end a game once all players left
628void Game::end_dedicated_game() {628void Game::end_dedicated_game() {
629 assert(not g_gr);629 assert(!g_gr);
630 m_state = gs_notrunning;630 m_state = gs_notrunning;
631}631}
632632
@@ -995,7 +995,7 @@
995 workerid < tribe_workers;995 workerid < tribe_workers;
996 ++workerid)996 ++workerid)
997 if997 if
998 (not998 (!
999 dynamic_cast<Carrier::Descr const *>999 dynamic_cast<Carrier::Descr const *>
1000 (tribe.get_worker_descr(workerid)))1000 (tribe.get_worker_descr(workerid)))
1001 wostock += eco->stock_worker(workerid);1001 wostock += eco->stock_worker(workerid);
10021002
=== modified file 'src/logic/game_controller.h'
--- src/logic/game_controller.h 2014-07-05 16:41:51 +0000
+++ src/logic/game_controller.h 2014-07-25 13:46:28 +0000
@@ -80,7 +80,7 @@
80 * Toggle pause state (convenience function)80 * Toggle pause state (convenience function)
81 */81 */
82 void togglePaused() {82 void togglePaused() {
83 setPaused(not isPaused());83 setPaused(!isPaused());
84 }84 }
8585
86 /**86 /**
8787
=== modified file 'src/logic/immovable.cc'
--- src/logic/immovable.cc 2014-07-16 08:23:42 +0000
+++ src/logic/immovable.cc 2014-07-25 13:46:28 +0000
@@ -142,7 +142,7 @@
142 Section& program_s = prof.get_safe_section(_name.c_str());142 Section& program_s = prof.get_safe_section(_name.c_str());
143 while (Section::Value* const v = program_s.get_next_val()) {143 while (Section::Value* const v = program_s.get_next_val()) {
144 Action* action;144 Action* action;
145 if (not strcmp(v->get_name(), "animate")) {145 if (!strcmp(v->get_name(), "animate")) {
146 // Copying, as next_word() modifies the string..... Awful design.146 // Copying, as next_word() modifies the string..... Awful design.
147 std::unique_ptr<char []> arguments(new char[strlen(v->get_string()) + 1]);147 std::unique_ptr<char []> arguments(new char[strlen(v->get_string()) + 1]);
148 strncpy(arguments.get(), v->get_string(), strlen(v->get_string()) + 1);148 strncpy(arguments.get(), v->get_string(), strlen(v->get_string()) + 1);
@@ -156,17 +156,17 @@
156 g_gr->animations().load(directory, prof.get_safe_section(animation_name)));156 g_gr->animations().load(directory, prof.get_safe_section(animation_name)));
157 }157 }
158 action = new ActAnimate(v->get_string(), immovable);158 action = new ActAnimate(v->get_string(), immovable);
159 } else if (not strcmp(v->get_name(), "transform")) {159 } else if (!strcmp(v->get_name(), "transform")) {
160 action = new ActTransform(v->get_string(), immovable);160 action = new ActTransform(v->get_string(), immovable);
161 } else if (not strcmp(v->get_name(), "grow")) {161 } else if (!strcmp(v->get_name(), "grow")) {
162 action = new ActGrow(v->get_string(), immovable);162 action = new ActGrow(v->get_string(), immovable);
163 } else if (not strcmp(v->get_name(), "remove")) {163 } else if (!strcmp(v->get_name(), "remove")) {
164 action = new ActRemove(v->get_string(), immovable);164 action = new ActRemove(v->get_string(), immovable);
165 } else if (not strcmp(v->get_name(), "seed")) {165 } else if (!strcmp(v->get_name(), "seed")) {
166 action = new ActSeed(v->get_string(), immovable);166 action = new ActSeed(v->get_string(), immovable);
167 } else if (not strcmp(v->get_name(), "playFX")) {167 } else if (!strcmp(v->get_name(), "playFX")) {
168 action = new ActPlayFX(directory, v->get_string(), immovable);168 action = new ActPlayFX(directory, v->get_string(), immovable);
169 } else if (not strcmp(v->get_name(), "construction")) {169 } else if (!strcmp(v->get_name(), "construction")) {
170 action = new ActConstruction(v->get_string(), immovable, directory, prof);170 action = new ActConstruction(v->get_string(), immovable, directory, prof);
171 } else {171 } else {
172 throw game_data_error("unknown command type \"%s\"", v->get_name());172 throw game_data_error("unknown command type \"%s\"", v->get_name());
@@ -769,7 +769,7 @@
769 try {769 try {
770 // The header has been peeled away by the caller770 // The header has been peeled away by the caller
771 uint8_t const version = fr.Unsigned8();771 uint8_t const version = fr.Unsigned8();
772 if (1 <= version and version <= IMMOVABLE_SAVEGAME_VERSION) {772 if (1 <= version && version <= IMMOVABLE_SAVEGAME_VERSION) {
773773
774 const std::string owner_name = fr.CString();774 const std::string owner_name = fr.CString();
775 const std::string old_name = fr.CString();775 const std::string old_name = fr.CString();
@@ -822,10 +822,10 @@
822 }822 }
823 m_id = descr.get_animation(animation_name);823 m_id = descr.get_animation(animation_name);
824824
825 if (not reached_end) { // The next parameter is the duration.825 if (!reached_end) { // The next parameter is the duration.
826 char * endp;826 char * endp;
827 long int const value = strtol(parameters, &endp, 0);827 long int const value = strtol(parameters, &endp, 0);
828 if (*endp or value <= 0)828 if (*endp || value <= 0)
829 throw game_data_error("expected %s but found \"%s\"", "duration in ms", parameters);829 throw game_data_error("expected %s but found \"%s\"", "duration in ms", parameters);
830 m_duration = value;830 m_duration = value;
831 } else {831 } else {
@@ -856,11 +856,11 @@
856 std::string filename = next_word(parameters, reached_end);856 std::string filename = next_word(parameters, reached_end);
857 name = directory + "/" + filename;857 name = directory + "/" + filename;
858858
859 if (not reached_end) {859 if (!reached_end) {
860 char * endp;860 char * endp;
861 unsigned long long int const value = strtoull(parameters, &endp, 0);861 unsigned long long int const value = strtoull(parameters, &endp, 0);
862 priority = value;862 priority = value;
863 if (*endp or priority != value)863 if (*endp || priority != value)
864 throw game_data_error864 throw game_data_error
865 ("expected %s but found \"%s\"", "priority", parameters);865 ("expected %s but found \"%s\"", "priority", parameters);
866 } else866 } else
@@ -899,7 +899,7 @@
899 bob = false;899 bob = false;
900 else if (params[i][0] >= '0' && params[i][0] <= '9') {900 else if (params[i][0] >= '0' && params[i][0] <= '9') {
901 long int const value = atoi(params[i].c_str());901 long int const value = atoi(params[i].c_str());
902 if (value < 1 or 254 < value)902 if (value < 1 || 254 < value)
903 throw game_data_error903 throw game_data_error
904 ("expected %s but found \"%s\"", "probability in range [1, 254]",904 ("expected %s but found \"%s\"", "probability in range [1, 254]",
905 params[i].c_str());905 params[i].c_str());
@@ -939,7 +939,7 @@
939void ImmovableProgram::ActTransform::execute939void ImmovableProgram::ActTransform::execute
940 (Game & game, Immovable & immovable) const940 (Game & game, Immovable & immovable) const
941{941{
942 if (probability == 0 or game.logic_rand() % 256 < probability) {942 if (probability == 0 || game.logic_rand() % 256 < probability) {
943 Player * player = immovable.get_owner();943 Player * player = immovable.get_owner();
944 Coords const c = immovable.get_position();944 Coords const c = immovable.get_position();
945 Tribe_Descr const * const owner_tribe =945 Tribe_Descr const * const owner_tribe =
@@ -974,7 +974,7 @@
974 *p = '\0';974 *p = '\0';
975 ++p;975 ++p;
976 Tribe_Descr const * const owner_tribe = descr.get_owner_tribe();976 Tribe_Descr const * const owner_tribe = descr.get_owner_tribe();
977 if (not owner_tribe)977 if (!owner_tribe)
978 throw game_data_error978 throw game_data_error
979 (979 (
980 "immovable type not in tribe but target type has scope "980 "immovable type not in tribe but target type has scope "
@@ -1027,7 +1027,7 @@
1027 if (*parameters) {1027 if (*parameters) {
1028 char * endp;1028 char * endp;
1029 long int const value = strtol(parameters, &endp, 0);1029 long int const value = strtol(parameters, &endp, 0);
1030 if (*endp or value < 1 or 254 < value)1030 if (*endp || value < 1 || 254 < value)
1031 throw game_data_error1031 throw game_data_error
1032 ("expected %s but found \"%s\"",1032 ("expected %s but found \"%s\"",
1033 "probability in range [1, 254]", parameters);1033 "probability in range [1, 254]", parameters);
@@ -1042,7 +1042,7 @@
1042void ImmovableProgram::ActRemove::execute1042void ImmovableProgram::ActRemove::execute
1043 (Game & game, Immovable & immovable) const1043 (Game & game, Immovable & immovable) const
1044{1044{
1045 if (probability == 0 or game.logic_rand() % 256 < probability)1045 if (probability == 0 || game.logic_rand() % 256 < probability)
1046 immovable.remove(game); // Now immovable is a dangling reference!1046 immovable.remove(game); // Now immovable is a dangling reference!
1047 else1047 else
1048 immovable.program_step(game);1048 immovable.program_step(game);
@@ -1059,7 +1059,7 @@
1059 *p = '\0';1059 *p = '\0';
1060 ++p;1060 ++p;
1061 Tribe_Descr const * const owner_tribe = descr.get_owner_tribe();1061 Tribe_Descr const * const owner_tribe = descr.get_owner_tribe();
1062 if (not owner_tribe)1062 if (!owner_tribe)
1063 throw game_data_error1063 throw game_data_error
1064 (1064 (
1065 "immovable type not in tribe but target type has scope "1065 "immovable type not in tribe but target type has scope "
@@ -1080,7 +1080,7 @@
1080 ++p;1080 ++p;
1081 char * endp;1081 char * endp;
1082 long int const value = strtol(p, &endp, 0);1082 long int const value = strtol(p, &endp, 0);
1083 if (*endp or value < 1 or 254 < value)1083 if (*endp || value < 1 || 254 < value)
1084 throw game_data_error1084 throw game_data_error
1085 ("expected %s but found \"%s\"", "probability in range [1, 254]",1085 ("expected %s but found \"%s\"", "probability in range [1, 254]",
1086 p);1086 p);
10871087
=== modified file 'src/logic/map.cc'
--- src/logic/map.cc 2014-07-23 14:49:10 +0000
+++ src/logic/map.cc 2014-07-25 13:46:28 +0000
@@ -270,7 +270,7 @@
270 }270 }
271 amount /= 6;271 amount /= 6;
272272
273 if (res == -1 or not amount) {273 if (res == -1 || !amount) {
274 f.field->set_resources(0, 0);274 f.field->set_resources(0, 0);
275 f.field->set_starting_res_amount(0);275 f.field->set_starting_res_amount(0);
276 } else {276 } else {
@@ -631,10 +631,10 @@
631 (pathfields->fields[neighb.field - m_fields.get()].cycle631 (pathfields->fields[neighb.field - m_fields.get()].cycle
632 !=632 !=
633 pathfields->cycle633 pathfields->cycle
634 and634 &&
635 // node within the radius?635 // node within the radius?
636 calc_distance(area, neighb) <= area.radius636 calc_distance(area, neighb) <= area.radius
637 and637 &&
638 // allowed to move onto this node?638 // allowed to move onto this node?
639 checkstep.allowed639 checkstep.allowed
640 (*this,640 (*this,
@@ -1084,7 +1084,7 @@
1084 // we cannot build anything on it. Exception: we can build flags on roads.1084 // we cannot build anything on it. Exception: we can build flags on roads.
1085 if (BaseImmovable * const imm = get_immovable(f))1085 if (BaseImmovable * const imm = get_immovable(f))
1086 if1086 if
1087 (not dynamic_cast<Road const *>(imm)1087 (!dynamic_cast<Road const *>(imm)
1088 &&1088 &&
1089 imm->get_size() >= BaseImmovable::SMALL)1089 imm->get_size() >= BaseImmovable::SMALL)
1090 {1090 {
@@ -1698,7 +1698,7 @@
1698 return 0; // duh...1698 return 0; // duh...
1699 }1699 }
17001700
1701 if (not checkstep.reachabledest(*this, end))1701 if (!checkstep.reachabledest(*this, end))
1702 return -1;1702 return -1;
17031703
1704 if (!persist)1704 if (!persist)
@@ -1755,7 +1755,7 @@
17551755
1756 // Check passability1756 // Check passability
1757 if1757 if
1758 (not1758 (!
1759 checkstep.allowed1759 checkstep.allowed
1760 (*this,1760 (*this,
1761 cur,1761 cur,
@@ -1870,7 +1870,7 @@
1870 do {1870 do {
1871 if1871 if
1872 (difference < 01872 (difference < 0
1873 and1873 &&
1874 mr.location().field->height1874 mr.location().field->height
1875 <1875 <
1876 static_cast<uint8_t>(-difference))1876 static_cast<uint8_t>(-difference))
18771877
=== modified file 'src/logic/mapdifferenceregion.cc'
--- src/logic/mapdifferenceregion.cc 2013-09-23 18:47:02 +0000
+++ src/logic/mapdifferenceregion.cc 2014-07-25 13:46:28 +0000
@@ -30,9 +30,9 @@
30 --m_remaining_in_edge;30 --m_remaining_in_edge;
31 return true;31 return true;
32 } else {32 } else {
33 if (not m_passed_corner) {33 if (!m_passed_corner) {
34 m_passed_corner = true;34 m_passed_corner = true;
35 --m_direction; if (not m_direction) m_direction = 6;35 --m_direction; if (!m_direction) m_direction = 6;
36 m_remaining_in_edge = m_area.radius;36 m_remaining_in_edge = m_area.radius;
37 return advance(map);37 return advance(map);
38 }38 }
@@ -46,7 +46,7 @@
46 assert(1 <= m_direction);46 assert(1 <= m_direction);
47 assert (m_direction <= 6);47 assert (m_direction <= 6);
48 assert(m_passed_corner);48 assert(m_passed_corner);
49 --m_direction; if (not m_direction) m_direction = 6;49 --m_direction; if (!m_direction) m_direction = 6;
50 Area<FCoords>::Radius_type steps_left = m_area.radius + 1;50 Area<FCoords>::Radius_type steps_left = m_area.radius + 1;
51 switch (m_direction) {51 switch (m_direction) {
52#define DIRECTION_CASE(dir, neighbour_function) \52#define DIRECTION_CASE(dir, neighbour_function) \
@@ -63,7 +63,7 @@
63 DIRECTION_CASE(WALK_W, get_ln);63 DIRECTION_CASE(WALK_W, get_ln);
64 default: assert(false);64 default: assert(false);
65 }65 }
66 --m_direction; if (not m_direction) m_direction = 6;66 --m_direction; if (!m_direction) m_direction = 6;
67 m_remaining_in_edge = m_area.radius;67 m_remaining_in_edge = m_area.radius;
68 m_passed_corner = false;68 m_passed_corner = false;
69}69}
7070
=== modified file 'src/logic/mapdifferenceregion.h'
--- src/logic/mapdifferenceregion.h 2014-07-05 16:41:51 +0000
+++ src/logic/mapdifferenceregion.h 2014-07-25 13:46:28 +0000
@@ -44,8 +44,8 @@
44 {44 {
45 assert(1 <= direction);45 assert(1 <= direction);
46 assert (direction <= 6);46 assert (direction <= 6);
47 --direction; if (not direction) direction = 6;47 --direction; if (!direction) direction = 6;
48 --direction; if (not direction) direction = 6;48 --direction; if (!direction) direction = 6;
49 switch (direction) {49 switch (direction) {
50#define DIRECTION_CASE(dir, neighbour_function) \50#define DIRECTION_CASE(dir, neighbour_function) \
51 case dir: \51 case dir: \
@@ -61,8 +61,8 @@
61 DIRECTION_CASE(WALK_W, get_ln);61 DIRECTION_CASE(WALK_W, get_ln);
62#undef DIRECTION_CASE62#undef DIRECTION_CASE
63 }63 }
64 --direction; if (not direction) direction = 6;64 --direction; if (!direction) direction = 6;
65 --direction; if (not direction) direction = 6;65 --direction; if (!direction) direction = 6;
66 m_direction = direction;66 m_direction = direction;
67 }67 }
6868
6969
=== modified file 'src/logic/maphollowregion.cc'
--- src/logic/maphollowregion.cc 2013-09-23 18:47:02 +0000
+++ src/logic/maphollowregion.cc 2014-07-25 13:46:28 +0000
@@ -44,7 +44,7 @@
44 ++m_rowpos;44 ++m_rowpos;
45 if (m_rowpos < m_rowwidth) {45 if (m_rowpos < m_rowwidth) {
46 map.get_rn(m_hollow_area, &m_hollow_area);46 map.get_rn(m_hollow_area, &m_hollow_area);
47 if ((m_phase & (Upper|Lower)) and m_rowpos == m_delta_radius) {47 if ((m_phase & (Upper|Lower)) && m_rowpos == m_delta_radius) {
48 // Jump over the hole.48 // Jump over the hole.
49 const uint32_t holewidth = m_rowwidth - 2 * m_delta_radius;49 const uint32_t holewidth = m_rowwidth - 2 * m_delta_radius;
50 for (uint32_t i = 0; i < holewidth; ++i)50 for (uint32_t i = 0; i < holewidth; ++i)
@@ -53,13 +53,13 @@
53 }53 }
54 } else {54 } else {
55 ++m_row;55 ++m_row;
56 if (m_phase == Top and m_row == m_delta_radius)56 if (m_phase == Top && m_row == m_delta_radius)
57 m_phase = Upper;57 m_phase = Upper;
5858
59 // If we completed the widest, center line, switch into lower mode59 // If we completed the widest, center line, switch into lower mode
60 // There are m_radius+1 lines in the upper "half", because the upper60 // There are m_radius+1 lines in the upper "half", because the upper
61 // half includes the center line.61 // half includes the center line.
62 else if (m_phase == Upper and m_row > m_hollow_area.radius) {62 else if (m_phase == Upper && m_row > m_hollow_area.radius) {
63 m_row = 1;63 m_row = 1;
64 m_phase = Lower;64 m_phase = Lower;
65 }65 }
@@ -72,7 +72,7 @@
72 if (m_row > m_hollow_area.radius) {72 if (m_row > m_hollow_area.radius) {
73 m_phase = None;73 m_phase = None;
74 return true; // early out74 return true; // early out
75 } else if (m_phase == Lower and m_row > m_hollow_area.hole_radius)75 } else if (m_phase == Lower && m_row > m_hollow_area.hole_radius)
76 m_phase = Bottom;76 m_phase = Bottom;
7777
78 map.get_brn(m_left, &m_hollow_area);78 map.get_brn(m_left, &m_hollow_area);
7979
=== modified file 'src/logic/maptriangleregion.cc'
--- src/logic/maptriangleregion.cc 2013-09-23 18:47:02 +0000
+++ src/logic/maptriangleregion.cc 2014-07-25 13:46:28 +0000
@@ -25,7 +25,7 @@
25 (const Map & map, Area<TCoords<> > area)25 (const Map & map, Area<TCoords<> > area)
26: m_radius_is_odd(area.radius & 1)26: m_radius_is_odd(area.radius & 1)
27{27{
28 assert(area.t == TCoords<>::R or area.t == TCoords<>::D);28 assert(area.t == TCoords<>::R || area.t == TCoords<>::D);
29 const uint16_t radius_plus_1 = area.radius + 1;29 const uint16_t radius_plus_1 = area.radius + 1;
30 const uint16_t half_radius_rounded_down = area.radius / 2;30 const uint16_t half_radius_rounded_down = area.radius / 2;
31 m_row_length = radius_plus_1;31 m_row_length = radius_plus_1;
@@ -151,7 +151,7 @@
151 (const Map & map, Area<TCoords<FCoords> > area)151 (const Map & map, Area<TCoords<FCoords> > area)
152: m_radius_is_odd(area.radius & 1)152: m_radius_is_odd(area.radius & 1)
153{153{
154 assert(area.t == TCoords<FCoords>::R or area.t == TCoords<FCoords>::D);154 assert(area.t == TCoords<FCoords>::R || area.t == TCoords<FCoords>::D);
155 const uint16_t radius_plus_1 = area.radius + 1;155 const uint16_t radius_plus_1 = area.radius + 1;
156 const uint16_t half_radius_rounded_down = area.radius / 2;156 const uint16_t half_radius_rounded_down = area.radius / 2;
157 m_row_length = radius_plus_1;157 m_row_length = radius_plus_1;
158158
=== modified file 'src/logic/militarysite.cc'
--- src/logic/militarysite.cc 2014-07-23 15:58:57 +0000
+++ src/logic/militarysite.cc 2014-07-25 13:46:28 +0000
@@ -523,10 +523,10 @@
523 }523 }
524 else // not doing upgrade request524 else // not doing upgrade request
525 {525 {
526 if ((capacity != stationed) or (m_normal_soldier_request))526 if ((capacity != stationed) || (m_normal_soldier_request))
527 update_normal_soldier_request();527 update_normal_soldier_request();
528528
529 if ((capacity == stationed) and (! m_normal_soldier_request))529 if ((capacity == stationed) && (! m_normal_soldier_request))
530 {530 {
531 if (presentSoldiers().size() == capacity)531 if (presentSoldiers().size() == capacity)
532 {532 {
@@ -922,9 +922,9 @@
922 for (uint32_t i = 0; i < immovables.size(); ++i)922 for (uint32_t i = 0; i < immovables.size(); ++i)
923 if (upcast(MilitarySite const, militarysite, immovables[i].object))923 if (upcast(MilitarySite const, militarysite, immovables[i].object))
924 if924 if
925 (this != militarysite and925 (this != militarysite &&
926 &owner () == &militarysite->owner() and926 &owner () == &militarysite->owner() &&
927 get_size() <= militarysite->get_size() and927 get_size() <= militarysite->get_size() &&
928 militarysite->m_didconquer)928 militarysite->m_didconquer)
929 return true;929 return true;
930 return false;930 return false;
@@ -1060,7 +1060,7 @@
1060 bool maxchanged = reqmax != soldier_upgrade_required_max;1060 bool maxchanged = reqmax != soldier_upgrade_required_max;
1061 bool minchanged = reqmin != soldier_upgrade_required_min;1061 bool minchanged = reqmin != soldier_upgrade_required_min;
10621062
1063 if (maxchanged or minchanged)1063 if (maxchanged || minchanged)
1064 {1064 {
1065 if (m_upgrade_soldier_request && (m_upgrade_soldier_request->is_open()))1065 if (m_upgrade_soldier_request && (m_upgrade_soldier_request->is_open()))
1066 {1066 {
10671067
=== modified file 'src/logic/player.cc'
--- src/logic/player.cc 2014-07-23 14:49:10 +0000
+++ src/logic/player.cc 2014-07-25 13:46:28 +0000
@@ -348,8 +348,8 @@
348 Coords const position = m .position ();348 Coords const position = m .position ();
349 container_iterate_const(MessageQueue, messages(), i)349 container_iterate_const(MessageQueue, messages(), i)
350 if350 if
351 (i.current->second->sender() == m.sender() and351 (i.current->second->sender() == m.sender() &&
352 gametime < i.current->second->sent() + timeout and352 gametime < i.current->second->sent() + timeout &&
353 map.calc_distance(i.current->second->position(), position) <= radius)353 map.calc_distance(i.current->second->position(), position) <= radius)
354 {354 {
355 delete &m;355 delete &m;
@@ -382,25 +382,25 @@
382 const Map & map = egbase().map();382 const Map & map = egbase().map();
383 uint8_t buildcaps = fc.field->nodecaps();383 uint8_t buildcaps = fc.field->nodecaps();
384384
385 if (not fc.field->is_interior(m_plnum))385 if (!fc.field->is_interior(m_plnum))
386 buildcaps = 0;386 buildcaps = 0;
387387
388 // Check if a building's flag can't be build due to ownership388 // Check if a building's flag can't be build due to ownership
389 else if (buildcaps & BUILDCAPS_BUILDINGMASK) {389 else if (buildcaps & BUILDCAPS_BUILDINGMASK) {
390 FCoords flagcoords;390 FCoords flagcoords;
391 map.get_brn(fc, &flagcoords);391 map.get_brn(fc, &flagcoords);
392 if (not flagcoords.field->is_interior(m_plnum))392 if (!flagcoords.field->is_interior(m_plnum))
393 buildcaps &= ~BUILDCAPS_BUILDINGMASK;393 buildcaps &= ~BUILDCAPS_BUILDINGMASK;
394394
395 // Prevent big buildings that would swell over borders.395 // Prevent big buildings that would swell over borders.
396 if396 if
397 ((buildcaps & BUILDCAPS_BIG) == BUILDCAPS_BIG397 ((buildcaps & BUILDCAPS_BIG) == BUILDCAPS_BIG
398 and398 &&
399 (not map.tr_n(fc).field->is_interior(m_plnum)399 (!map.tr_n(fc).field->is_interior(m_plnum)
400 or400 ||
401 not map.tl_n(fc).field->is_interior(m_plnum)401 !map.tl_n(fc).field->is_interior(m_plnum)
402 or402 ||
403 not map. l_n(fc).field->is_interior(m_plnum)))403 !map. l_n(fc).field->is_interior(m_plnum)))
404 buildcaps &= ~BUILDCAPS_SMALL;404 buildcaps &= ~BUILDCAPS_SMALL;
405 }405 }
406406
@@ -428,7 +428,7 @@
428 if (upcast(Flag, existing_flag, immovable)) {428 if (upcast(Flag, existing_flag, immovable)) {
429 if (&existing_flag->owner() == this)429 if (&existing_flag->owner() == this)
430 return *existing_flag;430 return *existing_flag;
431 } else if (not dynamic_cast<Road const *>(immovable)) // A road is OK.431 } else if (!dynamic_cast<Road const *>(immovable)) // A road is OK.
432 immovable->remove(egbase()); // Make room for the flag.432 immovable->remove(egbase()); // Make room for the flag.
433 }433 }
434 MapRegion<Area<FCoords> > mr(map, Area<FCoords>(c, 1));434 MapRegion<Area<FCoords> > mr(map, Area<FCoords>(c, 1));
@@ -734,7 +734,7 @@
734 (Building * building, Building_Index const index_of_new_building)734 (Building * building, Building_Index const index_of_new_building)
735{735{
736 if (&building->owner() ==736 if (&building->owner() ==
737 this and(index_of_new_building == INVALID_INDEX ||737 this &&(index_of_new_building == INVALID_INDEX ||
738 building->descr().enhancement() == index_of_new_building)) {738 building->descr().enhancement() == index_of_new_building)) {
739 Building::FormerBuildings former_buildings = building->get_former_buildings();739 Building::FormerBuildings former_buildings = building->get_former_buildings();
740 const Coords position = building->get_position();740 const Coords position = building->get_position();
@@ -791,7 +791,7 @@
791791
792void Player::allow_worker_type(Ware_Index const i, bool const allow) {792void Player::allow_worker_type(Ware_Index const i, bool const allow) {
793 assert(i < m_allowed_worker_types.size());793 assert(i < m_allowed_worker_types.size());
794 assert(not allow or tribe().get_worker_descr(i)->is_buildable());794 assert(!allow || tribe().get_worker_descr(i)->is_buildable());
795 m_allowed_worker_types[i] = allow;795 m_allowed_worker_types[i] = allow;
796}796}
797797
@@ -811,7 +811,7 @@
811 */811 */
812void Player::add_economy(Economy & economy)812void Player::add_economy(Economy & economy)
813{813{
814 if (not has_economy(economy))814 if (!has_economy(economy))
815 m_economies.push_back(&economy);815 m_economies.push_back(&economy);
816}816}
817817
@@ -924,7 +924,7 @@
924 present.begin(), present.begin() + nr_taken);924 present.begin(), present.begin() + nr_taken);
925 count += nr_taken;925 count += nr_taken;
926 nr_wanted -= nr_taken;926 nr_wanted -= nr_taken;
927 if (not nr_wanted)927 if (!nr_wanted)
928 break;928 break;
929 }929 }
930 }930 }
@@ -1014,17 +1014,17 @@
10141014
1015 field.border = f.field->is_border();1015 field.border = f.field->is_border();
1016 field.border_r =1016 field.border_r =
1017 ((1 | r_vision) and (r_owner_number == field.owner)1017 ((1 | r_vision) && (r_owner_number == field.owner)
1018 and1018 &&
1019 ((tr_owner_number == field.owner) xor (br_owner_number == field.owner)));1019 ((tr_owner_number == field.owner) ^ (br_owner_number == field.owner)));
1020 field.border_br =1020 field.border_br =
1021 ((1 | bl_vision) and (bl_owner_number == field.owner)1021 ((1 | bl_vision) && (bl_owner_number == field.owner)
1022 and1022 &&
1023 ((l_owner_number == field.owner) xor (br_owner_number == field.owner)));1023 ((l_owner_number == field.owner) ^ (br_owner_number == field.owner)));
1024 field.border_bl =1024 field.border_bl =
1025 ((1 | br_vision) and (br_owner_number == field.owner)1025 ((1 | br_vision) && (br_owner_number == field.owner)
1026 and1026 &&
1027 ((r_owner_number == field.owner) xor (bl_owner_number == field.owner)));1027 ((r_owner_number == field.owner) ^ (bl_owner_number == field.owner)));
10281028
1029 { // map_object_descr[TCoords::None]1029 { // map_object_descr[TCoords::None]
10301030
10311031
=== modified file 'src/logic/playercommand.cc'
--- src/logic/playercommand.cc 2014-07-14 21:52:13 +0000
+++ src/logic/playercommand.cc 2014-07-25 13:46:28 +0000
@@ -156,10 +156,10 @@
156{156{
157 try {157 try {
158 const uint16_t packet_version = fr.Unsigned16();158 const uint16_t packet_version = fr.Unsigned16();
159 if (2 <= packet_version and packet_version <= PLAYER_COMMAND_VERSION) {159 if (2 <= packet_version && packet_version <= PLAYER_COMMAND_VERSION) {
160 GameLogicCommand::Read(fr, egbase, mol);160 GameLogicCommand::Read(fr, egbase, mol);
161 m_sender = fr.Unsigned8 ();161 m_sender = fr.Unsigned8 ();
162 if (not egbase.get_player(m_sender))162 if (!egbase.get_player(m_sender))
163 throw game_data_error("player %u does not exist", m_sender);163 throw game_data_error("player %u does not exist", m_sender);
164 m_cmdserial = fr.Unsigned32();164 m_cmdserial = fr.Unsigned32();
165 } else165 } else
@@ -198,7 +198,7 @@
198 try {198 try {
199 const uint16_t packet_version = fr.Unsigned16();199 const uint16_t packet_version = fr.Unsigned16();
200 if200 if
201 (1 <= packet_version and201 (1 <= packet_version &&
202 packet_version <= PLAYER_CMD_BULLDOZE_VERSION)202 packet_version <= PLAYER_CMD_BULLDOZE_VERSION)
203 {203 {
204 PlayerCommand::Read(fr, egbase, mol);204 PlayerCommand::Read(fr, egbase, mol);
@@ -1251,7 +1251,7 @@
1251{1251{
1252 Player & player = game.player(sender());1252 Player & player = game.player(sender());
1253 if1253 if
1254 (economy () < player.get_nr_economies() and1254 (economy () < player.get_nr_economies() &&
1255 ware_type() < player.tribe().get_nrwares())1255 ware_type() < player.tribe().get_nrwares())
1256 player.get_economy_by_number(economy())->set_ware_target_quantity1256 player.get_economy_by_number(economy())->set_ware_target_quantity
1257 (ware_type(), m_permanent, duetime());1257 (ware_type(), m_permanent, duetime());
@@ -1314,7 +1314,7 @@
1314 Player & player = game.player(sender());1314 Player & player = game.player(sender());
1315 const Tribe_Descr & tribe = player.tribe();1315 const Tribe_Descr & tribe = player.tribe();
1316 if1316 if
1317 (economy () < player.get_nr_economies() and1317 (economy () < player.get_nr_economies() &&
1318 ware_type() < tribe.get_nrwares())1318 ware_type() < tribe.get_nrwares())
1319 {1319 {
1320 const int32_t count =1320 const int32_t count =
@@ -1373,7 +1373,7 @@
1373{1373{
1374 Player & player = game.player(sender());1374 Player & player = game.player(sender());
1375 if1375 if
1376 (economy () < player.get_nr_economies() and1376 (economy () < player.get_nr_economies() &&
1377 ware_type() < player.tribe().get_nrwares())1377 ware_type() < player.tribe().get_nrwares())
1378 player.get_economy_by_number(economy())->set_worker_target_quantity1378 player.get_economy_by_number(economy())->set_worker_target_quantity
1379 (ware_type(), m_permanent, duetime());1379 (ware_type(), m_permanent, duetime());
@@ -1436,7 +1436,7 @@
1436 Player & player = game.player(sender());1436 Player & player = game.player(sender());
1437 const Tribe_Descr & tribe = player.tribe();1437 const Tribe_Descr & tribe = player.tribe();
1438 if1438 if
1439 (economy () < player.get_nr_economies() and1439 (economy () < player.get_nr_economies() &&
1440 ware_type() < tribe.get_nrwares())1440 ware_type() < tribe.get_nrwares())
1441 {1441 {
1442 const int32_t count =1442 const int32_t count =
@@ -1682,7 +1682,7 @@
1682 if (const Building * const building = flag->get_building()) {1682 if (const Building * const building = flag->get_building()) {
1683 if1683 if
1684 (player.is_hostile(flag->owner())1684 (player.is_hostile(flag->owner())
1685 and1685 &&
1686 11686 1
1687 <1687 <
1688 player.vision1688 player.vision
@@ -1759,7 +1759,7 @@
1759 if (packet_version == PLAYER_MESSAGE_CMD_VERSION) {1759 if (packet_version == PLAYER_MESSAGE_CMD_VERSION) {
1760 PlayerCommand::Read(fr, egbase, mol);1760 PlayerCommand::Read(fr, egbase, mol);
1761 m_message_id = Message_Id(fr.Unsigned32());1761 m_message_id = Message_Id(fr.Unsigned32());
1762 if (not m_message_id)1762 if (!m_message_id)
1763 throw game_data_error1763 throw game_data_error
1764 ("(player %u): message id is null", sender());1764 ("(player %u): message id is null", sender());
1765 } else1765 } else
17661766
=== modified file 'src/logic/production_program.cc'
--- src/logic/production_program.cc 2014-07-23 15:58:57 +0000
+++ src/logic/production_program.cc 2014-07-25 13:46:28 +0000
@@ -83,7 +83,7 @@
83/// now candidate points to " 75" and result is true83/// now candidate points to " 75" and result is true
84bool match(char* & candidate, const char* pattern) {84bool match(char* & candidate, const char* pattern) {
85 for (char* p = candidate;; ++p, ++pattern)85 for (char* p = candidate;; ++p, ++pattern)
86 if (not * pattern) {86 if (!*pattern) {
87 candidate = p;87 candidate = p;
88 return true;88 return true;
89 } else if (*p != *pattern)89 } else if (*p != *pattern)
@@ -129,7 +129,7 @@
129/// throws _wexception129/// throws _wexception
130bool match_force_skip(char* & candidate, const char* pattern) {130bool match_force_skip(char* & candidate, const char* pattern) {
131 for (char* p = candidate;; ++p, ++pattern)131 for (char* p = candidate;; ++p, ++pattern)
132 if (not * pattern) {132 if (!*pattern) {
133 force_skip(p);133 force_skip(p);
134 candidate = p;134 candidate = p;
135 return true;135 return true;
@@ -164,8 +164,8 @@
164 for (;;) {164 for (;;) {
165 char const * ware = parameters;165 char const * ware = parameters;
166 while166 while
167 (*parameters and *parameters != ',' and167 (*parameters && *parameters != ',' &&
168 *parameters != ':' and *parameters != ' ')168 *parameters != ':' && *parameters != ' ')
169 ++parameters;169 ++parameters;
170 char const terminator = *parameters;170 char const terminator = *parameters;
171 *parameters = '\0';171 *parameters = '\0';
@@ -181,7 +181,7 @@
181 count_max += i.front().second;181 count_max += i.front().second;
182 break;182 break;
183 }183 }
184 if (group.first.size() and ware_index <= *group.first.begin())184 if (group.first.size() && ware_index <= *group.first.begin())
185 throw game_data_error185 throw game_data_error
186 (186 (
187 "wrong order of ware types within group: ware type %s appears "187 "wrong order of ware types within group: ware type %s appears "
@@ -196,7 +196,7 @@
196 char * endp;196 char * endp;
197 unsigned long long int const value = strtoull(parameters, &endp, 0);197 unsigned long long int const value = strtoull(parameters, &endp, 0);
198 count = value;198 count = value;
199 if ((*endp and *endp != ' ') or value < 1 or count != value)199 if ((*endp && *endp != ' ') || value < 1 || count != value)
200 throw game_data_error200 throw game_data_error
201 ("expected %s but found \"%s\"", "count", parameters);201 ("expected %s but found \"%s\"", "count", parameters);
202 parameters = endp;202 parameters = endp;
@@ -233,7 +233,7 @@
233bool ProductionProgram::ActReturn::Negation::evaluate233bool ProductionProgram::ActReturn::Negation::evaluate
234 (const ProductionSite & ps) const234 (const ProductionSite & ps) const
235{235{
236 return not operand->evaluate(ps);236 return !operand->evaluate(ps);
237}237}
238std::string ProductionProgram::ActReturn::Negation::description238std::string ProductionProgram::ActReturn::Negation::description
239 (const Tribe_Descr & tribe) const239 (const Tribe_Descr & tribe) const
@@ -438,7 +438,7 @@
438 m_conditions.push_back(create_condition(parameters, descr));438 m_conditions.push_back(create_condition(parameters, descr));
439 if (*parameters) {439 if (*parameters) {
440 skip(parameters);440 skip(parameters);
441 if (not match_force_skip(parameters, "and"))441 if (!match_force_skip(parameters, "and"))
442 throw game_data_error442 throw game_data_error
443 ("expected \"%s\" or end of input", "and");443 ("expected \"%s\" or end of input", "and");
444 } else444 } else
@@ -447,13 +447,13 @@
447 } else if (match_force_skip(parameters, "unless")) {447 } else if (match_force_skip(parameters, "unless")) {
448 m_is_when = false;448 m_is_when = false;
449 for (;;) {449 for (;;) {
450 if (not *parameters)450 if (!*parameters)
451 throw game_data_error451 throw game_data_error
452 ("expected condition at end of input");452 ("expected condition at end of input");
453 m_conditions.push_back(create_condition(parameters, descr));453 m_conditions.push_back(create_condition(parameters, descr));
454 if (*parameters) {454 if (*parameters) {
455 skip(parameters);455 skip(parameters);
456 if (not match_force_skip(parameters, "or"))456 if (!match_force_skip(parameters, "or"))
457 throw game_data_error457 throw game_data_error
458 ("expected \"%s\" or end of input", "or");458 ("expected \"%s\" or end of input", "or");
459 } else459 } else
@@ -497,7 +497,7 @@
497 std::string condition_string = "";497 std::string condition_string = "";
498 for (wl_const_range<Conditions> i(m_conditions); i;)498 for (wl_const_range<Conditions> i(m_conditions); i;)
499 {499 {
500 if (not (i.front()->evaluate(ps))) // A condition is false,500 if (!(i.front()->evaluate(ps))) // A condition is false,
501 return ps.program_step(game); // continue program.501 return ps.program_step(game); // continue program.
502502
503 condition_string += i.front()->description(ps.owner().tribe());503 condition_string += i.front()->description(ps.owner().tribe());
@@ -573,7 +573,7 @@
573 }573 }
574574
575 // Override with specified handling methods.575 // Override with specified handling methods.
576 while (not reached_end) {576 while (!reached_end) {
577 skip(parameters);577 skip(parameters);
578 match_force_skip(parameters, "on");578 match_force_skip(parameters, "on");
579 log("found \"on \": parameters = \"%s\"\n", parameters);579 log("found \"on \": parameters = \"%s\"\n", parameters);
@@ -614,7 +614,7 @@
614 "{\"fail\"|\"complete\"|\"skip\"|\"repeat\"}",614 "{\"fail\"|\"complete\"|\"skip\"|\"repeat\"}",
615 parameters);615 parameters);
616 m_handling_methods[result_to_set_method_for - 1] = handling_method;616 m_handling_methods[result_to_set_method_for - 1] = handling_method;
617 reached_end = not *parameters;617 reached_end = !*parameters;
618 log618 log
619 ("read handling method for result %u: %u, parameters = \"%s\", "619 ("read handling method for result %u: %u, parameters = \"%s\", "
620 "reached_end = %u\n",620 "reached_end = %u\n",
@@ -722,7 +722,7 @@
722 char * endp;722 char * endp;
723 long long int const value = strtoll(parameters, &endp, 0);723 long long int const value = strtoll(parameters, &endp, 0);
724 m_duration = value;724 m_duration = value;
725 if (*endp or value <= 0 or m_duration != value)725 if (*endp || value <= 0 || m_duration != value)
726 throw game_data_error726 throw game_data_error
727 ("expected %s but found \"%s\"",727 ("expected %s but found \"%s\"",
728 "duration in ms", parameters);728 "duration in ms", parameters);
@@ -777,7 +777,7 @@
777 try {777 try {
778 bool reached_end;778 bool reached_end;
779 char * const animation_name = next_word(parameters, reached_end);779 char * const animation_name = next_word(parameters, reached_end);
780 if (not strcmp(animation_name, "idle"))780 if (!strcmp(animation_name, "idle"))
781 throw game_data_error781 throw game_data_error
782 ("idle animation is default; calling is not allowed");782 ("idle animation is default; calling is not allowed");
783 if (descr->is_animation_known(animation_name))783 if (descr->is_animation_known(animation_name))
@@ -786,11 +786,11 @@
786 m_id = g_gr->animations().load(directory.c_str(), prof.get_safe_section(animation_name));786 m_id = g_gr->animations().load(directory.c_str(), prof.get_safe_section(animation_name));
787 descr->add_animation(animation_name, m_id);787 descr->add_animation(animation_name, m_id);
788 }788 }
789 if (not reached_end) { // The next parameter is the duration.789 if (!reached_end) { // The next parameter is the duration.
790 char * endp;790 char * endp;
791 long long int const value = strtoll(parameters, &endp, 0);791 long long int const value = strtoll(parameters, &endp, 0);
792 m_duration = value;792 m_duration = value;
793 if (*endp or value <= 0 or m_duration != value)793 if (*endp || value <= 0 || m_duration != value)
794 throw game_data_error794 throw game_data_error
795 ("expected %s but found \"%s\"",795 ("expected %s but found \"%s\"",
796 "duration in ms", parameters);796 "duration in ms", parameters);
@@ -819,7 +819,7 @@
819 m_groups.resize(m_groups.size() + 1);819 m_groups.resize(m_groups.size() + 1);
820 parse_ware_type_group820 parse_ware_type_group
821 (parameters, *m_groups.rbegin(), tribe, descr.inputs());821 (parameters, *m_groups.rbegin(), tribe, descr.inputs());
822 if (not *parameters)822 if (!*parameters)
823 break;823 break;
824 force_skip(parameters);824 force_skip(parameters);
825 }825 }
@@ -957,9 +957,9 @@
957 strtoull(parameters, &endp, 0);957 strtoull(parameters, &endp, 0);
958 item.second = value;958 item.second = value;
959 if959 if
960 ((*endp and *endp != ' ')960 ((*endp && *endp != ' ')
961 or961 ||
962 value < 1 or item.second != value)962 value < 1 || item.second != value)
963 throw game_data_error963 throw game_data_error
964 ("expected %s but found \"%s\"",964 ("expected %s but found \"%s\"",
965 "count", parameters);965 "count", parameters);
@@ -972,7 +972,7 @@
972 more = *parameters != '\0';972 more = *parameters != '\0';
973 *parameters = '\0';973 *parameters = '\0';
974 if974 if
975 (not975 (!
976 descr.is_output_ware_type976 descr.is_output_ware_type
977 (item.first = tribe.safe_ware_index(ware)))977 (item.first = tribe.safe_ware_index(ware)))
978 throw game_data_error978 throw game_data_error
@@ -1058,9 +1058,9 @@
1058 strtoull(parameters, &endp, 0);1058 strtoull(parameters, &endp, 0);
1059 item.second = value;1059 item.second = value;
1060 if1060 if
1061 ((*endp and *endp != ' ')1061 ((*endp && *endp != ' ')
1062 or1062 ||
1063 value < 1 or item.second != value)1063 value < 1 || item.second != value)
1064 throw game_data_error1064 throw game_data_error
1065 ("expected %s but found \"%s\"",1065 ("expected %s but found \"%s\"",
1066 "count", parameters);1066 "count", parameters);
@@ -1073,7 +1073,7 @@
1073 more = *parameters != '\0';1073 more = *parameters != '\0';
1074 *parameters = '\0';1074 *parameters = '\0';
1075 if1075 if
1076 (not1076 (!
1077 descr.is_output_worker_type1077 descr.is_output_worker_type
1078 (item.first = tribe.safe_worker_index(worker)))1078 (item.first = tribe.safe_worker_index(worker)))
1079 throw game_data_error1079 throw game_data_error
@@ -1141,7 +1141,7 @@
1141 char * endp;1141 char * endp;
1142 unsigned long long int const value = strtoull(parameters, &endp, 0);1142 unsigned long long int const value = strtoull(parameters, &endp, 0);
1143 m_distance = value;1143 m_distance = value;
1144 if (*endp != ' ' or m_distance != value)1144 if (*endp != ' ' || m_distance != value)
1145 throw game_data_error1145 throw game_data_error
1146 ("expected %s but found \"%s\"", "distance", parameters);1146 ("expected %s but found \"%s\"", "distance", parameters);
1147 parameters = endp;1147 parameters = endp;
@@ -1151,7 +1151,7 @@
1151 char * endp;1151 char * endp;
1152 unsigned long long int const value = strtoull(parameters, &endp, 0);1152 unsigned long long int const value = strtoull(parameters, &endp, 0);
1153 m_max = value;1153 m_max = value;
1154 if (*endp != ' ' or value < 1 or 100 < value)1154 if (*endp != ' ' || value < 1 || 100 < value)
1155 throw game_data_error1155 throw game_data_error
1156 ("expected %s but found \"%s\"",1156 ("expected %s but found \"%s\"",
1157 "percentage", parameters);1157 "percentage", parameters);
@@ -1162,7 +1162,7 @@
1162 char * endp;1162 char * endp;
1163 unsigned long long int const value = strtoull(parameters, &endp, 0);1163 unsigned long long int const value = strtoull(parameters, &endp, 0);
1164 m_chance = value;1164 m_chance = value;
1165 if (*endp != ' ' or value < 1 or 100 < value)1165 if (*endp != ' ' || value < 1 || 100 < value)
1166 throw game_data_error1166 throw game_data_error
1167 ("expected %s but found \"%s\"",1167 ("expected %s but found \"%s\"",
1168 "percentage", parameters);1168 "percentage", parameters);
@@ -1172,7 +1172,7 @@
1172 char * endp;1172 char * endp;
1173 unsigned long long int const value = strtoull(parameters, &endp, 0);1173 unsigned long long int const value = strtoull(parameters, &endp, 0);
1174 m_training = value;1174 m_training = value;
1175 if (*endp or value < 1 or 100 < value)1175 if (*endp || value < 1 || 100 < value)
1176 throw game_data_error1176 throw game_data_error
1177 ("expected %s but found \"%s\"",1177 ("expected %s but found \"%s\"",
1178 "percentage", parameters);1178 "percentage", parameters);
@@ -1235,7 +1235,7 @@
1235 int32_t digged_percentage = 100;1235 int32_t digged_percentage = 100;
1236 if (totalstart)1236 if (totalstart)
1237 digged_percentage = 100 - totalres * 100 / totalstart;1237 digged_percentage = 100 - totalres * 100 / totalstart;
1238 if (not totalres)1238 if (!totalres)
1239 digged_percentage = 100;1239 digged_percentage = 100;
12401240
1241 if (digged_percentage < m_max) {1241 if (digged_percentage < m_max) {
@@ -1326,7 +1326,7 @@
1326ProductionProgram::ActCheck_Soldier::ActCheck_Soldier(char* parameters) {1326ProductionProgram::ActCheck_Soldier::ActCheck_Soldier(char* parameters) {
1327 // TODO(unknown) This is currently hardcoded for "soldier", but should allow any1327 // TODO(unknown) This is currently hardcoded for "soldier", but should allow any
1328 // soldier type name.1328 // soldier type name.
1329 if (not match_force_skip(parameters, "soldier"))1329 if (!match_force_skip(parameters, "soldier"))
1330 throw game_data_error1330 throw game_data_error
1331 ("expected %s but found \"%s\"", "soldier type", parameters);1331 ("expected %s but found \"%s\"", "soldier type", parameters);
1332 try {1332 try {
@@ -1346,7 +1346,7 @@
1346 char * endp;1346 char * endp;
1347 unsigned long long int const value = strtoull(parameters, &endp, 0);1347 unsigned long long int const value = strtoull(parameters, &endp, 0);
1348 level = value;1348 level = value;
1349 if (*endp or level != value)1349 if (*endp || level != value)
1350 throw game_data_error1350 throw game_data_error
1351 ("expected %s but found \"%s\"", "level", parameters);1351 ("expected %s but found \"%s\"", "level", parameters);
1352 } catch (const _wexception & e) {1352 } catch (const _wexception & e) {
@@ -1402,7 +1402,7 @@
1402ProductionProgram::ActTrain::ActTrain(char* parameters) {1402ProductionProgram::ActTrain::ActTrain(char* parameters) {
1403 // TODO(unknown) This is currently hardcoded for "soldier", but should allow any1403 // TODO(unknown) This is currently hardcoded for "soldier", but should allow any
1404 // soldier type name.1404 // soldier type name.
1405 if (not match_force_skip(parameters, "soldier"))1405 if (!match_force_skip(parameters, "soldier"))
1406 throw game_data_error1406 throw game_data_error
1407 ("expected %s but found \"%s\"", "soldier type", parameters);1407 ("expected %s but found \"%s\"", "soldier type", parameters);
1408 try {1408 try {
@@ -1423,7 +1423,7 @@
1423 char * endp;1423 char * endp;
1424 unsigned long long int const value = strtoull(parameters, &endp, 0);1424 unsigned long long int const value = strtoull(parameters, &endp, 0);
1425 level = value;1425 level = value;
1426 if (*endp != ' ' or level != value)1426 if (*endp != ' ' || level != value)
1427 throw game_data_error1427 throw game_data_error
1428 ("expected %s but found \"%s\"", "level", parameters);1428 ("expected %s but found \"%s\"", "level", parameters);
1429 parameters = endp;1429 parameters = endp;
@@ -1433,7 +1433,7 @@
1433 char * endp;1433 char * endp;
1434 unsigned long long int const value = strtoull(parameters, &endp, 0);1434 unsigned long long int const value = strtoull(parameters, &endp, 0);
1435 target_level = value;1435 target_level = value;
1436 if (*endp or target_level != value or target_level <= level)1436 if (*endp || target_level != value || target_level <= level)
1437 throw game_data_error1437 throw game_data_error
1438 ("expected level > %u but found \"%s\"", level, parameters);1438 ("expected level > %u but found \"%s\"", level, parameters);
1439 }1439 }
@@ -1509,11 +1509,11 @@
1509 std::string filename = next_word(parameters, reached_end);1509 std::string filename = next_word(parameters, reached_end);
1510 name = directory + "/" + filename;1510 name = directory + "/" + filename;
15111511
1512 if (not reached_end) {1512 if (!reached_end) {
1513 char * endp;1513 char * endp;
1514 unsigned long long int const value = strtoull(parameters, &endp, 0);1514 unsigned long long int const value = strtoull(parameters, &endp, 0);
1515 priority = value;1515 priority = value;
1516 if (*endp or priority != value)1516 if (*endp || priority != value)
1517 throw game_data_error1517 throw game_data_error
1518 ("expected %s but found \"%s\"", "priority", parameters);1518 ("expected %s but found \"%s\"", "priority", parameters);
1519 } else1519 } else
@@ -1689,31 +1689,31 @@
1689 ProductionProgram::Action* action;1689 ProductionProgram::Action* action;
1690 if (not strcmp(v->get_name(), "return"))1690 if (not strcmp(v->get_name(), "return"))
1691 action = new ActReturn(v->get_string(), *building);1691 action = new ActReturn(v->get_string(), *building);
1692 else if (not strcmp(v->get_name(), "call"))1692 else if (!strcmp(v->get_name(), "call"))
1693 action = new ActCall(v->get_string(), *building);1693 action = new ActCall(v->get_string(), *building);
1694 else if (not strcmp(v->get_name(), "sleep"))1694 else if (!strcmp(v->get_name(), "sleep"))
1695 action = new ActSleep(v->get_string());1695 action = new ActSleep(v->get_string());
1696 else if (not strcmp(v->get_name(), "animate"))1696 else if (!strcmp(v->get_name(), "animate"))
1697 action = new ActAnimate(v->get_string(), directory, prof, building);1697 action = new ActAnimate(v->get_string(), directory, prof, building);
1698 else if (not strcmp(v->get_name(), "consume"))1698 else if (!strcmp(v->get_name(), "consume"))
1699 action = new ActConsume(v->get_string(), *building);1699 action = new ActConsume(v->get_string(), *building);
1700 else if (not strcmp(v->get_name(), "produce"))1700 else if (!strcmp(v->get_name(), "produce"))
1701 action = new ActProduce(v->get_string(), *building);1701 action = new ActProduce(v->get_string(), *building);
1702 else if (not strcmp(v->get_name(), "recruit"))1702 else if (!strcmp(v->get_name(), "recruit"))
1703 action = new ActRecruit(v->get_string(), *building);1703 action = new ActRecruit(v->get_string(), *building);
1704 else if (not strcmp(v->get_name(), "worker"))1704 else if (!strcmp(v->get_name(), "worker"))
1705 action = new ActWorker(v->get_string(), _name, building);1705 action = new ActWorker(v->get_string(), _name, building);
1706 else if (not strcmp(v->get_name(), "mine"))1706 else if (!strcmp(v->get_name(), "mine"))
1707 action = new ActMine(v->get_string(), world, _name, building);1707 action = new ActMine(v->get_string(), world, _name, building);
1708 else if (not strcmp(v->get_name(), "check_soldier"))1708 else if (!strcmp(v->get_name(), "check_soldier"))
1709 action = new ActCheck_Soldier(v->get_string());1709 action = new ActCheck_Soldier(v->get_string());
1710 else if (not strcmp(v->get_name(), "train"))1710 else if (!strcmp(v->get_name(), "train"))
1711 action = new ActTrain(v->get_string());1711 action = new ActTrain(v->get_string());
1712 else if (not strcmp(v->get_name(), "playFX"))1712 else if (!strcmp(v->get_name(), "playFX"))
1713 action = new ActPlayFX(directory, v->get_string());1713 action = new ActPlayFX(directory, v->get_string());
1714 else if (not strcmp(v->get_name(), "construct"))1714 else if (!strcmp(v->get_name(), "construct"))
1715 action = new ActConstruct(v->get_string(), _name, building);1715 action = new ActConstruct(v->get_string(), _name, building);
1716 else if (not strcmp(v->get_name(), "check_map"))1716 else if (!strcmp(v->get_name(), "check_map"))
1717 action = new ActCheck_Map(v->get_string());1717 action = new ActCheck_Map(v->get_string());
1718 else1718 else
1719 throw game_data_error("unknown command type \"%s\"", v->get_name());1719 throw game_data_error("unknown command type \"%s\"", v->get_name());
17201720
=== modified file 'src/logic/productionsite.cc'
--- src/logic/productionsite.cc 2014-07-23 04:47:30 +0000
+++ src/logic/productionsite.cc 2014-07-25 13:46:28 +0000
@@ -100,7 +100,7 @@
100 if (i.current->first == idx)100 if (i.current->first == idx)
101 throw wexception("duplicated");101 throw wexception("duplicated");
102 int32_t const value = val->get_int();102 int32_t const value = val->get_int();
103 if (value < 1 or 255 < value)103 if (value < 1 || 255 < value)
104 throw wexception("count is out of range 1 .. 255");104 throw wexception("count is out of range 1 .. 255");
105 m_inputs.push_back(std::pair<Ware_Index, uint8_t>(idx, value));105 m_inputs.push_back(std::pair<Ware_Index, uint8_t>(idx, value));
106 } else106 } else
@@ -126,7 +126,7 @@
126 } catch (const _wexception & e) {126 } catch (const _wexception & e) {
127 throw wexception("%s=\"%s\": %s", v->get_name(), v->get_string(), e.what());127 throw wexception("%s=\"%s\": %s", v->get_name(), v->get_string(), e.what());
128 }128 }
129 if (working_positions().empty() and not global_s.has_val("max_soldiers"))129 if (working_positions().empty() && !global_s.has_val("max_soldiers"))
130 throw wexception("no working/soldier positions");130 throw wexception("no working/soldier positions");
131131
132 // Get programs132 // Get programs
@@ -297,7 +297,7 @@
297 unsigned int lastPercOk = (lastOk * 100) / (STATISTICS_VECTOR_LENGTH / 2);297 unsigned int lastPercOk = (lastOk * 100) / (STATISTICS_VECTOR_LENGTH / 2);
298298
299 std::string color;299 std::string color;
300 if (percOk > (m_crude_percent / 10000) and percOk - (m_crude_percent / 10000) > 50)300 if (percOk > (m_crude_percent / 10000) && percOk - (m_crude_percent / 10000) > 50)
301 color = UI_FONT_CLR_IDLE_HEX;301 color = UI_FONT_CLR_IDLE_HEX;
302 else if (percOk < 33)302 else if (percOk < 33)
303 color = UI_FONT_CLR_BAD_HEX;303 color = UI_FONT_CLR_BAD_HEX;
@@ -322,7 +322,7 @@
322 const std::string trend_str =322 const std::string trend_str =
323 (boost::format("<font color=%s>%s</font>") % color % trend).str();323 (boost::format("<font color=%s>%s</font>") % color % trend).str();
324324
325 if (0 < percOk and percOk < 100) {325 if (0 < percOk && percOk < 100) {
326 snprintf326 snprintf
327 (m_statistics_buffer, sizeof(m_statistics_buffer),327 (m_statistics_buffer, sizeof(m_statistics_buffer),
328 "%s %s", perc_str.c_str(), trend_str.c_str());328 "%s %s", perc_str.c_str(), trend_str.c_str());
@@ -452,7 +452,7 @@
452 assigned = true;452 assigned = true;
453 break;453 break;
454 }454 }
455 if (not assigned)455 if (!assigned)
456 return -1;456 return -1;
457457
458 if (upcast(Game, game, &egbase))458 if (upcast(Game, game, &egbase))
@@ -595,7 +595,7 @@
595595
596 if596 if
597 (m_program_timer597 (m_program_timer
598 and598 &&
599 static_cast<int32_t>(game.get_gametime() - m_program_time) >= 0)599 static_cast<int32_t>(game.get_gametime() - m_program_time) >= 0)
600 {600 {
601 m_program_timer = false;601 m_program_timer = false;
@@ -689,7 +689,7 @@
689689
690690
691void ProductionSite::try_start_working(Game & game) {691void ProductionSite::try_start_working(Game & game) {
692 if (can_start_working() and descr().working_positions().size()) {692 if (can_start_working() && descr().working_positions().size()) {
693 Worker & main_worker = *m_working_positions[0].worker;693 Worker & main_worker = *m_working_positions[0].worker;
694 main_worker.reset_tasks(game);694 main_worker.reset_tasks(game);
695 main_worker.start_task_buildingwork(game);695 main_worker.start_task_buildingwork(game);
696696
=== modified file 'src/logic/requirements.cc'
--- src/logic/requirements.cc 2014-07-05 12:17:03 +0000
+++ src/logic/requirements.cc 2014-07-25 13:46:28 +0000
@@ -30,7 +30,7 @@
3030
31bool Requirements::check(const Map_Object & obj) const31bool Requirements::check(const Map_Object & obj) const
32{32{
33 return !m or m->check(obj);33 return !m || m->check(obj);
34}34}
3535
36#define REQUIREMENTS_VERSION 336#define REQUIREMENTS_VERSION 3
@@ -227,8 +227,8 @@
227{227{
228 tAttribute const at = static_cast<tAttribute>(fr.Unsigned32());228 tAttribute const at = static_cast<tAttribute>(fr.Unsigned32());
229 if229 if
230 (at != atrHP and at != atrAttack and at != atrDefense and at != atrEvade230 (at != atrHP && at != atrAttack && at != atrDefense && at != atrEvade
231 and231 &&
232 at != atrTotal)232 at != atrTotal)
233 throw game_data_error233 throw game_data_error
234 (234 (
235235
=== modified file 'src/logic/single_player_game_settings_provider.cc'
--- src/logic/single_player_game_settings_provider.cc 2014-07-16 19:23:38 +0000
+++ src/logic/single_player_game_settings_provider.cc 2014-07-25 13:46:28 +0000
@@ -220,8 +220,8 @@
220 PlayerSettings const position = settings().players.at(number);220 PlayerSettings const position = settings().players.at(number);
221 PlayerSettings const player = settings().players.at(settings().playernum);221 PlayerSettings const player = settings().players.at(settings().playernum);
222 if222 if
223 (number < settings().players.size() and223 (number < settings().players.size() &&
224 (position.state == PlayerSettings::stateOpen or224 (position.state == PlayerSettings::stateOpen ||
225 position.state == PlayerSettings::stateComputer))225 position.state == PlayerSettings::stateComputer))
226 {226 {
227 setPlayer(number, player);227 setPlayer(number, player);
228228
=== modified file 'src/logic/soldier.cc'
--- src/logic/soldier.cc 2014-07-16 08:25:35 +0000
+++ src/logic/soldier.cc 2014-07-25 13:46:28 +0000
@@ -60,10 +60,10 @@
60 * remove spaces at the beginning or the end of a string60 * remove spaces at the beginning or the end of a string
61 */61 */
62void remove_spaces(std::string& s) {62void remove_spaces(std::string& s) {
63 while (s[0] == ' ' or s[0] == '\t' or s[0] == '\n')63 while (s[0] == ' ' || s[0] == '\t' || s[0] == '\n')
64 s.erase(0, 1);64 s.erase(0, 1);
6565
66 while (*s.rbegin() == ' ' or * s.rbegin() == '\t' or * s.rbegin() == '\n')66 while (*s.rbegin() == ' ' || * s.rbegin() == '\t' || * s.rbegin() == '\n')
67 s.erase(s.size() - 1, 1);67 s.erase(s.size() - 1, 1);
68}68}
6969
@@ -91,12 +91,12 @@
91 remove_spaces(*i.current);91 remove_spaces(*i.current);
92 char * endp;92 char * endp;
93 m_min_attack = strtol(list[0].c_str(), &endp, 0);93 m_min_attack = strtol(list[0].c_str(), &endp, 0);
94 if (*endp or 0 == m_min_attack)94 if (*endp || 0 == m_min_attack)
95 throw game_data_error95 throw game_data_error
96 ("expected %s but found \"%s\"",96 ("expected %s but found \"%s\"",
97 "positive integer", list[0].c_str());97 "positive integer", list[0].c_str());
98 m_max_attack = strtol(list[1].c_str(), &endp, 0);98 m_max_attack = strtol(list[1].c_str(), &endp, 0);
99 if (*endp or m_max_attack < m_min_attack)99 if (*endp || m_max_attack < m_min_attack)
100 throw game_data_error100 throw game_data_error
101 ("expected positive integer >= %u but found \"%s\"",101 ("expected positive integer >= %u but found \"%s\"",
102 m_min_attack, list[1].c_str());102 m_min_attack, list[1].c_str());
@@ -988,13 +988,13 @@
988 }988 }
989989
990 if990 if
991 (!enemy or991 (!enemy ||
992 ((state.ivar1 & CF_RETREAT_WHEN_INJURED) and992 ((state.ivar1 & CF_RETREAT_WHEN_INJURED) &&
993 state.ui32var3 > get_current_hitpoints() and993 state.ui32var3 > get_current_hitpoints() &&
994 defenders > 0))994 defenders > 0))
995 {995 {
996 // Injured soldiers will try to return to safe site at home.996 // Injured soldiers will try to return to safe site at home.
997 if (state.ui32var3 > get_current_hitpoints() and defenders) {997 if (state.ui32var3 > get_current_hitpoints() && defenders) {
998 state.coords = Coords::Null();998 state.coords = Coords::Null();
999 state.objvar1 = nullptr;999 state.objvar1 = nullptr;
1000 }1000 }
@@ -1004,12 +1004,12 @@
1004 if (state.coords) {1004 if (state.coords) {
1005 BaseImmovable * const newimm = game.map()[state.coords].get_immovable();1005 BaseImmovable * const newimm = game.map()[state.coords].get_immovable();
1006 upcast(MilitarySite, newsite, newimm);1006 upcast(MilitarySite, newsite, newimm);
1007 if (newsite and (&newsite->owner() == &owner())) {1007 if (newsite && (&newsite->owner() == &owner())) {
1008 if (upcast(SoldierControl, ctrl, newsite)) {1008 if (upcast(SoldierControl, ctrl, newsite)) {
1009 state.objvar1 = nullptr;1009 state.objvar1 = nullptr;
1010 // We may also have our location destroyed in between1010 // We may also have our location destroyed in between
1011 if1011 if
1012 (ctrl->stationedSoldiers().size() < ctrl->soldierCapacity() and1012 (ctrl->stationedSoldiers().size() < ctrl->soldierCapacity() &&
1013 (!location || location->base_flag().get_position()1013 (!location || location->base_flag().get_position()
1014 !=1014 !=
1015 newsite ->base_flag().get_position()))1015 newsite ->base_flag().get_position()))
@@ -1078,8 +1078,8 @@
1078 {1078 {
1079 if (upcast(Soldier, soldier, bob)) {1079 if (upcast(Soldier, soldier, bob)) {
1080 return1080 return
1081 soldier->get_current_hitpoints() and1081 soldier->get_current_hitpoints() &&
1082 soldier->is_attacking_player(game, player) and1082 soldier->is_attacking_player(game, player) &&
1083 soldier->owner().is_hostile(player);1083 soldier->owner().is_hostile(player);
1084 }1084 }
1085 return false;1085 return false;
@@ -1169,7 +1169,7 @@
1169 * Attempt to fix a crash when player bulldozes a building being defended1169 * Attempt to fix a crash when player bulldozes a building being defended
1170 * by soldiers.1170 * by soldiers.
1171 */1171 */
1172 if (not location)1172 if (!location)
1173 return pop_task(game);1173 return pop_task(game);
11741174
1175 Flag & baseflag = location->base_flag();1175 Flag & baseflag = location->base_flag();
@@ -1186,7 +1186,7 @@
11861186
1187 // If we only are defending our home ...1187 // If we only are defending our home ...
1188 if (state.ivar1 & CF_DEFEND_STAYHOME) {1188 if (state.ivar1 & CF_DEFEND_STAYHOME) {
1189 if (position == location and state.ivar2 == 1) {1189 if (position == location && state.ivar2 == 1) {
1190 molog("[defense] stayhome: returned home\n");1190 molog("[defense] stayhome: returned home\n");
1191 return pop_task_or_fight(game);1191 return pop_task_or_fight(game);
1192 }1192 }
@@ -1233,8 +1233,8 @@
1233 FindBobSoldierAttackingPlayer(game, *get_owner()));1233 FindBobSoldierAttackingPlayer(game, *get_owner()));
12341234
1235 if1235 if
1236 (soldiers.empty() or1236 (soldiers.empty() ||
1237 ((state.ivar1 & CF_RETREAT_WHEN_INJURED) and1237 ((state.ivar1 & CF_RETREAT_WHEN_INJURED) &&
1238 get_current_hitpoints() < state.ui32var3))1238 get_current_hitpoints() < state.ui32var3))
1239 {1239 {
12401240
@@ -1290,7 +1290,7 @@
1290 // Check soldier, be sure that we can fight against soldier.1290 // Check soldier, be sure that we can fight against soldier.
1291 // Soldiers can not go over enemy land when defending.1291 // Soldiers can not go over enemy land when defending.
1292 if1292 if
1293 ((soldier->canBeChallenged()) and1293 ((soldier->canBeChallenged()) &&
1294 (f.get_owned_by() == get_owner()->player_number()))1294 (f.get_owned_by() == get_owner()->player_number()))
1295 {1295 {
1296 uint32_t thisDist = game.map().calc_distance1296 uint32_t thisDist = game.map().calc_distance
@@ -1510,7 +1510,7 @@
1510 }1510 }
1511 }1511 }
1512 } else {1512 } else {
1513 if (opponent.stayHome() and (this == m_battle->second())) {1513 if (opponent.stayHome() && (this == m_battle->second())) {
1514 // Wait until correct roles are assigned1514 // Wait until correct roles are assigned
1515 new Battle(game, *m_battle->second(), *m_battle->first());1515 new Battle(game, *m_battle->second(), *m_battle->first());
1516 return schedule_act(game, 10);1516 return schedule_act(game, 10);
@@ -1682,7 +1682,7 @@
1682 {1682 {
1683 if (upcast(Soldier, soldier, bob))1683 if (upcast(Soldier, soldier, bob))
1684 return1684 return
1685 soldier->isOnBattlefield() and1685 soldier->isOnBattlefield() &&
1686 soldier->get_current_hitpoints();1686 soldier->get_current_hitpoints();
1687 return false;1687 return false;
1688 }1688 }
@@ -1703,7 +1703,7 @@
17031703
1704 if1704 if
1705 (!attackdefense ||1705 (!attackdefense ||
1706 ((attackdefense->ivar1 & CF_RETREAT_WHEN_INJURED) and1706 ((attackdefense->ivar1 & CF_RETREAT_WHEN_INJURED) &&
1707 attackdefense->ui32var3 > get_current_hitpoints()))1707 attackdefense->ui32var3 > get_current_hitpoints()))
1708 {1708 {
1709 // Retreating or non-combatant soldiers act like normal bobs1709 // Retreating or non-combatant soldiers act like normal bobs
17101710
=== modified file 'src/logic/trainingsite.cc'
--- src/logic/trainingsite.cc 2014-07-22 09:54:49 +0000
+++ src/logic/trainingsite.cc 2014-07-25 13:46:28 +0000
@@ -208,7 +208,7 @@
208208
209 container_iterate_const(std::vector<Soldier *>, m_soldiers, i) {209 container_iterate_const(std::vector<Soldier *>, m_soldiers, i) {
210 (*i.current)->set_location_initially(*this);210 (*i.current)->set_location_initially(*this);
211 assert(not (*i.current)->get_state()); // Should be newly created.211 assert(!(*i.current)->get_state()); // Should be newly created.
212212
213 if (game)213 if (game)
214 (*i.current)->start_task_idle(*game, 0, -1);214 (*i.current)->start_task_idle(*game, 0, -1);
215215
=== modified file 'src/logic/tribe.cc'
--- src/logic/tribe.cc 2014-07-22 09:54:49 +0000
+++ src/logic/tribe.cc 2014-07-25 13:46:28 +0000
@@ -105,7 +105,7 @@
105 (_name, _descname, path, prof, global_s, *this); \105 (_name, _descname, path, prof, global_s, *this); \
106 Ware_Index const worker_idx = m_workers.add(&worker_descr); \106 Ware_Index const worker_idx = m_workers.add(&worker_descr); \
107 if \107 if \
108 (worker_descr.is_buildable() and \108 (worker_descr.is_buildable() && \
109 worker_descr.buildcost().empty()) \109 worker_descr.buildcost().empty()) \
110 m_worker_types_without_cost.push_back(worker_idx); \110 m_worker_types_without_cost.push_back(worker_idx); \
111 PARSE_MAP_OBJECT_TYPES_END;111 PARSE_MAP_OBJECT_TYPES_END;
@@ -384,7 +384,7 @@
384uint32_t Tribe_Descr::get_resource_indicator384uint32_t Tribe_Descr::get_resource_indicator
385 (ResourceDescription const * const res, uint32_t const amount) const385 (ResourceDescription const * const res, uint32_t const amount) const
386{386{
387 if (not res or not amount) {387 if (!res || !amount) {
388 int32_t idx = get_immovable_index("resi_none");388 int32_t idx = get_immovable_index("resi_none");
389 if (idx == -1)389 if (idx == -1)
390 throw game_data_error390 throw game_data_error
@@ -405,7 +405,7 @@
405 ++num_indicators;405 ++num_indicators;
406 }406 }
407407
408 if (not num_indicators)408 if (!num_indicators)
409 throw game_data_error409 throw game_data_error
410 ("tribe %s does not declare a resource indicator for resource %s",410 ("tribe %s does not declare a resource indicator for resource %s",
411 name().c_str(),411 name().c_str(),
412412
=== modified file 'src/logic/warehouse.cc'
--- src/logic/warehouse.cc 2014-07-22 09:54:49 +0000
+++ src/logic/warehouse.cc 2014-07-25 13:46:28 +0000
@@ -372,7 +372,7 @@
372 for (uint8_t i = worker_types_without_cost.size(); i;) {372 for (uint8_t i = worker_types_without_cost.size(); i;) {
373 Ware_Index const worker_index = worker_types_without_cost.at(--i);373 Ware_Index const worker_index = worker_types_without_cost.at(--i);
374 if374 if
375 (owner().is_worker_type_allowed(worker_index) and375 (owner().is_worker_type_allowed(worker_index) &&
376 m_next_worker_without_cost_spawn[i] == static_cast<uint32_t>(Never()))376 m_next_worker_without_cost_spawn[i] == static_cast<uint32_t>(Never()))
377 {377 {
378 if (next_spawn == static_cast<uint32_t>(Never()))378 if (next_spawn == static_cast<uint32_t>(Never()))
@@ -610,7 +610,7 @@
610 Soldier * soldier = static_cast<Soldier *>(*it);610 Soldier * soldier = static_cast<Soldier *>(*it);
611611
612 // Soldier dead ...612 // Soldier dead ...
613 if (not soldier or soldier->get_current_hitpoints() == 0) {613 if (!soldier || soldier->get_current_hitpoints() == 0) {
614 it = soldiers.erase(it);614 it = soldiers.erase(it);
615 m_supply->remove_workers(ware, 1);615 m_supply->remove_workers(ware, 1);
616 continue;616 continue;
@@ -950,14 +950,14 @@
950950
951951
952bool Warehouse::can_create_worker(Game &, Ware_Index const worker) const {952bool Warehouse::can_create_worker(Game &, Ware_Index const worker) const {
953 if (not (worker < m_supply->get_workers().get_nrwareids()))953 if (!(worker < m_supply->get_workers().get_nrwareids()))
954 throw wexception954 throw wexception
955 ("worker type %d does not exists (max is %d)",955 ("worker type %d does not exists (max is %d)",
956 worker, m_supply->get_workers().get_nrwareids());956 worker, m_supply->get_workers().get_nrwareids());
957957
958 const Worker_Descr & w_desc = *descr().tribe().get_worker_descr(worker);958 const Worker_Descr & w_desc = *descr().tribe().get_worker_descr(worker);
959 assert(&w_desc);959 assert(&w_desc);
960 if (not w_desc.is_buildable())960 if (!w_desc.is_buildable())
961 return false;961 return false;
962962
963 // see if we have the resources963 // see if we have the resources
964964
=== modified file 'src/logic/warelist.h'
--- src/logic/warelist.h 2014-07-05 16:41:51 +0000
+++ src/logic/warelist.h 2014-07-25 13:46:28 +0000
@@ -59,7 +59,7 @@
59 }59 }
6060
61 bool operator== (const WareList &) const;61 bool operator== (const WareList &) const;
62 bool operator!= (const WareList & wl) const {return not (*this == wl);}62 bool operator!= (const WareList & wl) const {return !(*this == wl);}
6363
64 mutable boost::signals2::signal<void ()> changed;64 mutable boost::signals2::signal<void ()> changed;
6565
6666
=== modified file 'src/logic/widelands.h'
--- src/logic/widelands.h 2014-07-22 09:54:49 +0000
+++ src/logic/widelands.h 2014-07-25 13:46:28 +0000
@@ -72,19 +72,19 @@
72 uint8_t hp, attack, defense, evade;72 uint8_t hp, attack, defense, evade;
73 bool operator== (const Soldier_Strength & other) const {73 bool operator== (const Soldier_Strength & other) const {
74 return74 return
75 hp == other.hp and75 hp == other.hp &&
76 attack == other.attack and76 attack == other.attack &&
77 defense == other.defense and77 defense == other.defense &&
78 evade == other.evade;78 evade == other.evade;
79 }79 }
80 bool operator< (const Soldier_Strength & other) const {80 bool operator< (const Soldier_Strength & other) const {
81 return81 return
82 hp < other.hp or82 hp < other.hp ||
83 (hp == other.hp and83 (hp == other.hp &&
84 (attack < other.attack or84 (attack < other.attack ||
85 (attack == other.attack and85 (attack == other.attack &&
86 (defense < other.defense or86 (defense < other.defense ||
87 (defense == other.defense and87 (defense == other.defense &&
88 evade < other.evade)))));88 evade < other.evade)))));
89 }89 }
90};90};
9191
=== modified file 'src/logic/widelands_geometry.cc'
--- src/logic/widelands_geometry.cc 2014-06-21 16:01:35 +0000
+++ src/logic/widelands_geometry.cc 2014-07-25 13:46:28 +0000
@@ -28,11 +28,11 @@
28 {}28 {}
2929
30bool Coords::operator== (const Coords& other) const {30bool Coords::operator== (const Coords& other) const {
31 return x == other.x and y == other.y;31 return x == other.x && y == other.y;
32}32}
3333
34bool Coords::operator!= (const Coords & other) const {34bool Coords::operator!= (const Coords & other) const {
35 return not (*this == other);35 return !(*this == other);
36}36}
3737
38Coords::operator bool() const {38Coords::operator bool() const {
@@ -44,7 +44,7 @@
44 if (y < new_origin.y)44 if (y < new_origin.y)
45 y += extent.h;45 y += extent.h;
46 y -= new_origin.y;46 y -= new_origin.y;
47 if ((y & 1)and(new_origin.y & 1) and++ new_origin.x == extent.w)47 if ((y & 1) && (new_origin.y & 1) && ++ new_origin.x == extent.w)
48 new_origin.x = 0;48 new_origin.x = 0;
49 if (x < new_origin.x)49 if (x < new_origin.x)
50 x += extent.w;50 x += extent.w;
5151
=== modified file 'src/logic/widelands_geometry.h'
--- src/logic/widelands_geometry.h 2014-07-05 16:41:51 +0000
+++ src/logic/widelands_geometry.h 2014-07-25 13:46:28 +0000
@@ -79,10 +79,10 @@
79 {}79 {}
8080
81 bool operator== (const Area& other) const {81 bool operator== (const Area& other) const {
82 return Coords_type::operator== (other) and radius == other.radius;82 return Coords_type::operator== (other) && radius == other.radius;
83 }83 }
84 bool operator!= (const Area& other) const {84 bool operator!= (const Area& other) const {
85 return Coords_type::operator!= (other) or radius != other.radius;85 return Coords_type::operator!= (other) || radius != other.radius;
86 }86 }
8787
88 Radius_type radius;88 Radius_type radius;
@@ -96,10 +96,10 @@
9696
97 bool operator== (const HollowArea& other) const {97 bool operator== (const HollowArea& other) const {
98 return98 return
99 Area_type::operator== (other) and hole_radius == other.hole_radius;99 Area_type::operator== (other) && hole_radius == other.hole_radius;
100 }100 }
101 bool operator!= (const HollowArea& other) const {101 bool operator!= (const HollowArea& other) const {
102 return not (*this == other);102 return !(*this == other);
103 }103 }
104104
105 typename Area_type::Radius_type hole_radius;105 typename Area_type::Radius_type hole_radius;
@@ -133,10 +133,10 @@
133 {}133 {}
134134
135 bool operator== (const TCoords& other) const {135 bool operator== (const TCoords& other) const {
136 return Coords_type::operator== (other) and t == other.t;136 return Coords_type::operator== (other) && t == other.t;
137 }137 }
138 bool operator!= (const TCoords& other) const {138 bool operator!= (const TCoords& other) const {
139 return Coords_type::operator!= (other) or t != other.t;139 return Coords_type::operator!= (other) || t != other.t;
140 }140 }
141141
142 TriangleIndex t;142 TriangleIndex t;
@@ -155,10 +155,10 @@
155 {}155 {}
156156
157 bool operator== (Node_and_Triangle<> const other) const {157 bool operator== (Node_and_Triangle<> const other) const {
158 return node == other.node and triangle == other.triangle;158 return node == other.node && triangle == other.triangle;
159 }159 }
160 bool operator!= (Node_and_Triangle<> const other) const {160 bool operator!= (Node_and_Triangle<> const other) const {
161 return not (*this == other);161 return !(*this == other);
162 }162 }
163163
164 Node_Coords_type node;164 Node_Coords_type node;
165165
=== modified file 'src/logic/widelands_geometry_io.cc'
--- src/logic/widelands_geometry_io.cc 2014-05-11 07:38:01 +0000
+++ src/logic/widelands_geometry_io.cc 2014-07-25 13:46:28 +0000
@@ -94,8 +94,8 @@
94}94}
9595
96void WriteCoords32(StreamWrite* wr, const Coords& c) {96void WriteCoords32(StreamWrite* wr, const Coords& c) {
97 assert(static_cast<uint16_t>(c.x) < 0x8000 or c.x == -1);97 assert(static_cast<uint16_t>(c.x) < 0x8000 || c.x == -1);
98 assert(static_cast<uint16_t>(c.y) < 0x8000 or c.y == -1);98 assert(static_cast<uint16_t>(c.y) < 0x8000 || c.y == -1);
99 {99 {
100 uint16_t const x = Little16(c.x);100 uint16_t const x = Little16(c.x);
101 wr->Data(&x, 2);101 wr->Data(&x, 2);
102102
=== modified file 'src/logic/worker.cc'
--- src/logic/worker.cc 2014-07-24 05:21:20 +0000
+++ src/logic/worker.cc 2014-07-25 13:46:28 +0000
@@ -646,7 +646,7 @@
646646
647 // Walk towards it647 // Walk towards it
648 if648 if
649 (not649 (!
650 start_task_movepath650 start_task_movepath
651 (game,651 (game,
652 dest,652 dest,
@@ -1072,7 +1072,7 @@
1072 */1072 */
1073void Worker::set_location(PlayerImmovable * const location)1073void Worker::set_location(PlayerImmovable * const location)
1074{1074{
1075 assert(not location or Object_Ptr(location).get(owner().egbase()));1075 assert(!location || Object_Ptr(location).get(owner().egbase()));
10761076
1077 PlayerImmovable * const oldlocation = get_location(owner().egbase());1077 PlayerImmovable * const oldlocation = get_location(owner().egbase());
1078 if (oldlocation == location)1078 if (oldlocation == location)
@@ -1486,7 +1486,7 @@
1486 } else if (upcast(Road, road, nextstep)) { // Flag to Road1486 } else if (upcast(Road, road, nextstep)) { // Flag to Road
1487 if1487 if
1488 (&road->get_flag(Road::FlagStart) != location1488 (&road->get_flag(Road::FlagStart) != location
1489 and1489 &&
1490 &road->get_flag(Road::FlagEnd) != location)1490 &road->get_flag(Road::FlagEnd) != location)
1491 throw wexception1491 throw wexception
1492 ("MO(%u): [transfer]: nextstep is road, but we are nowhere near",1492 ("MO(%u): [transfer]: nextstep is road, but we are nowhere near",
@@ -1696,7 +1696,7 @@
1696 // state pointer might become invalid1696 // state pointer might become invalid
1697 state.ivar1 = 1;1697 state.ivar1 = 1;
16981698
1699 if (not building->get_building_work(game, *this, success)) {1699 if (!building->get_building_work(game, *this, success)) {
1700 set_animation(game, 0);1700 set_animation(game, 0);
1701 return skip_act();1701 return skip_act();
1702 }1702 }
@@ -1820,7 +1820,7 @@
1820 // Determine the building's flag and move to it1820 // Determine the building's flag and move to it
18211821
1822 if1822 if
1823 (not1823 (!
1824 start_task_movepath1824 start_task_movepath
1825 (game,1825 (game,
1826 location->base_flag().get_position(),1826 location->base_flag().get_position(),
@@ -2185,7 +2185,7 @@
21852185
2186 state.ivar1 = 1; // force return to building2186 state.ivar1 = 1; // force return to building
21872187
2188 if (not location) {2188 if (!location) {
2189 // this can happen if the flag (and the building) is destroyed while2189 // this can happen if the flag (and the building) is destroyed while
2190 // the worker leaves the building.2190 // the worker leaves the building.
2191 molog2191 molog
@@ -2216,7 +2216,7 @@
2216 descr().get_right_walk_anims(does_carry_ware()), true);2216 descr().get_right_walk_anims(does_carry_ware()), true);
2217 }2217 }
22182218
2219 if (not dynamic_cast<Building const *>(location)) {2219 if (!dynamic_cast<Building const *>(location)) {
2220 // This can happen "naturally" if the building gets destroyed, but the2220 // This can happen "naturally" if the building gets destroyed, but the
2221 // flag is still there and the worker tries to enter from that flag.2221 // flag is still there and the worker tries to enter from that flag.
2222 // E.g. the player destroyed the building, it is destroyed, through an2222 // E.g. the player destroyed the building, it is destroyed, through an
@@ -2510,7 +2510,7 @@
25102510
2511 // check whether we're on a flag and it's time to return home2511 // check whether we're on a flag and it's time to return home
2512 if (upcast(Flag, flag, map[get_position()].get_immovable())) {2512 if (upcast(Flag, flag, map[get_position()].get_immovable())) {
2513 if (&flag->owner() == &owner() and flag->economy().warehouses().size()) {2513 if (&flag->owner() == &owner() && flag->economy().warehouses().size()) {
2514 set_location(flag);2514 set_location(flag);
2515 return pop_task(game);2515 return pop_task(game);
2516 }2516 }
@@ -2650,11 +2650,11 @@
2650 BaseImmovable * const imm = map.get_immovable(get_position());2650 BaseImmovable * const imm = map.get_immovable(get_position());
26512651
2652 if2652 if
2653 (not imm2653 (!imm
2654 or2654 ||
2655 (imm->get_size() == BaseImmovable::NONE2655 (imm->get_size() == BaseImmovable::NONE
2656 and2656 &&
2657 not imm->has_attribute(RESI)))2657 !imm->has_attribute(RESI)))
2658 {2658 {
2659 --state.ivar1;2659 --state.ivar1;
2660 return start_task_program(game, state.svar1);2660 return start_task_program(game, state.svar1);
@@ -2732,7 +2732,7 @@
2732 return pop_task(game);2732 return pop_task(game);
27332733
2734 if2734 if
2735 (not2735 (!
2736 start_task_movepath2736 start_task_movepath
2737 (game, owner_area, 0, descr().get_right_walk_anims(does_carry_ware())))2737 (game, owner_area, 0, descr().get_right_walk_anims(does_carry_ware())))
2738 {2738 {
@@ -2854,7 +2854,7 @@
28542854
2855 if2855 if
2856 (dist > oldest_distance2856 (dist > oldest_distance
2857 || (dist == oldest_distance and time < oldest_time))2857 || (dist == oldest_distance && time < oldest_time))
2858 {2858 {
2859 oldest_distance = dist;2859 oldest_distance = dist;
2860 oldest_time = time;2860 oldest_time = time;
28612861
=== modified file 'src/logic/worker.h'
--- src/logic/worker.h 2014-07-23 16:01:30 +0000
+++ src/logic/worker.h 2014-07-25 13:46:28 +0000
@@ -92,7 +92,7 @@
92 /// should be there already). The worker must already be in the same economy92 /// should be there already). The worker must already be in the same economy
93 /// as the location.93 /// as the location.
94 void set_location_initially(PlayerImmovable & location) {94 void set_location_initially(PlayerImmovable & location) {
95 assert(not m_location.is_set());95 assert(!m_location.is_set());
96 assert(location.serial());96 assert(location.serial());
97 assert(m_economy);97 assert(m_economy);
98 assert(m_economy == location.get_economy());98 assert(m_economy == location.get_economy());
9999
=== modified file 'src/map_io/s2map.cc'
--- src/map_io/s2map.cc 2014-07-23 14:49:10 +0000
+++ src/map_io/s2map.cc 2014-07-25 13:46:28 +0000
@@ -174,11 +174,11 @@
174 std::unique_ptr<uint8_t[]> section;174 std::unique_ptr<uint8_t[]> section;
175 memcpy(buffer, fr.Data(6), 6);175 memcpy(buffer, fr.Data(6), 6);
176 if176 if
177 (buffer[0] != 0x10 or177 (buffer[0] != 0x10 ||
178 buffer[1] != 0x27 or178 buffer[1] != 0x27 ||
179 buffer[2] != 0x00 or179 buffer[2] != 0x00 ||
180 buffer[3] != 0x00 or180 buffer[3] != 0x00 ||
181 buffer[4] != 0x00 or181 buffer[4] != 0x00 ||
182 buffer[5] != 0x00)182 buffer[5] != 0x00)
183 {183 {
184 cerr << "Section marker not found" << endl;184 cerr << "Section marker not found" << endl;
185185
=== modified file 'src/map_io/widelands_map_building_data_packet.cc'
--- src/map_io/widelands_map_building_data_packet.cc 2014-07-14 21:52:13 +0000
+++ src/map_io/widelands_map_building_data_packet.cc 2014-07-25 13:46:28 +0000
@@ -131,7 +131,7 @@
131 Extent const extent = map.extent();131 Extent const extent = map.extent();
132 iterate_Map_FCoords(map, extent, fc) {132 iterate_Map_FCoords(map, extent, fc) {
133 upcast(Building const, building, fc.field->get_immovable());133 upcast(Building const, building, fc.field->get_immovable());
134 if (building and building->get_position() == fc) {134 if (building && building->get_position() == fc) {
135 // We only write Buildings.135 // We only write Buildings.
136 // Buildings can life on only one main position.136 // Buildings can life on only one main position.
137 assert(!mos.is_object_known(*building));137 assert(!mos.is_object_known(*building));
138138
=== modified file 'src/map_io/widelands_map_buildingdata_data_packet.cc'
--- src/map_io/widelands_map_buildingdata_data_packet.cc 2014-07-16 08:25:35 +0000
+++ src/map_io/widelands_map_buildingdata_data_packet.cc 2014-07-25 13:46:28 +0000
@@ -80,13 +80,13 @@
8080
81 try {81 try {
82 uint16_t const packet_version = fr.Unsigned16();82 uint16_t const packet_version = fr.Unsigned16();
83 if (1 <= packet_version and packet_version <= CURRENT_PACKET_VERSION) {83 if (1 <= packet_version && packet_version <= CURRENT_PACKET_VERSION) {
84 for (;;) {84 for (;;) {
85 if (2 <= packet_version and fr.EndOfFile())85 if (2 <= packet_version && fr.EndOfFile())
86 break;86 break;
87 Serial const serial = fr.Unsigned32();87 Serial const serial = fr.Unsigned32();
88 if (packet_version < 2 and serial == 0xffffffff) {88 if (packet_version < 2 && serial == 0xffffffff) {
89 if (not fr.EndOfFile())89 if (!fr.EndOfFile())
90 throw game_data_error90 throw game_data_error
91 ("expected end of file after serial 0xffffffff");91 ("expected end of file after serial 0xffffffff");
92 break;92 break;
@@ -478,7 +478,7 @@
478 try {478 try {
479 uint16_t const packet_version = fr.Unsigned16();479 uint16_t const packet_version = fr.Unsigned16();
480 if480 if
481 (1 <= packet_version and481 (1 <= packet_version &&
482 packet_version <= CURRENT_WAREHOUSE_PACKET_VERSION)482 packet_version <= CURRENT_WAREHOUSE_PACKET_VERSION)
483 {483 {
484 Ware_Index const nr_wares = warehouse.descr().tribe().get_nrwares();484 Ware_Index const nr_wares = warehouse.descr().tribe().get_nrwares();
@@ -617,7 +617,7 @@
617 } else617 } else
618 for (;;) {618 for (;;) {
619 char const * const worker_typename = fr.CString ();619 char const * const worker_typename = fr.CString ();
620 if (not *worker_typename) // encountered the terminator ("")620 if (!*worker_typename) // encountered the terminator ("")
621 break;621 break;
622 uint32_t const next_spawn = fr.Unsigned32();622 uint32_t const next_spawn = fr.Unsigned32();
623 Ware_Index const worker_index =623 Ware_Index const worker_index =
@@ -852,7 +852,7 @@
852 try {852 try {
853 uint16_t const packet_version = fr.Unsigned16();853 uint16_t const packet_version = fr.Unsigned16();
854 if854 if
855 (1 <= packet_version and855 (1 <= packet_version &&
856 packet_version <= CURRENT_PRODUCTIONSITE_PACKET_VERSION)856 packet_version <= CURRENT_PRODUCTIONSITE_PACKET_VERSION)
857 {857 {
858 ProductionSite::Working_Position & wp_begin =858 ProductionSite::Working_Position & wp_begin =
@@ -923,9 +923,9 @@
923 uint32_t count = j->second;923 uint32_t count = j->second;
924 assert(count);924 assert(count);
925 if (worker_descr.can_act_as(j->first)) {925 if (worker_descr.can_act_as(j->first)) {
926 while (wp->worker or wp->worker_request) {926 while (wp->worker || wp->worker_request) {
927 ++wp;927 ++wp;
928 if (not --count)928 if (!--count)
929 goto end_working_position;929 goto end_working_position;
930 }930 }
931 break;931 break;
@@ -1504,7 +1504,7 @@
1504 fw.Unsigned16(nr_workers);1504 fw.Unsigned16(nr_workers);
1505 for (ProductionSite::Working_Position const * i = &begin; i < &end; ++i)1505 for (ProductionSite::Working_Position const * i = &begin; i < &end; ++i)
1506 if (Worker const * const w = i->worker) {1506 if (Worker const * const w = i->worker) {
1507 assert(not i->worker_request);1507 assert(!i->worker_request);
1508 assert(mos.is_object_known(*w));1508 assert(mos.is_object_known(*w));
1509 fw.Unsigned32(mos.get_object_file_index(*w));1509 fw.Unsigned32(mos.get_object_file_index(*w));
1510 }1510 }
15111511
=== modified file 'src/map_io/widelands_map_extradata_data_packet.cc'
--- src/map_io/widelands_map_extradata_data_packet.cc 2014-07-15 18:38:06 +0000
+++ src/map_io/widelands_map_extradata_data_packet.cc 2014-07-25 13:46:28 +0000
@@ -47,7 +47,7 @@
47 prof.get_safe_section("global").get_safe_int("packet_version");47 prof.get_safe_section("global").get_safe_int("packet_version");
48 if (packet_version == CURRENT_PACKET_VERSION) {48 if (packet_version == CURRENT_PACKET_VERSION) {
49 // Read all pics.49 // Read all pics.
50 if (fs.FileExists("pics") and fs.IsDirectory("pics")) {50 if (fs.FileExists("pics") && fs.IsDirectory("pics")) {
51 filenameset_t pictures = fs.ListDirectory("pics");51 filenameset_t pictures = fs.ListDirectory("pics");
52 for52 for
53 (filenameset_t::iterator pname = pictures.begin();53 (filenameset_t::iterator pname = pictures.begin();
5454
=== modified file 'src/map_io/widelands_map_flagdata_data_packet.cc'
--- src/map_io/widelands_map_flagdata_data_packet.cc 2014-07-03 19:26:30 +0000
+++ src/map_io/widelands_map_flagdata_data_packet.cc 2014-07-25 13:46:28 +0000
@@ -54,15 +54,15 @@
5454
55 try {55 try {
56 uint16_t const packet_version = fr.Unsigned16();56 uint16_t const packet_version = fr.Unsigned16();
57 if (1 <= packet_version and packet_version <= CURRENT_PACKET_VERSION) {57 if (1 <= packet_version && packet_version <= CURRENT_PACKET_VERSION) {
58 const Map & map = egbase.map();58 const Map & map = egbase.map();
59 Extent const extent = map.extent();59 Extent const extent = map.extent();
60 for (;;) {60 for (;;) {
61 if (2 <= packet_version and fr.EndOfFile())61 if (2 <= packet_version && fr.EndOfFile())
62 break;62 break;
63 Serial const serial = fr.Unsigned32();63 Serial const serial = fr.Unsigned32();
64 if (packet_version < 2 and serial == 0xffffffff) {64 if (packet_version < 2 && serial == 0xffffffff) {
65 if (not fr.EndOfFile())65 if (!fr.EndOfFile())
66 throw game_data_error66 throw game_data_error
67 ("expected end of file after serial 0xffffffff");67 ("expected end of file after serial 0xffffffff");
68 break;68 break;
6969
=== modified file 'src/map_io/widelands_map_players_messages_data_packet.cc'
--- src/map_io/widelands_map_players_messages_data_packet.cc 2014-06-08 21:02:17 +0000
+++ src/map_io/widelands_map_players_messages_data_packet.cc 2014-07-25 13:46:28 +0000
@@ -123,9 +123,9 @@
123 Message::Status status = Message::Archived; // default status123 Message::Status status = Message::Archived; // default status
124 if (char const * const status_string = s->get_string("status")) {124 if (char const * const status_string = s->get_string("status")) {
125 try {125 try {
126 if (not strcmp(status_string, "new"))126 if (!strcmp(status_string, "new"))
127 status = Message::New;127 status = Message::New;
128 else if (not strcmp(status_string, "read"))128 else if (!strcmp(status_string, "read"))
129 status = Message::Read;129 status = Message::Read;
130 else130 else
131 throw game_data_error131 throw game_data_error
@@ -184,10 +184,10 @@
184 const Message & message = *i.current->second;184 const Message & message = *i.current->second;
185 assert(message.sent() <= static_cast<uint32_t>(egbase.get_gametime()));185 assert(message.sent() <= static_cast<uint32_t>(egbase.get_gametime()));
186 assert186 assert
187 (message.duration() == Forever() or187 (message.duration() == Forever() ||
188 message.sent() < message.sent() + message.duration());188 message.sent() < message.sent() + message.duration());
189 if189 if
190 (message.duration() != Forever() and190 (message.duration() != Forever() &&
191 message.sent() + message.duration()191 message.sent() + message.duration()
192 <192 <
193 static_cast<uint32_t>(egbase.get_gametime()))193 static_cast<uint32_t>(egbase.get_gametime()))
@@ -208,7 +208,7 @@
208 message.status() == Message::Read ? "read" :208 message.status() == Message::Read ? "read" :
209 message.status() == Message::Archived ? "archived" : "ERROR");209 message.status() == Message::Archived ? "archived" : "ERROR");
210 assert210 assert
211 (message.duration() == Forever() or211 (message.duration() == Forever() ||
212 static_cast<uint32_t>(egbase.get_gametime())212 static_cast<uint32_t>(egbase.get_gametime())
213 <=213 <=
214 message.sent() + message.duration());214 message.sent() + message.duration());
215215
=== modified file 'src/map_io/widelands_map_players_view_data_packet.cc'
--- src/map_io/widelands_map_players_view_data_packet.cc 2014-07-23 14:49:10 +0000
+++ src/map_io/widelands_map_players_view_data_packet.cc 2014-07-25 13:46:28 +0000
@@ -162,7 +162,7 @@
162 }162 }
163163
164#define CHECK_TRAILING_BYTES(file, filename) \164#define CHECK_TRAILING_BYTES(file, filename) \
165 if (not(file).EndOfFile()) \165 if (!(file).EndOfFile()) \
166 throw game_data_error("Map_Players_View_Data_Packet::Read: player %u:" \166 throw game_data_error("Map_Players_View_Data_Packet::Read: player %u:" \
167 "Found %lu trailing bytes in \"%s\"", \167 "Found %lu trailing bytes in \"%s\"", \
168 plnum, \168 plnum, \
@@ -171,7 +171,7 @@
171171
172// TODO(unknown) Legacy code deprecated since build18172// TODO(unknown) Legacy code deprecated since build18
173template <uint8_t const Size> struct BitInBuffer {173template <uint8_t const Size> struct BitInBuffer {
174 static_assert(Size == 1 or Size == 2 or Size == 4, "Unexpected Size.");174 static_assert(Size == 1 || Size == 2 || Size == 4, "Unexpected Size.");
175 BitInBuffer(FileRead* fr) : buffer(0), mask(0x00) {175 BitInBuffer(FileRead* fr) : buffer(0), mask(0x00) {
176 m_fr = fr;176 m_fr = fr;
177 }177 }
@@ -991,10 +991,10 @@
991{991{
992 Map_Object_Descr const * const map_object_descr = map_object_data->map_object_descr;992 Map_Object_Descr const * const map_object_descr = map_object_data->map_object_descr;
993 const Player::Constructionsite_Information & csi = map_object_data->csi;993 const Player::Constructionsite_Information & csi = map_object_data->csi;
994 assert(not Road::IsRoadDescr(map_object_descr));994 assert(!Road::IsRoadDescr(map_object_descr));
995 uint8_t immovable_kind = 255;995 uint8_t immovable_kind = 255;
996996
997 if (not map_object_descr)997 if (!map_object_descr)
998 immovable_kind = 0;998 immovable_kind = 0;
999 else if (upcast(Immovable_Descr const, immovable_descr, map_object_descr)) {999 else if (upcast(Immovable_Descr const, immovable_descr, map_object_descr)) {
1000 immovable_kind = 1;1000 immovable_kind = 1;
@@ -1094,7 +1094,7 @@
10941094
1095 vision_file.Unsigned32(f_player_field.vision);1095 vision_file.Unsigned32(f_player_field.vision);
10961096
1097 if (not f_seen) {1097 if (!f_seen) {
10981098
1099 if (f_everseen) { // node1099 if (f_everseen) { // node
1100 unseen_times_file.Unsigned321100 unseen_times_file.Unsigned32
@@ -1119,7 +1119,7 @@
1119 if1119 if
1120 // the player does not see the D triangle now but has1120 // the player does not see the D triangle now but has
1121 // seen it1121 // seen it
1122 (not bl_seen & not br_seen &1122 (!bl_seen & !br_seen &
1123 (f_everseen | bl_everseen | br_everseen))1123 (f_everseen | bl_everseen | br_everseen))
1124 {1124 {
1125 terrains_file.Unsigned8(f_player_field.terrains.d);1125 terrains_file.Unsigned8(f_player_field.terrains.d);
@@ -1130,7 +1130,7 @@
1130 if1130 if
1131 // the player does not see the R triangle now but has1131 // the player does not see the R triangle now but has
1132 // seen it1132 // seen it
1133 (not br_seen & not r_seen &1133 (!br_seen & !r_seen &
1134 (f_everseen | br_everseen | r_everseen))1134 (f_everseen | br_everseen | r_everseen))
1135 {1135 {
1136 terrains_file.Unsigned8(f_player_field.terrains.r);1136 terrains_file.Unsigned8(f_player_field.terrains.r);
@@ -1140,11 +1140,11 @@
1140 }1140 }
11411141
1142 // edges1142 // edges
1143 if (not bl_seen & (f_everseen | bl_everseen))1143 if (!bl_seen & (f_everseen | bl_everseen))
1144 roads_file.Unsigned8(f_player_field.road_sw());1144 roads_file.Unsigned8(f_player_field.road_sw());
1145 if (not br_seen & (f_everseen | br_everseen))1145 if (!br_seen & (f_everseen | br_everseen))
1146 roads_file.Unsigned8(f_player_field.road_se());1146 roads_file.Unsigned8(f_player_field.road_se());
1147 if (not r_seen & (f_everseen | r_everseen))1147 if (!r_seen & (f_everseen | r_everseen))
1148 roads_file.Unsigned8(f_player_field.road_e ());1148 roads_file.Unsigned8(f_player_field.road_e ());
1149 }1149 }
11501150
11511151
=== modified file 'src/map_io/widelands_map_road_data_packet.cc'
--- src/map_io/widelands_map_road_data_packet.cc 2014-07-03 19:26:30 +0000
+++ src/map_io/widelands_map_road_data_packet.cc 2014-07-25 13:46:28 +0000
@@ -85,7 +85,7 @@
85 for (; field < fields_end; ++field)85 for (; field < fields_end; ++field)
86 if (upcast(Road const, road, field->get_immovable())) // only roads86 if (upcast(Road const, road, field->get_immovable())) // only roads
87 // Roads can life on multiple positions.87 // Roads can life on multiple positions.
88 if (not mos.is_object_known(*road))88 if (!mos.is_object_known(*road))
89 fw.Unsigned32(mos.register_object(*road));89 fw.Unsigned32(mos.register_object(*road));
90 fw.Unsigned32(0xffffffff);90 fw.Unsigned32(0xffffffff);
9191
9292
=== modified file 'src/map_io/widelands_map_roaddata_data_packet.cc'
--- src/map_io/widelands_map_roaddata_data_packet.cc 2014-07-22 09:54:49 +0000
+++ src/map_io/widelands_map_roaddata_data_packet.cc 2014-07-25 13:46:28 +0000
@@ -55,15 +55,15 @@
5555
56 try {56 try {
57 uint16_t const packet_version = fr.Unsigned16();57 uint16_t const packet_version = fr.Unsigned16();
58 if (1 <= packet_version and packet_version <= CURRENT_PACKET_VERSION) {58 if (1 <= packet_version && packet_version <= CURRENT_PACKET_VERSION) {
59 const Map & map = egbase.map();59 const Map & map = egbase.map();
60 Player_Number const nr_players = map.get_nrplayers();60 Player_Number const nr_players = map.get_nrplayers();
61 for (;;) {61 for (;;) {
62 if (2 <= packet_version and fr.EndOfFile())62 if (2 <= packet_version && fr.EndOfFile())
63 break;63 break;
64 Serial const serial = fr.Unsigned32();64 Serial const serial = fr.Unsigned32();
65 if (packet_version < 2 and serial == 0xffffffff) {65 if (packet_version < 2 && serial == 0xffffffff) {
66 if (not fr.EndOfFile())66 if (!fr.EndOfFile())
67 throw game_data_error67 throw game_data_error
68 ("expected end of file after serial 0xffffffff");68 ("expected end of file after serial 0xffffffff");
69 break;69 break;
@@ -108,7 +108,7 @@
108 road.m_cost[0] = fr.Unsigned32();108 road.m_cost[0] = fr.Unsigned32();
109 road.m_cost[1] = fr.Unsigned32();109 road.m_cost[1] = fr.Unsigned32();
110 Path::Step_Vector::size_type const nr_steps = fr.Unsigned16();110 Path::Step_Vector::size_type const nr_steps = fr.Unsigned16();
111 if (not nr_steps)111 if (!nr_steps)
112 throw game_data_error("nr_steps = 0");112 throw game_data_error("nr_steps = 0");
113 Path p(road.m_flags[0]->get_position());113 Path p(road.m_flags[0]->get_position());
114 for (Path::Step_Vector::size_type i = nr_steps; i; --i)114 for (Path::Step_Vector::size_type i = nr_steps; i; --i)
@@ -129,9 +129,9 @@
129 road.m_idle_index = fr.Unsigned32();129 road.m_idle_index = fr.Unsigned32();
130130
131 uint32_t const count = fr.Unsigned32();131 uint32_t const count = fr.Unsigned32();
132 if (not count)132 if (!count)
133 throw game_data_error("no carrier slot");133 throw game_data_error("no carrier slot");
134 if (packet_version <= 2 and 1 < count)134 if (packet_version <= 2 && 1 < count)
135 throw game_data_error135 throw game_data_error
136 (136 (
137 "expected 1 but found %u carrier slots in road saved "137 "expected 1 but found %u carrier slots in road saved "
@@ -176,13 +176,13 @@
176 packet_version < 3 ? 1 : fr.Unsigned32();176 packet_version < 3 ? 1 : fr.Unsigned32();
177177
178 if178 if
179 (i < road.m_carrier_slots.size() and179 (i < road.m_carrier_slots.size() &&
180 road.m_carrier_slots[i].carrier_type == carrier_type)180 road.m_carrier_slots[i].carrier_type == carrier_type)
181 {181 {
182 assert(!road.m_carrier_slots[i].carrier.get(egbase));182 assert(!road.m_carrier_slots[i].carrier.get(egbase));
183183
184 road.m_carrier_slots[i].carrier = carrier;184 road.m_carrier_slots[i].carrier = carrier;
185 if (carrier or carrier_request) {185 if (carrier || carrier_request) {
186 delete road.m_carrier_slots[i].carrier_request;186 delete road.m_carrier_slots[i].carrier_request;
187 road.m_carrier_slots[i].carrier_request =187 road.m_carrier_slots[i].carrier_request =
188 carrier_request;188 carrier_request;
@@ -226,7 +226,7 @@
226 const Field & fields_end = map[map.max_index()];226 const Field & fields_end = map[map.max_index()];
227 for (Field const * field = &map[0]; field < &fields_end; ++field)227 for (Field const * field = &map[0]; field < &fields_end; ++field)
228 if (upcast(Road const, r, field->get_immovable()))228 if (upcast(Road const, r, field->get_immovable()))
229 if (not mos.is_object_saved(*r)) {229 if (!mos.is_object_saved(*r)) {
230 assert(mos.is_object_known(*r));230 assert(mos.is_object_known(*r));
231231
232 fw.Unsigned32(mos.get_object_file_index(*r));232 fw.Unsigned32(mos.get_object_file_index(*r));
233233
=== modified file 'src/map_io/widelands_map_saver.cc'
--- src/map_io/widelands_map_saver.cc 2014-07-05 13:14:42 +0000
+++ src/map_io/widelands_map_saver.cc 2014-07-25 13:46:28 +0000
@@ -136,7 +136,7 @@
136 iterate_players_existing_const(plnum, nr_players, m_egbase, player) {136 iterate_players_existing_const(plnum, nr_players, m_egbase, player) {
137 Building_Index const nr_buildings = player->tribe().get_nrbuildings();137 Building_Index const nr_buildings = player->tribe().get_nrbuildings();
138 for (Building_Index i = 0; i < nr_buildings; ++i)138 for (Building_Index i = 0; i < nr_buildings; ++i)
139 if (not player->is_building_type_allowed(i)) {139 if (!player->is_building_type_allowed(i)) {
140 log("Writing Allowed Building Types Data ... ");140 log("Writing Allowed Building Types Data ... ");
141 Map_Allowed_Building_Types_Data_Packet p;141 Map_Allowed_Building_Types_Data_Packet p;
142 p .Write(m_fs, m_egbase, *m_mos);142 p .Write(m_fs, m_egbase, *m_mos);
143143
=== modified file 'src/map_io/widelands_map_scripting_data_packet.cc'
--- src/map_io/widelands_map_scripting_data_packet.cc 2014-07-03 19:26:30 +0000
+++ src/map_io/widelands_map_scripting_data_packet.cc 2014-07-25 13:46:28 +0000
@@ -56,7 +56,7 @@
56 // wise this makes no sense.56 // wise this makes no sense.
57 upcast(Game, g, &egbase);57 upcast(Game, g, &egbase);
58 FileRead fr;58 FileRead fr;
59 if (g and fr.TryOpen(fs, "scripting/globals.dump"))59 if (g && fr.TryOpen(fs, "scripting/globals.dump"))
60 {60 {
61 const uint32_t sentinel = fr.Unsigned32();61 const uint32_t sentinel = fr.Unsigned32();
62 const uint32_t packet_version = fr.Unsigned32();62 const uint32_t packet_version = fr.Unsigned32();
6363
=== modified file 'src/network/internet_gaming.cc'
--- src/network/internet_gaming.cc 2014-07-14 10:45:44 +0000
+++ src/network/internet_gaming.cc 2014-07-25 13:46:28 +0000
@@ -97,7 +97,7 @@
9797
98/// \returns the one and only InternetGaming instance.98/// \returns the one and only InternetGaming instance.
99InternetGaming & InternetGaming::ref() {99InternetGaming & InternetGaming::ref() {
100 if (not ig)100 if (!ig)
101 ig = new InternetGaming();101 ig = new InternetGaming();
102 return * ig;102 return * ig;
103}103}
104104
=== modified file 'src/network/nethost.cc'
--- src/network/nethost.cc 2014-07-22 09:54:49 +0000
+++ src/network/nethost.cc 2014-07-25 13:46:28 +0000
@@ -281,7 +281,7 @@
281281
282 virtual void setPlayerNumber(uint8_t const number) override {282 virtual void setPlayerNumber(uint8_t const number) override {
283 if283 if
284 (number == UserSettings::none() or284 (number == UserSettings::none() ||
285 number < h->settings().players.size())285 number < h->settings().players.size())
286 h->setPlayerNumber(number);286 h->setPlayerNumber(number);
287 }287 }
@@ -765,7 +765,7 @@
765 // Setup by the users765 // Setup by the users
766 log ("[Dedicated] Entering set up mode, waiting for user interaction!\n");766 log ("[Dedicated] Entering set up mode, waiting for user interaction!\n");
767767
768 while (not d->dedicated_start) {768 while (!d->dedicated_start) {
769 handle_network();769 handle_network();
770 // TODO(unknown) this should be improved.770 // TODO(unknown) this should be improved.
771#ifndef _WIN32771#ifndef _WIN32
@@ -1303,7 +1303,7 @@
1303}1303}
13041304
1305void NetHost::dserver_send_maps_and_saves(Client & client) {1305void NetHost::dserver_send_maps_and_saves(Client & client) {
1306 assert (not d->game);1306 assert (!d->game);
13071307
1308 if (d->settings.maps.empty()) {1308 if (d->settings.maps.empty()) {
1309 // Read in maps1309 // Read in maps
@@ -2014,7 +2014,7 @@
2014 */2014 */
2015bool NetHost::haveUserName(const std::string & name, uint8_t ignoreplayer) {2015bool NetHost::haveUserName(const std::string & name, uint8_t ignoreplayer) {
2016 for (uint32_t i = 0; i < d->settings.users.size(); ++i)2016 for (uint32_t i = 0; i < d->settings.users.size(); ++i)
2017 if (i != ignoreplayer and d->settings.users.at(i).name == name)2017 if (i != ignoreplayer && d->settings.users.at(i).name == name)
2018 return true;2018 return true;
20192019
2020 // Computer players are not handled like human users,2020 // Computer players are not handled like human users,
@@ -2022,7 +2022,7 @@
2022 if (ignoreplayer < d->settings.users.size())2022 if (ignoreplayer < d->settings.users.size())
2023 ignoreplayer = d->settings.users.at(ignoreplayer).position;2023 ignoreplayer = d->settings.users.at(ignoreplayer).position;
2024 for (uint32_t i = 0; i < d->settings.players.size(); ++i)2024 for (uint32_t i = 0; i < d->settings.players.size(); ++i)
2025 if (i != ignoreplayer and d->settings.players.at(i).name == name)2025 if (i != ignoreplayer && d->settings.players.at(i).name == name)
2026 return true;2026 return true;
20272027
2028 return false;2028 return false;
20292029
=== modified file 'src/network/network.cc'
--- src/network/network.cc 2014-06-23 21:07:36 +0000
+++ src/network/network.cc 2014-07-25 13:46:28 +0000
@@ -195,7 +195,7 @@
195195
196 queue.insert(queue.end(), &buffer[0], &buffer[bytes]);196 queue.insert(queue.end(), &buffer[0], &buffer[bytes]);
197197
198 return queue.size() < 2 or 2 <= (queue[0] << 8 | queue[1]);198 return queue.size() < 2 || 2 <= (queue[0] << 8 | queue[1]);
199}199}
200200
201/**201/**
202202
=== modified file 'src/profile/profile.cc'
--- src/profile/profile.cc 2014-06-23 20:17:05 +0000
+++ src/profile/profile.cc 2014-07-25 13:46:28 +0000
@@ -109,7 +109,7 @@
109{109{
110 char * endp;110 char * endp;
111 long long int i = strtoll(m_value, &endp, 0);111 long long int i = strtoll(m_value, &endp, 0);
112 if (*endp or i < 0)112 if (*endp || i < 0)
113 throw wexception("%s: '%s' is not natural", get_name(), m_value);113 throw wexception("%s: '%s' is not natural", get_name(), m_value);
114 return i;114 return i;
115}115}
@@ -119,7 +119,7 @@
119{119{
120 char * endp;120 char * endp;
121 long long int i = strtoll(m_value, &endp, 0);121 long long int i = strtoll(m_value, &endp, 0);
122 if (*endp or i < 1)122 if (*endp || i < 1)
123 throw wexception("%s: '%s' is not positive", get_name(), m_value);123 throw wexception("%s: '%s' is not positive", get_name(), m_value);
124 return i;124 return i;
125}125}
@@ -217,7 +217,7 @@
217void Section::check_used() const217void Section::check_used() const
218{218{
219 container_iterate_const(Value_list, m_values, i)219 container_iterate_const(Value_list, m_values, i)
220 if (not i.current->is_used())220 if (!i.current->is_used())
221 m_profile->error221 m_profile->error
222 ("Section [%s], key '%s' not used (did you spell the name "222 ("Section [%s], key '%s' not used (did you spell the name "
223 "correctly?)",223 "correctly?)",
@@ -228,7 +228,7 @@
228bool Section::has_val(char const * const name) const228bool Section::has_val(char const * const name) const
229{229{
230 container_iterate_const(Value_list, m_values, i)230 container_iterate_const(Value_list, m_values, i)
231 if (not strcasecmp(i.current->get_name(), name))231 if (!strcasecmp(i.current->get_name(), name))
232 return true;232 return true;
233 return false;233 return false;
234}234}
@@ -260,7 +260,7 @@
260Section::Value * Section::get_next_val(char const * const name)260Section::Value * Section::get_next_val(char const * const name)
261{261{
262 container_iterate(Value_list, m_values, i)262 container_iterate(Value_list, m_values, i)
263 if (not i.current->is_used())263 if (!i.current->is_used())
264 if (!name || !strcasecmp(i.current->get_name(), name)) {264 if (!name || !strcasecmp(i.current->get_name(), name)) {
265 i.current->mark_used();265 i.current->mark_used();
266 return &*i.current;266 return &*i.current;
@@ -634,7 +634,7 @@
634Section * Profile::get_next_section(char const * const name)634Section * Profile::get_next_section(char const * const name)
635{635{
636 container_iterate(Section_list, m_sections, i)636 container_iterate(Section_list, m_sections, i)
637 if (not i.current->is_used())637 if (!i.current->is_used())
638 if (!name || !strcasecmp(i.current->get_name(), name)) {638 if (!name || !strcasecmp(i.current->get_name(), name)) {
639 i.current->mark_used();639 i.current->mark_used();
640 return &*i.current;640 return &*i.current;
@@ -769,9 +769,9 @@
769769
770 // first, check for multiline string770 // first, check for multiline string
771 if771 if
772 ((tail[0] == '\'' or tail[0] == '"')772 ((tail[0] == '\'' || tail[0] == '"')
773 and773 &&
774 (tail[1] == '\'' or tail[1] == '"'))774 (tail[1] == '\'' || tail[1] == '"'))
775 {775 {
776 reading_multiline = true;776 reading_multiline = true;
777 tail += 2;777 tail += 2;
@@ -826,7 +826,7 @@
826 }826 }
827827
828 // Make sure that the requested global section exists, even if it is empty.828 // Make sure that the requested global section exists, even if it is empty.
829 if (global_section and not get_section(global_section))829 if (global_section && !get_section(global_section))
830 create_section_duplicate(global_section);830 create_section_duplicate(global_section);
831}831}
832832
833833
=== modified file 'src/scripting/c_utils.cc'
--- src/scripting/c_utils.cc 2014-06-05 05:40:53 +0000
+++ src/scripting/c_utils.cc 2014-07-25 13:46:28 +0000
@@ -32,7 +32,7 @@
32 Factory * fac = static_cast<Factory *>(lua_touserdata(L, -1));32 Factory * fac = static_cast<Factory *>(lua_touserdata(L, -1));
33 lua_pop(L, 1); // pop this userdata33 lua_pop(L, 1); // pop this userdata
3434
35 if (not fac)35 if (!fac)
36 throw LuaError("\"factory\" field was nil, which should be impossible!");36 throw LuaError("\"factory\" field was nil, which should be impossible!");
3737
38 return *fac;38 return *fac;
@@ -43,7 +43,7 @@
43 Widelands::Game * g = static_cast<Widelands::Game *>(lua_touserdata(L, -1));43 Widelands::Game * g = static_cast<Widelands::Game *>(lua_touserdata(L, -1));
44 lua_pop(L, 1); // pop this userdata44 lua_pop(L, 1); // pop this userdata
4545
46 if (not g)46 if (!g)
47 throw LuaError47 throw LuaError
48 ("\"game\" field was nil. get_game was not called in a game.");48 ("\"game\" field was nil. get_game was not called in a game.");
4949
@@ -56,7 +56,7 @@
56 (lua_touserdata(L, -1));56 (lua_touserdata(L, -1));
57 lua_pop(L, 1); // pop this userdata57 lua_pop(L, 1); // pop this userdata
5858
59 if (not g)59 if (!g)
60 throw LuaError60 throw LuaError
61 ("\"egbase\" field was nil. This should be impossible.");61 ("\"egbase\" field was nil. This should be impossible.");
6262
@@ -73,7 +73,7 @@
7373
74 lua_pop(L, 1); // pop this userdata74 lua_pop(L, 1); // pop this userdata
7575
76 if (not mol)76 if (!mol)
77 throw LuaError77 throw LuaError
78 ("\"mol\" field was nil. This should be impossible.");78 ("\"mol\" field was nil. This should be impossible.");
7979
@@ -89,7 +89,7 @@
8989
90 lua_pop(L, 1); // pop this userdata90 lua_pop(L, 1); // pop this userdata
9191
92 if (not mos)92 if (!mos)
93 throw LuaError93 throw LuaError
94 ("\"mos\" field was nil. This should be impossible.");94 ("\"mos\" field was nil. This should be impossible.");
9595
9696
=== modified file 'src/scripting/lua_bases.cc'
--- src/scripting/lua_bases.cc 2014-07-11 22:53:34 +0000
+++ src/scripting/lua_bases.cc 2014-07-25 13:46:28 +0000
@@ -127,7 +127,7 @@
127 uint32_t idx = 1;127 uint32_t idx = 1;
128 for (Player_Number i = 1; i <= MAX_PLAYERS; i++) {128 for (Player_Number i = 1; i <= MAX_PLAYERS; i++) {
129 Player * rv = egbase.get_player(i);129 Player * rv = egbase.get_player(i);
130 if (not rv)130 if (!rv)
131 continue;131 continue;
132132
133 lua_pushuint32(L, idx++);133 lua_pushuint32(L, idx++);
@@ -349,7 +349,7 @@
349 force = luaL_checkboolean(L, 3);349 force = luaL_checkboolean(L, 3);
350350
351 Flag * f;351 Flag * f;
352 if (not force) {352 if (!force) {
353 f = get(L, get_egbase(L)).build_flag(c->fcoords(L));353 f = get(L, get_egbase(L)).build_flag(c->fcoords(L));
354 if (!f)354 if (!f)
355 report_error(L, "Couldn't build flag!");355 report_error(L, "Couldn't build flag!");
@@ -398,22 +398,22 @@
398 for (int32_t i = 3; i <= lua_gettop(L); i++) {398 for (int32_t i = 3; i <= lua_gettop(L); i++) {
399 std::string d = luaL_checkstring(L, i);399 std::string d = luaL_checkstring(L, i);
400400
401 if (d == "ne" or d == "tr") {401 if (d == "ne" || d == "tr") {
402 path.append(map, 1);402 path.append(map, 1);
403 map.get_trn(current, &current);403 map.get_trn(current, &current);
404 } else if (d == "e" or d == "r") {404 } else if (d == "e" || d == "r") {
405 path.append(map, 2);405 path.append(map, 2);
406 map.get_rn(current, &current);406 map.get_rn(current, &current);
407 } else if (d == "se" or d == "br") {407 } else if (d == "se" || d == "br") {
408 path.append(map, 3);408 path.append(map, 3);
409 map.get_brn(current, &current);409 map.get_brn(current, &current);
410 } else if (d == "sw" or d == "bl") {410 } else if (d == "sw" || d == "bl") {
411 path.append(map, 4);411 path.append(map, 4);
412 map.get_bln(current, &current);412 map.get_bln(current, &current);
413 } else if (d == "w" or d == "l") {413 } else if (d == "w" || d == "l") {
414 path.append(map, 5);414 path.append(map, 5);
415 map.get_ln(current, &current);415 map.get_ln(current, &current);
416 } else if (d == "nw" or d == "tl") {416 } else if (d == "nw" || d == "tl") {
417 path.append(map, 6);417 path.append(map, 6);
418 map.get_tln(current, &current);418 map.get_tln(current, &current);
419 } else419 } else
@@ -438,11 +438,11 @@
438 r = &get(L, egbase).force_road(path);438 r = &get(L, egbase).force_road(path);
439 } else {439 } else {
440 BaseImmovable * bi = map.get_immovable(current);440 BaseImmovable * bi = map.get_immovable(current);
441 if (!bi or bi->get_type() != Map_Object::FLAG) {441 if (!bi || bi->get_type() != Map_Object::FLAG) {
442 if (!get(L, egbase).build_flag(current))442 if (!get(L, egbase).build_flag(current))
443 report_error(L, "Could not place end flag!");443 report_error(L, "Could not place end flag!");
444 }444 }
445 if (bi and bi == starting_flag)445 if (bi && bi == starting_flag)
446 report_error(L, "Cannot build a closed loop!");446 report_error(L, "Cannot build a closed loop!");
447447
448 r = get(L, egbase).build_road(path);448 r = get(L, egbase).build_road(path);
@@ -508,7 +508,7 @@
508 b = get(L, get_egbase(L)).build508 b = get(L, get_egbase(L)).build
509 (c->coords(), i, constructionsite, former_buildings);509 (c->coords(), i, constructionsite, former_buildings);
510 }510 }
511 if (not b)511 if (!b)
512 report_error(L, "Couldn't place building!");512 report_error(L, "Couldn't place building!");
513513
514 LuaMap::upcasted_immovable_to_lua(L, b);514 LuaMap::upcasted_immovable_to_lua(L, b);
515515
=== modified file 'src/scripting/lua_game.cc'
--- src/scripting/lua_game.cc 2014-07-05 14:22:44 +0000
+++ src/scripting/lua_game.cc 2014-07-25 13:46:28 +0000
@@ -305,17 +305,17 @@
305 if (n == 4) {305 if (n == 4) {
306 // Optional arguments306 // Optional arguments
307 lua_getfield(L, 4, "duration");307 lua_getfield(L, 4, "duration");
308 if (not lua_isnil(L, -1))308 if (!lua_isnil(L, -1))
309 d = luaL_checkuint32(L, -1);309 d = luaL_checkuint32(L, -1);
310 lua_pop(L, 1);310 lua_pop(L, 1);
311311
312 lua_getfield(L, 4, "field");312 lua_getfield(L, 4, "field");
313 if (not lua_isnil(L, -1))313 if (!lua_isnil(L, -1))
314 c = (*get_user_class<L_Field>(L, -1))->coords();314 c = (*get_user_class<L_Field>(L, -1))->coords();
315 lua_pop(L, 1);315 lua_pop(L, 1);
316316
317 lua_getfield(L, 4, "status");317 lua_getfield(L, 4, "status");
318 if (not lua_isnil(L, -1)) {318 if (!lua_isnil(L, -1)) {
319 std::string s = luaL_checkstring(L, -1);319 std::string s = luaL_checkstring(L, -1);
320 if (s == "new") st = Message::New;320 if (s == "new") st = Message::New;
321 else if (s == "read") st = Message::Read;321 else if (s == "read") st = Message::Read;
@@ -325,12 +325,12 @@
325 lua_pop(L, 1);325 lua_pop(L, 1);
326326
327 lua_getfield(L, 4, "sender");327 lua_getfield(L, 4, "sender");
328 if (not lua_isnil(L, -1))328 if (!lua_isnil(L, -1))
329 sender = luaL_checkstring(L, -1);329 sender = luaL_checkstring(L, -1);
330 lua_pop(L, 1);330 lua_pop(L, 1);
331331
332 lua_getfield(L, 4, "popup");332 lua_getfield(L, 4, "popup");
333 if (not lua_isnil(L, -1))333 if (!lua_isnil(L, -1))
334 popup = luaL_checkboolean(L, -1);334 popup = luaL_checkboolean(L, -1);
335 lua_pop(L, 1);335 lua_pop(L, 1);
336 }336 }
@@ -406,7 +406,7 @@
406406
407#define CHECK_ARG(var, type) \407#define CHECK_ARG(var, type) \
408 lua_getfield(L, -1, #var); \408 lua_getfield(L, -1, #var); \
409 if (not lua_isnil(L, -1)) var = luaL_check ## type(L, -1); \409 if (!lua_isnil(L, -1)) var = luaL_check ## type(L, -1); \
410 lua_pop(L, 1);410 lua_pop(L, 1);
411411
412 if (lua_gettop(L) == 4) {412 if (lua_gettop(L) == 4) {
@@ -418,7 +418,7 @@
418418
419 // This must be done manually419 // This must be done manually
420 lua_getfield(L, 4, "field");420 lua_getfield(L, 4, "field");
421 if (not lua_isnil(L, -1)) {421 if (!lua_isnil(L, -1)) {
422 Coords c = (*get_user_class<L_Field>(L, -1))->coords();422 Coords c = (*get_user_class<L_Field>(L, -1))->coords();
423 game.get_ipl()->move_view_to(c);423 game.get_ipl()->move_view_to(c);
424 }424 }
@@ -774,7 +774,7 @@
774774
775 for (Ware_Index i = 0; i < tribe.get_nrworkers(); ++i) {775 for (Ware_Index i = 0; i < tribe.get_nrworkers(); ++i) {
776 const Worker_Descr & worker_descr = *tribe.get_worker_descr(i);776 const Worker_Descr & worker_descr = *tribe.get_worker_descr(i);
777 if (not worker_descr.is_buildable())777 if (!worker_descr.is_buildable())
778 continue;778 continue;
779779
780 player.allow_worker_type(i, true);780 player.allow_worker_type(i, true);
781781
=== modified file 'src/scripting/lua_globals.cc'
--- src/scripting/lua_globals.cc 2014-07-16 08:23:42 +0000
+++ src/scripting/lua_globals.cc 2014-07-25 13:46:28 +0000
@@ -149,7 +149,7 @@
149static int L__(lua_State * L) {149static int L__(lua_State * L) {
150 lua_getglobal(L, "__TEXTDOMAIN");150 lua_getglobal(L, "__TEXTDOMAIN");
151151
152 if (not lua_isnil(L, -1)) {152 if (!lua_isnil(L, -1)) {
153 i18n::Textdomain dom(luaL_checkstring(L, -1));153 i18n::Textdomain dom(luaL_checkstring(L, -1));
154 lua_pushstring(L, i18n::translate(luaL_checkstring(L, 1)));154 lua_pushstring(L, i18n::translate(luaL_checkstring(L, 1)));
155 } else {155 } else {
@@ -181,7 +181,7 @@
181 const uint32_t n = luaL_checkuint32(L, 3);181 const uint32_t n = luaL_checkuint32(L, 3);
182182
183 lua_getglobal(L, "__TEXTDOMAIN");183 lua_getglobal(L, "__TEXTDOMAIN");
184 if (not lua_isnil(L, -1)) {184 if (!lua_isnil(L, -1)) {
185 i18n::Textdomain dom(luaL_checkstring(L, -1));185 i18n::Textdomain dom(luaL_checkstring(L, -1));
186 lua_pushstring(L, ngettext(msgid.c_str(), msgid_plural.c_str(), n));186 lua_pushstring(L, ngettext(msgid.c_str(), msgid_plural.c_str(), n));
187 } else {187 } else {
188188
=== modified file 'src/scripting/lua_map.cc'
--- src/scripting/lua_map.cc 2014-07-24 05:21:20 +0000
+++ src/scripting/lua_map.cc 2014-07-25 13:46:28 +0000
@@ -166,7 +166,7 @@
166 (lua_State * L, const Tribe_Descr & tribe) \166 (lua_State * L, const Tribe_Descr & tribe) \
167{ \167{ \
168 int32_t nargs = lua_gettop(L); \168 int32_t nargs = lua_gettop(L); \
169 if (nargs != 2 and nargs != 3) \169 if (nargs != 2 && nargs != 3) \
170 report_error(L, "Wrong number of arguments to set_" #type "!"); \170 report_error(L, "Wrong number of arguments to set_" #type "!"); \
171 btype##sMap rv; \171 btype##sMap rv; \
172 if (nargs == 3) { \172 if (nargs == 3) { \
@@ -2069,7 +2069,7 @@
20692069
2070 // Both objects are destroyed: they are equal2070 // Both objects are destroyed: they are equal
2071 if (me == you) lua_pushboolean(L, true);2071 if (me == you) lua_pushboolean(L, true);
2072 else if (!me or !you) // One of the objects is destroyed: they are distinct2072 else if (!me || !you) // One of the objects is destroyed: they are distinct
2073 lua_pushboolean(L, false);2073 lua_pushboolean(L, false);
2074 else // Compare them2074 else // Compare them
2075 lua_pushboolean2075 lua_pushboolean
@@ -3619,7 +3619,7 @@
3619 int32_t amount = luaL_checkint32(L, -1);3619 int32_t amount = luaL_checkint32(L, -1);
3620 int32_t max_amount = get_egbase(L).world().get_resource(res)->max_amount();3620 int32_t max_amount = get_egbase(L).world().get_resource(res)->max_amount();
36213621
3622 if (amount < 0 or amount > max_amount)3622 if (amount < 0 || amount > max_amount)
3623 report_error(L, "Illegal amount: %i, must be >= 0 and <= %i", amount, max_amount);3623 report_error(L, "Illegal amount: %i, must be >= 0 and <= %i", amount, max_amount);
36243624
3625 field->set_resources(res, amount);3625 field->set_resources(res, amount);
36263626
=== modified file 'src/scripting/lua_table.h'
--- src/scripting/lua_table.h 2014-07-05 16:41:51 +0000
+++ src/scripting/lua_table.h 2014-07-25 13:46:28 +0000
@@ -167,7 +167,7 @@
167 lua_xmove(t, L_, 1);167 lua_xmove(t, L_, 1);
168 }168 }
169169
170 if (not lua_isthread(L_, -1)) {170 if (!lua_isthread(L_, -1)) {
171 lua_pop(L_, 1);171 lua_pop(L_, 1);
172 throw LuaError(boost::lexical_cast<std::string>(key) + " is not a function value.");172 throw LuaError(boost::lexical_cast<std::string>(key) + " is not a function value.");
173 }173 }
174174
=== modified file 'src/scripting/lua_ui.cc'
--- src/scripting/lua_ui.cc 2014-07-05 12:48:58 +0000
+++ src/scripting/lua_ui.cc 2014-07-25 13:46:28 +0000
@@ -107,7 +107,7 @@
107static void _put_all_visible_buttons_into_table107static void _put_all_visible_buttons_into_table
108 (lua_State * L, UI::Panel * g)108 (lua_State * L, UI::Panel * g)
109{109{
110 if (not g) return;110 if (!g) return;
111111
112 for (UI::Panel * f = g->get_first_child(); f; f = f->get_next_sibling())112 for (UI::Panel * f = g->get_first_child(); f; f = f->get_next_sibling())
113 {113 {
@@ -138,7 +138,7 @@
138static void _put_all_tabs_into_table138static void _put_all_tabs_into_table
139 (lua_State * L, UI::Panel * g)139 (lua_State * L, UI::Panel * g)
140{140{
141 if (not g) return;141 if (!g) return;
142142
143 for (UI::Panel * f = g->get_first_child(); f; f = f->get_next_sibling())143 for (UI::Panel * f = g->get_first_child(); f; f = f->get_next_sibling())
144 {144 {
@@ -171,7 +171,7 @@
171static void _put_all_visible_windows_into_table171static void _put_all_visible_windows_into_table
172 (lua_State * L, UI::Panel * g)172 (lua_State * L, UI::Panel * g)
173{173{
174 if (not g) return;174 if (!g) return;
175175
176 for (UI::Panel * f = g->get_first_child(); f; f = f->get_next_sibling())176 for (UI::Panel * f = g->get_first_child(); f; f = f->get_next_sibling())
177 {177 {
178178
=== modified file 'src/scripting/scripting.cc'
--- src/scripting/scripting.cc 2014-06-26 05:53:49 +0000
+++ src/scripting/scripting.cc 2014-07-25 13:46:28 +0000
@@ -111,7 +111,7 @@
111 lua_pop(L, 1); // No return value from script111 lua_pop(L, 1); // No return value from script
112 lua_newtable(L); // Push an empty table112 lua_newtable(L); // Push an empty table
113 }113 }
114 if (not lua_istable(L, -1))114 if (!lua_istable(L, -1))
115 throw LuaError("Script did not return a table!");115 throw LuaError("Script did not return a table!");
116116
117 // Restore old value of __file__.117 // Restore old value of __file__.
118118
=== modified file 'src/sound/sound_handler.cc'
--- src/sound/sound_handler.cc 2014-07-23 14:49:10 +0000
+++ src/sound/sound_handler.cc 2014-07-25 13:46:28 +0000
@@ -118,7 +118,7 @@
118118
119 if119 if
120 (SDL_InitSubSystem(SDL_INIT_AUDIO) == -1120 (SDL_InitSubSystem(SDL_INIT_AUDIO) == -1
121 or121 ||
122 Mix_OpenAudio(MIX_DEFAULT_FREQUENCY, MIX_DEFAULT_FORMAT, 2, bufsize) == -1)122 Mix_OpenAudio(MIX_DEFAULT_FREQUENCY, MIX_DEFAULT_FORMAT, 2, bufsize) == -1)
123 {123 {
124 SDL_QuitSubSystem(SDL_INIT_AUDIO);124 SDL_QuitSubSystem(SDL_INIT_AUDIO);
@@ -277,7 +277,7 @@
277 if (nosound_)277 if (nosound_)
278 return;278 return;
279279
280 if (not fr.TryOpen(*g_fs, path)) {280 if (!fr.TryOpen(*g_fs, path)) {
281 log("WARNING: Could not open %s for reading!\n", path);281 log("WARNING: Could not open %s for reading!\n", path);
282 return;282 return;
283 }283 }
@@ -535,7 +535,7 @@
535void Sound_Handler::start_music535void Sound_Handler::start_music
536 (const std::string & songset_name, int32_t fadein_ms)536 (const std::string & songset_name, int32_t fadein_ms)
537{537{
538 if (get_disable_music() or nosound_)538 if (get_disable_music() || nosound_)
539 return;539 return;
540540
541 if (fadein_ms == 0) fadein_ms = 250; // avoid clicks541 if (fadein_ms == 0) fadein_ms = 250; // avoid clicks
@@ -565,7 +565,7 @@
565*/565*/
566void Sound_Handler::stop_music(int32_t fadeout_ms)566void Sound_Handler::stop_music(int32_t fadeout_ms)
567{567{
568 if (get_disable_music() or nosound_)568 if (get_disable_music() || nosound_)
569 return;569 return;
570570
571 if (fadeout_ms == 0) fadeout_ms = 250; // avoid clicks571 if (fadeout_ms == 0) fadeout_ms = 250; // avoid clicks
@@ -658,7 +658,7 @@
658 * \param volume The new music volume.658 * \param volume The new music volume.
659 */659 */
660void Sound_Handler::set_music_volume(int32_t volume) {660void Sound_Handler::set_music_volume(int32_t volume) {
661 if (not lock_audio_disabling_ and not nosound_) {661 if (!lock_audio_disabling_ && !nosound_) {
662 music_volume_ = volume;662 music_volume_ = volume;
663 Mix_VolumeMusic(volume);663 Mix_VolumeMusic(volume);
664 g_options.pull_section("global").set_int("music_volume", volume);664 g_options.pull_section("global").set_int("music_volume", volume);
@@ -673,7 +673,7 @@
673 * \param volume The new music volume.673 * \param volume The new music volume.
674 */674 */
675void Sound_Handler::set_fx_volume(int32_t volume) {675void Sound_Handler::set_fx_volume(int32_t volume) {
676 if (not lock_audio_disabling_ and not nosound_) {676 if (!lock_audio_disabling_ && !nosound_) {
677 fx_volume_ = volume;677 fx_volume_ = volume;
678 Mix_Volume(-1, volume);678 Mix_Volume(-1, volume);
679 g_options.pull_section("global").set_int("fx_volume", volume);679 g_options.pull_section("global").set_int("fx_volume", volume);
680680
=== modified file 'src/ui_basic/button.cc'
--- src/ui_basic/button.cc 2014-07-14 10:45:44 +0000
+++ src/ui_basic/button.cc 2014-07-25 13:46:28 +0000
@@ -164,13 +164,13 @@
164void Button::draw(RenderTarget & dst)164void Button::draw(RenderTarget & dst)
165{165{
166 // Draw the background166 // Draw the background
167 if (not m_flat or m_draw_flat_background) {167 if (!m_flat || m_draw_flat_background) {
168 assert(m_pic_background);168 assert(m_pic_background);
169 dst.fill_rect(Rect(Point(0, 0), get_w(), get_h()), RGBAColor(0, 0, 0, 255));169 dst.fill_rect(Rect(Point(0, 0), get_w(), get_h()), RGBAColor(0, 0, 0, 255));
170 dst.tile(Rect(Point(0, 0), get_w(), get_h()), m_pic_background, Point(get_x(), get_y()));170 dst.tile(Rect(Point(0, 0), get_w(), get_h()), m_pic_background, Point(get_x(), get_y()));
171 }171 }
172172
173 if (m_enabled and m_highlighted and not m_flat)173 if (m_enabled && m_highlighted && !m_flat)
174 dst.brighten_rect174 dst.brighten_rect
175 (Rect(Point(0, 0), get_w(), get_h()), MOUSE_OVER_BRIGHT_FACTOR);175 (Rect(Point(0, 0), get_w(), get_h()), MOUSE_OVER_BRIGHT_FACTOR);
176176
@@ -207,14 +207,14 @@
207 RGBAColor black(0, 0, 0, 255);207 RGBAColor black(0, 0, 0, 255);
208208
209 // m_permpressed is true, we invert the behaviour on m_pressed209 // m_permpressed is true, we invert the behaviour on m_pressed
210 bool draw_pressed = m_permpressed ? not (m_pressed and m_highlighted)210 bool draw_pressed = m_permpressed ? !(m_pressed && m_highlighted)
211 : (m_pressed and m_highlighted);211 : (m_pressed && m_highlighted);
212212
213 if (not m_flat) {213 if (!m_flat) {
214 assert(2 <= get_w());214 assert(2 <= get_w());
215 assert(2 <= get_h());215 assert(2 <= get_h());
216 // button is a normal one, not flat216 // button is a normal one, not flat
217 if (not draw_pressed) {217 if (!draw_pressed) {
218 // top edge218 // top edge
219 dst.brighten_rect219 dst.brighten_rect
220 (Rect(Point(0, 0), get_w(), 2), BUTTON_EDGE_BRIGHT_FACTOR);220 (Rect(Point(0, 0), get_w(), 2), BUTTON_EDGE_BRIGHT_FACTOR);
@@ -246,7 +246,7 @@
246 } else {246 } else {
247 // Button is flat, do not draw borders, instead, if it is pressed, draw247 // Button is flat, do not draw borders, instead, if it is pressed, draw
248 // a box around it.248 // a box around it.
249 if (m_enabled and m_highlighted)249 if (m_enabled && m_highlighted)
250 {250 {
251 RGBAColor shade(100, 100, 100, 80);251 RGBAColor shade(100, 100, 100, 80);
252 dst.fill_rect(Rect(Point(0, 0), get_w(), 2), shade);252 dst.fill_rect(Rect(Point(0, 0), get_w(), 2), shade);
253253
=== modified file 'src/ui_basic/checkbox.cc'
--- src/ui_basic/checkbox.cc 2014-07-14 10:45:44 +0000
+++ src/ui_basic/checkbox.cc 2014-07-25 13:46:28 +0000
@@ -64,15 +64,15 @@
64 */64 */
65void Statebox::set_enabled(bool const enabled)65void Statebox::set_enabled(bool const enabled)
66{66{
67 if (((m_flags & Is_Enabled) > 1) and enabled)67 if (((m_flags & Is_Enabled) > 1) && enabled)
68 return;68 return;
6969
70 set_flags(Is_Enabled, enabled);70 set_flags(Is_Enabled, enabled);
7171
72 if (not (m_flags & Has_Custom_Picture)) {72 if (!(m_flags & Has_Custom_Picture)) {
73 m_pic_graphics = g_gr->images().get(enabled ? "pics/checkbox_light.png" : "pics/checkbox.png");73 m_pic_graphics = g_gr->images().get(enabled ? "pics/checkbox_light.png" : "pics/checkbox.png");
74 set_flags74 set_flags
75 (Is_Highlighted, (m_flags & Is_Highlighted) and (m_flags & Is_Enabled));75 (Is_Highlighted, (m_flags & Is_Highlighted) && (m_flags & Is_Enabled));
76 }76 }
7777
78 update();78 update();
@@ -85,7 +85,7 @@
85 * Args: on true if the checkbox should be checked85 * Args: on true if the checkbox should be checked
86 */86 */
87void Statebox::set_state(bool const on) {87void Statebox::set_state(bool const on) {
88 if (on xor ((m_flags & Is_Checked) > 1)) {88 if (on ^ ((m_flags & Is_Checked) > 1)) {
89 set_flags(Is_Checked, on);89 set_flags(Is_Checked, on);
90 changed();90 changed();
91 changedto(on);91 changedto(on);
@@ -136,7 +136,7 @@
136 */136 */
137void Statebox::handle_mousein(bool const inside) {137void Statebox::handle_mousein(bool const inside) {
138 bool oldhl = m_flags & Is_Highlighted;138 bool oldhl = m_flags & Is_Highlighted;
139 set_flags(Is_Highlighted, inside and (m_flags & Is_Enabled));139 set_flags(Is_Highlighted, inside && (m_flags & Is_Enabled));
140140
141 if (oldhl != (m_flags & Is_Highlighted))141 if (oldhl != (m_flags & Is_Highlighted))
142 update();142 update();
@@ -147,7 +147,7 @@
147 * Left-click: Toggle checkbox state147 * Left-click: Toggle checkbox state
148 */148 */
149bool Statebox::handle_mousepress(const uint8_t btn, int32_t, int32_t) {149bool Statebox::handle_mousepress(const uint8_t btn, int32_t, int32_t) {
150 if (btn == SDL_BUTTON_LEFT and (m_flags & Is_Enabled)) {150 if (btn == SDL_BUTTON_LEFT && (m_flags & Is_Enabled)) {
151 clicked();151 clicked();
152 return true;152 return true;
153 } else153 } else
154154
=== modified file 'src/ui_basic/editbox.cc'
--- src/ui_basic/editbox.cc 2014-07-23 14:49:10 +0000
+++ src/ui_basic/editbox.cc 2014-07-25 13:46:28 +0000
@@ -281,7 +281,7 @@
281 while ((m->text[--m->caret] & 0xc0) == 0x80) {};281 while ((m->text[--m->caret] & 0xc0) == 0x80) {};
282 if (code.mod & (KMOD_LCTRL | KMOD_RCTRL))282 if (code.mod & (KMOD_LCTRL | KMOD_RCTRL))
283 for (uint32_t new_caret = m->caret;; m->caret = new_caret)283 for (uint32_t new_caret = m->caret;; m->caret = new_caret)
284 if (0 == new_caret or isspace(m->text[--new_caret]))284 if (0 == new_caret || isspace(m->text[--new_caret]))
285 break;285 break;
286286
287 check_caret();287 check_caret();
@@ -303,7 +303,7 @@
303 for (uint32_t new_caret = m->caret;; ++new_caret)303 for (uint32_t new_caret = m->caret;; ++new_caret)
304 if304 if
305 (new_caret == m->text.size()305 (new_caret == m->text.size()
306 or306 ||
307 isspace(m->text[new_caret - 1]))307 isspace(m->text[new_caret - 1]))
308 {308 {
309 m->caret = new_caret;309 m->caret = new_caret;
@@ -390,7 +390,7 @@
390 // example ~ + o results in a o with a tilde over it. The ~ is reported390 // example ~ + o results in a o with a tilde over it. The ~ is reported
391 // as a 0 on keystroke, the o then as the unicode character. We simply391 // as a 0 on keystroke, the o then as the unicode character. We simply
392 // ignore the 0.392 // ignore the 0.
393 if (is_printable(code) and code.unicode) {393 if (is_printable(code) && code.unicode) {
394 insert(code);394 insert(code);
395 return true;395 return true;
396 }396 }
397397
=== modified file 'src/ui_basic/listselect.cc'
--- src/ui_basic/listselect.cc 2014-07-14 10:45:44 +0000
+++ src/ui_basic/listselect.cc 2014-07-25 13:46:28 +0000
@@ -374,7 +374,7 @@
374 }374 }
375 assert(2 <= get_eff_w());375 assert(2 <= get_eff_w());
376 // Make the area a bit more white and more transparent376 // Make the area a bit more white and more transparent
377 if (r.w > 0 and r.h > 0)377 if (r.w > 0 && r.h > 0)
378 {378 {
379 dst.brighten_rect(r, - ms_darken_value * 2);379 dst.brighten_rect(r, - ms_darken_value * 2);
380 }380 }
@@ -433,7 +433,7 @@
433 m_last_click_time = time;433 m_last_click_time = time;
434434
435 y = (y + m_scrollpos) / get_lineheight();435 y = (y + m_scrollpos) / get_lineheight();
436 if (y < 0 or static_cast<int32_t>(m_entry_records.size()) <= y)436 if (y < 0 || static_cast<int32_t>(m_entry_records.size()) <= y)
437 return false;437 return false;
438 play_click();438 play_click();
439 select(y);439 select(y);
@@ -441,9 +441,9 @@
441441
442 if // check if doubleclicked442 if // check if doubleclicked
443 (time - real_last_click_time < DOUBLE_CLICK_INTERVAL443 (time - real_last_click_time < DOUBLE_CLICK_INTERVAL
444 and444 &&
445 m_last_selection == m_selection445 m_last_selection == m_selection
446 and446 &&
447 m_selection != no_selection_index())447 m_selection != no_selection_index())
448 double_clicked(m_selection);448 double_clicked(m_selection);
449449
@@ -461,7 +461,7 @@
461461
462bool BaseListselect::handle_mousemove(uint8_t, int32_t, int32_t y, int32_t, int32_t) {462bool BaseListselect::handle_mousemove(uint8_t, int32_t, int32_t y, int32_t, int32_t) {
463 y = (y + m_scrollpos) / get_lineheight();463 y = (y + m_scrollpos) / get_lineheight();
464 if (y < 0 or static_cast<int32_t>(m_entry_records.size()) <= y) {464 if (y < 0 || static_cast<int32_t>(m_entry_records.size()) <= y) {
465 set_tooltip("");465 set_tooltip("");
466 return false;466 return false;
467 }467 }
468468
=== modified file 'src/ui_basic/multilineeditbox.cc'
--- src/ui_basic/multilineeditbox.cc 2014-07-05 14:22:44 +0000
+++ src/ui_basic/multilineeditbox.cc 2014-07-25 13:46:28 +0000
@@ -436,7 +436,7 @@
436 // example ~ + o results in a o with a tilde over it. The ~ is reported436 // example ~ + o results in a o with a tilde over it. The ~ is reported
437 // as a 0 on keystroke, the o then as the unicode character. We simply437 // as a 0 on keystroke, the o then as the unicode character. We simply
438 // ignore the 0.438 // ignore the 0.
439 if (is_printable(code) and code.unicode) {439 if (is_printable(code) && code.unicode) {
440 insert(code);440 insert(code);
441 }441 }
442 break;442 break;
443443
=== modified file 'src/ui_basic/multilinetextarea.cc'
--- src/ui_basic/multilinetextarea.cc 2014-07-14 10:45:44 +0000
+++ src/ui_basic/multilinetextarea.cc 2014-07-25 13:46:28 +0000
@@ -194,7 +194,7 @@
194 (uint8_t const btn, int32_t const x, int32_t const y)194 (uint8_t const btn, int32_t const x, int32_t const y)
195{195{
196 return196 return
197 btn == SDL_BUTTON_WHEELUP or btn == SDL_BUTTON_WHEELDOWN ?197 btn == SDL_BUTTON_WHEELUP || btn == SDL_BUTTON_WHEELDOWN ?
198 m_scrollbar.handle_mousepress(btn, x, y) : false;198 m_scrollbar.handle_mousepress(btn, x, y) : false;
199}199}
200200
201201
=== modified file 'src/ui_basic/panel.cc'
--- src/ui_basic/panel.cc 2014-07-22 09:54:49 +0000
+++ src/ui_basic/panel.cc 2014-07-25 13:46:28 +0000
@@ -499,9 +499,9 @@
499void Panel::update(int32_t x, int32_t y, int32_t w, int32_t h)499void Panel::update(int32_t x, int32_t y, int32_t w, int32_t h)
500{500{
501 if501 if
502 (x >= static_cast<int32_t>(_w) or x + w <= 0502 (x >= static_cast<int32_t>(_w) || x + w <= 0
503 or503 ||
504 y >= static_cast<int32_t>(_h) or y + h <= 0)504 y >= static_cast<int32_t>(_h) || y + h <= 0)
505 return;505 return;
506506
507 _needdraw = true;507 _needdraw = true;
@@ -950,9 +950,9 @@
950 if (!child->get_handle_mouse() || !child->is_visible())950 if (!child->get_handle_mouse() || !child->is_visible())
951 continue;951 continue;
952 if952 if
953 (x < child->_x + static_cast<int32_t>(child->_w) and x >= child->_x953 (x < child->_x + static_cast<int32_t>(child->_w) && x >= child->_x
954 and954 &&
955 y < child->_y + static_cast<int32_t>(child->_h) and y >= child->_y)955 y < child->_y + static_cast<int32_t>(child->_h) && y >= child->_y)
956 break;956 break;
957 }957 }
958958
@@ -971,7 +971,7 @@
971 */971 */
972void Panel::do_mousein(bool const inside)972void Panel::do_mousein(bool const inside)
973{973{
974 if (not _g_allow_user_input)974 if (!_g_allow_user_input)
975 return;975 return;
976976
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches

to status/vote changes: