Merge lp:~widelands-dev/widelands/cleanup_map into lp:widelands
- cleanup_map
- Merge into trunk
Status: | Merged |
---|---|
Merged at revision: | 8432 |
Proposed branch: | lp:~widelands-dev/widelands/cleanup_map |
Merge into: | lp:widelands |
Diff against target: |
3125 lines (+394/-469) 69 files modified
src/ai/ai_help_structs.cc (+1/-1) src/ai/ai_help_structs.h (+1/-1) src/ai/defaultai.cc (+13/-17) src/ai/defaultai_seafaring.cc (+2/-2) src/ai/defaultai_warfare.cc (+2/-3) src/economy/economy.cc (+4/-9) src/economy/fleet.cc (+2/-5) src/economy/road.cc (+4/-4) src/economy/test/test_road.cc (+3/-14) src/editor/editorinteractive.cc (+20/-22) src/editor/ui_menus/main_menu_map_options.cc (+6/-6) src/editor/ui_menus/main_menu_new_map.cc (+3/-3) src/editor/ui_menus/main_menu_random_map.cc (+9/-10) src/editor/ui_menus/main_menu_save_map.cc (+12/-12) src/editor/ui_menus/player_menu.cc (+25/-25) src/editor/ui_menus/tool_change_resources_options_menu.cc (+4/-4) src/editor/ui_menus/tool_menu.cc (+3/-3) src/game_io/game_map_packet.cc (+1/-1) src/game_io/game_player_ai_persistent_packet.cc (+2/-4) src/graphic/game_renderer.cc (+1/-1) src/graphic/minimap_renderer.cc (+1/-1) src/logic/editor_game_base.cc (+6/-23) src/logic/editor_game_base.h (+4/-9) src/logic/game.cc (+7/-19) src/logic/map.cc (+9/-9) src/logic/map.h (+30/-30) src/logic/map_objects/bob.cc (+7/-8) src/logic/map_objects/checkstep.cc (+12/-12) src/logic/map_objects/checkstep.h (+16/-16) src/logic/map_objects/immovable.cc (+11/-9) src/logic/map_objects/tribes/building.cc (+4/-4) src/logic/map_objects/tribes/carrier.cc (+1/-1) src/logic/map_objects/tribes/militarysite.cc (+1/-1) src/logic/map_objects/tribes/production_program.cc (+9/-9) src/logic/map_objects/tribes/ship.cc (+15/-16) src/logic/map_objects/tribes/soldier.cc (+9/-9) src/logic/map_objects/tribes/warehouse.cc (+4/-5) src/logic/map_objects/tribes/worker.cc (+20/-21) src/logic/player.cc (+6/-6) src/logic/replay_game_controller.cc (+0/-3) src/map_io/map_bob_packet.cc (+4/-4) src/map_io/map_building_packet.cc (+1/-1) src/map_io/map_buildingdata_packet.cc (+4/-3) src/map_io/map_elemental_packet.cc (+1/-1) src/map_io/map_exploration_packet.cc (+2/-2) src/map_io/map_heights_packet.cc (+2/-2) src/map_io/map_node_ownership_packet.cc (+2/-2) src/map_io/map_objective_packet.cc (+1/-1) src/map_io/map_player_names_and_tribes_packet.cc (+1/-1) src/map_io/map_player_position_packet.cc (+4/-4) src/map_io/map_port_spaces_packet.cc (+4/-4) src/map_io/map_resources_packet.cc (+6/-6) src/map_io/map_roaddata_packet.cc (+1/-1) src/map_io/map_saver.cc (+3/-5) src/map_io/map_terrain_packet.cc (+1/-1) src/map_io/map_version_packet.cc (+11/-11) src/scripting/lua_bases.cc (+1/-1) src/scripting/lua_game.cc (+12/-15) src/scripting/lua_map.cc (+22/-21) src/website/map_info.cc (+1/-2) src/wui/attack_box.cc (+2/-3) src/wui/attack_box.h (+1/-1) src/wui/building_statistics_menu.cc (+1/-2) src/wui/fieldaction.cc (+5/-5) src/wui/game_debug_ui.cc (+1/-1) src/wui/game_main_menu_save_game.cc (+1/-1) src/wui/interactive_base.cc (+4/-4) src/wui/interactive_gamebase.cc (+2/-3) src/wui/watchwindow.cc (+3/-3) |
To merge this branch: | bzr merge lp:~widelands-dev/widelands/cleanup_map |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
SirVer | Approve | ||
GunChleoc | Approve | ||
Review via email: mp+329282@code.launchpad.net |
Commit message
Cleanups map handling in EditorGameBase
- remove set_map which was unused.
- remove redundant functions, only keep map() and get_map().
- mark more functions around path finding as const to make the API of the map clearer.
This is a simple, but huge refactoring since it needs to touch all code that deals with the map.
Description of the change
bunnybot (widelandsofficial) wrote : | # |
GunChleoc (gunchleoc) wrote : | # |
LGTM :)
There is still 1 NOCOM in the code.
I did some additional cleanup - feel free to merge if you agree with my changes.
bunnybot (widelandsofficial) wrote : | # |
Continuous integration builds have changed state:
Travis build 2586. State: passed. Details: https:/
Appveyor build 2408. State: success. Details: https:/
SirVer (sirver) wrote : | # |
> There is still 1 NOCOM in the code.
Ups. Fixed.
> I did some additional cleanup - feel free to merge if you agree with my changes.
Thanks! lgtm.
@bunnybot merge
Preview Diff
1 | === modified file 'src/ai/ai_help_structs.cc' | |||
2 | --- src/ai/ai_help_structs.cc 2017-08-19 23:24:28 +0000 | |||
3 | +++ src/ai/ai_help_structs.cc 2017-08-20 12:33:35 +0000 | |||
4 | @@ -41,7 +41,7 @@ | |||
5 | 41 | } | 41 | } |
6 | 42 | 42 | ||
7 | 43 | bool CheckStepRoadAI::allowed( | 43 | bool CheckStepRoadAI::allowed( |
9 | 44 | Map& map, FCoords start, FCoords end, int32_t, CheckStep::StepId const id) const { | 44 | const Map& map, FCoords start, FCoords end, int32_t, CheckStep::StepId const id) const { |
10 | 45 | uint8_t endcaps = player->get_buildcaps(end); | 45 | uint8_t endcaps = player->get_buildcaps(end); |
11 | 46 | 46 | ||
12 | 47 | // we should not cross fields with road or flags (or any other immovable) | 47 | // we should not cross fields with road or flags (or any other immovable) |
13 | 48 | 48 | ||
14 | === modified file 'src/ai/ai_help_structs.h' | |||
15 | --- src/ai/ai_help_structs.h 2017-08-19 19:33:37 +0000 | |||
16 | +++ src/ai/ai_help_structs.h 2017-08-20 12:33:35 +0000 | |||
17 | @@ -131,7 +131,7 @@ | |||
18 | 131 | struct CheckStepRoadAI { | 131 | struct CheckStepRoadAI { |
19 | 132 | CheckStepRoadAI(Player* const pl, uint8_t const mc, bool const oe); | 132 | CheckStepRoadAI(Player* const pl, uint8_t const mc, bool const oe); |
20 | 133 | 133 | ||
22 | 134 | bool allowed(Map&, FCoords start, FCoords end, int32_t dir, CheckStep::StepId) const; | 134 | bool allowed(const Map&, FCoords start, FCoords end, int32_t dir, CheckStep::StepId) const; |
23 | 135 | bool reachable_dest(const Map&, const FCoords& dest) const; | 135 | bool reachable_dest(const Map&, const FCoords& dest) const; |
24 | 136 | 136 | ||
25 | 137 | Player* player; | 137 | Player* player; |
26 | 138 | 138 | ||
27 | === modified file 'src/ai/defaultai.cc' | |||
28 | --- src/ai/defaultai.cc 2017-08-19 19:33:37 +0000 | |||
29 | +++ src/ai/defaultai.cc 2017-08-20 12:33:35 +0000 | |||
30 | @@ -244,8 +244,6 @@ | |||
31 | 244 | 244 | ||
32 | 245 | const int32_t delay_time = gametime - taskPool.front().due_time; | 245 | const int32_t delay_time = gametime - taskPool.front().due_time; |
33 | 246 | 246 | ||
34 | 247 | Map& map = game().map(); | ||
35 | 248 | |||
36 | 249 | // Here we decide how many jobs will be run now (none - 5) | 247 | // Here we decide how many jobs will be run now (none - 5) |
37 | 250 | // in case no job is due now, it can be zero | 248 | // in case no job is due now, it can be zero |
38 | 251 | uint32_t jobs_to_run_count = (delay_time < 0) ? 0 : 1; | 249 | uint32_t jobs_to_run_count = (delay_time < 0) ? 0 : 1; |
39 | @@ -446,7 +444,7 @@ | |||
40 | 446 | { // statistics for spotted warehouses | 444 | { // statistics for spotted warehouses |
41 | 447 | uint16_t conquered_wh = 0; | 445 | uint16_t conquered_wh = 0; |
42 | 448 | for (auto coords : enemy_warehouses) { | 446 | for (auto coords : enemy_warehouses) { |
44 | 449 | if (get_land_owner(map, coords) == player_number()) { | 447 | if (get_land_owner(game().map(), coords) == player_number()) { |
45 | 450 | ++conquered_wh; | 448 | ++conquered_wh; |
46 | 451 | } | 449 | } |
47 | 452 | }; | 450 | }; |
48 | @@ -690,7 +688,7 @@ | |||
49 | 690 | for (const DescriptionIndex& temp_output : prod.output_ware_types()) { | 688 | for (const DescriptionIndex& temp_output : prod.output_ware_types()) { |
50 | 691 | bo.outputs.push_back(temp_output); | 689 | bo.outputs.push_back(temp_output); |
51 | 692 | } | 690 | } |
53 | 693 | for (const auto temp_position : prod.working_positions()) { | 691 | for (const auto& temp_position : prod.working_positions()) { |
54 | 694 | bo.positions.push_back(temp_position.first); | 692 | bo.positions.push_back(temp_position.first); |
55 | 695 | } | 693 | } |
56 | 696 | 694 | ||
57 | @@ -925,7 +923,7 @@ | |||
58 | 925 | taskPool.push_back(SchedulerTask( | 923 | taskPool.push_back(SchedulerTask( |
59 | 926 | std::max<uint32_t>(gametime, 10 * 1000), SchedulerTaskId::kUpdateStats, 15, "review")); | 924 | std::max<uint32_t>(gametime, 10 * 1000), SchedulerTaskId::kUpdateStats, 15, "review")); |
60 | 927 | 925 | ||
62 | 928 | Map& map = game().map(); | 926 | const Map& map = game().map(); |
63 | 929 | 927 | ||
64 | 930 | // here we generate list of all ports and their vicinity from entire map | 928 | // here we generate list of all ports and their vicinity from entire map |
65 | 931 | for (const Coords& c : map.get_port_spaces()) { | 929 | for (const Coords& c : map.get_port_spaces()) { |
66 | @@ -1185,7 +1183,7 @@ | |||
67 | 1185 | /// Updates one buildable field | 1183 | /// Updates one buildable field |
68 | 1186 | void DefaultAI::update_buildable_field(BuildableField& field) { | 1184 | void DefaultAI::update_buildable_field(BuildableField& field) { |
69 | 1187 | // look if there is any unowned land nearby | 1185 | // look if there is any unowned land nearby |
71 | 1188 | Map& map = game().map(); | 1186 | const Map& map = game().map(); |
72 | 1189 | const uint32_t gametime = game().get_gametime(); | 1187 | const uint32_t gametime = game().get_gametime(); |
73 | 1190 | FindNodeUnownedWalkable find_unowned_walkable(player_, game()); | 1188 | FindNodeUnownedWalkable find_unowned_walkable(player_, game()); |
74 | 1191 | FindEnemyNodeWalkable find_enemy_owned_walkable(player_, game()); | 1189 | FindEnemyNodeWalkable find_enemy_owned_walkable(player_, game()); |
75 | @@ -1813,7 +1811,7 @@ | |||
76 | 1813 | void DefaultAI::update_mineable_field(MineableField& field) { | 1811 | void DefaultAI::update_mineable_field(MineableField& field) { |
77 | 1814 | // collect information about resources in the area | 1812 | // collect information about resources in the area |
78 | 1815 | std::vector<ImmovableFound> immovables; | 1813 | std::vector<ImmovableFound> immovables; |
80 | 1816 | Map& map = game().map(); | 1814 | const Map& map = game().map(); |
81 | 1817 | map.find_immovables(Area<FCoords>(field.coords, 5), &immovables); | 1815 | map.find_immovables(Area<FCoords>(field.coords, 5), &immovables); |
82 | 1818 | field.preferred = false; | 1816 | field.preferred = false; |
83 | 1819 | field.mines_nearby = 0; | 1817 | field.mines_nearby = 0; |
84 | @@ -1948,7 +1946,7 @@ | |||
85 | 1948 | bool mine = false; | 1946 | bool mine = false; |
86 | 1949 | uint32_t consumers_nearby_count = 0; | 1947 | uint32_t consumers_nearby_count = 0; |
87 | 1950 | 1948 | ||
89 | 1951 | Map& map = game().map(); | 1949 | const Map& map = game().map(); |
90 | 1952 | 1950 | ||
91 | 1953 | for (int32_t i = 0; i < 4; ++i) | 1951 | for (int32_t i = 0; i < 4; ++i) |
92 | 1954 | spots_avail.at(i) = 0; | 1952 | spots_avail.at(i) = 0; |
93 | @@ -3226,7 +3224,6 @@ | |||
94 | 3226 | } else { | 3224 | } else { |
95 | 3227 | checkradius = 15; | 3225 | checkradius = 15; |
96 | 3228 | } | 3226 | } |
97 | 3229 | Map& map = game().map(); | ||
98 | 3230 | 3227 | ||
99 | 3231 | // algorithm to walk on roads | 3228 | // algorithm to walk on roads |
100 | 3232 | while (!queue.empty()) { | 3229 | while (!queue.empty()) { |
101 | @@ -3270,7 +3267,7 @@ | |||
102 | 3270 | endflag = &near_road->get_flag(Road::FlagEnd); | 3267 | endflag = &near_road->get_flag(Road::FlagEnd); |
103 | 3271 | } | 3268 | } |
104 | 3272 | 3269 | ||
106 | 3273 | int32_t dist = map.calc_distance(roadstartflag.get_position(), endflag->get_position()); | 3270 | int32_t dist = game().map().calc_distance(roadstartflag.get_position(), endflag->get_position()); |
107 | 3274 | 3271 | ||
108 | 3275 | if (dist > checkradius) { // out of range of interest | 3272 | if (dist > checkradius) { // out of range of interest |
109 | 3276 | continue; | 3273 | continue; |
110 | @@ -3371,7 +3368,7 @@ | |||
111 | 3371 | checkradius += 2; | 3368 | checkradius += 2; |
112 | 3372 | } | 3369 | } |
113 | 3373 | 3370 | ||
115 | 3374 | Map& map = game().map(); | 3371 | const Map& map = game().map(); |
116 | 3375 | 3372 | ||
117 | 3376 | // initializing new object of FlagsForRoads, we will push there all candidate flags | 3373 | // initializing new object of FlagsForRoads, we will push there all candidate flags |
118 | 3377 | Widelands::FlagsForRoads RoadCandidates(min_reduction); | 3374 | Widelands::FlagsForRoads RoadCandidates(min_reduction); |
119 | @@ -3514,7 +3511,7 @@ | |||
120 | 3514 | // first we block the field and vicinity for 15 minutes, probably it is not a good place to | 3511 | // first we block the field and vicinity for 15 minutes, probably it is not a good place to |
121 | 3515 | // build on | 3512 | // build on |
122 | 3516 | MapRegion<Area<FCoords>> mr( | 3513 | MapRegion<Area<FCoords>> mr( |
124 | 3517 | game().map(), Area<FCoords>(map.get_fcoords(bld->get_position()), 2)); | 3514 | map, Area<FCoords>(map.get_fcoords(bld->get_position()), 2)); |
125 | 3518 | do { | 3515 | do { |
126 | 3519 | blocked_fields.add(mr.location(), game().get_gametime() + 15 * 60 * 1000); | 3516 | blocked_fields.add(mr.location(), game().get_gametime() + 15 * 60 * 1000); |
127 | 3520 | } while (mr.advance(map)); | 3517 | } while (mr.advance(map)); |
128 | @@ -3605,7 +3602,7 @@ | |||
129 | 3605 | } | 3602 | } |
130 | 3606 | } | 3603 | } |
131 | 3607 | 3604 | ||
133 | 3608 | Map& map = game().map(); | 3605 | const Map& map = game().map(); |
134 | 3609 | 3606 | ||
135 | 3610 | // The code here is bit complicated | 3607 | // The code here is bit complicated |
136 | 3611 | // a) Either this site is pending for upgrade, if ready, order the upgrade | 3608 | // a) Either this site is pending for upgrade, if ready, order the upgrade |
137 | @@ -5437,7 +5434,7 @@ | |||
138 | 5437 | uint16_t* mineable_fields_count, | 5434 | uint16_t* mineable_fields_count, |
139 | 5438 | const Coords& starting_spot, | 5435 | const Coords& starting_spot, |
140 | 5439 | const WalkSearch& type) { | 5436 | const WalkSearch& type) { |
142 | 5440 | Map& map = game().map(); | 5437 | const Map& map = game().map(); |
143 | 5441 | std::list<uint32_t> queue; | 5438 | std::list<uint32_t> queue; |
144 | 5442 | std::unordered_set<uint32_t> done; | 5439 | std::unordered_set<uint32_t> done; |
145 | 5443 | queue.push_front(starting_spot.hash()); | 5440 | queue.push_front(starting_spot.hash()); |
146 | @@ -5640,7 +5637,7 @@ | |||
147 | 5640 | ++num_ports; | 5637 | ++num_ports; |
148 | 5641 | seafaring_economy = true; | 5638 | seafaring_economy = true; |
149 | 5642 | // unblock nearby fields, might be used for other buildings... | 5639 | // unblock nearby fields, might be used for other buildings... |
151 | 5643 | Map& map = game().map(); | 5640 | const Map& map = game().map(); |
152 | 5644 | MapRegion<Area<FCoords>> mr( | 5641 | MapRegion<Area<FCoords>> mr( |
153 | 5645 | map, Area<FCoords>(map.get_fcoords(warehousesites.back().site->get_position()), 3)); | 5642 | map, Area<FCoords>(map.get_fcoords(warehousesites.back().site->get_position()), 3)); |
154 | 5646 | do { | 5643 | do { |
155 | @@ -5809,9 +5806,8 @@ | |||
156 | 5809 | return; | 5806 | return; |
157 | 5810 | } | 5807 | } |
158 | 5811 | player_statistics.set_update_time(gametime); | 5808 | player_statistics.set_update_time(gametime); |
159 | 5812 | Map& map = game().map(); | ||
160 | 5813 | Widelands::PlayerNumber const pn = player_number(); | 5809 | Widelands::PlayerNumber const pn = player_number(); |
162 | 5814 | PlayerNumber const nr_players = map.get_nrplayers(); | 5810 | PlayerNumber const nr_players = game().map().get_nrplayers(); |
163 | 5815 | uint32_t plr_in_game = 0; | 5811 | uint32_t plr_in_game = 0; |
164 | 5816 | iterate_players_existing_novar(p, nr_players, game())++ plr_in_game; | 5812 | iterate_players_existing_novar(p, nr_players, game())++ plr_in_game; |
165 | 5817 | 5813 | ||
166 | 5818 | 5814 | ||
167 | === modified file 'src/ai/defaultai_seafaring.cc' | |||
168 | --- src/ai/defaultai_seafaring.cc 2017-06-26 15:09:21 +0000 | |||
169 | +++ src/ai/defaultai_seafaring.cc 2017-08-20 12:33:35 +0000 | |||
170 | @@ -26,7 +26,7 @@ | |||
171 | 26 | // this scores spot for potential colony | 26 | // this scores spot for potential colony |
172 | 27 | uint8_t DefaultAI::spot_scoring(Widelands::Coords candidate_spot) { | 27 | uint8_t DefaultAI::spot_scoring(Widelands::Coords candidate_spot) { |
173 | 28 | 28 | ||
175 | 29 | Map& map = game().map(); | 29 | const Map& map = game().map(); |
176 | 30 | PlayerNumber const pn = player_->player_number(); | 30 | PlayerNumber const pn = player_->player_number(); |
177 | 31 | uint8_t score = 0; | 31 | uint8_t score = 0; |
178 | 32 | uint16_t mineable_fields_count = 0; | 32 | uint16_t mineable_fields_count = 0; |
179 | @@ -421,7 +421,6 @@ | |||
180 | 421 | // navigation decisions (these notifications are processes not in 'real time') | 421 | // navigation decisions (these notifications are processes not in 'real time') |
181 | 422 | void DefaultAI::expedition_management(ShipObserver& so) { | 422 | void DefaultAI::expedition_management(ShipObserver& so) { |
182 | 423 | 423 | ||
183 | 424 | Map& map = game().map(); | ||
184 | 425 | const int32_t gametime = game().get_gametime(); | 424 | const int32_t gametime = game().get_gametime(); |
185 | 426 | PlayerNumber const pn = player_->player_number(); | 425 | PlayerNumber const pn = player_->player_number(); |
186 | 427 | // probability for island exploration repetition | 426 | // probability for island exploration repetition |
187 | @@ -484,6 +483,7 @@ | |||
188 | 484 | // we head for open sea again | 483 | // we head for open sea again |
189 | 485 | } else { | 484 | } else { |
190 | 486 | // determine swimmable directions | 485 | // determine swimmable directions |
191 | 486 | const Map& map = game().map(); | ||
192 | 487 | std::vector<Direction> possible_directions; | 487 | std::vector<Direction> possible_directions; |
193 | 488 | for (Direction dir = FIRST_DIRECTION; dir <= LAST_DIRECTION; ++dir) { | 488 | for (Direction dir = FIRST_DIRECTION; dir <= LAST_DIRECTION; ++dir) { |
194 | 489 | // testing distance of 8 fields | 489 | // testing distance of 8 fields |
195 | 490 | 490 | ||
196 | === modified file 'src/ai/defaultai_warfare.cc' | |||
197 | --- src/ai/defaultai_warfare.cc 2017-08-19 13:27:38 +0000 | |||
198 | +++ src/ai/defaultai_warfare.cc 2017-08-20 12:33:35 +0000 | |||
199 | @@ -23,7 +23,7 @@ | |||
200 | 23 | 23 | ||
201 | 24 | bool DefaultAI::check_enemy_sites(uint32_t const gametime) { | 24 | bool DefaultAI::check_enemy_sites(uint32_t const gametime) { |
202 | 25 | 25 | ||
204 | 26 | Map& map = game().map(); | 26 | const Map& map = game().map(); |
205 | 27 | 27 | ||
206 | 28 | PlayerNumber const nr_players = map.get_nrplayers(); | 28 | PlayerNumber const nr_players = map.get_nrplayers(); |
207 | 29 | uint32_t plr_in_game = 0; | 29 | uint32_t plr_in_game = 0; |
208 | @@ -777,7 +777,6 @@ | |||
209 | 777 | 777 | ||
210 | 778 | // Check next militarysite | 778 | // Check next militarysite |
211 | 779 | bool changed = false; | 779 | bool changed = false; |
212 | 780 | Map& map = game().map(); | ||
213 | 781 | MilitarySite* ms = militarysites.front().site; | 780 | MilitarySite* ms = militarysites.front().site; |
214 | 782 | 781 | ||
215 | 783 | // Don't do anything if last change took place lately | 782 | // Don't do anything if last change took place lately |
216 | @@ -787,7 +786,7 @@ | |||
217 | 787 | return false; | 786 | return false; |
218 | 788 | } | 787 | } |
219 | 789 | 788 | ||
221 | 790 | FCoords f = map.get_fcoords(ms->get_position()); | 789 | FCoords f = game().map().get_fcoords(ms->get_position()); |
222 | 791 | 790 | ||
223 | 792 | BuildableField bf(f); | 791 | BuildableField bf(f); |
224 | 793 | update_buildable_field(bf); | 792 | update_buildable_field(bf); |
225 | 794 | 793 | ||
226 | === modified file 'src/economy/economy.cc' | |||
227 | --- src/economy/economy.cc 2017-06-20 08:17:02 +0000 | |||
228 | +++ src/economy/economy.cc 2017-08-20 12:33:35 +0000 | |||
229 | @@ -136,8 +136,6 @@ | |||
230 | 136 | 136 | ||
231 | 137 | void Economy::check_splits() { | 137 | void Economy::check_splits() { |
232 | 138 | EditorGameBase& egbase = owner().egbase(); | 138 | EditorGameBase& egbase = owner().egbase(); |
233 | 139 | Map& map = egbase.map(); | ||
234 | 140 | |||
235 | 141 | while (split_checks_.size()) { | 139 | while (split_checks_.size()) { |
236 | 142 | Flag* f1 = split_checks_.back().first.get(egbase); | 140 | Flag* f1 = split_checks_.back().first.get(egbase); |
237 | 143 | Flag* f2 = split_checks_.back().second.get(egbase); | 141 | Flag* f2 = split_checks_.back().second.get(egbase); |
238 | @@ -172,7 +170,7 @@ | |||
239 | 172 | // reached from f1. These nodes induce a connected subgraph. | 170 | // reached from f1. These nodes induce a connected subgraph. |
240 | 173 | // This means that the newly created economy, which contains all the | 171 | // This means that the newly created economy, which contains all the |
241 | 174 | // flags that have been split, is already connected. | 172 | // flags that have been split, is already connected. |
243 | 175 | RouteAStar<AStarEstimator> astar(*router_, wwWORKER, AStarEstimator(map, *f2)); | 173 | RouteAStar<AStarEstimator> astar(*router_, wwWORKER, AStarEstimator(*egbase.mutable_map(), *f2)); |
244 | 176 | astar.push(*f1); | 174 | astar.push(*f1); |
245 | 177 | std::set<OPtr<Flag>> reachable; | 175 | std::set<OPtr<Flag>> reachable; |
246 | 178 | 176 | ||
247 | @@ -198,10 +196,8 @@ | |||
248 | 198 | Flag& start, Flag& end, Route* const route, WareWorker const type, int32_t const cost_cutoff) { | 196 | Flag& start, Flag& end, Route* const route, WareWorker const type, int32_t const cost_cutoff) { |
249 | 199 | assert(start.get_economy() == this); | 197 | assert(start.get_economy() == this); |
250 | 200 | assert(end.get_economy() == this); | 198 | assert(end.get_economy() == this); |
255 | 201 | 199 | return router_->find_route( | |
256 | 202 | Map& map = owner().egbase().map(); | 200 | start, end, route, type, cost_cutoff, *owner().egbase().mutable_map()); |
253 | 203 | |||
254 | 204 | return router_->find_route(start, end, route, type, cost_cutoff, map); | ||
257 | 205 | } | 201 | } |
258 | 206 | 202 | ||
259 | 207 | struct ZeroEstimator { | 203 | struct ZeroEstimator { |
260 | @@ -604,7 +600,6 @@ | |||
261 | 604 | Route* best_route = nullptr; | 600 | Route* best_route = nullptr; |
262 | 605 | int32_t best_cost = -1; | 601 | int32_t best_cost = -1; |
263 | 606 | Flag& target_flag = req.target_flag(); | 602 | Flag& target_flag = req.target_flag(); |
264 | 607 | Map& map = game.map(); | ||
265 | 608 | 603 | ||
266 | 609 | available_supplies_.clear(); | 604 | available_supplies_.clear(); |
267 | 610 | 605 | ||
268 | @@ -626,7 +621,7 @@ | |||
269 | 626 | const Widelands::Coords provider_position = | 621 | const Widelands::Coords provider_position = |
270 | 627 | supp.get_position(game)->base_flag().get_position(); | 622 | supp.get_position(game)->base_flag().get_position(); |
271 | 628 | 623 | ||
273 | 629 | const uint32_t dist = map.calc_distance(target_flag.get_position(), provider_position); | 624 | const uint32_t dist = game.map().calc_distance(target_flag.get_position(), provider_position); |
274 | 630 | 625 | ||
275 | 631 | UniqueDistance ud = {dist, supp.get_position(game)->serial(), provider}; | 626 | UniqueDistance ud = {dist, supp.get_position(game)->serial(), provider}; |
276 | 632 | 627 | ||
277 | 633 | 628 | ||
278 | === modified file 'src/economy/fleet.cc' | |||
279 | --- src/economy/fleet.cc 2017-08-09 19:25:04 +0000 | |||
280 | +++ src/economy/fleet.cc 2017-08-20 12:33:35 +0000 | |||
281 | @@ -138,9 +138,7 @@ | |||
282 | 138 | * of the same player. | 138 | * of the same player. |
283 | 139 | */ | 139 | */ |
284 | 140 | void Fleet::find_other_fleet(EditorGameBase& egbase) { | 140 | void Fleet::find_other_fleet(EditorGameBase& egbase) { |
288 | 141 | Map& map = egbase.map(); | 141 | MapAStar<StepEvalFindFleet> astar(*egbase.mutable_map(), StepEvalFindFleet()); |
286 | 142 | MapAStar<StepEvalFindFleet> astar(map, StepEvalFindFleet()); | ||
287 | 143 | |||
289 | 144 | for (const Ship* temp_ship : ships_) { | 142 | for (const Ship* temp_ship : ships_) { |
290 | 145 | astar.push(temp_ship->get_position()); | 143 | astar.push(temp_ship->get_position()); |
291 | 146 | } | 144 | } |
292 | @@ -443,7 +441,6 @@ | |||
293 | 443 | * because path finding is flaky during map loading. | 441 | * because path finding is flaky during map loading. |
294 | 444 | */ | 442 | */ |
295 | 445 | void Fleet::connect_port(EditorGameBase& egbase, uint32_t idx) { | 443 | void Fleet::connect_port(EditorGameBase& egbase, uint32_t idx) { |
296 | 446 | Map& map = egbase.map(); | ||
297 | 447 | StepEvalFindPorts se; | 444 | StepEvalFindPorts se; |
298 | 448 | 445 | ||
299 | 449 | for (uint32_t i = 0; i < ports_.size(); ++i) { | 446 | for (uint32_t i = 0; i < ports_.size(); ++i) { |
300 | @@ -463,7 +460,7 @@ | |||
301 | 463 | if (se.targets.empty()) | 460 | if (se.targets.empty()) |
302 | 464 | return; | 461 | return; |
303 | 465 | 462 | ||
305 | 466 | MapAStar<StepEvalFindPorts> astar(map, se); | 463 | MapAStar<StepEvalFindPorts> astar(*egbase.mutable_map(), se); |
306 | 467 | 464 | ||
307 | 468 | BaseImmovable::PositionList src(ports_[idx]->get_positions(egbase)); | 465 | BaseImmovable::PositionList src(ports_[idx]->get_positions(egbase)); |
308 | 469 | for (const Coords& temp_pos : src) { | 466 | for (const Coords& temp_pos : src) { |
309 | 470 | 467 | ||
310 | === modified file 'src/economy/road.cc' | |||
311 | --- src/economy/road.cc 2017-04-23 12:11:19 +0000 | |||
312 | +++ src/economy/road.cc 2017-08-20 12:33:35 +0000 | |||
313 | @@ -109,7 +109,7 @@ | |||
314 | 109 | } | 109 | } |
315 | 110 | 110 | ||
316 | 111 | BaseImmovable::PositionList Road::get_positions(const EditorGameBase& egbase) const { | 111 | BaseImmovable::PositionList Road::get_positions(const EditorGameBase& egbase) const { |
318 | 112 | Map& map = egbase.map(); | 112 | const Map& map = egbase.map(); |
319 | 113 | Coords curf = map.get_fcoords(path_.get_start()); | 113 | Coords curf = map.get_fcoords(path_.get_start()); |
320 | 114 | 114 | ||
321 | 115 | PositionList rv; | 115 | PositionList rv; |
322 | @@ -155,7 +155,7 @@ | |||
323 | 155 | * Add road markings to the map | 155 | * Add road markings to the map |
324 | 156 | */ | 156 | */ |
325 | 157 | void Road::mark_map(EditorGameBase& egbase) { | 157 | void Road::mark_map(EditorGameBase& egbase) { |
327 | 158 | Map& map = egbase.map(); | 158 | const Map& map = egbase.map(); |
328 | 159 | FCoords curf = map.get_fcoords(path_.get_start()); | 159 | FCoords curf = map.get_fcoords(path_.get_start()); |
329 | 160 | 160 | ||
330 | 161 | const Path::StepVector::size_type nr_steps = path_.get_nsteps(); | 161 | const Path::StepVector::size_type nr_steps = path_.get_nsteps(); |
331 | @@ -189,7 +189,7 @@ | |||
332 | 189 | * Remove road markings from the map | 189 | * Remove road markings from the map |
333 | 190 | */ | 190 | */ |
334 | 191 | void Road::unmark_map(EditorGameBase& egbase) { | 191 | void Road::unmark_map(EditorGameBase& egbase) { |
336 | 192 | Map& map = egbase.map(); | 192 | const Map& map = egbase.map(); |
337 | 193 | FCoords curf(path_.get_start(), &map[path_.get_start()]); | 193 | FCoords curf(path_.get_start(), &map[path_.get_start()]); |
338 | 194 | 194 | ||
339 | 195 | const Path::StepVector::size_type nr_steps = path_.get_nsteps(); | 195 | const Path::StepVector::size_type nr_steps = path_.get_nsteps(); |
340 | @@ -425,7 +425,7 @@ | |||
341 | 425 | oldend.detach_road(flagidx_[FlagEnd]); | 425 | oldend.detach_road(flagidx_[FlagEnd]); |
342 | 426 | 426 | ||
343 | 427 | // build our new path and the new road's path | 427 | // build our new path and the new road's path |
345 | 428 | Map& map = game.map(); | 428 | const Map& map = game.map(); |
346 | 429 | CoordPath path(map, path_); | 429 | CoordPath path(map, path_); |
347 | 430 | CoordPath secondpath(path); | 430 | CoordPath secondpath(path); |
348 | 431 | int32_t const index = path.get_index(flag.get_position()); | 431 | int32_t const index = path.get_index(flag.get_position()); |
349 | 432 | 432 | ||
350 | === modified file 'src/economy/test/test_road.cc' | |||
351 | --- src/economy/test/test_road.cc 2017-06-22 16:49:12 +0000 | |||
352 | +++ src/economy/test/test_road.cc 2017-08-20 12:33:35 +0000 | |||
353 | @@ -45,14 +45,6 @@ | |||
354 | 45 | set_flag_position(c); | 45 | set_flag_position(c); |
355 | 46 | } | 46 | } |
356 | 47 | }; | 47 | }; |
357 | 48 | struct TestingMap : public Map { | ||
358 | 49 | TestingMap(int const w, int const h) : Map() { | ||
359 | 50 | set_size(w, h); | ||
360 | 51 | } | ||
361 | 52 | |||
362 | 53 | void recalc_for_field_area(const World&, Area<FCoords>) override { | ||
363 | 54 | } | ||
364 | 55 | }; | ||
365 | 56 | 48 | ||
366 | 57 | /*************************************************************************/ | 49 | /*************************************************************************/ |
367 | 58 | /* TESTS */ | 50 | /* TESTS */ |
368 | @@ -69,11 +61,9 @@ | |||
369 | 69 | 61 | ||
370 | 70 | struct SimpleRoadTestsFixture : public WlTestFixture { | 62 | struct SimpleRoadTestsFixture : public WlTestFixture { |
371 | 71 | SimpleRoadTestsFixture() : g(nullptr), path(Coords(5, 5)) { | 63 | SimpleRoadTestsFixture() : g(nullptr), path(Coords(5, 5)) { |
377 | 72 | map = new TestingMap(32, 32); | 64 | g.mutable_map()->set_size(32, 32); |
378 | 73 | g.set_map(map); | 65 | path.append(g.map(), WALK_E); |
379 | 74 | 66 | path.append(g.map(), WALK_E); | |
375 | 75 | path.append(*map, WALK_E); | ||
376 | 76 | path.append(*map, WALK_E); | ||
380 | 77 | 67 | ||
381 | 78 | start = new TestingFlag(g, Coords(5, 5)); | 68 | start = new TestingFlag(g, Coords(5, 5)); |
382 | 79 | end = new TestingFlag(g, Coords(7, 5)); | 69 | end = new TestingFlag(g, Coords(7, 5)); |
383 | @@ -84,7 +74,6 @@ | |||
384 | 84 | // Map is deleted by EditorGameBase | 74 | // Map is deleted by EditorGameBase |
385 | 85 | } | 75 | } |
386 | 86 | 76 | ||
387 | 87 | TestingMap* map; | ||
388 | 88 | EditorGameBase g; | 77 | EditorGameBase g; |
389 | 89 | Road r; | 78 | Road r; |
390 | 90 | Path path; | 79 | Path path; |
391 | 91 | 80 | ||
392 | === modified file 'src/editor/editorinteractive.cc' | |||
393 | --- src/editor/editorinteractive.cc 2017-08-17 15:34:45 +0000 | |||
394 | +++ src/editor/editorinteractive.cc 2017-08-20 12:33:35 +0000 | |||
395 | @@ -177,21 +177,21 @@ | |||
396 | 177 | } | 177 | } |
397 | 178 | 178 | ||
398 | 179 | void EditorInteractive::register_overlays() { | 179 | void EditorInteractive::register_overlays() { |
400 | 180 | Widelands::Map& map = egbase().map(); | 180 | Widelands::Map* map = egbase().mutable_map(); |
401 | 181 | 181 | ||
402 | 182 | // Starting locations | 182 | // Starting locations |
404 | 183 | Widelands::PlayerNumber const nr_players = map.get_nrplayers(); | 183 | Widelands::PlayerNumber const nr_players = map->get_nrplayers(); |
405 | 184 | assert(nr_players <= kMaxPlayers); | 184 | assert(nr_players <= kMaxPlayers); |
406 | 185 | iterate_player_numbers(p, nr_players) { | 185 | iterate_player_numbers(p, nr_players) { |
409 | 186 | if (Widelands::Coords const sp = map.get_starting_pos(p)) { | 186 | if (Widelands::Coords const sp = map->get_starting_pos(p)) { |
410 | 187 | tools_->set_starting_pos.set_starting_pos(*this, p, sp, &map); | 187 | tools_->set_starting_pos.set_starting_pos(*this, p, sp, map); |
411 | 188 | } | 188 | } |
412 | 189 | } | 189 | } |
413 | 190 | 190 | ||
414 | 191 | // Resources: we do not calculate default resources, therefore we do not | 191 | // Resources: we do not calculate default resources, therefore we do not |
415 | 192 | // expect to meet them here. | 192 | // expect to meet them here. |
418 | 193 | Widelands::Extent const extent = map.extent(); | 193 | Widelands::Extent const extent = map->extent(); |
419 | 194 | iterate_Map_FCoords(map, extent, fc) { | 194 | iterate_Map_FCoords(*map, extent, fc) { |
420 | 195 | if (uint8_t const amount = fc.field->get_resources_amount()) { | 195 | if (uint8_t const amount = fc.field->get_resources_amount()) { |
421 | 196 | const std::string& immname = | 196 | const std::string& immname = |
422 | 197 | egbase().world().get_resource(fc.field->get_resources())->editor_image(amount); | 197 | egbase().world().get_resource(fc.field->get_resources())->editor_image(amount); |
423 | @@ -206,11 +206,11 @@ | |||
424 | 206 | void EditorInteractive::load(const std::string& filename) { | 206 | void EditorInteractive::load(const std::string& filename) { |
425 | 207 | assert(filename.size()); | 207 | assert(filename.size()); |
426 | 208 | 208 | ||
428 | 209 | Widelands::Map& map = egbase().map(); | 209 | Widelands::Map* map = egbase().mutable_map(); |
429 | 210 | 210 | ||
430 | 211 | cleanup_for_load(); | 211 | cleanup_for_load(); |
431 | 212 | 212 | ||
433 | 213 | std::unique_ptr<Widelands::MapLoader> ml(map.get_correct_loader(filename)); | 213 | std::unique_ptr<Widelands::MapLoader> ml(map->get_correct_loader(filename)); |
434 | 214 | if (!ml.get()) | 214 | if (!ml.get()) |
435 | 215 | throw WLWarning( | 215 | throw WLWarning( |
436 | 216 | _("Unsupported format"), | 216 | _("Unsupported format"), |
437 | @@ -228,8 +228,8 @@ | |||
438 | 228 | 228 | ||
439 | 229 | // Create the players. TODO(SirVer): this must be managed better | 229 | // Create the players. TODO(SirVer): this must be managed better |
440 | 230 | loader_ui.step(_("Creating players")); | 230 | loader_ui.step(_("Creating players")); |
443 | 231 | iterate_player_numbers(p, map.get_nrplayers()) { | 231 | iterate_player_numbers(p, map->get_nrplayers()) { |
444 | 232 | egbase().add_player(p, 0, map.get_scenario_player_tribe(p), map.get_scenario_player_name(p)); | 232 | egbase().add_player(p, 0, map->get_scenario_player_tribe(p), map->get_scenario_player_name(p)); |
445 | 233 | } | 233 | } |
446 | 234 | 234 | ||
447 | 235 | ml->load_map_complete(egbase(), Widelands::MapLoader::LoadType::kEditor); | 235 | ml->load_map_complete(egbase(), Widelands::MapLoader::LoadType::kEditor); |
448 | @@ -288,8 +288,8 @@ | |||
449 | 288 | } | 288 | } |
450 | 289 | 289 | ||
451 | 290 | void EditorInteractive::map_clicked(bool should_draw) { | 290 | void EditorInteractive::map_clicked(bool should_draw) { |
454 | 291 | history_->do_action(tools_->current(), tools_->use_tool, egbase().map(), egbase().world(), | 291 | history_->do_action(tools_->current(), tools_->use_tool, *egbase().mutable_map(), |
455 | 292 | get_sel_pos(), *this, should_draw); | 292 | egbase().world(), get_sel_pos(), *this, should_draw); |
456 | 293 | set_need_save(true); | 293 | set_need_save(true); |
457 | 294 | } | 294 | } |
458 | 295 | 295 | ||
459 | @@ -523,11 +523,10 @@ | |||
460 | 523 | toolsize_menu.update(toolsize_menu.value()); | 523 | toolsize_menu.update(toolsize_menu.value()); |
461 | 524 | } | 524 | } |
462 | 525 | } | 525 | } |
463 | 526 | Widelands::Map& map = egbase().map(); | ||
464 | 527 | // A new tool has been selected. Remove all registered overlay callback | 526 | // A new tool has been selected. Remove all registered overlay callback |
465 | 528 | // functions. | 527 | // functions. |
466 | 529 | mutable_field_overlay_manager()->register_overlay_callback_function(nullptr); | 528 | mutable_field_overlay_manager()->register_overlay_callback_function(nullptr); |
468 | 530 | map.recalc_whole_map(egbase().world()); | 529 | egbase().mutable_map()->recalc_whole_map(egbase().world()); |
469 | 531 | } | 530 | } |
470 | 532 | tools_->current_pointer = &primary; | 531 | tools_->current_pointer = &primary; |
471 | 533 | tools_->use_tool = which; | 532 | tools_->use_tool = which; |
472 | @@ -603,16 +602,15 @@ | |||
473 | 603 | GameTips editortips(loader_ui, tipstext); | 602 | GameTips editortips(loader_ui, tipstext); |
474 | 604 | 603 | ||
475 | 605 | { | 604 | { |
476 | 606 | Widelands::Map& map = *new Widelands::Map; | ||
477 | 607 | egbase.set_map(&map); | ||
478 | 608 | if (filename.empty()) { | 605 | if (filename.empty()) { |
479 | 609 | loader_ui.step(_("Creating empty map…")); | 606 | loader_ui.step(_("Creating empty map…")); |
486 | 610 | map.create_empty_map(egbase.world(), 64, 64, 0, | 607 | egbase.mutable_map()->create_empty_map( |
487 | 611 | /** TRANSLATORS: Default name for new map */ | 608 | egbase.world(), 64, 64, 0, |
488 | 612 | _("No Name"), | 609 | /** TRANSLATORS: Default name for new map */ |
489 | 613 | /** TRANSLATORS: Map author name when it hasn't been set yet */ | 610 | _("No Name"), |
490 | 614 | g_options.pull_section("global").get_string( | 611 | /** TRANSLATORS: Map author name when it hasn't been set yet */ |
491 | 615 | "realname", pgettext("author_name", "Unknown"))); | 612 | g_options.pull_section("global").get_string( |
492 | 613 | "realname", pgettext("author_name", "Unknown"))); | ||
493 | 616 | 614 | ||
494 | 617 | load_all_tribes(&egbase, &loader_ui); | 615 | load_all_tribes(&egbase, &loader_ui); |
495 | 618 | 616 | ||
496 | 619 | 617 | ||
497 | === modified file 'src/editor/ui_menus/main_menu_map_options.cc' | |||
498 | --- src/editor/ui_menus/main_menu_map_options.cc 2017-06-11 20:09:05 +0000 | |||
499 | +++ src/editor/ui_menus/main_menu_map_options.cc 2017-08-20 12:33:35 +0000 | |||
500 | @@ -193,16 +193,16 @@ | |||
501 | 193 | } | 193 | } |
502 | 194 | 194 | ||
503 | 195 | void MainMenuMapOptions::clicked_ok() { | 195 | void MainMenuMapOptions::clicked_ok() { |
506 | 196 | eia().egbase().map().set_name(name_.text()); | 196 | eia().egbase().mutable_map()->set_name(name_.text()); |
507 | 197 | eia().egbase().map().set_author(author_.text()); | 197 | eia().egbase().mutable_map()->set_author(author_.text()); |
508 | 198 | g_options.pull_section("global").set_string("realname", author_.text()); | 198 | g_options.pull_section("global").set_string("realname", author_.text()); |
511 | 199 | eia().egbase().map().set_description(descr_->get_text()); | 199 | eia().egbase().mutable_map()->set_description(descr_->get_text()); |
512 | 200 | eia().egbase().map().set_hint(hint_->get_text()); | 200 | eia().egbase().mutable_map()->set_hint(hint_->get_text()); |
513 | 201 | 201 | ||
515 | 202 | eia().egbase().map().clear_tags(); | 202 | eia().egbase().mutable_map()->clear_tags(); |
516 | 203 | for (const auto& tag : tags_checkboxes_) { | 203 | for (const auto& tag : tags_checkboxes_) { |
517 | 204 | if (tag.second->get_state()) { | 204 | if (tag.second->get_state()) { |
519 | 205 | eia().egbase().map().add_tag(tag.first); | 205 | eia().egbase().mutable_map()->add_tag(tag.first); |
520 | 206 | } | 206 | } |
521 | 207 | } | 207 | } |
522 | 208 | 208 | ||
523 | 209 | 209 | ||
524 | === modified file 'src/editor/ui_menus/main_menu_new_map.cc' | |||
525 | --- src/editor/ui_menus/main_menu_new_map.cc 2017-02-25 11:17:28 +0000 | |||
526 | +++ src/editor/ui_menus/main_menu_new_map.cc 2017-08-20 12:33:35 +0000 | |||
527 | @@ -138,14 +138,14 @@ | |||
528 | 138 | void MainMenuNewMap::clicked_create_map() { | 138 | void MainMenuNewMap::clicked_create_map() { |
529 | 139 | EditorInteractive& parent = eia(); | 139 | EditorInteractive& parent = eia(); |
530 | 140 | Widelands::EditorGameBase& egbase = parent.egbase(); | 140 | Widelands::EditorGameBase& egbase = parent.egbase(); |
532 | 141 | Widelands::Map& map = egbase.map(); | 141 | Widelands::Map* map = egbase.mutable_map(); |
533 | 142 | UI::ProgressWindow loader_ui; | 142 | UI::ProgressWindow loader_ui; |
534 | 143 | 143 | ||
535 | 144 | loader_ui.step(_("Creating empty map…")); | 144 | loader_ui.step(_("Creating empty map…")); |
536 | 145 | 145 | ||
537 | 146 | parent.cleanup_for_load(); | 146 | parent.cleanup_for_load(); |
538 | 147 | 147 | ||
540 | 148 | map.create_empty_map( | 148 | map->create_empty_map( |
541 | 149 | egbase.world(), width_.get_value() > 0 ? width_.get_value() : Widelands::kMapDimensions[0], | 149 | egbase.world(), width_.get_value() > 0 ? width_.get_value() : Widelands::kMapDimensions[0], |
542 | 150 | height_.get_value() > 0 ? height_.get_value() : Widelands::kMapDimensions[0], | 150 | height_.get_value() > 0 ? height_.get_value() : Widelands::kMapDimensions[0], |
543 | 151 | list_.get_selected(), _("No Name"), | 151 | list_.get_selected(), _("No Name"), |
544 | @@ -154,7 +154,7 @@ | |||
545 | 154 | egbase.postload(); | 154 | egbase.postload(); |
546 | 155 | egbase.load_graphics(loader_ui); | 155 | egbase.load_graphics(loader_ui); |
547 | 156 | 156 | ||
549 | 157 | map.recalc_whole_map(egbase.world()); | 157 | map->recalc_whole_map(egbase.world()); |
550 | 158 | parent.map_changed(EditorInteractive::MapWas::kReplaced); | 158 | parent.map_changed(EditorInteractive::MapWas::kReplaced); |
551 | 159 | die(); | 159 | die(); |
552 | 160 | } | 160 | } |
553 | 161 | 161 | ||
554 | === modified file 'src/editor/ui_menus/main_menu_random_map.cc' | |||
555 | --- src/editor/ui_menus/main_menu_random_map.cc 2017-06-20 08:18:38 +0000 | |||
556 | +++ src/editor/ui_menus/main_menu_random_map.cc 2017-08-20 12:33:35 +0000 | |||
557 | @@ -231,8 +231,7 @@ | |||
558 | 231 | width_.set_value_list(Widelands::kMapDimensions); | 231 | width_.set_value_list(Widelands::kMapDimensions); |
559 | 232 | height_.set_value_list(Widelands::kMapDimensions); | 232 | height_.set_value_list(Widelands::kMapDimensions); |
560 | 233 | { | 233 | { |
563 | 234 | const Widelands::Map& map = parent.egbase().map(); | 234 | Widelands::Extent const map_extent = parent.egbase().map().extent(); |
562 | 235 | Widelands::Extent const map_extent = map.extent(); | ||
564 | 236 | width_.set_value(find_dimension_index(map_extent.w)); | 235 | width_.set_value(find_dimension_index(map_extent.w)); |
565 | 237 | height_.set_value(find_dimension_index(map_extent.h)); | 236 | height_.set_value(find_dimension_index(map_extent.h)); |
566 | 238 | } | 237 | } |
567 | @@ -512,7 +511,7 @@ | |||
568 | 512 | cancel_button_.set_enabled(false); | 511 | cancel_button_.set_enabled(false); |
569 | 513 | EditorInteractive& eia = dynamic_cast<EditorInteractive&>(*get_parent()); | 512 | EditorInteractive& eia = dynamic_cast<EditorInteractive&>(*get_parent()); |
570 | 514 | Widelands::EditorGameBase& egbase = eia.egbase(); | 513 | Widelands::EditorGameBase& egbase = eia.egbase(); |
572 | 515 | Widelands::Map& map = egbase.map(); | 514 | Widelands::Map* map = egbase.mutable_map(); |
573 | 516 | UI::ProgressWindow loader_ui; | 515 | UI::ProgressWindow loader_ui; |
574 | 517 | 516 | ||
575 | 518 | eia.cleanup_for_load(); | 517 | eia.cleanup_for_load(); |
576 | @@ -528,12 +527,12 @@ | |||
577 | 528 | << "Resources = " << resources_.get_title() << "\n" | 527 | << "Resources = " << resources_.get_title() << "\n" |
578 | 529 | << "ID = " << map_id_edit_.text() << "\n"; | 528 | << "ID = " << map_id_edit_.text() << "\n"; |
579 | 530 | 529 | ||
586 | 531 | MapGenerator gen(map, map_info, egbase); | 530 | MapGenerator gen(*map, map_info, egbase); |
587 | 532 | map.create_empty_map( | 531 | map->create_empty_map( |
588 | 533 | egbase.world(), map_info.w, map_info.h, 0, _("No Name"), | 532 | egbase.world(), map_info.w, map_info.h, 0, _("No Name"), |
589 | 534 | g_options.pull_section("global").get_string("realname", pgettext("author_name", "Unknown")), | 533 | g_options.pull_section("global").get_string("realname", pgettext("author_name", "Unknown")), |
590 | 535 | sstrm.str().c_str()); | 534 | sstrm.str().c_str()); |
591 | 536 | loader_ui.step(_("Generating random map…")); | 535 | loader_ui.step(_("Generating random map…")); |
592 | 537 | 536 | ||
593 | 538 | log("============== Generating Map ==============\n"); | 537 | log("============== Generating Map ==============\n"); |
594 | 539 | log("ID: %s\n", map_id_edit_.text().c_str()); | 538 | log("ID: %s\n", map_id_edit_.text().c_str()); |
595 | @@ -564,7 +563,7 @@ | |||
596 | 564 | egbase.postload(); | 563 | egbase.postload(); |
597 | 565 | egbase.load_graphics(loader_ui); | 564 | egbase.load_graphics(loader_ui); |
598 | 566 | 565 | ||
600 | 567 | map.recalc_whole_map(egbase.world()); | 566 | map->recalc_whole_map(egbase.world()); |
601 | 568 | eia.map_changed(EditorInteractive::MapWas::kReplaced); | 567 | eia.map_changed(EditorInteractive::MapWas::kReplaced); |
602 | 569 | UI::WLMessageBox mbox( | 568 | UI::WLMessageBox mbox( |
603 | 570 | &eia, | 569 | &eia, |
604 | 571 | 570 | ||
605 | === modified file 'src/editor/ui_menus/main_menu_save_map.cc' | |||
606 | --- src/editor/ui_menus/main_menu_save_map.cc 2017-02-26 12:16:09 +0000 | |||
607 | +++ src/editor/ui_menus/main_menu_save_map.cc 2017-08-20 12:33:35 +0000 | |||
608 | @@ -129,10 +129,10 @@ | |||
609 | 129 | set_current_directory(complete_filename); | 129 | set_current_directory(complete_filename); |
610 | 130 | fill_table(); | 130 | fill_table(); |
611 | 131 | } else { // Ok, save this map | 131 | } else { // Ok, save this map |
614 | 132 | Widelands::Map& map = eia().egbase().map(); | 132 | Widelands::Map* map = eia().egbase().mutable_map(); |
615 | 133 | if (map.get_name() == _("No Name")) { | 133 | if (map->get_name() == _("No Name")) { |
616 | 134 | std::string::size_type const filename_size = filename.size(); | 134 | std::string::size_type const filename_size = filename.size(); |
618 | 135 | map.set_name(4 <= filename_size && boost::iends_with(filename, WLMF_SUFFIX) ? | 135 | map->set_name(4 <= filename_size && boost::iends_with(filename, WLMF_SUFFIX) ? |
619 | 136 | filename.substr(0, filename_size - 4) : | 136 | filename.substr(0, filename_size - 4) : |
620 | 137 | filename); | 137 | filename); |
621 | 138 | } | 138 | } |
622 | @@ -272,23 +272,23 @@ | |||
623 | 272 | } | 272 | } |
624 | 273 | 273 | ||
625 | 274 | Widelands::EditorGameBase& egbase = eia().egbase(); | 274 | Widelands::EditorGameBase& egbase = eia().egbase(); |
627 | 275 | Widelands::Map& map = egbase.map(); | 275 | Widelands::Map* map = egbase.mutable_map(); |
628 | 276 | 276 | ||
629 | 277 | { // fs scope | 277 | { // fs scope |
630 | 278 | std::unique_ptr<FileSystem> fs( | 278 | std::unique_ptr<FileSystem> fs( |
631 | 279 | g_fs->create_sub_file_system(tmp_name, binary ? FileSystem::ZIP : FileSystem::DIR)); | 279 | g_fs->create_sub_file_system(tmp_name, binary ? FileSystem::ZIP : FileSystem::DIR)); |
632 | 280 | 280 | ||
633 | 281 | // Recompute seafaring tag | 281 | // Recompute seafaring tag |
636 | 282 | if (map.allows_seafaring()) { | 282 | if (map->allows_seafaring()) { |
637 | 283 | map.add_tag("seafaring"); | 283 | map->add_tag("seafaring"); |
638 | 284 | } else { | 284 | } else { |
640 | 285 | map.delete_tag("seafaring"); | 285 | map->delete_tag("seafaring"); |
641 | 286 | } | 286 | } |
642 | 287 | 287 | ||
645 | 288 | if (map.has_artifacts()) { | 288 | if (map->has_artifacts()) { |
646 | 289 | map.add_tag("artifacts"); | 289 | map->add_tag("artifacts"); |
647 | 290 | } else { | 290 | } else { |
649 | 291 | map.delete_tag("artifacts"); | 291 | map->delete_tag("artifacts"); |
650 | 292 | } | 292 | } |
651 | 293 | 293 | ||
652 | 294 | try { | 294 | try { |
653 | @@ -297,14 +297,14 @@ | |||
654 | 297 | delete wms; | 297 | delete wms; |
655 | 298 | // Reset filesystem to avoid file locks on saves | 298 | // Reset filesystem to avoid file locks on saves |
656 | 299 | fs.reset(); | 299 | fs.reset(); |
658 | 300 | map.reset_filesystem(); | 300 | map->reset_filesystem(); |
659 | 301 | eia().set_need_save(false); | 301 | eia().set_need_save(false); |
660 | 302 | g_fs->fs_unlink(complete_filename); | 302 | g_fs->fs_unlink(complete_filename); |
661 | 303 | g_fs->fs_rename(tmp_name, complete_filename); | 303 | g_fs->fs_rename(tmp_name, complete_filename); |
662 | 304 | // Also change fs, as we assign it to the map below | 304 | // Also change fs, as we assign it to the map below |
663 | 305 | fs.reset(g_fs->make_sub_file_system(complete_filename)); | 305 | fs.reset(g_fs->make_sub_file_system(complete_filename)); |
664 | 306 | // Set the filesystem of the map to the current save file / directory | 306 | // Set the filesystem of the map to the current save file / directory |
666 | 307 | map.swap_filesystem(fs); | 307 | map->swap_filesystem(fs); |
667 | 308 | // DONT use fs as of here, its garbage now! | 308 | // DONT use fs as of here, its garbage now! |
668 | 309 | 309 | ||
669 | 310 | } catch (const std::exception& e) { | 310 | } catch (const std::exception& e) { |
670 | 311 | 311 | ||
671 | === modified file 'src/editor/ui_menus/player_menu.cc' | |||
672 | --- src/editor/ui_menus/player_menu.cc 2017-08-18 02:28:27 +0000 | |||
673 | +++ src/editor/ui_menus/player_menu.cc 2017-08-20 12:33:35 +0000 | |||
674 | @@ -110,8 +110,8 @@ | |||
675 | 110 | if (is_minimal()) | 110 | if (is_minimal()) |
676 | 111 | return; | 111 | return; |
677 | 112 | 112 | ||
680 | 113 | Widelands::Map& map = eia().egbase().map(); | 113 | Widelands::Map* map = eia().egbase().mutable_map(); |
681 | 114 | Widelands::PlayerNumber const nr_players = map.get_nrplayers(); | 114 | Widelands::PlayerNumber const nr_players = map->get_nrplayers(); |
682 | 115 | { | 115 | { |
683 | 116 | assert(nr_players <= 99); // 2 decimal digits | 116 | assert(nr_players <= 99); // 2 decimal digits |
684 | 117 | char text[3]; | 117 | char text[3]; |
685 | @@ -147,7 +147,7 @@ | |||
686 | 147 | plr_names_[p - 1]->changed.connect( | 147 | plr_names_[p - 1]->changed.connect( |
687 | 148 | boost::bind(&EditorPlayerMenu::name_changed, this, p - 1)); | 148 | boost::bind(&EditorPlayerMenu::name_changed, this, p - 1)); |
688 | 149 | posx += 140 + spacing; | 149 | posx += 140 + spacing; |
690 | 150 | plr_names_[p - 1]->set_text(map.get_scenario_player_name(p)); | 150 | plr_names_[p - 1]->set_text(map->get_scenario_player_name(p)); |
691 | 151 | } | 151 | } |
692 | 152 | 152 | ||
693 | 153 | if (!plr_set_tribes_buts_[p - 1]) { | 153 | if (!plr_set_tribes_buts_[p - 1]) { |
694 | @@ -160,19 +160,19 @@ | |||
695 | 160 | } | 160 | } |
696 | 161 | 161 | ||
697 | 162 | // Get/Set (localized) tribe names | 162 | // Get/Set (localized) tribe names |
700 | 163 | if (map.get_scenario_player_tribe(p) != UNDEFINED_TRIBE_NAME) { | 163 | if (map->get_scenario_player_tribe(p) != UNDEFINED_TRIBE_NAME) { |
701 | 164 | selected_tribes_[p - 1] = map.get_scenario_player_tribe(p); | 164 | selected_tribes_[p - 1] = map->get_scenario_player_tribe(p); |
702 | 165 | } else { | 165 | } else { |
703 | 166 | selected_tribes_[p - 1] = tribenames_[0]; | 166 | selected_tribes_[p - 1] = tribenames_[0]; |
705 | 167 | map.set_scenario_player_tribe(p, selected_tribes_[p - 1]); | 167 | map->set_scenario_player_tribe(p, selected_tribes_[p - 1]); |
706 | 168 | } | 168 | } |
707 | 169 | 169 | ||
708 | 170 | plr_set_tribes_buts_[p - 1]->set_title( | 170 | plr_set_tribes_buts_[p - 1]->set_title( |
709 | 171 | Widelands::get_tribeinfo(selected_tribes_[p - 1]).descname); | 171 | Widelands::get_tribeinfo(selected_tribes_[p - 1]).descname); |
710 | 172 | 172 | ||
711 | 173 | // Set default AI and closeable to false (always default - should be changed by hand) | 173 | // Set default AI and closeable to false (always default - should be changed by hand) |
714 | 174 | map.set_scenario_player_ai(p, ""); | 174 | map->set_scenario_player_ai(p, ""); |
715 | 175 | map.set_scenario_player_closeable(p, false); | 175 | map->set_scenario_player_closeable(p, false); |
716 | 176 | 176 | ||
717 | 177 | // Set Starting pos button. | 177 | // Set Starting pos button. |
718 | 178 | if (!plr_set_pos_buts_[p - 1]) { | 178 | if (!plr_set_pos_buts_[p - 1]) { |
719 | @@ -195,18 +195,18 @@ | |||
720 | 195 | } | 195 | } |
721 | 196 | 196 | ||
722 | 197 | void EditorPlayerMenu::clicked_add_player() { | 197 | void EditorPlayerMenu::clicked_add_player() { |
725 | 198 | Widelands::Map& map = eia().egbase().map(); | 198 | Widelands::Map* map = eia().egbase().mutable_map(); |
726 | 199 | Widelands::PlayerNumber const nr_players = map.get_nrplayers() + 1; | 199 | Widelands::PlayerNumber const nr_players = map->get_nrplayers() + 1; |
727 | 200 | assert(nr_players <= kMaxPlayers); | 200 | assert(nr_players <= kMaxPlayers); |
729 | 201 | map.set_nrplayers(nr_players); | 201 | map->set_nrplayers(nr_players); |
730 | 202 | { // register new default name for this players | 202 | { // register new default name for this players |
731 | 203 | assert(nr_players <= 99); // 2 decimal digits | 203 | assert(nr_players <= 99); // 2 decimal digits |
732 | 204 | /** TRANSLATORS: Default player name, e.g. Player 1 */ | 204 | /** TRANSLATORS: Default player name, e.g. Player 1 */ |
733 | 205 | const std::string name = | 205 | const std::string name = |
734 | 206 | (boost::format(_("Player %u")) % static_cast<unsigned int>(nr_players)).str(); | 206 | (boost::format(_("Player %u")) % static_cast<unsigned int>(nr_players)).str(); |
736 | 207 | map.set_scenario_player_name(nr_players, name); | 207 | map->set_scenario_player_name(nr_players, name); |
737 | 208 | } | 208 | } |
739 | 209 | map.set_scenario_player_tribe(nr_players, tribenames_[0]); | 209 | map->set_scenario_player_tribe(nr_players, tribenames_[0]); |
740 | 210 | eia().set_need_save(true); | 210 | eia().set_need_save(true); |
741 | 211 | add_player_.set_enabled(nr_players < kMaxPlayers); | 211 | add_player_.set_enabled(nr_players < kMaxPlayers); |
742 | 212 | remove_last_player_.set_enabled(true); | 212 | remove_last_player_.set_enabled(true); |
743 | @@ -215,13 +215,13 @@ | |||
744 | 215 | 215 | ||
745 | 216 | void EditorPlayerMenu::clicked_remove_last_player() { | 216 | void EditorPlayerMenu::clicked_remove_last_player() { |
746 | 217 | EditorInteractive& menu = eia(); | 217 | EditorInteractive& menu = eia(); |
749 | 218 | Widelands::Map& map = menu.egbase().map(); | 218 | Widelands::Map* map = menu.egbase().mutable_map(); |
750 | 219 | Widelands::PlayerNumber const old_nr_players = map.get_nrplayers(); | 219 | Widelands::PlayerNumber const old_nr_players = map->get_nrplayers(); |
751 | 220 | Widelands::PlayerNumber const nr_players = old_nr_players - 1; | 220 | Widelands::PlayerNumber const nr_players = old_nr_players - 1; |
752 | 221 | assert(1 <= nr_players); | 221 | assert(1 <= nr_players); |
753 | 222 | 222 | ||
754 | 223 | if (!menu.is_player_tribe_referenced(old_nr_players)) { | 223 | if (!menu.is_player_tribe_referenced(old_nr_players)) { |
756 | 224 | if (const Widelands::Coords sp = map.get_starting_pos(old_nr_players)) { | 224 | if (const Widelands::Coords sp = map->get_starting_pos(old_nr_players)) { |
757 | 225 | // Remove starting position marker. | 225 | // Remove starting position marker. |
758 | 226 | const Image* player_image = | 226 | const Image* player_image = |
759 | 227 | playercolor_image(old_nr_players - 1, "images/players/player_position.png"); | 227 | playercolor_image(old_nr_players - 1, "images/players/player_position.png"); |
760 | @@ -232,7 +232,7 @@ | |||
761 | 232 | if (old_nr_players == menu.tools()->set_starting_pos.get_current_player()) | 232 | if (old_nr_players == menu.tools()->set_starting_pos.get_current_player()) |
762 | 233 | set_starting_pos_clicked(nr_players); | 233 | set_starting_pos_clicked(nr_players); |
763 | 234 | } | 234 | } |
765 | 235 | map.set_nrplayers(nr_players); | 235 | map->set_nrplayers(nr_players); |
766 | 236 | add_player_.set_enabled(nr_players < kMaxPlayers); | 236 | add_player_.set_enabled(nr_players < kMaxPlayers); |
767 | 237 | remove_last_player_.set_enabled(1 < nr_players); | 237 | remove_last_player_.set_enabled(1 < nr_players); |
768 | 238 | update(); | 238 | update(); |
769 | @@ -257,7 +257,7 @@ | |||
770 | 257 | } | 257 | } |
771 | 258 | } | 258 | } |
772 | 259 | selected_tribes_[n] = i == tribenames_.size() - 1 ? tribenames_[0] : tribenames_[++i]; | 259 | selected_tribes_[n] = i == tribenames_.size() - 1 ? tribenames_[0] : tribenames_[++i]; |
774 | 260 | menu.egbase().map().set_scenario_player_tribe(n + 1, selected_tribes_[n]); | 260 | menu.egbase().mutable_map()->set_scenario_player_tribe(n + 1, selected_tribes_[n]); |
775 | 261 | menu.set_need_save(true); | 261 | menu.set_need_save(true); |
776 | 262 | } else { | 262 | } else { |
777 | 263 | UI::WLMessageBox mmb(&menu, _("Error!"), | 263 | UI::WLMessageBox mmb(&menu, _("Error!"), |
778 | @@ -275,8 +275,8 @@ | |||
779 | 275 | void EditorPlayerMenu::set_starting_pos_clicked(uint8_t n) { | 275 | void EditorPlayerMenu::set_starting_pos_clicked(uint8_t n) { |
780 | 276 | EditorInteractive& menu = eia(); | 276 | EditorInteractive& menu = eia(); |
781 | 277 | // jump to the current node | 277 | // jump to the current node |
784 | 278 | Widelands::Map& map = menu.egbase().map(); | 278 | Widelands::Map* map = menu.egbase().mutable_map(); |
785 | 279 | if (Widelands::Coords const sp = map.get_starting_pos(n)) { | 279 | if (Widelands::Coords const sp = map->get_starting_pos(n)) { |
786 | 280 | menu.map_view()->scroll_to_field(sp, MapView::Transition::Smooth); | 280 | menu.map_view()->scroll_to_field(sp, MapView::Transition::Smooth); |
787 | 281 | } | 281 | } |
788 | 282 | 282 | ||
789 | @@ -290,8 +290,8 @@ | |||
790 | 290 | // Register callback function to make sure that only valid locations are | 290 | // Register callback function to make sure that only valid locations are |
791 | 291 | // selected. | 291 | // selected. |
792 | 292 | menu.mutable_field_overlay_manager()->register_overlay_callback_function( | 292 | menu.mutable_field_overlay_manager()->register_overlay_callback_function( |
795 | 293 | boost::bind(&editor_tool_set_starting_pos_callback, _1, boost::ref(map))); | 293 | boost::bind(&editor_tool_set_starting_pos_callback, _1, boost::ref(*map))); |
796 | 294 | map.recalc_whole_map(menu.egbase().world()); | 294 | map->recalc_whole_map(menu.egbase().world()); |
797 | 295 | update(); | 295 | update(); |
798 | 296 | } | 296 | } |
799 | 297 | 297 | ||
800 | @@ -302,8 +302,8 @@ | |||
801 | 302 | // Player name has been changed. | 302 | // Player name has been changed. |
802 | 303 | std::string text = plr_names_[m]->text(); | 303 | std::string text = plr_names_[m]->text(); |
803 | 304 | EditorInteractive& menu = eia(); | 304 | EditorInteractive& menu = eia(); |
807 | 305 | Widelands::Map& map = menu.egbase().map(); | 305 | Widelands::Map* map = menu.egbase().mutable_map(); |
808 | 306 | map.set_scenario_player_name(m + 1, text); | 306 | map->set_scenario_player_name(m + 1, text); |
809 | 307 | plr_names_[m]->set_text(map.get_scenario_player_name(m + 1)); | 307 | plr_names_[m]->set_text(map->get_scenario_player_name(m + 1)); |
810 | 308 | menu.set_need_save(true); | 308 | menu.set_need_save(true); |
811 | 309 | } | 309 | } |
812 | 310 | 310 | ||
813 | === modified file 'src/editor/ui_menus/tool_change_resources_options_menu.cc' | |||
814 | --- src/editor/ui_menus/tool_change_resources_options_menu.cc 2017-08-13 18:02:53 +0000 | |||
815 | +++ src/editor/ui_menus/tool_change_resources_options_menu.cc 2017-08-20 12:33:35 +0000 | |||
816 | @@ -154,16 +154,16 @@ | |||
817 | 154 | increase_tool_.decrease_tool().set_cur_res(resource_index); | 154 | increase_tool_.decrease_tool().set_cur_res(resource_index); |
818 | 155 | 155 | ||
819 | 156 | Widelands::EditorGameBase& egbase = eia().egbase(); | 156 | Widelands::EditorGameBase& egbase = eia().egbase(); |
821 | 157 | Widelands::Map& map = egbase.map(); | 157 | Widelands::Map* map = egbase.mutable_map(); |
822 | 158 | eia().mutable_field_overlay_manager()->register_overlay_callback_function( | 158 | eia().mutable_field_overlay_manager()->register_overlay_callback_function( |
825 | 159 | [resource_index, &map, &egbase](const Widelands::FCoords& fc) -> uint32_t { | 159 | [resource_index, map, &egbase](const Widelands::FCoords& fc) -> uint32_t { |
826 | 160 | if (map.is_resource_valid(egbase.world(), fc, resource_index)) { | 160 | if (map->is_resource_valid(egbase.world(), fc, resource_index)) { |
827 | 161 | return fc.field->nodecaps(); | 161 | return fc.field->nodecaps(); |
828 | 162 | } | 162 | } |
829 | 163 | return 0; | 163 | return 0; |
830 | 164 | }); | 164 | }); |
831 | 165 | 165 | ||
833 | 166 | map.recalc_whole_map(egbase.world()); | 166 | map->recalc_whole_map(egbase.world()); |
834 | 167 | select_correct_tool(); | 167 | select_correct_tool(); |
835 | 168 | update(); | 168 | update(); |
836 | 169 | } | 169 | } |
837 | 170 | 170 | ||
838 | === modified file 'src/editor/ui_menus/tool_menu.cc' | |||
839 | --- src/editor/ui_menus/tool_menu.cc 2017-08-13 18:02:53 +0000 | |||
840 | +++ src/editor/ui_menus/tool_menu.cc 2017-08-20 12:33:35 +0000 | |||
841 | @@ -142,10 +142,10 @@ | |||
842 | 142 | parent.select_tool(*current_tool_pointer, EditorTool::First); | 142 | parent.select_tool(*current_tool_pointer, EditorTool::First); |
843 | 143 | if (current_tool_pointer == &parent.tools()->set_port_space) { | 143 | if (current_tool_pointer == &parent.tools()->set_port_space) { |
844 | 144 | // Set correct overlay | 144 | // Set correct overlay |
846 | 145 | Widelands::Map& map = parent.egbase().map(); | 145 | Widelands::Map* map = parent.egbase().mutable_map(); |
847 | 146 | parent.mutable_field_overlay_manager()->register_overlay_callback_function( | 146 | parent.mutable_field_overlay_manager()->register_overlay_callback_function( |
850 | 147 | boost::bind(&editor_tool_set_port_space_callback, _1, boost::ref(map))); | 147 | boost::bind(&editor_tool_set_port_space_callback, _1, boost::ref(*map))); |
851 | 148 | map.recalc_whole_map(parent.egbase().world()); | 148 | map->recalc_whole_map(parent.egbase().world()); |
852 | 149 | } | 149 | } |
853 | 150 | 150 | ||
854 | 151 | if (current_registry_pointer) { | 151 | if (current_registry_pointer) { |
855 | 152 | 152 | ||
856 | === modified file 'src/game_io/game_map_packet.cc' | |||
857 | --- src/game_io/game_map_packet.cc 2017-01-25 18:55:59 +0000 | |||
858 | +++ src/game_io/game_map_packet.cc 2017-08-20 12:33:35 +0000 | |||
859 | @@ -41,7 +41,7 @@ | |||
860 | 41 | // Now Load the map as it would be a normal map saving. | 41 | // Now Load the map as it would be a normal map saving. |
861 | 42 | delete wml_; | 42 | delete wml_; |
862 | 43 | 43 | ||
864 | 44 | wml_ = new WidelandsMapLoader(fs.make_sub_file_system("map"), &game.map()); | 44 | wml_ = new WidelandsMapLoader(fs.make_sub_file_system("map"), game.mutable_map()); |
865 | 45 | 45 | ||
866 | 46 | wml_->preload_map(true); | 46 | wml_->preload_map(true); |
867 | 47 | 47 | ||
868 | 48 | 48 | ||
869 | === modified file 'src/game_io/game_player_ai_persistent_packet.cc' | |||
870 | --- src/game_io/game_player_ai_persistent_packet.cc 2017-06-28 08:50:42 +0000 | |||
871 | +++ src/game_io/game_player_ai_persistent_packet.cc 2017-08-20 12:33:35 +0000 | |||
872 | @@ -32,8 +32,7 @@ | |||
873 | 32 | 32 | ||
874 | 33 | void GamePlayerAiPersistentPacket::read(FileSystem& fs, Game& game, MapObjectLoader*) { | 33 | void GamePlayerAiPersistentPacket::read(FileSystem& fs, Game& game, MapObjectLoader*) { |
875 | 34 | try { | 34 | try { |
878 | 35 | const Map& map = game.map(); | 35 | PlayerNumber const nr_players = game.map().get_nrplayers(); |
877 | 36 | PlayerNumber const nr_players = map.get_nrplayers(); | ||
879 | 37 | 36 | ||
880 | 38 | FileRead fr; | 37 | FileRead fr; |
881 | 39 | fr.open(fs, "binary/player_ai"); | 38 | fr.open(fs, "binary/player_ai"); |
882 | @@ -125,8 +124,7 @@ | |||
883 | 125 | 124 | ||
884 | 126 | fw.unsigned_16(kCurrentPacketVersion); | 125 | fw.unsigned_16(kCurrentPacketVersion); |
885 | 127 | 126 | ||
888 | 128 | const Map& map = game.map(); | 127 | PlayerNumber const nr_players = game.map().get_nrplayers(); |
887 | 129 | PlayerNumber const nr_players = map.get_nrplayers(); | ||
889 | 130 | iterate_players_existing_const(p, nr_players, game, player) { | 128 | iterate_players_existing_const(p, nr_players, game, player) { |
890 | 131 | fw.unsigned_8(player->ai_data.initialized); | 129 | fw.unsigned_8(player->ai_data.initialized); |
891 | 132 | fw.unsigned_32(player->ai_data.colony_scan_area); | 130 | fw.unsigned_32(player->ai_data.colony_scan_area); |
892 | 133 | 131 | ||
893 | === modified file 'src/graphic/game_renderer.cc' | |||
894 | --- src/graphic/game_renderer.cc 2017-08-16 08:59:09 +0000 | |||
895 | +++ src/graphic/game_renderer.cc 2017-08-20 12:33:35 +0000 | |||
896 | @@ -340,7 +340,7 @@ | |||
897 | 340 | const int surface_width = surface->width(); | 340 | const int surface_width = surface->width(); |
898 | 341 | const int surface_height = surface->height(); | 341 | const int surface_height = surface->height(); |
899 | 342 | 342 | ||
901 | 343 | Map& map = egbase.map(); | 343 | const Map& map = egbase.map(); |
902 | 344 | const uint32_t gametime = egbase.get_gametime(); | 344 | const uint32_t gametime = egbase.get_gametime(); |
903 | 345 | 345 | ||
904 | 346 | const float scale = 1.f / zoom; | 346 | const float scale = 1.f / zoom; |
905 | 347 | 347 | ||
906 | === modified file 'src/graphic/minimap_renderer.cc' | |||
907 | --- src/graphic/minimap_renderer.cc 2017-08-09 19:25:04 +0000 | |||
908 | +++ src/graphic/minimap_renderer.cc 2017-08-20 12:33:35 +0000 | |||
909 | @@ -158,7 +158,7 @@ | |||
910 | 158 | const Widelands::Map& map = egbase.map(); | 158 | const Widelands::Map& map = egbase.map(); |
911 | 159 | const uint16_t surface_h = texture->height(); | 159 | const uint16_t surface_h = texture->height(); |
912 | 160 | const uint16_t surface_w = texture->width(); | 160 | const uint16_t surface_w = texture->width(); |
914 | 161 | const int32_t mapwidth = egbase.get_map().get_width(); | 161 | const int32_t mapwidth = map.get_width(); |
915 | 162 | 162 | ||
916 | 163 | for (uint32_t y = 0; y < surface_h; ++y) { | 163 | for (uint32_t y = 0; y < surface_h; ++y) { |
917 | 164 | Widelands::FCoords f( | 164 | Widelands::FCoords f( |
918 | 165 | 165 | ||
919 | === modified file 'src/logic/editor_game_base.cc' | |||
920 | --- src/logic/editor_game_base.cc 2017-06-25 08:20:25 +0000 | |||
921 | +++ src/logic/editor_game_base.cc 2017-08-20 12:33:35 +0000 | |||
922 | @@ -67,14 +67,12 @@ | |||
923 | 67 | : gametime_(0), | 67 | : gametime_(0), |
924 | 68 | lua_(lua_interface), | 68 | lua_(lua_interface), |
925 | 69 | player_manager_(new PlayersManager(*this)), | 69 | player_manager_(new PlayersManager(*this)), |
928 | 70 | ibase_(nullptr), | 70 | ibase_(nullptr) { |
927 | 71 | map_(nullptr) { | ||
929 | 72 | if (!lua_) // TODO(SirVer): this is sooo ugly, I can't say | 71 | if (!lua_) // TODO(SirVer): this is sooo ugly, I can't say |
930 | 73 | lua_.reset(new LuaEditorInterface(this)); | 72 | lua_.reset(new LuaEditorInterface(this)); |
931 | 74 | } | 73 | } |
932 | 75 | 74 | ||
933 | 76 | EditorGameBase::~EditorGameBase() { | 75 | EditorGameBase::~EditorGameBase() { |
934 | 77 | delete map_; | ||
935 | 78 | delete player_manager_.release(); | 76 | delete player_manager_.release(); |
936 | 79 | } | 77 | } |
937 | 80 | 78 | ||
938 | @@ -187,19 +185,6 @@ | |||
939 | 187 | } | 185 | } |
940 | 188 | } | 186 | } |
941 | 189 | 187 | ||
942 | 190 | /** | ||
943 | 191 | * Replaces the current map with the given one. Ownership of the map is transferred | ||
944 | 192 | * to the EditorGameBase object. | ||
945 | 193 | */ | ||
946 | 194 | void EditorGameBase::set_map(Map* const new_map) { | ||
947 | 195 | assert(new_map != map_); | ||
948 | 196 | assert(new_map); | ||
949 | 197 | |||
950 | 198 | delete map_; | ||
951 | 199 | |||
952 | 200 | map_ = new_map; | ||
953 | 201 | } | ||
954 | 202 | |||
955 | 203 | void EditorGameBase::allocate_player_maps() { | 188 | void EditorGameBase::allocate_player_maps() { |
956 | 204 | iterate_players_existing(plnum, kMaxPlayers, *this, p) { | 189 | iterate_players_existing(plnum, kMaxPlayers, *this, p) { |
957 | 205 | p->allocate_map(); | 190 | p->allocate_map(); |
958 | @@ -412,8 +397,7 @@ | |||
959 | 412 | 397 | ||
960 | 413 | player_manager_->cleanup(); | 398 | player_manager_->cleanup(); |
961 | 414 | 399 | ||
964 | 415 | if (map_) | 400 | map_.cleanup(); |
963 | 416 | map_->cleanup(); | ||
965 | 417 | } | 401 | } |
966 | 418 | 402 | ||
967 | 419 | void EditorGameBase::set_road(const FCoords& f, uint8_t const direction, uint8_t const roadtype) { | 403 | void EditorGameBase::set_road(const FCoords& f, uint8_t const direction, uint8_t const roadtype) { |
968 | @@ -566,7 +550,7 @@ | |||
969 | 566 | // This must reach one step beyond the conquered area to adjust the borders | 550 | // This must reach one step beyond the conquered area to adjust the borders |
970 | 567 | // of neighbour players. | 551 | // of neighbour players. |
971 | 568 | ++player_area.radius; | 552 | ++player_area.radius; |
973 | 569 | map().recalc_for_field_area(world(), player_area); | 553 | map_.recalc_for_field_area(world(), player_area); |
974 | 570 | } | 554 | } |
975 | 571 | 555 | ||
976 | 572 | /// Conquers the given area for that player; does the actual work. | 556 | /// Conquers the given area for that player; does the actual work. |
977 | @@ -642,21 +626,20 @@ | |||
978 | 642 | // This must reach one step beyond the conquered area to adjust the borders | 626 | // This must reach one step beyond the conquered area to adjust the borders |
979 | 643 | // of neighbour players. | 627 | // of neighbour players. |
980 | 644 | ++player_area.radius; | 628 | ++player_area.radius; |
982 | 645 | map().recalc_for_field_area(world(), player_area); | 629 | map_.recalc_for_field_area(world(), player_area); |
983 | 646 | } | 630 | } |
984 | 647 | 631 | ||
985 | 648 | /// Makes sure that buildings cannot exist outside their owner's territory. | 632 | /// Makes sure that buildings cannot exist outside their owner's territory. |
986 | 649 | void EditorGameBase::cleanup_playerimmovables_area(PlayerArea<Area<FCoords>> const area) { | 633 | void EditorGameBase::cleanup_playerimmovables_area(PlayerArea<Area<FCoords>> const area) { |
987 | 650 | std::vector<ImmovableFound> immovables; | 634 | std::vector<ImmovableFound> immovables; |
988 | 651 | std::vector<PlayerImmovable*> burnlist; | 635 | std::vector<PlayerImmovable*> burnlist; |
989 | 652 | Map& m = map(); | ||
990 | 653 | 636 | ||
991 | 654 | // find all immovables that need fixing | 637 | // find all immovables that need fixing |
993 | 655 | m.find_immovables(area, &immovables, FindImmovablePlayerImmovable()); | 638 | map_.find_immovables(area, &immovables, FindImmovablePlayerImmovable()); |
994 | 656 | 639 | ||
995 | 657 | for (const ImmovableFound& temp_imm : immovables) { | 640 | for (const ImmovableFound& temp_imm : immovables) { |
996 | 658 | upcast(PlayerImmovable, imm, temp_imm.object); | 641 | upcast(PlayerImmovable, imm, temp_imm.object); |
998 | 659 | if (!m[temp_imm.coords].is_interior(imm->owner().player_number())) { | 642 | if (!map_[temp_imm.coords].is_interior(imm->owner().player_number())) { |
999 | 660 | if (std::find(burnlist.begin(), burnlist.end(), imm) == burnlist.end()) { | 643 | if (std::find(burnlist.begin(), burnlist.end(), imm) == burnlist.end()) { |
1000 | 661 | burnlist.push_back(imm); | 644 | burnlist.push_back(imm); |
1001 | 662 | } | 645 | } |
1002 | 663 | 646 | ||
1003 | === modified file 'src/logic/editor_game_base.h' | |||
1004 | --- src/logic/editor_game_base.h 2017-06-25 19:12:30 +0000 | |||
1005 | +++ src/logic/editor_game_base.h 2017-08-20 12:33:35 +0000 | |||
1006 | @@ -84,16 +84,11 @@ | |||
1007 | 84 | explicit EditorGameBase(LuaInterface* lua); | 84 | explicit EditorGameBase(LuaInterface* lua); |
1008 | 85 | virtual ~EditorGameBase(); | 85 | virtual ~EditorGameBase(); |
1009 | 86 | 86 | ||
1016 | 87 | void set_map(Map*); | 87 | const Map& map() const { |
1011 | 88 | // TODO(sirver): this should just be const Map& map() and Map* mutable_map(). | ||
1012 | 89 | Map& map() const { | ||
1013 | 90 | return *map_; | ||
1014 | 91 | } | ||
1015 | 92 | Map* get_map() { | ||
1017 | 93 | return map_; | 88 | return map_; |
1018 | 94 | } | 89 | } |
1021 | 95 | Map& get_map() const { | 90 | Map* mutable_map() { |
1022 | 96 | return *map_; | 91 | return &map_; |
1023 | 97 | } | 92 | } |
1024 | 98 | const ObjectManager& objects() const { | 93 | const ObjectManager& objects() const { |
1025 | 99 | return objects_; | 94 | return objects_; |
1026 | @@ -258,7 +253,7 @@ | |||
1027 | 258 | std::unique_ptr<World> world_; | 253 | std::unique_ptr<World> world_; |
1028 | 259 | std::unique_ptr<Tribes> tribes_; | 254 | std::unique_ptr<Tribes> tribes_; |
1029 | 260 | std::unique_ptr<InteractiveBase> ibase_; | 255 | std::unique_ptr<InteractiveBase> ibase_; |
1031 | 261 | Map* map_; | 256 | Map map_; |
1032 | 262 | 257 | ||
1033 | 263 | DISALLOW_COPY_AND_ASSIGN(EditorGameBase); | 258 | DISALLOW_COPY_AND_ASSIGN(EditorGameBase); |
1034 | 264 | }; | 259 | }; |
1035 | 265 | 260 | ||
1036 | === modified file 'src/logic/game.cc' | |||
1037 | --- src/logic/game.cc 2017-08-18 02:28:27 +0000 | |||
1038 | +++ src/logic/game.cc 2017-08-20 12:33:35 +0000 | |||
1039 | @@ -192,14 +192,10 @@ | |||
1040 | 192 | 192 | ||
1041 | 193 | bool Game::run_splayer_scenario_direct(const std::string& mapname, | 193 | bool Game::run_splayer_scenario_direct(const std::string& mapname, |
1042 | 194 | const std::string& script_to_run) { | 194 | const std::string& script_to_run) { |
1043 | 195 | assert(!get_map()); | ||
1044 | 196 | |||
1045 | 197 | // Replays can't handle scenarios | 195 | // Replays can't handle scenarios |
1046 | 198 | set_write_replay(false); | 196 | set_write_replay(false); |
1047 | 199 | 197 | ||
1051 | 200 | set_map(new Map); | 198 | std::unique_ptr<MapLoader> maploader(mutable_map()->get_correct_loader(mapname)); |
1049 | 201 | |||
1050 | 202 | std::unique_ptr<MapLoader> maploader(map().get_correct_loader(mapname)); | ||
1052 | 203 | if (!maploader) | 199 | if (!maploader) |
1053 | 204 | throw wexception("could not load \"%s\"", mapname.c_str()); | 200 | throw wexception("could not load \"%s\"", mapname.c_str()); |
1054 | 205 | UI::ProgressWindow loader_ui; | 201 | UI::ProgressWindow loader_ui; |
1055 | @@ -252,10 +248,7 @@ | |||
1056 | 252 | 248 | ||
1057 | 253 | loader_ui->step(_("Preloading map")); | 249 | loader_ui->step(_("Preloading map")); |
1058 | 254 | 250 | ||
1063 | 255 | assert(!get_map()); | 251 | std::unique_ptr<MapLoader> maploader(mutable_map()->get_correct_loader(settings.mapfilename)); |
1060 | 256 | set_map(new Map); | ||
1061 | 257 | |||
1062 | 258 | std::unique_ptr<MapLoader> maploader(map().get_correct_loader(settings.mapfilename)); | ||
1064 | 259 | assert(maploader != nullptr); | 252 | assert(maploader != nullptr); |
1065 | 260 | maploader->preload_map(settings.scenario); | 253 | maploader->preload_map(settings.scenario); |
1066 | 261 | 254 | ||
1067 | @@ -325,8 +318,6 @@ | |||
1068 | 325 | 318 | ||
1069 | 326 | loader_ui->step(_("Preloading map")); | 319 | loader_ui->step(_("Preloading map")); |
1070 | 327 | 320 | ||
1071 | 328 | assert(!get_map()); | ||
1072 | 329 | set_map(new Map); | ||
1073 | 330 | try { | 321 | try { |
1074 | 331 | GameLoader gl(settings.mapfilename, *this); | 322 | GameLoader gl(settings.mapfilename, *this); |
1075 | 332 | Widelands::GamePreloadPacket gpdp; | 323 | Widelands::GamePreloadPacket gpdp; |
1076 | @@ -355,9 +346,6 @@ | |||
1077 | 355 | 346 | ||
1078 | 356 | loader_ui.step(_("Preloading map")); | 347 | loader_ui.step(_("Preloading map")); |
1079 | 357 | 348 | ||
1080 | 358 | // We have to create an empty map, otherwise nothing will load properly | ||
1081 | 359 | set_map(new Map); | ||
1082 | 360 | |||
1083 | 361 | { | 349 | { |
1084 | 362 | GameLoader gl(filename, *this); | 350 | GameLoader gl(filename, *this); |
1085 | 363 | 351 | ||
1086 | @@ -462,7 +450,7 @@ | |||
1087 | 462 | } | 450 | } |
1088 | 463 | 451 | ||
1089 | 464 | // Prepare the map, set default textures | 452 | // Prepare the map, set default textures |
1091 | 465 | map().recalc_default_resources(world()); | 453 | mutable_map()->recalc_default_resources(world()); |
1092 | 466 | 454 | ||
1093 | 467 | // Finally, set the scenario names and tribes to represent | 455 | // Finally, set the scenario names and tribes to represent |
1094 | 468 | // the correct names of the players | 456 | // the correct names of the players |
1095 | @@ -472,10 +460,10 @@ | |||
1096 | 472 | const std::string& player_tribe = plr ? plr->tribe().name() : no_name; | 460 | const std::string& player_tribe = plr ? plr->tribe().name() : no_name; |
1097 | 473 | const std::string& player_name = plr ? plr->get_name() : no_name; | 461 | const std::string& player_name = plr ? plr->get_name() : no_name; |
1098 | 474 | const std::string& player_ai = plr ? plr->get_ai() : no_name; | 462 | const std::string& player_ai = plr ? plr->get_ai() : no_name; |
1103 | 475 | map().set_scenario_player_tribe(p, player_tribe); | 463 | mutable_map()->set_scenario_player_tribe(p, player_tribe); |
1104 | 476 | map().set_scenario_player_name(p, player_name); | 464 | mutable_map()->set_scenario_player_name(p, player_name); |
1105 | 477 | map().set_scenario_player_ai(p, player_ai); | 465 | mutable_map()->set_scenario_player_ai(p, player_ai); |
1106 | 478 | map().set_scenario_player_closeable(p, false); // player is already initialized. | 466 | mutable_map()->set_scenario_player_closeable(p, false); // player is already initialized. |
1107 | 479 | } | 467 | } |
1108 | 480 | 468 | ||
1109 | 481 | // Run the init script, if the map provides one. | 469 | // Run the init script, if the map provides one. |
1110 | 482 | 470 | ||
1111 | === modified file 'src/logic/map.cc' | |||
1112 | --- src/logic/map.cc 2017-08-12 20:13:24 +0000 | |||
1113 | +++ src/logic/map.cc 2017-08-20 12:33:35 +0000 | |||
1114 | @@ -565,7 +565,7 @@ | |||
1115 | 565 | =============== | 565 | =============== |
1116 | 566 | */ | 566 | */ |
1117 | 567 | template <typename functorT> | 567 | template <typename functorT> |
1119 | 568 | void Map::find_reachable(const Area<FCoords>& area, const CheckStep& checkstep, functorT& functor) { | 568 | void Map::find_reachable(const Area<FCoords>& area, const CheckStep& checkstep, functorT& functor) const { |
1120 | 569 | std::vector<Coords> queue; | 569 | std::vector<Coords> queue; |
1121 | 570 | boost::shared_ptr<Pathfields> pathfields = pathfieldmgr_->allocate(); | 570 | boost::shared_ptr<Pathfields> pathfields = pathfieldmgr_->allocate(); |
1122 | 571 | 571 | ||
1123 | @@ -655,7 +655,7 @@ | |||
1124 | 655 | =============== | 655 | =============== |
1125 | 656 | */ | 656 | */ |
1126 | 657 | uint32_t | 657 | uint32_t |
1128 | 658 | Map::find_bobs(Area<FCoords> const area, std::vector<Bob*>* const list, const FindBob& functor) { | 658 | Map::find_bobs(Area<FCoords> const area, std::vector<Bob*>* const list, const FindBob& functor) const { |
1129 | 659 | FindBobsCallback cb(list, functor); | 659 | FindBobsCallback cb(list, functor); |
1130 | 660 | 660 | ||
1131 | 661 | find(area, cb); | 661 | find(area, cb); |
1132 | @@ -678,7 +678,7 @@ | |||
1133 | 678 | uint32_t Map::find_reachable_bobs(Area<FCoords> const area, | 678 | uint32_t Map::find_reachable_bobs(Area<FCoords> const area, |
1134 | 679 | std::vector<Bob*>* const list, | 679 | std::vector<Bob*>* const list, |
1135 | 680 | const CheckStep& checkstep, | 680 | const CheckStep& checkstep, |
1137 | 681 | const FindBob& functor) { | 681 | const FindBob& functor) const { |
1138 | 682 | FindBobsCallback cb(list, functor); | 682 | FindBobsCallback cb(list, functor); |
1139 | 683 | 683 | ||
1140 | 684 | find_reachable(area, checkstep, cb); | 684 | find_reachable(area, checkstep, cb); |
1141 | @@ -731,7 +731,7 @@ | |||
1142 | 731 | */ | 731 | */ |
1143 | 732 | uint32_t Map::find_immovables(Area<FCoords> const area, | 732 | uint32_t Map::find_immovables(Area<FCoords> const area, |
1144 | 733 | std::vector<ImmovableFound>* const list, | 733 | std::vector<ImmovableFound>* const list, |
1146 | 734 | const FindImmovable& functor) { | 734 | const FindImmovable& functor) const{ |
1147 | 735 | FindImmovablesCallback cb(list, functor); | 735 | FindImmovablesCallback cb(list, functor); |
1148 | 736 | 736 | ||
1149 | 737 | find(area, cb); | 737 | find(area, cb); |
1150 | @@ -752,7 +752,7 @@ | |||
1151 | 752 | uint32_t Map::find_reachable_immovables(Area<FCoords> const area, | 752 | uint32_t Map::find_reachable_immovables(Area<FCoords> const area, |
1152 | 753 | std::vector<ImmovableFound>* const list, | 753 | std::vector<ImmovableFound>* const list, |
1153 | 754 | const CheckStep& checkstep, | 754 | const CheckStep& checkstep, |
1155 | 755 | const FindImmovable& functor) { | 755 | const FindImmovable& functor) const { |
1156 | 756 | FindImmovablesCallback cb(list, functor); | 756 | FindImmovablesCallback cb(list, functor); |
1157 | 757 | 757 | ||
1158 | 758 | find_reachable(area, checkstep, cb); | 758 | find_reachable(area, checkstep, cb); |
1159 | @@ -770,7 +770,7 @@ | |||
1160 | 770 | uint32_t Map::find_reachable_immovables_unique(const Area<FCoords> area, | 770 | uint32_t Map::find_reachable_immovables_unique(const Area<FCoords> area, |
1161 | 771 | std::vector<BaseImmovable*>& list, | 771 | std::vector<BaseImmovable*>& list, |
1162 | 772 | const CheckStep& checkstep, | 772 | const CheckStep& checkstep, |
1164 | 773 | const FindImmovable& functor) { | 773 | const FindImmovable& functor) const { |
1165 | 774 | std::vector<ImmovableFound> duplist; | 774 | std::vector<ImmovableFound> duplist; |
1166 | 775 | FindImmovablesCallback cb(&duplist, find_immovable_always_true()); | 775 | FindImmovablesCallback cb(&duplist, find_immovable_always_true()); |
1167 | 776 | 776 | ||
1168 | @@ -824,7 +824,7 @@ | |||
1169 | 824 | =============== | 824 | =============== |
1170 | 825 | */ | 825 | */ |
1171 | 826 | uint32_t | 826 | uint32_t |
1173 | 827 | Map::find_fields(Area<FCoords> const area, std::vector<Coords>* list, const FindNode& functor) { | 827 | Map::find_fields(Area<FCoords> const area, std::vector<Coords>* list, const FindNode& functor) const { |
1174 | 828 | FindNodesCallback cb(list, functor); | 828 | FindNodesCallback cb(list, functor); |
1175 | 829 | 829 | ||
1176 | 830 | find(area, cb); | 830 | find(area, cb); |
1177 | @@ -844,7 +844,7 @@ | |||
1178 | 844 | uint32_t Map::find_reachable_fields(Area<FCoords> const area, | 844 | uint32_t Map::find_reachable_fields(Area<FCoords> const area, |
1179 | 845 | std::vector<Coords>* list, | 845 | std::vector<Coords>* list, |
1180 | 846 | const CheckStep& checkstep, | 846 | const CheckStep& checkstep, |
1182 | 847 | const FindNode& functor) { | 847 | const FindNode& functor) const { |
1183 | 848 | FindNodesCallback cb(list, functor); | 848 | FindNodesCallback cb(list, functor); |
1184 | 849 | 849 | ||
1185 | 850 | find_reachable(area, checkstep, cb); | 850 | find_reachable(area, checkstep, cb); |
1186 | @@ -1595,7 +1595,7 @@ | |||
1187 | 1595 | int32_t const persist, | 1595 | int32_t const persist, |
1188 | 1596 | Path& path, | 1596 | Path& path, |
1189 | 1597 | const CheckStep& checkstep, | 1597 | const CheckStep& checkstep, |
1191 | 1598 | uint32_t const flags) { | 1598 | uint32_t const flags) const { |
1192 | 1599 | FCoords start; | 1599 | FCoords start; |
1193 | 1600 | FCoords end; | 1600 | FCoords end; |
1194 | 1601 | int32_t upper_cost_limit; | 1601 | int32_t upper_cost_limit; |
1195 | 1602 | 1602 | ||
1196 | === modified file 'src/logic/map.h' | |||
1197 | --- src/logic/map.h 2017-08-12 06:51:08 +0000 | |||
1198 | +++ src/logic/map.h 2017-08-20 12:33:35 +0000 | |||
1199 | @@ -181,7 +181,7 @@ | |||
1200 | 181 | const std::string& description = _("No description defined")); | 181 | const std::string& description = _("No description defined")); |
1201 | 182 | 182 | ||
1202 | 183 | void recalc_whole_map(const World& world); | 183 | void recalc_whole_map(const World& world); |
1204 | 184 | virtual void recalc_for_field_area(const World& world, Area<FCoords>); | 184 | void recalc_for_field_area(const World& world, Area<FCoords>); |
1205 | 185 | 185 | ||
1206 | 186 | /*** | 186 | /*** |
1207 | 187 | * Ensures that resources match their adjacent terrains. | 187 | * Ensures that resources match their adjacent terrains. |
1208 | @@ -292,27 +292,27 @@ | |||
1209 | 292 | BaseImmovable* get_immovable(const Coords&) const; | 292 | BaseImmovable* get_immovable(const Coords&) const; |
1210 | 293 | uint32_t find_bobs(const Area<FCoords>, | 293 | uint32_t find_bobs(const Area<FCoords>, |
1211 | 294 | std::vector<Bob*>* list, | 294 | std::vector<Bob*>* list, |
1213 | 295 | const FindBob& functor = FindBobAlwaysTrue()); | 295 | const FindBob& functor = FindBobAlwaysTrue()) const; |
1214 | 296 | uint32_t find_reachable_bobs(const Area<FCoords>, | 296 | uint32_t find_reachable_bobs(const Area<FCoords>, |
1215 | 297 | std::vector<Bob*>* list, | 297 | std::vector<Bob*>* list, |
1216 | 298 | const CheckStep&, | 298 | const CheckStep&, |
1218 | 299 | const FindBob& functor = FindBobAlwaysTrue()); | 299 | const FindBob& functor = FindBobAlwaysTrue()) const; |
1219 | 300 | uint32_t find_immovables(const Area<FCoords>, | 300 | uint32_t find_immovables(const Area<FCoords>, |
1220 | 301 | std::vector<ImmovableFound>* list, | 301 | std::vector<ImmovableFound>* list, |
1222 | 302 | const FindImmovable& = find_immovable_always_true()); | 302 | const FindImmovable& = find_immovable_always_true()) const; |
1223 | 303 | uint32_t find_reachable_immovables(const Area<FCoords>, | 303 | uint32_t find_reachable_immovables(const Area<FCoords>, |
1224 | 304 | std::vector<ImmovableFound>* list, | 304 | std::vector<ImmovableFound>* list, |
1225 | 305 | const CheckStep&, | 305 | const CheckStep&, |
1227 | 306 | const FindImmovable& = find_immovable_always_true()); | 306 | const FindImmovable& = find_immovable_always_true()) const; |
1228 | 307 | uint32_t find_reachable_immovables_unique(const Area<FCoords>, | 307 | uint32_t find_reachable_immovables_unique(const Area<FCoords>, |
1229 | 308 | std::vector<BaseImmovable*>& list, | 308 | std::vector<BaseImmovable*>& list, |
1230 | 309 | const CheckStep&, | 309 | const CheckStep&, |
1233 | 310 | const FindImmovable& = find_immovable_always_true()); | 310 | const FindImmovable& = find_immovable_always_true()) const; |
1234 | 311 | uint32_t find_fields(const Area<FCoords>, std::vector<Coords>* list, const FindNode& functor); | 311 | uint32_t find_fields(const Area<FCoords>, std::vector<Coords>* list, const FindNode& functor) const; |
1235 | 312 | uint32_t find_reachable_fields(const Area<FCoords>, | 312 | uint32_t find_reachable_fields(const Area<FCoords>, |
1236 | 313 | std::vector<Coords>* list, | 313 | std::vector<Coords>* list, |
1237 | 314 | const CheckStep&, | 314 | const CheckStep&, |
1239 | 315 | const FindNode&); | 315 | const FindNode&) const; |
1240 | 316 | 316 | ||
1241 | 317 | // Field logic | 317 | // Field logic |
1242 | 318 | static MapIndex get_index(const Coords&, int16_t width); | 318 | static MapIndex get_index(const Coords&, int16_t width); |
1243 | @@ -370,7 +370,7 @@ | |||
1244 | 370 | const int32_t persist, | 370 | const int32_t persist, |
1245 | 371 | Path&, | 371 | Path&, |
1246 | 372 | const CheckStep&, | 372 | const CheckStep&, |
1248 | 373 | const uint32_t flags = 0); | 373 | const uint32_t flags = 0) const; |
1249 | 374 | 374 | ||
1250 | 375 | /** | 375 | /** |
1251 | 376 | * We can reach a field by water either if it has MOVECAPS_SWIM or if it has | 376 | * We can reach a field by water either if it has MOVECAPS_SWIM or if it has |
1252 | @@ -464,11 +464,31 @@ | |||
1253 | 464 | /// Checks whether there are any artifacts on the map | 464 | /// Checks whether there are any artifacts on the map |
1254 | 465 | bool has_artifacts(); | 465 | bool has_artifacts(); |
1255 | 466 | 466 | ||
1257 | 467 | protected: /// These functions are needed in Testclasses | 467 | // Visible for testing. |
1258 | 468 | void set_size(uint32_t w, uint32_t h); | 468 | void set_size(uint32_t w, uint32_t h); |
1259 | 469 | 469 | ||
1260 | 470 | private: | 470 | private: |
1261 | 471 | void recalc_border(const FCoords&); | 471 | void recalc_border(const FCoords&); |
1262 | 472 | void recalc_brightness(const FCoords&); | ||
1263 | 473 | void recalc_nodecaps_pass1(const World& world, const FCoords&); | ||
1264 | 474 | void recalc_nodecaps_pass2(const World& world, const FCoords& f); | ||
1265 | 475 | NodeCaps calc_nodecaps_pass1(const World& world, const FCoords&, bool consider_mobs = true); | ||
1266 | 476 | NodeCaps calc_nodecaps_pass2(const World& world, | ||
1267 | 477 | const FCoords&, | ||
1268 | 478 | bool consider_mobs = true, | ||
1269 | 479 | NodeCaps initcaps = CAPS_NONE); | ||
1270 | 480 | void check_neighbour_heights(FCoords, uint32_t& radius); | ||
1271 | 481 | int calc_buildsize(const World& world, | ||
1272 | 482 | const FCoords& f, | ||
1273 | 483 | bool avoidnature, | ||
1274 | 484 | bool* ismine = nullptr, | ||
1275 | 485 | bool consider_mobs = true, | ||
1276 | 486 | NodeCaps initcaps = CAPS_NONE); | ||
1277 | 487 | bool is_cycle_connected(const FCoords& start, uint32_t length, const WalkingDir* dirs); | ||
1278 | 488 | template <typename functorT> | ||
1279 | 489 | void find_reachable(const Area<FCoords>&, const CheckStep&, functorT&) const; | ||
1280 | 490 | template <typename functorT> void find(const Area<FCoords>&, functorT&) const; | ||
1281 | 491 | |||
1282 | 472 | 492 | ||
1283 | 473 | /// # of players this map supports (!= Game's number of players!) | 493 | /// # of players this map supports (!= Game's number of players!) |
1284 | 474 | PlayerNumber nrplayers_; | 494 | PlayerNumber nrplayers_; |
1285 | @@ -501,26 +521,6 @@ | |||
1286 | 501 | PortSpacesSet port_spaces_; | 521 | PortSpacesSet port_spaces_; |
1287 | 502 | Objectives objectives_; | 522 | Objectives objectives_; |
1288 | 503 | 523 | ||
1289 | 504 | void recalc_brightness(const FCoords&); | ||
1290 | 505 | void recalc_nodecaps_pass1(const World& world, const FCoords&); | ||
1291 | 506 | void recalc_nodecaps_pass2(const World& world, const FCoords& f); | ||
1292 | 507 | NodeCaps calc_nodecaps_pass1(const World& world, const FCoords&, bool consider_mobs = true); | ||
1293 | 508 | NodeCaps calc_nodecaps_pass2(const World& world, | ||
1294 | 509 | const FCoords&, | ||
1295 | 510 | bool consider_mobs = true, | ||
1296 | 511 | NodeCaps initcaps = CAPS_NONE); | ||
1297 | 512 | void check_neighbour_heights(FCoords, uint32_t& radius); | ||
1298 | 513 | int calc_buildsize(const World& world, | ||
1299 | 514 | const FCoords& f, | ||
1300 | 515 | bool avoidnature, | ||
1301 | 516 | bool* ismine = nullptr, | ||
1302 | 517 | bool consider_mobs = true, | ||
1303 | 518 | NodeCaps initcaps = CAPS_NONE); | ||
1304 | 519 | bool is_cycle_connected(const FCoords& start, uint32_t length, const WalkingDir* dirs); | ||
1305 | 520 | template <typename functorT> | ||
1306 | 521 | void find_reachable(const Area<FCoords>&, const CheckStep&, functorT&); | ||
1307 | 522 | template <typename functorT> void find(const Area<FCoords>&, functorT&) const; | ||
1308 | 523 | |||
1309 | 524 | MapVersion map_version_; | 524 | MapVersion map_version_; |
1310 | 525 | }; | 525 | }; |
1311 | 526 | 526 | ||
1312 | 527 | 527 | ||
1313 | === modified file 'src/logic/map_objects/bob.cc' | |||
1314 | --- src/logic/map_objects/bob.cc 2017-06-24 08:47:46 +0000 | |||
1315 | +++ src/logic/map_objects/bob.cc 2017-08-20 12:33:35 +0000 | |||
1316 | @@ -464,7 +464,7 @@ | |||
1317 | 464 | 464 | ||
1318 | 465 | Game& game_; | 465 | Game& game_; |
1319 | 466 | Bob& bob_; | 466 | Bob& bob_; |
1321 | 467 | Map& map_; | 467 | const Map& map_; |
1322 | 468 | Coords finaldest_; | 468 | Coords finaldest_; |
1323 | 469 | Cache nodes_; | 469 | Cache nodes_; |
1324 | 470 | int nrblocked_; | 470 | int nrblocked_; |
1325 | @@ -475,13 +475,13 @@ | |||
1326 | 475 | explicit CheckStepBlocked(BlockedTracker& tracker) : tracker_(tracker) { | 475 | explicit CheckStepBlocked(BlockedTracker& tracker) : tracker_(tracker) { |
1327 | 476 | } | 476 | } |
1328 | 477 | 477 | ||
1330 | 478 | bool allowed(Map&, FCoords, FCoords end, int32_t, CheckStep::StepId) const { | 478 | bool allowed(const Map&, FCoords, FCoords end, int32_t, CheckStep::StepId) const { |
1331 | 479 | if (end == tracker_.finaldest_) | 479 | if (end == tracker_.finaldest_) |
1332 | 480 | return true; | 480 | return true; |
1333 | 481 | 481 | ||
1334 | 482 | return !tracker_.is_blocked(end); | 482 | return !tracker_.is_blocked(end); |
1335 | 483 | } | 483 | } |
1337 | 484 | bool reachable_dest(Map&, FCoords) const { | 484 | bool reachable_dest(const Map&, FCoords) const { |
1338 | 485 | return true; | 485 | return true; |
1339 | 486 | } | 486 | } |
1340 | 487 | 487 | ||
1341 | @@ -519,7 +519,7 @@ | |||
1342 | 519 | if (forceall) | 519 | if (forceall) |
1343 | 520 | tracker.disabled_ = true; | 520 | tracker.disabled_ = true; |
1344 | 521 | 521 | ||
1346 | 522 | Map& map = game.map(); | 522 | const Map& map = game.map(); |
1347 | 523 | if (map.findpath(position_, dest, persist, path, cstep) < 0) { | 523 | if (map.findpath(position_, dest, persist, path, cstep) < 0) { |
1348 | 524 | if (!tracker.nrblocked_) | 524 | if (!tracker.nrblocked_) |
1349 | 525 | return false; | 525 | return false; |
1350 | @@ -634,8 +634,7 @@ | |||
1351 | 634 | // Using probability of 1/8 and pausing it for 5, 10 or 15 seconds | 634 | // Using probability of 1/8 and pausing it for 5, 10 or 15 seconds |
1352 | 635 | if (game.logic_rand() % 8 == 0) { | 635 | if (game.logic_rand() % 8 == 0) { |
1353 | 636 | if (is_a(Ship, this)) { | 636 | if (is_a(Ship, this)) { |
1356 | 637 | Map& map = game.map(); | 637 | const uint32_t ships_count = game.map().find_bobs( |
1355 | 638 | const uint32_t ships_count = map.find_bobs( | ||
1357 | 639 | Widelands::Area<Widelands::FCoords>(get_position(), 0), nullptr, FindBobShip()); | 638 | Widelands::Area<Widelands::FCoords>(get_position(), 0), nullptr, FindBobShip()); |
1358 | 640 | assert(ships_count > 0); | 639 | assert(ships_count > 0); |
1359 | 641 | if (ships_count > 1) { | 640 | if (ships_count > 1) { |
1360 | @@ -694,7 +693,7 @@ | |||
1361 | 694 | Vector2f Bob::calc_drawpos(const EditorGameBase& game, | 693 | Vector2f Bob::calc_drawpos(const EditorGameBase& game, |
1362 | 695 | const Vector2f& field_on_dst, | 694 | const Vector2f& field_on_dst, |
1363 | 696 | const float scale) const { | 695 | const float scale) const { |
1365 | 697 | const Map& map = game.get_map(); | 696 | const Map& map = game.map(); |
1366 | 698 | const FCoords end = position_; | 697 | const FCoords end = position_; |
1367 | 699 | FCoords start; | 698 | FCoords start; |
1368 | 700 | Vector2f spos = field_on_dst; | 699 | Vector2f spos = field_on_dst; |
1369 | @@ -793,7 +792,7 @@ | |||
1370 | 793 | int32_t Bob::start_walk(Game& game, WalkingDir const dir, uint32_t const a, bool const force) { | 792 | int32_t Bob::start_walk(Game& game, WalkingDir const dir, uint32_t const a, bool const force) { |
1371 | 794 | FCoords newnode; | 793 | FCoords newnode; |
1372 | 795 | 794 | ||
1374 | 796 | Map& map = game.map(); | 795 | const Map& map = game.map(); |
1375 | 797 | map.get_neighbour(position_, dir, &newnode); | 796 | map.get_neighbour(position_, dir, &newnode); |
1376 | 798 | 797 | ||
1377 | 799 | // Move capability check | 798 | // Move capability check |
1378 | 800 | 799 | ||
1379 | === modified file 'src/logic/map_objects/checkstep.cc' | |||
1380 | --- src/logic/map_objects/checkstep.cc 2017-01-25 18:55:59 +0000 | |||
1381 | +++ src/logic/map_objects/checkstep.cc 2017-08-20 12:33:35 +0000 | |||
1382 | @@ -34,10 +34,10 @@ | |||
1383 | 34 | } | 34 | } |
1384 | 35 | 35 | ||
1385 | 36 | struct CheckStepAlwaysFalse { | 36 | struct CheckStepAlwaysFalse { |
1387 | 37 | bool allowed(Map&, const FCoords&, const FCoords&, int32_t, CheckStep::StepId) const { | 37 | bool allowed(const Map&, const FCoords&, const FCoords&, int32_t, CheckStep::StepId) const { |
1388 | 38 | return false; | 38 | return false; |
1389 | 39 | } | 39 | } |
1391 | 40 | bool reachable_dest(Map&, const FCoords&) const { | 40 | bool reachable_dest(const Map&, const FCoords&) const { |
1392 | 41 | return false; | 41 | return false; |
1393 | 42 | } | 42 | } |
1394 | 43 | }; | 43 | }; |
1395 | @@ -51,7 +51,7 @@ | |||
1396 | 51 | subs.push_back(sub); | 51 | subs.push_back(sub); |
1397 | 52 | } | 52 | } |
1398 | 53 | 53 | ||
1400 | 54 | bool CheckStepAnd::allowed(Map& map, | 54 | bool CheckStepAnd::allowed(const Map& map, |
1401 | 55 | const FCoords& start, | 55 | const FCoords& start, |
1402 | 56 | const FCoords& end, | 56 | const FCoords& end, |
1403 | 57 | int32_t const dir, | 57 | int32_t const dir, |
1404 | @@ -64,7 +64,7 @@ | |||
1405 | 64 | return true; | 64 | return true; |
1406 | 65 | } | 65 | } |
1407 | 66 | 66 | ||
1409 | 67 | bool CheckStepAnd::reachable_dest(Map& map, const FCoords& dest) const { | 67 | bool CheckStepAnd::reachable_dest(const Map& map, const FCoords& dest) const { |
1410 | 68 | for (const CheckStep& checkstep : subs) { | 68 | for (const CheckStep& checkstep : subs) { |
1411 | 69 | if (!checkstep.reachable_dest(map, dest)) { | 69 | if (!checkstep.reachable_dest(map, dest)) { |
1412 | 70 | return false; | 70 | return false; |
1413 | @@ -79,7 +79,7 @@ | |||
1414 | 79 | =============== | 79 | =============== |
1415 | 80 | */ | 80 | */ |
1416 | 81 | bool CheckStepDefault::allowed( | 81 | bool CheckStepDefault::allowed( |
1418 | 82 | Map&, const FCoords& start, const FCoords& end, int32_t, CheckStep::StepId) const { | 82 | const Map&, const FCoords& start, const FCoords& end, int32_t, CheckStep::StepId) const { |
1419 | 83 | NodeCaps const endcaps = end.field->nodecaps(); | 83 | NodeCaps const endcaps = end.field->nodecaps(); |
1420 | 84 | 84 | ||
1421 | 85 | if (endcaps & movecaps_) | 85 | if (endcaps & movecaps_) |
1422 | @@ -94,7 +94,7 @@ | |||
1423 | 94 | return false; | 94 | return false; |
1424 | 95 | } | 95 | } |
1425 | 96 | 96 | ||
1427 | 97 | bool CheckStepDefault::reachable_dest(Map& map, const FCoords& dest) const { | 97 | bool CheckStepDefault::reachable_dest(const Map& map, const FCoords& dest) const { |
1428 | 98 | NodeCaps const caps = dest.field->nodecaps(); | 98 | NodeCaps const caps = dest.field->nodecaps(); |
1429 | 99 | 99 | ||
1430 | 100 | if (!(caps & movecaps_)) { | 100 | if (!(caps & movecaps_)) { |
1431 | @@ -114,7 +114,7 @@ | |||
1432 | 114 | =============== | 114 | =============== |
1433 | 115 | */ | 115 | */ |
1434 | 116 | bool CheckStepWalkOn::allowed( | 116 | bool CheckStepWalkOn::allowed( |
1436 | 117 | Map&, const FCoords& start, const FCoords& end, int32_t, CheckStep::StepId const id) const { | 117 | const Map&, const FCoords& start, const FCoords& end, int32_t, CheckStep::StepId const id) const { |
1437 | 118 | NodeCaps const startcaps = start.field->nodecaps(); | 118 | NodeCaps const startcaps = start.field->nodecaps(); |
1438 | 119 | NodeCaps const endcaps = end.field->nodecaps(); | 119 | NodeCaps const endcaps = end.field->nodecaps(); |
1439 | 120 | 120 | ||
1440 | @@ -138,13 +138,13 @@ | |||
1441 | 138 | return false; | 138 | return false; |
1442 | 139 | } | 139 | } |
1443 | 140 | 140 | ||
1445 | 141 | bool CheckStepWalkOn::reachable_dest(Map&, FCoords) const { | 141 | bool CheckStepWalkOn::reachable_dest(const Map&, FCoords) const { |
1446 | 142 | // Don't bother solving this. | 142 | // Don't bother solving this. |
1447 | 143 | return true; | 143 | return true; |
1448 | 144 | } | 144 | } |
1449 | 145 | 145 | ||
1450 | 146 | bool CheckStepRoad::allowed( | 146 | bool CheckStepRoad::allowed( |
1452 | 147 | Map& map, const FCoords& start, const FCoords& end, int32_t, CheckStep::StepId const id) const { | 147 | const Map& map, const FCoords& start, const FCoords& end, int32_t, CheckStep::StepId const id) const { |
1453 | 148 | uint8_t const endcaps = player_.get_buildcaps(end); | 148 | uint8_t const endcaps = player_.get_buildcaps(end); |
1454 | 149 | 149 | ||
1455 | 150 | // Calculate cost and passability | 150 | // Calculate cost and passability |
1456 | @@ -165,7 +165,7 @@ | |||
1457 | 165 | return true; | 165 | return true; |
1458 | 166 | } | 166 | } |
1459 | 167 | 167 | ||
1461 | 168 | bool CheckStepRoad::reachable_dest(Map& map, const FCoords& dest) const { | 168 | bool CheckStepRoad::reachable_dest(const Map& map, const FCoords& dest) const { |
1462 | 169 | NodeCaps const caps = dest.field->nodecaps(); | 169 | NodeCaps const caps = dest.field->nodecaps(); |
1463 | 170 | 170 | ||
1464 | 171 | if (!(caps & movecaps_)) { | 171 | if (!(caps & movecaps_)) { |
1465 | @@ -180,11 +180,11 @@ | |||
1466 | 180 | } | 180 | } |
1467 | 181 | 181 | ||
1468 | 182 | bool CheckStepLimited::allowed( | 182 | bool CheckStepLimited::allowed( |
1470 | 183 | Map&, const FCoords&, const FCoords& end, int32_t, CheckStep::StepId) const { | 183 | const Map&, const FCoords&, const FCoords& end, int32_t, CheckStep::StepId) const { |
1471 | 184 | return allowed_locations_.find(end) != allowed_locations_.end(); | 184 | return allowed_locations_.find(end) != allowed_locations_.end(); |
1472 | 185 | } | 185 | } |
1473 | 186 | 186 | ||
1475 | 187 | bool CheckStepLimited::reachable_dest(Map&, FCoords) const { | 187 | bool CheckStepLimited::reachable_dest(const Map&, FCoords) const { |
1476 | 188 | return true; | 188 | return true; |
1477 | 189 | } | 189 | } |
1478 | 190 | } | 190 | } |
1479 | 191 | 191 | ||
1480 | === modified file 'src/logic/map_objects/checkstep.h' | |||
1481 | --- src/logic/map_objects/checkstep.h 2017-08-12 06:51:08 +0000 | |||
1482 | +++ src/logic/map_objects/checkstep.h 2017-08-20 12:33:35 +0000 | |||
1483 | @@ -44,21 +44,21 @@ | |||
1484 | 44 | virtual ~BaseCapsule() { | 44 | virtual ~BaseCapsule() { |
1485 | 45 | } | 45 | } |
1486 | 46 | virtual bool | 46 | virtual bool |
1489 | 47 | allowed(Map&, const FCoords& start, const FCoords& end, int32_t dir, StepId id) const = 0; | 47 | allowed(const Map&, const FCoords& start, const FCoords& end, int32_t dir, StepId id) const = 0; |
1490 | 48 | virtual bool reachable_dest(Map&, const FCoords& dest) const = 0; | 48 | virtual bool reachable_dest(const Map&, const FCoords& dest) const = 0; |
1491 | 49 | }; | 49 | }; |
1492 | 50 | template <typename T> struct Capsule : public BaseCapsule { | 50 | template <typename T> struct Capsule : public BaseCapsule { |
1493 | 51 | Capsule(const T& init_op) : op(init_op) { | 51 | Capsule(const T& init_op) : op(init_op) { |
1494 | 52 | } | 52 | } |
1495 | 53 | 53 | ||
1497 | 54 | bool allowed(Map& map, | 54 | bool allowed(const Map& map, |
1498 | 55 | const FCoords& start, | 55 | const FCoords& start, |
1499 | 56 | const FCoords& end, | 56 | const FCoords& end, |
1500 | 57 | int32_t const dir, | 57 | int32_t const dir, |
1501 | 58 | StepId const id) const override { | 58 | StepId const id) const override { |
1502 | 59 | return op.allowed(map, start, end, dir, id); | 59 | return op.allowed(map, start, end, dir, id); |
1503 | 60 | } | 60 | } |
1505 | 61 | bool reachable_dest(Map& map, const FCoords& dest) const override { | 61 | bool reachable_dest(const Map& map, const FCoords& dest) const override { |
1506 | 62 | return op.reachable_dest(map, dest); | 62 | return op.reachable_dest(map, dest); |
1507 | 63 | } | 63 | } |
1508 | 64 | 64 | ||
1509 | @@ -79,7 +79,7 @@ | |||
1510 | 79 | * \return \c true true if moving from start to end (single step in the given | 79 | * \return \c true true if moving from start to end (single step in the given |
1511 | 80 | * direction) is allowed. | 80 | * direction) is allowed. |
1512 | 81 | */ | 81 | */ |
1514 | 82 | bool allowed(Map& map, | 82 | bool allowed(const Map& map, |
1515 | 83 | const FCoords& start, | 83 | const FCoords& start, |
1516 | 84 | const FCoords& end, | 84 | const FCoords& end, |
1517 | 85 | int32_t const dir, | 85 | int32_t const dir, |
1518 | @@ -91,7 +91,7 @@ | |||
1519 | 91 | * \return \c true if the destination field can be reached at all | 91 | * \return \c true if the destination field can be reached at all |
1520 | 92 | * (e.g. return false for land-based bobs when dest is in water). | 92 | * (e.g. return false for land-based bobs when dest is in water). |
1521 | 93 | */ | 93 | */ |
1523 | 94 | bool reachable_dest(Map& map, const FCoords& dest) const { | 94 | bool reachable_dest(const Map& map, const FCoords& dest) const { |
1524 | 95 | return capsule->reachable_dest(map, dest); | 95 | return capsule->reachable_dest(map, dest); |
1525 | 96 | } | 96 | } |
1526 | 97 | }; | 97 | }; |
1527 | @@ -104,8 +104,8 @@ | |||
1528 | 104 | void add(const CheckStep& sub); | 104 | void add(const CheckStep& sub); |
1529 | 105 | 105 | ||
1530 | 106 | bool | 106 | bool |
1533 | 107 | allowed(Map&, const FCoords& start, const FCoords& end, int32_t dir, CheckStep::StepId id) const; | 107 | allowed(const Map&, const FCoords& start, const FCoords& end, int32_t dir, CheckStep::StepId id) const; |
1534 | 108 | bool reachable_dest(Map&, const FCoords& dest) const; | 108 | bool reachable_dest(const Map&, const FCoords& dest) const; |
1535 | 109 | 109 | ||
1536 | 110 | private: | 110 | private: |
1537 | 111 | std::vector<CheckStep> subs; | 111 | std::vector<CheckStep> subs; |
1538 | @@ -123,8 +123,8 @@ | |||
1539 | 123 | } | 123 | } |
1540 | 124 | 124 | ||
1541 | 125 | bool | 125 | bool |
1544 | 126 | allowed(Map&, const FCoords& start, const FCoords& end, int32_t dir, CheckStep::StepId) const; | 126 | allowed(const Map&, const FCoords& start, const FCoords& end, int32_t dir, CheckStep::StepId) const; |
1545 | 127 | bool reachable_dest(Map&, const FCoords& dest) const; | 127 | bool reachable_dest(const Map&, const FCoords& dest) const; |
1546 | 128 | 128 | ||
1547 | 129 | private: | 129 | private: |
1548 | 130 | uint8_t movecaps_; | 130 | uint8_t movecaps_; |
1549 | @@ -141,8 +141,8 @@ | |||
1550 | 141 | } | 141 | } |
1551 | 142 | 142 | ||
1552 | 143 | bool | 143 | bool |
1555 | 144 | allowed(Map&, const FCoords& start, const FCoords& end, int32_t dir, CheckStep::StepId) const; | 144 | allowed(const Map&, const FCoords& start, const FCoords& end, int32_t dir, CheckStep::StepId) const; |
1556 | 145 | bool reachable_dest(Map&, FCoords dest) const; | 145 | bool reachable_dest(const Map&, FCoords dest) const; |
1557 | 146 | 146 | ||
1558 | 147 | private: | 147 | private: |
1559 | 148 | uint8_t movecaps_; | 148 | uint8_t movecaps_; |
1560 | @@ -162,8 +162,8 @@ | |||
1561 | 162 | } | 162 | } |
1562 | 163 | 163 | ||
1563 | 164 | bool | 164 | bool |
1566 | 165 | allowed(Map&, const FCoords& start, const FCoords& end, int32_t dir, CheckStep::StepId) const; | 165 | allowed(const Map&, const FCoords& start, const FCoords& end, int32_t dir, CheckStep::StepId) const; |
1567 | 166 | bool reachable_dest(Map&, const FCoords& dest) const; | 166 | bool reachable_dest(const Map&, const FCoords& dest) const; |
1568 | 167 | 167 | ||
1569 | 168 | private: | 168 | private: |
1570 | 169 | const Player& player_; | 169 | const Player& player_; |
1571 | @@ -179,8 +179,8 @@ | |||
1572 | 179 | allowed_locations_.insert(c); | 179 | allowed_locations_.insert(c); |
1573 | 180 | } | 180 | } |
1574 | 181 | bool | 181 | bool |
1577 | 182 | allowed(Map&, const FCoords& start, const FCoords& end, int32_t dir, CheckStep::StepId) const; | 182 | allowed(const Map&, const FCoords& start, const FCoords& end, int32_t dir, CheckStep::StepId) const; |
1578 | 183 | bool reachable_dest(Map&, FCoords dest) const; | 183 | bool reachable_dest(const Map&, FCoords dest) const; |
1579 | 184 | 184 | ||
1580 | 185 | private: | 185 | private: |
1581 | 186 | // The ordering of the set does not matter, as long as it is system | 186 | // The ordering of the set does not matter, as long as it is system |
1582 | 187 | 187 | ||
1583 | === modified file 'src/logic/map_objects/immovable.cc' | |||
1584 | --- src/logic/map_objects/immovable.cc 2017-07-04 11:34:00 +0000 | |||
1585 | +++ src/logic/map_objects/immovable.cc 2017-08-20 12:33:35 +0000 | |||
1586 | @@ -100,15 +100,16 @@ | |||
1587 | 100 | void BaseImmovable::set_position(EditorGameBase& egbase, const Coords& c) { | 100 | void BaseImmovable::set_position(EditorGameBase& egbase, const Coords& c) { |
1588 | 101 | assert(c); | 101 | assert(c); |
1589 | 102 | 102 | ||
1592 | 103 | Map& map = egbase.map(); | 103 | Map* map = egbase.mutable_map(); |
1593 | 104 | FCoords f = map.get_fcoords(c); | 104 | FCoords f = map->get_fcoords(c); |
1594 | 105 | if (f.field->immovable && f.field->immovable != this) | 105 | if (f.field->immovable && f.field->immovable != this) |
1595 | 106 | f.field->immovable->remove(egbase); | 106 | f.field->immovable->remove(egbase); |
1596 | 107 | 107 | ||
1597 | 108 | f.field->immovable = this; | 108 | f.field->immovable = this; |
1598 | 109 | 109 | ||
1601 | 110 | if (get_size() >= SMALL) | 110 | if (get_size() >= SMALL) { |
1602 | 111 | map.recalc_for_field_area(egbase.world(), Area<FCoords>(f, 2)); | 111 | map->recalc_for_field_area(egbase.world(), Area<FCoords>(f, 2)); |
1603 | 112 | } | ||
1604 | 112 | } | 113 | } |
1605 | 113 | 114 | ||
1606 | 114 | /** | 115 | /** |
1607 | @@ -117,8 +118,8 @@ | |||
1608 | 117 | * Only call this during cleanup. | 118 | * Only call this during cleanup. |
1609 | 118 | */ | 119 | */ |
1610 | 119 | void BaseImmovable::unset_position(EditorGameBase& egbase, const Coords& c) { | 120 | void BaseImmovable::unset_position(EditorGameBase& egbase, const Coords& c) { |
1613 | 120 | Map& map = egbase.map(); | 121 | Map* map = egbase.mutable_map(); |
1614 | 121 | FCoords const f = map.get_fcoords(c); | 122 | FCoords const f = map->get_fcoords(c); |
1615 | 122 | 123 | ||
1616 | 123 | // this is to help to debug failing assertion below (see bug 1542238) | 124 | // this is to help to debug failing assertion below (see bug 1542238) |
1617 | 124 | if (f.field->immovable != this) { | 125 | if (f.field->immovable != this) { |
1618 | @@ -130,10 +131,11 @@ | |||
1619 | 130 | assert(f.field->immovable == this); | 131 | assert(f.field->immovable == this); |
1620 | 131 | 132 | ||
1621 | 132 | f.field->immovable = nullptr; | 133 | f.field->immovable = nullptr; |
1623 | 133 | egbase.inform_players_about_immovable(f.field - &map[0], nullptr); | 134 | egbase.inform_players_about_immovable(f.field - &(*map)[0], nullptr); |
1624 | 134 | 135 | ||
1627 | 135 | if (get_size() >= SMALL) | 136 | if (get_size() >= SMALL) { |
1628 | 136 | map.recalc_for_field_area(egbase.world(), Area<FCoords>(f, 2)); | 137 | map->recalc_for_field_area(egbase.world(), Area<FCoords>(f, 2)); |
1629 | 138 | } | ||
1630 | 137 | } | 139 | } |
1631 | 138 | 140 | ||
1632 | 139 | /* | 141 | /* |
1633 | 140 | 142 | ||
1634 | === modified file 'src/logic/map_objects/tribes/building.cc' | |||
1635 | --- src/logic/map_objects/tribes/building.cc 2017-08-16 04:31:56 +0000 | |||
1636 | +++ src/logic/map_objects/tribes/building.cc 2017-08-20 12:33:35 +0000 | |||
1637 | @@ -329,7 +329,7 @@ | |||
1638 | 329 | PlayerImmovable::init(egbase); | 329 | PlayerImmovable::init(egbase); |
1639 | 330 | 330 | ||
1640 | 331 | // Set the building onto the map | 331 | // Set the building onto the map |
1642 | 332 | Map& map = egbase.map(); | 332 | const Map& map = egbase.map(); |
1643 | 333 | Coords neighb; | 333 | Coords neighb; |
1644 | 334 | 334 | ||
1645 | 335 | set_position(egbase, position_); | 335 | set_position(egbase, position_); |
1646 | @@ -385,7 +385,7 @@ | |||
1647 | 385 | unset_position(egbase, position_); | 385 | unset_position(egbase, position_); |
1648 | 386 | 386 | ||
1649 | 387 | if (get_size() == BIG) { | 387 | if (get_size() == BIG) { |
1651 | 388 | Map& map = egbase.map(); | 388 | const Map& map = egbase.map(); |
1652 | 389 | Coords neighb; | 389 | Coords neighb; |
1653 | 390 | 390 | ||
1654 | 391 | map.get_ln(position_, &neighb); | 391 | map.get_ln(position_, &neighb); |
1655 | @@ -421,7 +421,7 @@ | |||
1656 | 421 | 421 | ||
1657 | 422 | rv.push_back(position_); | 422 | rv.push_back(position_); |
1658 | 423 | if (get_size() == BIG) { | 423 | if (get_size() == BIG) { |
1660 | 424 | Map& map = egbase.map(); | 424 | const Map& map = egbase.map(); |
1661 | 425 | Coords neighb; | 425 | Coords neighb; |
1662 | 426 | 426 | ||
1663 | 427 | map.get_ln(position_, &neighb); | 427 | map.get_ln(position_, &neighb); |
1664 | @@ -727,7 +727,7 @@ | |||
1665 | 727 | return; | 727 | return; |
1666 | 728 | 728 | ||
1667 | 729 | Player& player = owner(); | 729 | Player& player = owner(); |
1669 | 730 | Map& map = player.egbase().map(); | 730 | const Map& map = player.egbase().map(); |
1670 | 731 | 731 | ||
1671 | 732 | if (see) | 732 | if (see) |
1672 | 733 | player.see_area(Area<FCoords>(map.get_fcoords(get_position()), descr().vision_range())); | 733 | player.see_area(Area<FCoords>(map.get_fcoords(get_position()), descr().vision_range())); |
1673 | 734 | 734 | ||
1674 | === modified file 'src/logic/map_objects/tribes/carrier.cc' | |||
1675 | --- src/logic/map_objects/tribes/carrier.cc 2017-04-22 06:45:52 +0000 | |||
1676 | +++ src/logic/map_objects/tribes/carrier.cc 2017-08-20 12:33:35 +0000 | |||
1677 | @@ -432,7 +432,7 @@ | |||
1678 | 432 | * Find the flag we are closest to (in walking time). | 432 | * Find the flag we are closest to (in walking time). |
1679 | 433 | */ | 433 | */ |
1680 | 434 | int32_t Carrier::find_closest_flag(Game& game) { | 434 | int32_t Carrier::find_closest_flag(Game& game) { |
1682 | 435 | Map& map = game.map(); | 435 | const Map& map = game.map(); |
1683 | 436 | CoordPath startpath(map, dynamic_cast<Road&>(*get_location(game)).get_path()); | 436 | CoordPath startpath(map, dynamic_cast<Road&>(*get_location(game)).get_path()); |
1684 | 437 | 437 | ||
1685 | 438 | CoordPath endpath; | 438 | CoordPath endpath; |
1686 | 439 | 439 | ||
1687 | === modified file 'src/logic/map_objects/tribes/militarysite.cc' | |||
1688 | --- src/logic/map_objects/tribes/militarysite.cc 2017-08-16 13:23:15 +0000 | |||
1689 | +++ src/logic/map_objects/tribes/militarysite.cc 2017-08-20 12:33:35 +0000 | |||
1690 | @@ -156,7 +156,7 @@ | |||
1691 | 156 | void MilitarySite::AttackTarget::enemy_soldier_approaches(const Soldier& enemy) const { | 156 | void MilitarySite::AttackTarget::enemy_soldier_approaches(const Soldier& enemy) const { |
1692 | 157 | auto& owner = military_site_->owner(); | 157 | auto& owner = military_site_->owner(); |
1693 | 158 | Game& game = dynamic_cast<Game&>(owner.egbase()); | 158 | Game& game = dynamic_cast<Game&>(owner.egbase()); |
1695 | 159 | Map& map = game.map(); | 159 | const Map& map = game.map(); |
1696 | 160 | if (enemy.get_owner() == &owner || enemy.get_battle() || | 160 | if (enemy.get_owner() == &owner || enemy.get_battle() || |
1697 | 161 | military_site_->descr().get_conquers() <= | 161 | military_site_->descr().get_conquers() <= |
1698 | 162 | map.calc_distance(enemy.get_position(), military_site_->get_position())) | 162 | map.calc_distance(enemy.get_position(), military_site_->get_position())) |
1699 | 163 | 163 | ||
1700 | === modified file 'src/logic/map_objects/tribes/production_program.cc' | |||
1701 | --- src/logic/map_objects/tribes/production_program.cc 2017-08-16 04:31:56 +0000 | |||
1702 | +++ src/logic/map_objects/tribes/production_program.cc 2017-08-20 12:33:35 +0000 | |||
1703 | @@ -1138,7 +1138,7 @@ | |||
1704 | 1138 | } | 1138 | } |
1705 | 1139 | 1139 | ||
1706 | 1140 | void ProductionProgram::ActMine::execute(Game& game, ProductionSite& ps) const { | 1140 | void ProductionProgram::ActMine::execute(Game& game, ProductionSite& ps) const { |
1708 | 1141 | Map& map = game.map(); | 1141 | Map* map = game.mutable_map(); |
1709 | 1142 | 1142 | ||
1710 | 1143 | // select one of the nodes randomly | 1143 | // select one of the nodes randomly |
1711 | 1144 | uint32_t totalres = 0; | 1144 | uint32_t totalres = 0; |
1712 | @@ -1147,7 +1147,7 @@ | |||
1713 | 1147 | 1147 | ||
1714 | 1148 | { | 1148 | { |
1715 | 1149 | MapRegion<Area<FCoords>> mr( | 1149 | MapRegion<Area<FCoords>> mr( |
1717 | 1150 | map, Area<FCoords>(map.get_fcoords(ps.get_position()), distance_)); | 1150 | *map, Area<FCoords>(map->get_fcoords(ps.get_position()), distance_)); |
1718 | 1151 | do { | 1151 | do { |
1719 | 1152 | DescriptionIndex fres = mr.location().field->get_resources(); | 1152 | DescriptionIndex fres = mr.location().field->get_resources(); |
1720 | 1153 | ResourceAmount amount = mr.location().field->get_resources_amount(); | 1153 | ResourceAmount amount = mr.location().field->get_resources_amount(); |
1721 | @@ -1172,7 +1172,7 @@ | |||
1722 | 1172 | totalchance += 4; | 1172 | totalchance += 4; |
1723 | 1173 | else if (amount <= 6) | 1173 | else if (amount <= 6) |
1724 | 1174 | totalchance += 2; | 1174 | totalchance += 2; |
1726 | 1175 | } while (mr.advance(map)); | 1175 | } while (mr.advance(*map)); |
1727 | 1176 | } | 1176 | } |
1728 | 1177 | 1177 | ||
1729 | 1178 | // how much is digged | 1178 | // how much is digged |
1730 | @@ -1193,7 +1193,7 @@ | |||
1731 | 1193 | 1193 | ||
1732 | 1194 | { | 1194 | { |
1733 | 1195 | MapRegion<Area<FCoords>> mr( | 1195 | MapRegion<Area<FCoords>> mr( |
1735 | 1196 | map, Area<FCoords>(map.get_fcoords(ps.get_position()), distance_)); | 1196 | *map, Area<FCoords>(map->get_fcoords(ps.get_position()), distance_)); |
1736 | 1197 | do { | 1197 | do { |
1737 | 1198 | DescriptionIndex fres = mr.location().field->get_resources(); | 1198 | DescriptionIndex fres = mr.location().field->get_resources(); |
1738 | 1199 | ResourceAmount amount = mr.location().field->get_resources_amount(); | 1199 | ResourceAmount amount = mr.location().field->get_resources_amount(); |
1739 | @@ -1206,10 +1206,10 @@ | |||
1740 | 1206 | assert(amount > 0); | 1206 | assert(amount > 0); |
1741 | 1207 | 1207 | ||
1742 | 1208 | --amount; | 1208 | --amount; |
1744 | 1209 | map.set_resources(mr.location(), amount); | 1209 | map->set_resources(mr.location(), amount); |
1745 | 1210 | break; | 1210 | break; |
1746 | 1211 | } | 1211 | } |
1748 | 1212 | } while (mr.advance(map)); | 1212 | } while (mr.advance(*map)); |
1749 | 1213 | } | 1213 | } |
1750 | 1214 | 1214 | ||
1751 | 1215 | if (pick >= 0) { | 1215 | if (pick >= 0) { |
1752 | @@ -1489,10 +1489,11 @@ | |||
1753 | 1489 | } | 1489 | } |
1754 | 1490 | 1490 | ||
1755 | 1491 | // Look for an appropriate object in the given radius | 1491 | // Look for an appropriate object in the given radius |
1756 | 1492 | const Map& map = game.map(); | ||
1757 | 1492 | std::vector<ImmovableFound> immovables; | 1493 | std::vector<ImmovableFound> immovables; |
1758 | 1493 | CheckStepWalkOn cstep(MOVECAPS_WALK, true); | 1494 | CheckStepWalkOn cstep(MOVECAPS_WALK, true); |
1761 | 1494 | Area<FCoords> area(game.map().get_fcoords(psite.base_flag().get_position()), radius); | 1495 | Area<FCoords> area(map.get_fcoords(psite.base_flag().get_position()), radius); |
1762 | 1495 | if (game.map().find_reachable_immovables( | 1496 | if (map.find_reachable_immovables( |
1763 | 1496 | area, &immovables, cstep, FindImmovableByDescr(descr))) { | 1497 | area, &immovables, cstep, FindImmovableByDescr(descr))) { |
1764 | 1497 | state.objvar = immovables[0].object; | 1498 | state.objvar = immovables[0].object; |
1765 | 1498 | 1499 | ||
1766 | @@ -1502,7 +1503,6 @@ | |||
1767 | 1502 | 1503 | ||
1768 | 1503 | // No object found, look for a field where we can build | 1504 | // No object found, look for a field where we can build |
1769 | 1504 | std::vector<Coords> fields; | 1505 | std::vector<Coords> fields; |
1770 | 1505 | Map& map = game.map(); | ||
1771 | 1506 | FindNodeAnd fna; | 1506 | FindNodeAnd fna; |
1772 | 1507 | // 10 is custom value to make sure the "water" is at least 10 nodes big | 1507 | // 10 is custom value to make sure the "water" is at least 10 nodes big |
1773 | 1508 | fna.add(FindNodeShore(10)); | 1508 | fna.add(FindNodeShore(10)); |
1774 | 1509 | 1509 | ||
1775 | === modified file 'src/logic/map_objects/tribes/ship.cc' | |||
1776 | --- src/logic/map_objects/tribes/ship.cc 2017-08-16 14:30:17 +0000 | |||
1777 | +++ src/logic/map_objects/tribes/ship.cc 2017-08-20 12:33:35 +0000 | |||
1778 | @@ -288,7 +288,7 @@ | |||
1779 | 288 | 288 | ||
1780 | 289 | /// updates a ships tasks in transport mode \returns false if failed to update tasks | 289 | /// updates a ships tasks in transport mode \returns false if failed to update tasks |
1781 | 290 | bool Ship::ship_update_transport(Game& game, Bob::State& state) { | 290 | bool Ship::ship_update_transport(Game& game, Bob::State& state) { |
1783 | 291 | Map& map = game.map(); | 291 | const Map& map = game.map(); |
1784 | 292 | 292 | ||
1785 | 293 | PortDock* dst = get_destination(game); | 293 | PortDock* dst = get_destination(game); |
1786 | 294 | if (!dst) { | 294 | if (!dst) { |
1787 | @@ -366,7 +366,7 @@ | |||
1788 | 366 | 366 | ||
1789 | 367 | /// updates a ships tasks in expedition mode | 367 | /// updates a ships tasks in expedition mode |
1790 | 368 | void Ship::ship_update_expedition(Game& game, Bob::State&) { | 368 | void Ship::ship_update_expedition(Game& game, Bob::State&) { |
1792 | 369 | Map& map = game.map(); | 369 | Map* map = game.mutable_map(); |
1793 | 370 | 370 | ||
1794 | 371 | assert(expedition_); | 371 | assert(expedition_); |
1795 | 372 | 372 | ||
1796 | @@ -374,29 +374,29 @@ | |||
1797 | 374 | FCoords position = get_position(); | 374 | FCoords position = get_position(); |
1798 | 375 | for (Direction dir = FIRST_DIRECTION; dir <= LAST_DIRECTION; ++dir) { | 375 | for (Direction dir = FIRST_DIRECTION; dir <= LAST_DIRECTION; ++dir) { |
1799 | 376 | expedition_->swimmable[dir - 1] = | 376 | expedition_->swimmable[dir - 1] = |
1801 | 377 | map.get_neighbour(position, dir).field->nodecaps() & MOVECAPS_SWIM; | 377 | map->get_neighbour(position, dir).field->nodecaps() & MOVECAPS_SWIM; |
1802 | 378 | } | 378 | } |
1803 | 379 | 379 | ||
1804 | 380 | if (ship_state_ == ShipStates::kExpeditionScouting) { | 380 | if (ship_state_ == ShipStates::kExpeditionScouting) { |
1805 | 381 | // Check surrounding fields for port buildspaces | 381 | // Check surrounding fields for port buildspaces |
1806 | 382 | std::vector<Coords> temp_port_buildspaces; | 382 | std::vector<Coords> temp_port_buildspaces; |
1808 | 383 | MapRegion<Area<Coords>> mr(map, Area<Coords>(position, descr().vision_range())); | 383 | MapRegion<Area<Coords>> mr(*map, Area<Coords>(position, descr().vision_range())); |
1809 | 384 | bool new_port_space = false; | 384 | bool new_port_space = false; |
1810 | 385 | do { | 385 | do { |
1812 | 386 | if (!map.is_port_space(mr.location())) { | 386 | if (!map->is_port_space(mr.location())) { |
1813 | 387 | continue; | 387 | continue; |
1814 | 388 | } | 388 | } |
1815 | 389 | 389 | ||
1817 | 390 | const FCoords fc = map.get_fcoords(mr.location()); | 390 | const FCoords fc = map->get_fcoords(mr.location()); |
1818 | 391 | 391 | ||
1819 | 392 | // Check whether the maximum theoretical possible NodeCap of the field | 392 | // Check whether the maximum theoretical possible NodeCap of the field |
1820 | 393 | // is of the size big and whether it can theoretically be a port space | 393 | // is of the size big and whether it can theoretically be a port space |
1823 | 394 | if ((map.get_max_nodecaps(game.world(), fc) & BUILDCAPS_SIZEMASK) != BUILDCAPS_BIG || | 394 | if ((map->get_max_nodecaps(game.world(), fc) & BUILDCAPS_SIZEMASK) != BUILDCAPS_BIG || |
1824 | 395 | map.find_portdock(fc).empty()) { | 395 | map->find_portdock(fc).empty()) { |
1825 | 396 | continue; | 396 | continue; |
1826 | 397 | } | 397 | } |
1827 | 398 | 398 | ||
1829 | 399 | if (!can_build_port_here(get_owner()->player_number(), map, fc)) { | 399 | if (!can_build_port_here(get_owner()->player_number(), *map, fc)) { |
1830 | 400 | continue; | 400 | continue; |
1831 | 401 | } | 401 | } |
1832 | 402 | 402 | ||
1833 | @@ -409,7 +409,7 @@ | |||
1834 | 409 | new_port_space = true; | 409 | new_port_space = true; |
1835 | 410 | temp_port_buildspaces.insert(temp_port_buildspaces.begin(), mr.location()); | 410 | temp_port_buildspaces.insert(temp_port_buildspaces.begin(), mr.location()); |
1836 | 411 | } | 411 | } |
1838 | 412 | } while (mr.advance(map)); | 412 | } while (mr.advance(*map)); |
1839 | 413 | 413 | ||
1840 | 414 | if (new_port_space) { | 414 | if (new_port_space) { |
1841 | 415 | ship_state_ = ShipStates::kExpeditionPortspaceFound; | 415 | ship_state_ = ShipStates::kExpeditionPortspaceFound; |
1842 | @@ -438,10 +438,10 @@ | |||
1843 | 438 | 438 | ||
1844 | 439 | // If we are waiting for the next transport job, check if we should move away from ships and | 439 | // If we are waiting for the next transport job, check if we should move away from ships and |
1845 | 440 | // shores | 440 | // shores |
1846 | 441 | const Map& map = game.map(); | ||
1847 | 441 | switch (ship_state_) { | 442 | switch (ship_state_) { |
1848 | 442 | case ShipStates::kTransport: { | 443 | case ShipStates::kTransport: { |
1849 | 443 | FCoords position = get_position(); | 444 | FCoords position = get_position(); |
1850 | 444 | Map& map = game.map(); | ||
1851 | 445 | unsigned int dirs[LAST_DIRECTION + 1]; | 445 | unsigned int dirs[LAST_DIRECTION + 1]; |
1852 | 446 | unsigned int dirmax = 0; | 446 | unsigned int dirmax = 0; |
1853 | 447 | 447 | ||
1854 | @@ -569,7 +569,6 @@ | |||
1855 | 569 | // Most likely the command was send as the ship was on an exploration and just leaving | 569 | // Most likely the command was send as the ship was on an exploration and just leaving |
1856 | 570 | // the island - therefore we try to find the island again. | 570 | // the island - therefore we try to find the island again. |
1857 | 571 | FCoords position = get_position(); | 571 | FCoords position = get_position(); |
1858 | 572 | Map& map = game.map(); | ||
1859 | 573 | for (uint8_t dir = FIRST_DIRECTION; dir <= LAST_DIRECTION; ++dir) { | 572 | for (uint8_t dir = FIRST_DIRECTION; dir <= LAST_DIRECTION; ++dir) { |
1860 | 574 | FCoords neighbour = map.get_neighbour(position, dir); | 573 | FCoords neighbour = map.get_neighbour(position, dir); |
1861 | 575 | for (uint8_t sur = FIRST_DIRECTION; sur <= LAST_DIRECTION; ++sur) | 574 | for (uint8_t sur = FIRST_DIRECTION; sur <= LAST_DIRECTION; ++sur) |
1862 | @@ -612,7 +611,7 @@ | |||
1863 | 612 | } | 611 | } |
1864 | 613 | case ShipStates::kExpeditionColonizing: { | 612 | case ShipStates::kExpeditionColonizing: { |
1865 | 614 | assert(!expedition_->seen_port_buildspaces.empty()); | 613 | assert(!expedition_->seen_port_buildspaces.empty()); |
1867 | 615 | BaseImmovable* baim = game.map()[expedition_->seen_port_buildspaces.front()].get_immovable(); | 614 | BaseImmovable* baim = map[expedition_->seen_port_buildspaces.front()].get_immovable(); |
1868 | 616 | if (baim) { | 615 | if (baim) { |
1869 | 617 | upcast(ConstructionSite, cs, baim); | 616 | upcast(ConstructionSite, cs, baim); |
1870 | 618 | 617 | ||
1871 | @@ -742,13 +741,13 @@ | |||
1872 | 742 | * Find a path to the dock @p pd, returns its length, and the path optionally. | 741 | * Find a path to the dock @p pd, returns its length, and the path optionally. |
1873 | 743 | */ | 742 | */ |
1874 | 744 | uint32_t Ship::calculate_sea_route(Game& game, PortDock& pd, Path* finalpath) const { | 743 | uint32_t Ship::calculate_sea_route(Game& game, PortDock& pd, Path* finalpath) const { |
1876 | 745 | Map& map = game.map(); | 744 | Map* map = game.mutable_map(); |
1877 | 746 | StepEvalAStar se(pd.get_warehouse()->get_position()); | 745 | StepEvalAStar se(pd.get_warehouse()->get_position()); |
1878 | 747 | se.swim_ = true; | 746 | se.swim_ = true; |
1879 | 748 | se.conservative_ = false; | 747 | se.conservative_ = false; |
1881 | 749 | se.estimator_bias_ = -5 * map.calc_cost(0); | 748 | se.estimator_bias_ = -5 * map->calc_cost(0); |
1882 | 750 | 749 | ||
1884 | 751 | MapAStar<StepEvalAStar> astar(map, se); | 750 | MapAStar<StepEvalAStar> astar(*map, se); |
1885 | 752 | 751 | ||
1886 | 753 | astar.push(get_position()); | 752 | astar.push(get_position()); |
1887 | 754 | 753 | ||
1888 | 755 | 754 | ||
1889 | === modified file 'src/logic/map_objects/tribes/soldier.cc' | |||
1890 | --- src/logic/map_objects/tribes/soldier.cc 2017-07-05 19:21:57 +0000 | |||
1891 | +++ src/logic/map_objects/tribes/soldier.cc 2017-08-20 12:33:35 +0000 | |||
1892 | @@ -735,6 +735,7 @@ | |||
1893 | 735 | upcast(Building, enemy, state.objvar1.get(game)); | 735 | upcast(Building, enemy, state.objvar1.get(game)); |
1894 | 736 | 736 | ||
1895 | 737 | // Handle returns | 737 | // Handle returns |
1896 | 738 | const Map& map = game.map(); | ||
1897 | 738 | if (state.ivar2 > 0) { | 739 | if (state.ivar2 > 0) { |
1898 | 739 | if (state.ivar2 == 1) { | 740 | if (state.ivar2 == 1) { |
1899 | 740 | // Return home | 741 | // Return home |
1900 | @@ -774,7 +775,7 @@ | |||
1901 | 774 | } | 775 | } |
1902 | 775 | if (state.ivar2 == 2) { | 776 | if (state.ivar2 == 2) { |
1903 | 776 | // No more home, so return to homeland | 777 | // No more home, so return to homeland |
1905 | 777 | upcast(Flag, flag, game.map().get_immovable(get_position())); | 778 | upcast(Flag, flag, map.get_immovable(get_position())); |
1906 | 778 | if (flag && flag->get_owner() == get_owner()) { | 779 | if (flag && flag->get_owner() == get_owner()) { |
1907 | 779 | // At a flag | 780 | // At a flag |
1908 | 780 | molog("[attack] Returned to own flag\n"); | 781 | molog("[attack] Returned to own flag\n"); |
1909 | @@ -793,11 +794,10 @@ | |||
1910 | 793 | return pop_task(game); | 794 | return pop_task(game); |
1911 | 794 | } | 795 | } |
1912 | 795 | // Try to find our land | 796 | // Try to find our land |
1913 | 796 | Map* map = game.get_map(); | ||
1914 | 797 | std::vector<Coords> coords; | 797 | std::vector<Coords> coords; |
1915 | 798 | uint32_t maxdist = descr().vision_range() * 2; | 798 | uint32_t maxdist = descr().vision_range() * 2; |
1918 | 799 | Area<FCoords> area(map->get_fcoords(get_position()), maxdist); | 799 | Area<FCoords> area(map.get_fcoords(get_position()), maxdist); |
1919 | 800 | if (map->find_reachable_fields(area, &coords, CheckStepDefault(descr().movecaps()), | 800 | if (map.find_reachable_fields(area, &coords, CheckStepDefault(descr().movecaps()), |
1920 | 801 | FindNodeOwned(get_owner()->player_number()))) { | 801 | FindNodeOwned(get_owner()->player_number()))) { |
1921 | 802 | // Found home land | 802 | // Found home land |
1922 | 803 | target = coords.front(); | 803 | target = coords.front(); |
1923 | @@ -842,8 +842,8 @@ | |||
1924 | 842 | } | 842 | } |
1925 | 843 | // Any enemy soldier at baseflag count as defender. | 843 | // Any enemy soldier at baseflag count as defender. |
1926 | 844 | std::vector<Bob*> soldiers; | 844 | std::vector<Bob*> soldiers; |
1929 | 845 | game.map().find_bobs( | 845 | map.find_bobs( |
1930 | 846 | Area<FCoords>(game.map().get_fcoords(enemy->base_flag().get_position()), 0), &soldiers, | 846 | Area<FCoords>(map.get_fcoords(enemy->base_flag().get_position()), 0), &soldiers, |
1931 | 847 | FindBobEnemySoldier(get_owner())); | 847 | FindBobEnemySoldier(get_owner())); |
1932 | 848 | defenders += soldiers.size(); | 848 | defenders += soldiers.size(); |
1933 | 849 | } | 849 | } |
1934 | @@ -862,7 +862,7 @@ | |||
1935 | 862 | // valid anymore, we either "conquered" the new building, or it was | 862 | // valid anymore, we either "conquered" the new building, or it was |
1936 | 863 | // destroyed. | 863 | // destroyed. |
1937 | 864 | if (state.coords) { | 864 | if (state.coords) { |
1939 | 865 | BaseImmovable* const newimm = game.map()[state.coords].get_immovable(); | 865 | BaseImmovable* const newimm = map[state.coords].get_immovable(); |
1940 | 866 | upcast(MilitarySite, newsite, newimm); | 866 | upcast(MilitarySite, newsite, newimm); |
1941 | 867 | if (newsite && (&newsite->owner() == &owner())) { | 867 | if (newsite && (&newsite->owner() == &owner())) { |
1942 | 868 | const SoldierControl* soldier_control = newsite->soldier_control(); | 868 | const SoldierControl* soldier_control = newsite->soldier_control(); |
1943 | @@ -1182,7 +1182,7 @@ | |||
1944 | 1182 | throw GameDataError("bad direction '%d'", dir); | 1182 | throw GameDataError("bad direction '%d'", dir); |
1945 | 1183 | } | 1183 | } |
1946 | 1184 | 1184 | ||
1948 | 1185 | Map& map = game.map(); | 1185 | const Map& map = game.map(); |
1949 | 1186 | int32_t const tdelta = (map.calc_cost(get_position(), mapdir)) / 2; | 1186 | int32_t const tdelta = (map.calc_cost(get_position(), mapdir)) / 2; |
1950 | 1187 | molog("[move_in_battle] dir: (%d) tdelta: (%d)\n", dir, tdelta); | 1187 | molog("[move_in_battle] dir: (%d) tdelta: (%d)\n", dir, tdelta); |
1951 | 1188 | combat_walking_ = dir; | 1188 | combat_walking_ = dir; |
1952 | @@ -1275,7 +1275,7 @@ | |||
1953 | 1275 | return pop_task(game); | 1275 | return pop_task(game); |
1954 | 1276 | } | 1276 | } |
1955 | 1277 | 1277 | ||
1957 | 1278 | Map& map = game.map(); | 1278 | const Map& map = game.map(); |
1958 | 1279 | Soldier& opponent = *battle_->opponent(*this); | 1279 | Soldier& opponent = *battle_->opponent(*this); |
1959 | 1280 | if (opponent.get_position() != get_position()) { | 1280 | if (opponent.get_position() != get_position()) { |
1960 | 1281 | if (is_a(Building, map[get_position()].get_immovable())) { | 1281 | if (is_a(Building, map[get_position()].get_immovable())) { |
1961 | 1282 | 1282 | ||
1962 | === modified file 'src/logic/map_objects/tribes/warehouse.cc' | |||
1963 | --- src/logic/map_objects/tribes/warehouse.cc 2017-07-01 15:36:36 +0000 | |||
1964 | +++ src/logic/map_objects/tribes/warehouse.cc 2017-08-20 12:33:35 +0000 | |||
1965 | @@ -80,13 +80,13 @@ | |||
1966 | 80 | 80 | ||
1967 | 81 | Player& owner = warehouse_->owner(); | 81 | Player& owner = warehouse_->owner(); |
1968 | 82 | Game& game = dynamic_cast<Game&>(owner.egbase()); | 82 | Game& game = dynamic_cast<Game&>(owner.egbase()); |
1970 | 83 | Map& map = game.map(); | 83 | const Map& map = game.map(); |
1971 | 84 | if (enemy.get_owner() == &owner || enemy.get_battle() || | 84 | if (enemy.get_owner() == &owner || enemy.get_battle() || |
1972 | 85 | warehouse_->descr().get_conquers() <= | 85 | warehouse_->descr().get_conquers() <= |
1973 | 86 | map.calc_distance(enemy.get_position(), warehouse_->get_position())) | 86 | map.calc_distance(enemy.get_position(), warehouse_->get_position())) |
1974 | 87 | return; | 87 | return; |
1975 | 88 | 88 | ||
1977 | 89 | if (game.map().find_bobs( | 89 | if (map.find_bobs( |
1978 | 90 | Area<FCoords>(map.get_fcoords(warehouse_->base_flag().get_position()), 2), nullptr, | 90 | Area<FCoords>(map.get_fcoords(warehouse_->base_flag().get_position()), 2), nullptr, |
1979 | 91 | FindBobEnemySoldier(&owner))) | 91 | FindBobEnemySoldier(&owner))) |
1980 | 92 | return; | 92 | return; |
1981 | @@ -581,8 +581,7 @@ | |||
1982 | 581 | void Warehouse::init_portdock(EditorGameBase& egbase) { | 581 | void Warehouse::init_portdock(EditorGameBase& egbase) { |
1983 | 582 | molog("Setting up port dock fields\n"); | 582 | molog("Setting up port dock fields\n"); |
1984 | 583 | 583 | ||
1987 | 584 | Map& map = egbase.map(); | 584 | std::vector<Coords> dock = egbase.map().find_portdock(get_position()); |
1986 | 585 | std::vector<Coords> dock = map.find_portdock(get_position()); | ||
1988 | 586 | if (dock.empty()) { | 585 | if (dock.empty()) { |
1989 | 587 | log("Attempting to setup port without neighboring water (coords: %3dx%3d).\n", | 586 | log("Attempting to setup port without neighboring water (coords: %3dx%3d).\n", |
1990 | 588 | get_position().x, get_position().y); | 587 | get_position().x, get_position().y); |
1991 | @@ -670,7 +669,7 @@ | |||
1992 | 670 | planned_workers_.pop_back(); | 669 | planned_workers_.pop_back(); |
1993 | 671 | } | 670 | } |
1994 | 672 | 671 | ||
1996 | 673 | Map& map = egbase.map(); | 672 | const Map& map = egbase.map(); |
1997 | 674 | if (const uint32_t conquer_radius = descr().get_conquers()) | 673 | if (const uint32_t conquer_radius = descr().get_conquers()) |
1998 | 675 | egbase.unconquer_area( | 674 | egbase.unconquer_area( |
1999 | 676 | PlayerArea<Area<FCoords>>(owner().player_number(), | 675 | PlayerArea<Area<FCoords>>(owner().player_number(), |
2000 | 677 | 676 | ||
2001 | === modified file 'src/logic/map_objects/tribes/worker.cc' | |||
2002 | --- src/logic/map_objects/tribes/worker.cc 2017-07-07 11:19:07 +0000 | |||
2003 | +++ src/logic/map_objects/tribes/worker.cc 2017-08-20 12:33:35 +0000 | |||
2004 | @@ -106,7 +106,7 @@ | |||
2005 | 106 | */ | 106 | */ |
2006 | 107 | // TODO(unknown): Lots of magic numbers in here | 107 | // TODO(unknown): Lots of magic numbers in here |
2007 | 108 | bool Worker::run_mine(Game& game, State& state, const Action& action) { | 108 | bool Worker::run_mine(Game& game, State& state, const Action& action) { |
2009 | 109 | Map& map = game.map(); | 109 | Map* map = game.mutable_map(); |
2010 | 110 | 110 | ||
2011 | 111 | // Make sure that the specified resource is available in this world | 111 | // Make sure that the specified resource is available in this world |
2012 | 112 | DescriptionIndex const res = game.world().get_resource(action.sparam1.c_str()); | 112 | DescriptionIndex const res = game.world().get_resource(action.sparam1.c_str()); |
2013 | @@ -119,7 +119,7 @@ | |||
2014 | 119 | uint32_t totalres = 0; | 119 | uint32_t totalres = 0; |
2015 | 120 | uint32_t totalchance = 0; | 120 | uint32_t totalchance = 0; |
2016 | 121 | int32_t pick; | 121 | int32_t pick; |
2018 | 122 | MapRegion<Area<FCoords>> mr(map, Area<FCoords>(map.get_fcoords(get_position()), action.iparam1)); | 122 | MapRegion<Area<FCoords>> mr(*map, Area<FCoords>(map->get_fcoords(get_position()), action.iparam1)); |
2019 | 123 | do { | 123 | do { |
2020 | 124 | DescriptionIndex fres = mr.location().field->get_resources(); | 124 | DescriptionIndex fres = mr.location().field->get_resources(); |
2021 | 125 | ResourceAmount amount = mr.location().field->get_resources_amount(); | 125 | ResourceAmount amount = mr.location().field->get_resources_amount(); |
2022 | @@ -143,7 +143,7 @@ | |||
2023 | 143 | totalchance += 4; | 143 | totalchance += 4; |
2024 | 144 | else if (amount <= 6) | 144 | else if (amount <= 6) |
2025 | 145 | totalchance += 2; | 145 | totalchance += 2; |
2027 | 146 | } while (mr.advance(map)); | 146 | } while (mr.advance(*map)); |
2028 | 147 | 147 | ||
2029 | 148 | if (totalres == 0) { | 148 | if (totalres == 0) { |
2030 | 149 | molog(" Run out of resources\n"); | 149 | molog(" Run out of resources\n"); |
2031 | @@ -155,7 +155,7 @@ | |||
2032 | 155 | // Second pass through fields - reset mr | 155 | // Second pass through fields - reset mr |
2033 | 156 | pick = game.logic_rand() % totalchance; | 156 | pick = game.logic_rand() % totalchance; |
2034 | 157 | mr = | 157 | mr = |
2036 | 158 | MapRegion<Area<FCoords>>(map, Area<FCoords>(map.get_fcoords(get_position()), action.iparam1)); | 158 | MapRegion<Area<FCoords>>(*map, Area<FCoords>(map->get_fcoords(get_position()), action.iparam1)); |
2037 | 159 | do { | 159 | do { |
2038 | 160 | DescriptionIndex fres = mr.location().field->get_resources(); | 160 | DescriptionIndex fres = mr.location().field->get_resources(); |
2039 | 161 | if (fres != res) { | 161 | if (fres != res) { |
2040 | @@ -169,10 +169,10 @@ | |||
2041 | 169 | assert(amount > 0); | 169 | assert(amount > 0); |
2042 | 170 | 170 | ||
2043 | 171 | --amount; | 171 | --amount; |
2045 | 172 | map.set_resources(mr.location(), amount); | 172 | map->set_resources(mr.location(), amount); |
2046 | 173 | break; | 173 | break; |
2047 | 174 | } | 174 | } |
2049 | 175 | } while (mr.advance(map)); | 175 | } while (mr.advance(*map)); |
2050 | 176 | 176 | ||
2051 | 177 | if (pick >= 0) { | 177 | if (pick >= 0) { |
2052 | 178 | molog(" Not successful this time\n"); | 178 | molog(" Not successful this time\n"); |
2053 | @@ -206,7 +206,7 @@ | |||
2054 | 206 | bool Worker::run_breed(Game& game, State& state, const Action& action) { | 206 | bool Worker::run_breed(Game& game, State& state, const Action& action) { |
2055 | 207 | molog(" Breed(%s, %i)\n", action.sparam1.c_str(), action.iparam1); | 207 | molog(" Breed(%s, %i)\n", action.sparam1.c_str(), action.iparam1); |
2056 | 208 | 208 | ||
2058 | 209 | Map& map = game.map(); | 209 | Map* map = game.mutable_map(); |
2059 | 210 | 210 | ||
2060 | 211 | // Make sure that the specified resource is available in this world | 211 | // Make sure that the specified resource is available in this world |
2061 | 212 | DescriptionIndex const res = game.world().get_resource(action.sparam1.c_str()); | 212 | DescriptionIndex const res = game.world().get_resource(action.sparam1.c_str()); |
2062 | @@ -219,7 +219,7 @@ | |||
2063 | 219 | uint32_t totalres = 0; | 219 | uint32_t totalres = 0; |
2064 | 220 | uint32_t totalchance = 0; | 220 | uint32_t totalchance = 0; |
2065 | 221 | int32_t pick; | 221 | int32_t pick; |
2067 | 222 | MapRegion<Area<FCoords>> mr(map, Area<FCoords>(map.get_fcoords(get_position()), action.iparam1)); | 222 | MapRegion<Area<FCoords>> mr(*map, Area<FCoords>(map->get_fcoords(get_position()), action.iparam1)); |
2068 | 223 | do { | 223 | do { |
2069 | 224 | DescriptionIndex fres = mr.location().field->get_resources(); | 224 | DescriptionIndex fres = mr.location().field->get_resources(); |
2070 | 225 | ResourceAmount amount = mr.location().field->get_initial_res_amount() - | 225 | ResourceAmount amount = mr.location().field->get_initial_res_amount() - |
2071 | @@ -244,7 +244,7 @@ | |||
2072 | 244 | totalchance += 4; | 244 | totalchance += 4; |
2073 | 245 | else if (amount <= 6) | 245 | else if (amount <= 6) |
2074 | 246 | totalchance += 2; | 246 | totalchance += 2; |
2076 | 247 | } while (mr.advance(map)); | 247 | } while (mr.advance(*map)); |
2077 | 248 | 248 | ||
2078 | 249 | if (totalres == 0) { | 249 | if (totalres == 0) { |
2079 | 250 | molog(" All resources full\n"); | 250 | molog(" All resources full\n"); |
2080 | @@ -257,7 +257,7 @@ | |||
2081 | 257 | assert(totalchance); | 257 | assert(totalchance); |
2082 | 258 | pick = game.logic_rand() % totalchance; | 258 | pick = game.logic_rand() % totalchance; |
2083 | 259 | mr = | 259 | mr = |
2085 | 260 | MapRegion<Area<FCoords>>(map, Area<FCoords>(map.get_fcoords(get_position()), action.iparam1)); | 260 | MapRegion<Area<FCoords>>(*map, Area<FCoords>(map->get_fcoords(get_position()), action.iparam1)); |
2086 | 261 | 261 | ||
2087 | 262 | do { | 262 | do { |
2088 | 263 | DescriptionIndex fres = mr.location().field->get_resources(); | 263 | DescriptionIndex fres = mr.location().field->get_resources(); |
2089 | @@ -272,10 +272,10 @@ | |||
2090 | 272 | assert(amount > 0); | 272 | assert(amount > 0); |
2091 | 273 | 273 | ||
2092 | 274 | --amount; | 274 | --amount; |
2094 | 275 | map.set_resources(mr.location(), mr.location().field->get_initial_res_amount() - amount); | 275 | map->set_resources(mr.location(), mr.location().field->get_initial_res_amount() - amount); |
2095 | 276 | break; | 276 | break; |
2096 | 277 | } | 277 | } |
2098 | 278 | } while (mr.advance(map)); | 278 | } while (mr.advance(*map)); |
2099 | 279 | 279 | ||
2100 | 280 | if (pick >= 0) { | 280 | if (pick >= 0) { |
2101 | 281 | molog(" Not successful this time\n"); | 281 | molog(" Not successful this time\n"); |
2102 | @@ -341,7 +341,7 @@ | |||
2103 | 341 | bool Worker::run_findobject(Game& game, State& state, const Action& action) { | 341 | bool Worker::run_findobject(Game& game, State& state, const Action& action) { |
2104 | 342 | CheckStepWalkOn cstep(descr().movecaps(), false); | 342 | CheckStepWalkOn cstep(descr().movecaps(), false); |
2105 | 343 | 343 | ||
2107 | 344 | Map& map = game.map(); | 344 | const Map& map = game.map(); |
2108 | 345 | Area<FCoords> area(map.get_fcoords(get_position()), 0); | 345 | Area<FCoords> area(map.get_fcoords(get_position()), 0); |
2109 | 346 | bool found_reserved = false; | 346 | bool found_reserved = false; |
2110 | 347 | 347 | ||
2111 | @@ -486,7 +486,7 @@ | |||
2112 | 486 | 486 | ||
2113 | 487 | bool Worker::run_findspace(Game& game, State& state, const Action& action) { | 487 | bool Worker::run_findspace(Game& game, State& state, const Action& action) { |
2114 | 488 | std::vector<Coords> list; | 488 | std::vector<Coords> list; |
2116 | 489 | Map& map = game.map(); | 489 | const Map& map = game.map(); |
2117 | 490 | const World& world = game.world(); | 490 | const World& world = game.world(); |
2118 | 491 | 491 | ||
2119 | 492 | CheckStepDefault cstep(descr().movecaps()); | 492 | CheckStepDefault cstep(descr().movecaps()); |
2120 | @@ -706,7 +706,7 @@ | |||
2121 | 706 | } | 706 | } |
2122 | 707 | } | 707 | } |
2123 | 708 | 708 | ||
2125 | 709 | Map& map = game.map(); | 709 | const Map& map = game.map(); |
2126 | 710 | Coords pos = get_position(); | 710 | Coords pos = get_position(); |
2127 | 711 | FCoords fpos = map.get_fcoords(pos); | 711 | FCoords fpos = map.get_fcoords(pos); |
2128 | 712 | 712 | ||
2129 | @@ -863,8 +863,7 @@ | |||
2130 | 863 | * possible. | 863 | * possible. |
2131 | 864 | */ | 864 | */ |
2132 | 865 | bool Worker::run_geologist_find(Game& game, State& state, const Action&) { | 865 | bool Worker::run_geologist_find(Game& game, State& state, const Action&) { |
2135 | 866 | const Map& map = game.map(); | 866 | const FCoords position = game.map().get_fcoords(get_position()); |
2134 | 867 | const FCoords position = map.get_fcoords(get_position()); | ||
2136 | 868 | BaseImmovable const* const imm = position.field->get_immovable(); | 867 | BaseImmovable const* const imm = position.field->get_immovable(); |
2137 | 869 | const World& world = game.world(); | 868 | const World& world = game.world(); |
2138 | 870 | 869 | ||
2139 | @@ -1285,7 +1284,7 @@ | |||
2140 | 1285 | } | 1284 | } |
2141 | 1286 | 1285 | ||
2142 | 1287 | void Worker::transfer_update(Game& game, State& /* state */) { | 1286 | void Worker::transfer_update(Game& game, State& /* state */) { |
2144 | 1288 | Map& map = game.map(); | 1287 | const Map& map = game.map(); |
2145 | 1289 | PlayerImmovable* location = get_location(game); | 1288 | PlayerImmovable* location = get_location(game); |
2146 | 1290 | 1289 | ||
2147 | 1291 | // We expect to always have a location at this point, | 1290 | // We expect to always have a location at this point, |
2148 | @@ -2235,7 +2234,7 @@ | |||
2149 | 2235 | return pop_task(game); | 2234 | return pop_task(game); |
2150 | 2236 | } | 2235 | } |
2151 | 2237 | 2236 | ||
2153 | 2238 | Map& map = game.map(); | 2237 | const Map& map = game.map(); |
2154 | 2239 | PlayerImmovable const* location = get_location(game); | 2238 | PlayerImmovable const* location = get_location(game); |
2155 | 2240 | 2239 | ||
2156 | 2241 | if (location && &location->owner() == &owner()) { | 2240 | if (location && &location->owner() == &owner()) { |
2157 | @@ -2354,7 +2353,7 @@ | |||
2158 | 2354 | } | 2353 | } |
2159 | 2355 | 2354 | ||
2160 | 2356 | // | 2355 | // |
2162 | 2357 | Map& map = game.map(); | 2356 | const Map& map = game.map(); |
2163 | 2358 | const World& world = game.world(); | 2357 | const World& world = game.world(); |
2164 | 2359 | Area<FCoords> owner_area( | 2358 | Area<FCoords> owner_area( |
2165 | 2360 | map.get_fcoords(dynamic_cast<Flag&>(*get_location(game)).get_position()), state.ivar2); | 2359 | map.get_fcoords(dynamic_cast<Flag&>(*get_location(game)).get_position()), state.ivar2); |
2166 | @@ -2482,7 +2481,7 @@ | |||
2167 | 2482 | return pop_task(game); | 2481 | return pop_task(game); |
2168 | 2483 | } | 2482 | } |
2169 | 2484 | 2483 | ||
2171 | 2485 | Map& map = game.map(); | 2484 | const Map& map = game.map(); |
2172 | 2486 | 2485 | ||
2173 | 2487 | // If not yet time to go home | 2486 | // If not yet time to go home |
2174 | 2488 | if (static_cast<int32_t>(state.ivar2 - game.get_gametime()) > 0) { | 2487 | if (static_cast<int32_t>(state.ivar2 - game.get_gametime()) > 0) { |
2175 | 2489 | 2488 | ||
2176 | === modified file 'src/logic/player.cc' | |||
2177 | --- src/logic/player.cc 2017-08-16 04:31:56 +0000 | |||
2178 | +++ src/logic/player.cc 2017-08-20 12:33:35 +0000 | |||
2179 | @@ -60,7 +60,7 @@ | |||
2180 | 60 | const Widelands::PlayerNumber player_number, | 60 | const Widelands::PlayerNumber player_number, |
2181 | 61 | const Widelands::Coords& location, | 61 | const Widelands::Coords& location, |
2182 | 62 | const Widelands::BuildingDescr* descr) { | 62 | const Widelands::BuildingDescr* descr) { |
2184 | 63 | Widelands::Map& map = egbase.map(); | 63 | const Widelands::Map& map = egbase.map(); |
2185 | 64 | Widelands::FCoords c[4]; // Big buildings occupy 4 locations. | 64 | Widelands::FCoords c[4]; // Big buildings occupy 4 locations. |
2186 | 65 | c[0] = map.get_fcoords(location); | 65 | c[0] = map.get_fcoords(location); |
2187 | 66 | map.get_brn(c[0], &c[1]); | 66 | map.get_brn(c[0], &c[1]); |
2188 | @@ -412,7 +412,7 @@ | |||
2189 | 412 | =============== | 412 | =============== |
2190 | 413 | */ | 413 | */ |
2191 | 414 | Road* Player::build_road(const Path& path) { | 414 | Road* Player::build_road(const Path& path) { |
2193 | 415 | Map& map = egbase().map(); | 415 | const Map& map = egbase().map(); |
2194 | 416 | FCoords fc = map.get_fcoords(path.get_start()); | 416 | FCoords fc = map.get_fcoords(path.get_start()); |
2195 | 417 | if (upcast(Flag, start, fc.field->get_immovable())) { | 417 | if (upcast(Flag, start, fc.field->get_immovable())) { |
2196 | 418 | if (upcast(Flag, end, map.get_immovable(path.get_end()))) { | 418 | if (upcast(Flag, end, map.get_immovable(path.get_end()))) { |
2197 | @@ -441,7 +441,7 @@ | |||
2198 | 441 | } | 441 | } |
2199 | 442 | 442 | ||
2200 | 443 | Road& Player::force_road(const Path& path) { | 443 | Road& Player::force_road(const Path& path) { |
2202 | 444 | Map& map = egbase().map(); | 444 | const Map& map = egbase().map(); |
2203 | 445 | FCoords c = map.get_fcoords(path.get_start()); | 445 | FCoords c = map.get_fcoords(path.get_start()); |
2204 | 446 | Flag& start = force_flag(c); | 446 | Flag& start = force_flag(c); |
2205 | 447 | Flag& end = force_flag(map.get_fcoords(path.get_end())); | 447 | Flag& end = force_flag(map.get_fcoords(path.get_end())); |
2206 | @@ -466,7 +466,7 @@ | |||
2207 | 466 | 466 | ||
2208 | 467 | Building& Player::force_building(Coords const location, | 467 | Building& Player::force_building(Coords const location, |
2209 | 468 | const BuildingDescr::FormerBuildings& former_buildings) { | 468 | const BuildingDescr::FormerBuildings& former_buildings) { |
2211 | 469 | Map& map = egbase().map(); | 469 | const Map& map = egbase().map(); |
2212 | 470 | DescriptionIndex idx = former_buildings.back(); | 470 | DescriptionIndex idx = former_buildings.back(); |
2213 | 471 | const BuildingDescr* descr = egbase().tribes().get_building_descr(idx); | 471 | const BuildingDescr* descr = egbase().tribes().get_building_descr(idx); |
2214 | 472 | terraform_for_building(egbase(), player_number(), location, descr); | 472 | terraform_for_building(egbase(), player_number(), location, descr); |
2215 | @@ -481,7 +481,7 @@ | |||
2216 | 481 | DescriptionIndex b_idx, | 481 | DescriptionIndex b_idx, |
2217 | 482 | const BuildingDescr::FormerBuildings& former_buildings) { | 482 | const BuildingDescr::FormerBuildings& former_buildings) { |
2218 | 483 | EditorGameBase& eg = egbase(); | 483 | EditorGameBase& eg = egbase(); |
2220 | 484 | Map& map = eg.map(); | 484 | const Map& map = eg.map(); |
2221 | 485 | const Tribes& tribes = eg.tribes(); | 485 | const Tribes& tribes = eg.tribes(); |
2222 | 486 | const PlayerNumber pn = player_number(); | 486 | const PlayerNumber pn = player_number(); |
2223 | 487 | 487 | ||
2224 | @@ -833,7 +833,7 @@ | |||
2225 | 833 | if (soldiers) | 833 | if (soldiers) |
2226 | 834 | soldiers->clear(); | 834 | soldiers->clear(); |
2227 | 835 | 835 | ||
2229 | 836 | Map& map = egbase().map(); | 836 | const Map& map = egbase().map(); |
2230 | 837 | std::vector<BaseImmovable*> flags; | 837 | std::vector<BaseImmovable*> flags; |
2231 | 838 | 838 | ||
2232 | 839 | map.find_reachable_immovables_unique(Area<FCoords>(map.get_fcoords(flag.get_position()), 25), | 839 | map.find_reachable_immovables_unique(Area<FCoords>(map.get_fcoords(flag.get_position()), 25), |
2233 | 840 | 840 | ||
2234 | === modified file 'src/logic/replay_game_controller.cc' | |||
2235 | --- src/logic/replay_game_controller.cc 2017-06-24 10:38:19 +0000 | |||
2236 | +++ src/logic/replay_game_controller.cc 2017-08-20 12:33:35 +0000 | |||
2237 | @@ -31,9 +31,6 @@ | |||
2238 | 31 | speed_(1000), | 31 | speed_(1000), |
2239 | 32 | paused_(false) { | 32 | paused_(false) { |
2240 | 33 | game_.set_game_controller(this); | 33 | game_.set_game_controller(this); |
2241 | 34 | |||
2242 | 35 | // We have to create an empty map, otherwise nothing will load properly | ||
2243 | 36 | game.set_map(new Widelands::Map); | ||
2244 | 37 | replayreader_.reset(new Widelands::ReplayReader(game_, filename)); | 34 | replayreader_.reset(new Widelands::ReplayReader(game_, filename)); |
2245 | 38 | } | 35 | } |
2246 | 39 | 36 | ||
2247 | 40 | 37 | ||
2248 | === modified file 'src/map_io/map_bob_packet.cc' | |||
2249 | --- src/map_io/map_bob_packet.cc 2017-01-25 18:55:59 +0000 | |||
2250 | +++ src/map_io/map_bob_packet.cc 2017-08-20 12:33:35 +0000 | |||
2251 | @@ -75,13 +75,13 @@ | |||
2252 | 75 | FileRead fr; | 75 | FileRead fr; |
2253 | 76 | fr.open(fs, "binary/bob"); | 76 | fr.open(fs, "binary/bob"); |
2254 | 77 | 77 | ||
2257 | 78 | Map& map = egbase.map(); | 78 | Map* map = egbase.mutable_map(); |
2258 | 79 | map.recalc_whole_map(egbase.world()); // for movecaps checks in ReadBob | 79 | map->recalc_whole_map(egbase.world()); // for movecaps checks in ReadBob |
2259 | 80 | try { | 80 | try { |
2260 | 81 | uint16_t const packet_version = fr.unsigned_16(); | 81 | uint16_t const packet_version = fr.unsigned_16(); |
2261 | 82 | if (packet_version == kCurrentPacketVersion) | 82 | if (packet_version == kCurrentPacketVersion) |
2264 | 83 | for (uint16_t y = 0; y < map.get_height(); ++y) { | 83 | for (uint16_t y = 0; y < map->get_height(); ++y) { |
2265 | 84 | for (uint16_t x = 0; x < map.get_width(); ++x) { | 84 | for (uint16_t x = 0; x < map->get_width(); ++x) { |
2266 | 85 | uint32_t const nr_bobs = fr.unsigned_32(); | 85 | uint32_t const nr_bobs = fr.unsigned_32(); |
2267 | 86 | for (uint32_t i = 0; i < nr_bobs; ++i) | 86 | for (uint32_t i = 0; i < nr_bobs; ++i) |
2268 | 87 | read_bob(fr, egbase, mol, Coords(x, y), lookup_table); | 87 | read_bob(fr, egbase, mol, Coords(x, y), lookup_table); |
2269 | 88 | 88 | ||
2270 | === modified file 'src/map_io/map_building_packet.cc' | |||
2271 | --- src/map_io/map_building_packet.cc 2017-01-25 18:55:59 +0000 | |||
2272 | +++ src/map_io/map_building_packet.cc 2017-08-20 12:33:35 +0000 | |||
2273 | @@ -60,7 +60,7 @@ | |||
2274 | 60 | try { | 60 | try { |
2275 | 61 | uint16_t const packet_version = fr.unsigned_16(); | 61 | uint16_t const packet_version = fr.unsigned_16(); |
2276 | 62 | if (packet_version == kCurrentPacketVersion) { | 62 | if (packet_version == kCurrentPacketVersion) { |
2278 | 63 | Map& map = egbase.map(); | 63 | const Map& map = egbase.map(); |
2279 | 64 | uint16_t const width = map.get_width(); | 64 | uint16_t const width = map.get_width(); |
2280 | 65 | uint16_t const height = map.get_height(); | 65 | uint16_t const height = map.get_height(); |
2281 | 66 | FCoords c; | 66 | FCoords c; |
2282 | 67 | 67 | ||
2283 | === modified file 'src/map_io/map_buildingdata_packet.cc' | |||
2284 | --- src/map_io/map_buildingdata_packet.cc 2017-08-16 13:23:15 +0000 | |||
2285 | +++ src/map_io/map_buildingdata_packet.cc 2017-08-20 12:33:35 +0000 | |||
2286 | @@ -434,9 +434,10 @@ | |||
2287 | 434 | } | 434 | } |
2288 | 435 | } | 435 | } |
2289 | 436 | 436 | ||
2290 | 437 | const Map& map = game.map(); | ||
2291 | 438 | |||
2292 | 437 | if (uint32_t const conquer_radius = warehouse.descr().get_conquers()) { | 439 | if (uint32_t const conquer_radius = warehouse.descr().get_conquers()) { |
2293 | 438 | // Add to map of military influence. | 440 | // Add to map of military influence. |
2294 | 439 | const Map& map = game.map(); | ||
2295 | 440 | Area<FCoords> a(map.get_fcoords(warehouse.get_position()), conquer_radius); | 441 | Area<FCoords> a(map.get_fcoords(warehouse.get_position()), conquer_radius); |
2296 | 441 | const Field& first_map_field = map[0]; | 442 | const Field& first_map_field = map[0]; |
2297 | 442 | Player::Field* const player_fields = player.fields_; | 443 | Player::Field* const player_fields = player.fields_; |
2298 | @@ -447,7 +448,7 @@ | |||
2299 | 447 | while (mr.advance(map)); | 448 | while (mr.advance(map)); |
2300 | 448 | } | 449 | } |
2301 | 449 | player.see_area(Area<FCoords>( | 450 | player.see_area(Area<FCoords>( |
2303 | 450 | game.map().get_fcoords(warehouse.get_position()), warehouse.descr().vision_range())); | 451 | map.get_fcoords(warehouse.get_position()), warehouse.descr().vision_range())); |
2304 | 451 | warehouse.next_military_act_ = game.get_gametime(); | 452 | warehouse.next_military_act_ = game.get_gametime(); |
2305 | 452 | } else { | 453 | } else { |
2306 | 453 | throw UnhandledVersionError( | 454 | throw UnhandledVersionError( |
2307 | @@ -830,7 +831,7 @@ | |||
2308 | 830 | fw.unsigned_16(kCurrentPacketVersion); | 831 | fw.unsigned_16(kCurrentPacketVersion); |
2309 | 831 | 832 | ||
2310 | 832 | // Walk the map again | 833 | // Walk the map again |
2312 | 833 | Map& map = egbase.map(); | 834 | const Map& map = egbase.map(); |
2313 | 834 | const uint32_t mapwidth = map.get_width(); | 835 | const uint32_t mapwidth = map.get_width(); |
2314 | 835 | MapIndex const max_index = map.max_index(); | 836 | MapIndex const max_index = map.max_index(); |
2315 | 836 | for (MapIndex i = 0; i < max_index; ++i) { | 837 | for (MapIndex i = 0; i < max_index; ++i) { |
2316 | 837 | 838 | ||
2317 | === modified file 'src/map_io/map_elemental_packet.cc' | |||
2318 | --- src/map_io/map_elemental_packet.cc 2017-08-16 13:23:15 +0000 | |||
2319 | +++ src/map_io/map_elemental_packet.cc 2017-08-20 12:33:35 +0000 | |||
2320 | @@ -114,7 +114,7 @@ | |||
2321 | 114 | } | 114 | } |
2322 | 115 | 115 | ||
2323 | 116 | void MapElementalPacket::read(FileSystem& fs, EditorGameBase& egbase, bool, MapObjectLoader&) { | 116 | void MapElementalPacket::read(FileSystem& fs, EditorGameBase& egbase, bool, MapObjectLoader&) { |
2325 | 117 | pre_read(fs, &egbase.map()); | 117 | pre_read(fs, egbase.mutable_map()); |
2326 | 118 | } | 118 | } |
2327 | 119 | 119 | ||
2328 | 120 | void MapElementalPacket::write(FileSystem& fs, EditorGameBase& egbase, MapObjectSaver&) { | 120 | void MapElementalPacket::write(FileSystem& fs, EditorGameBase& egbase, MapObjectSaver&) { |
2329 | 121 | 121 | ||
2330 | === modified file 'src/map_io/map_exploration_packet.cc' | |||
2331 | --- src/map_io/map_exploration_packet.cc 2017-01-25 18:55:59 +0000 | |||
2332 | +++ src/map_io/map_exploration_packet.cc 2017-08-20 12:33:35 +0000 | |||
2333 | @@ -50,7 +50,7 @@ | |||
2334 | 50 | } | 50 | } |
2335 | 51 | 51 | ||
2336 | 52 | static_assert(kMaxPlayers < 32, "assert(MAX_PLAYERS < 32) failed."); | 52 | static_assert(kMaxPlayers < 32, "assert(MAX_PLAYERS < 32) failed."); |
2338 | 53 | Map& map = egbase.map(); | 53 | const Map& map = egbase.map(); |
2339 | 54 | PlayerNumber const nr_players = map.get_nrplayers(); | 54 | PlayerNumber const nr_players = map.get_nrplayers(); |
2340 | 55 | MapIndex const max_index = map.max_index(); | 55 | MapIndex const max_index = map.max_index(); |
2341 | 56 | try { | 56 | try { |
2342 | @@ -82,7 +82,7 @@ | |||
2343 | 82 | fw.unsigned_16(kCurrentPacketVersion); | 82 | fw.unsigned_16(kCurrentPacketVersion); |
2344 | 83 | 83 | ||
2345 | 84 | static_assert(kMaxPlayers < 32, "assert(MAX_PLAYERS < 32) failed."); | 84 | static_assert(kMaxPlayers < 32, "assert(MAX_PLAYERS < 32) failed."); |
2347 | 85 | Map& map = egbase.map(); | 85 | const Map& map = egbase.map(); |
2348 | 86 | PlayerNumber const nr_players = map.get_nrplayers(); | 86 | PlayerNumber const nr_players = map.get_nrplayers(); |
2349 | 87 | MapIndex const max_index = map.max_index(); | 87 | MapIndex const max_index = map.max_index(); |
2350 | 88 | for (MapIndex i = 0; i < max_index; ++i) { | 88 | for (MapIndex i = 0; i < max_index; ++i) { |
2351 | 89 | 89 | ||
2352 | === modified file 'src/map_io/map_heights_packet.cc' | |||
2353 | --- src/map_io/map_heights_packet.cc 2017-01-25 18:55:59 +0000 | |||
2354 | +++ src/map_io/map_heights_packet.cc 2017-08-20 12:33:35 +0000 | |||
2355 | @@ -38,7 +38,7 @@ | |||
2356 | 38 | try { | 38 | try { |
2357 | 39 | uint16_t const packet_version = fr.unsigned_16(); | 39 | uint16_t const packet_version = fr.unsigned_16(); |
2358 | 40 | if (packet_version == kCurrentPacketVersion) { | 40 | if (packet_version == kCurrentPacketVersion) { |
2360 | 41 | Map& map = egbase.map(); | 41 | const Map& map = egbase.map(); |
2361 | 42 | MapIndex const max_index = map.max_index(); | 42 | MapIndex const max_index = map.max_index(); |
2362 | 43 | for (MapIndex i = 0; i < max_index; ++i) | 43 | for (MapIndex i = 0; i < max_index; ++i) |
2363 | 44 | map[i].set_height(fr.unsigned_8()); | 44 | map[i].set_height(fr.unsigned_8()); |
2364 | @@ -60,7 +60,7 @@ | |||
2365 | 60 | 60 | ||
2366 | 61 | fw.unsigned_16(kCurrentPacketVersion); | 61 | fw.unsigned_16(kCurrentPacketVersion); |
2367 | 62 | 62 | ||
2369 | 63 | Map& map = egbase.map(); | 63 | const Map& map = egbase.map(); |
2370 | 64 | MapIndex const max_index = map.max_index(); | 64 | MapIndex const max_index = map.max_index(); |
2371 | 65 | for (MapIndex i = 0; i < max_index; ++i) | 65 | for (MapIndex i = 0; i < max_index; ++i) |
2372 | 66 | fw.unsigned_8(map[i].get_height()); | 66 | fw.unsigned_8(map[i].get_height()); |
2373 | 67 | 67 | ||
2374 | === modified file 'src/map_io/map_node_ownership_packet.cc' | |||
2375 | --- src/map_io/map_node_ownership_packet.cc 2017-01-25 18:55:59 +0000 | |||
2376 | +++ src/map_io/map_node_ownership_packet.cc 2017-08-20 12:33:35 +0000 | |||
2377 | @@ -51,7 +51,7 @@ | |||
2378 | 51 | try { | 51 | try { |
2379 | 52 | uint16_t const packet_version = fr.unsigned_16(); | 52 | uint16_t const packet_version = fr.unsigned_16(); |
2380 | 53 | if (packet_version == kCurrentPacketVersion) { | 53 | if (packet_version == kCurrentPacketVersion) { |
2382 | 54 | Map& map = egbase.map(); | 54 | const Map& map = egbase.map(); |
2383 | 55 | MapIndex const max_index = map.max_index(); | 55 | MapIndex const max_index = map.max_index(); |
2384 | 56 | for (MapIndex i = 0; i < max_index; ++i) | 56 | for (MapIndex i = 0; i < max_index; ++i) |
2385 | 57 | map[i].set_owned_by(fr.unsigned_8()); | 57 | map[i].set_owned_by(fr.unsigned_8()); |
2386 | @@ -69,7 +69,7 @@ | |||
2387 | 69 | 69 | ||
2388 | 70 | fw.unsigned_16(kCurrentPacketVersion); | 70 | fw.unsigned_16(kCurrentPacketVersion); |
2389 | 71 | 71 | ||
2391 | 72 | Map& map = egbase.map(); | 72 | const Map& map = egbase.map(); |
2392 | 73 | MapIndex const max_index = map.max_index(); | 73 | MapIndex const max_index = map.max_index(); |
2393 | 74 | for (MapIndex i = 0; i < max_index; ++i) | 74 | for (MapIndex i = 0; i < max_index; ++i) |
2394 | 75 | fw.unsigned_8(map[i].get_owned_by()); | 75 | fw.unsigned_8(map[i].get_owned_by()); |
2395 | 76 | 76 | ||
2396 | === modified file 'src/map_io/map_objective_packet.cc' | |||
2397 | --- src/map_io/map_objective_packet.cc 2017-01-25 18:55:59 +0000 | |||
2398 | +++ src/map_io/map_objective_packet.cc 2017-08-20 12:33:35 +0000 | |||
2399 | @@ -45,7 +45,7 @@ | |||
2400 | 45 | char const* const name = s->get_name(); | 45 | char const* const name = s->get_name(); |
2401 | 46 | try { | 46 | try { |
2402 | 47 | std::unique_ptr<Objective> objective(new Objective(name)); | 47 | std::unique_ptr<Objective> objective(new Objective(name)); |
2404 | 48 | Map::Objectives* objectives = egbase.map().mutable_objectives(); | 48 | Map::Objectives* objectives = egbase.mutable_map()->mutable_objectives(); |
2405 | 49 | if (objectives->count(name)) { | 49 | if (objectives->count(name)) { |
2406 | 50 | throw GameDataError("duplicated"); | 50 | throw GameDataError("duplicated"); |
2407 | 51 | } | 51 | } |
2408 | 52 | 52 | ||
2409 | === modified file 'src/map_io/map_player_names_and_tribes_packet.cc' | |||
2410 | --- src/map_io/map_player_names_and_tribes_packet.cc 2017-01-25 18:55:59 +0000 | |||
2411 | +++ src/map_io/map_player_names_and_tribes_packet.cc 2017-08-20 12:33:35 +0000 | |||
2412 | @@ -44,7 +44,7 @@ | |||
2413 | 44 | EditorGameBase& egbase, | 44 | EditorGameBase& egbase, |
2414 | 45 | bool const skip, | 45 | bool const skip, |
2415 | 46 | MapObjectLoader&) { | 46 | MapObjectLoader&) { |
2417 | 47 | pre_read(fs, egbase.get_map(), skip); | 47 | pre_read(fs, egbase.mutable_map(), skip); |
2418 | 48 | } | 48 | } |
2419 | 49 | 49 | ||
2420 | 50 | void MapPlayerNamesAndTribesPacket::pre_read(FileSystem& fs, Map* const map, bool const skip) { | 50 | void MapPlayerNamesAndTribesPacket::pre_read(FileSystem& fs, Map* const map, bool const skip) { |
2421 | 51 | 51 | ||
2422 | === modified file 'src/map_io/map_player_position_packet.cc' | |||
2423 | --- src/map_io/map_player_position_packet.cc 2017-01-25 18:55:59 +0000 | |||
2424 | +++ src/map_io/map_player_position_packet.cc 2017-08-20 12:33:35 +0000 | |||
2425 | @@ -42,12 +42,12 @@ | |||
2426 | 42 | // Read all the positions | 42 | // Read all the positions |
2427 | 43 | // This could bring trouble if one player position/ is not set (this | 43 | // This could bring trouble if one player position/ is not set (this |
2428 | 44 | // is possible in the editor), is also -1, -1. | 44 | // is possible in the editor), is also -1, -1. |
2432 | 45 | Map& map = egbase.map(); | 45 | Map* map = egbase.mutable_map(); |
2433 | 46 | Extent const extent = map.extent(); | 46 | Extent const extent = map->extent(); |
2434 | 47 | PlayerNumber const nr_players = map.get_nrplayers(); | 47 | PlayerNumber const nr_players = map->get_nrplayers(); |
2435 | 48 | iterate_player_numbers(p, nr_players) { | 48 | iterate_player_numbers(p, nr_players) { |
2436 | 49 | try { | 49 | try { |
2438 | 50 | map.set_starting_pos( | 50 | map->set_starting_pos( |
2439 | 51 | p, | 51 | p, |
2440 | 52 | get_safe_coords((boost::format("player_%u") % static_cast<unsigned int>(p)).str(), | 52 | get_safe_coords((boost::format("player_%u") % static_cast<unsigned int>(p)).str(), |
2441 | 53 | extent, &s)); | 53 | extent, &s)); |
2442 | 54 | 54 | ||
2443 | === modified file 'src/map_io/map_port_spaces_packet.cc' | |||
2444 | --- src/map_io/map_port_spaces_packet.cc 2017-01-25 18:55:59 +0000 | |||
2445 | +++ src/map_io/map_port_spaces_packet.cc 2017-08-20 12:33:35 +0000 | |||
2446 | @@ -39,8 +39,8 @@ | |||
2447 | 39 | prof.read("port_spaces", nullptr, fs); | 39 | prof.read("port_spaces", nullptr, fs); |
2448 | 40 | Section& s1 = prof.get_safe_section("global"); | 40 | Section& s1 = prof.get_safe_section("global"); |
2449 | 41 | 41 | ||
2452 | 42 | Map& map = egbase.map(); | 42 | Map* map = egbase.mutable_map(); |
2453 | 43 | Extent ext(map.extent()); | 43 | Extent ext(map->extent()); |
2454 | 44 | 44 | ||
2455 | 45 | try { | 45 | try { |
2456 | 46 | int32_t const packet_version = s1.get_int("packet_version"); | 46 | int32_t const packet_version = s1.get_int("packet_version"); |
2457 | @@ -51,7 +51,7 @@ | |||
2458 | 51 | 51 | ||
2459 | 52 | Section& s2 = prof.get_safe_section("port_spaces"); | 52 | Section& s2 = prof.get_safe_section("port_spaces"); |
2460 | 53 | for (uint16_t i = 0; i < num; ++i) { | 53 | for (uint16_t i = 0; i < num; ++i) { |
2462 | 54 | map.set_port_space( | 54 | map->set_port_space( |
2463 | 55 | get_safe_coords(std::to_string(static_cast<unsigned int>(i)), ext, &s2), true); | 55 | get_safe_coords(std::to_string(static_cast<unsigned int>(i)), ext, &s2), true); |
2464 | 56 | } | 56 | } |
2465 | 57 | } else { | 57 | } else { |
2466 | @@ -69,7 +69,7 @@ | |||
2467 | 69 | Section& s1 = prof.create_section("global"); | 69 | Section& s1 = prof.create_section("global"); |
2468 | 70 | s1.set_int("packet_version", kCurrentPacketVersion); | 70 | s1.set_int("packet_version", kCurrentPacketVersion); |
2469 | 71 | 71 | ||
2471 | 72 | Map& map = egbase.map(); | 72 | const Map& map = egbase.map(); |
2472 | 73 | const uint16_t num = map.get_port_spaces().size(); | 73 | const uint16_t num = map.get_port_spaces().size(); |
2473 | 74 | s1.set_int("number_of_port_spaces", num); | 74 | s1.set_int("number_of_port_spaces", num); |
2474 | 75 | 75 | ||
2475 | 76 | 76 | ||
2476 | === modified file 'src/map_io/map_resources_packet.cc' | |||
2477 | --- src/map_io/map_resources_packet.cc 2017-01-25 18:55:59 +0000 | |||
2478 | +++ src/map_io/map_resources_packet.cc 2017-08-20 12:33:35 +0000 | |||
2479 | @@ -39,7 +39,7 @@ | |||
2480 | 39 | FileRead fr; | 39 | FileRead fr; |
2481 | 40 | fr.open(fs, "binary/resource"); | 40 | fr.open(fs, "binary/resource"); |
2482 | 41 | 41 | ||
2484 | 42 | Map& map = egbase.map(); | 42 | Map* map = egbase.mutable_map(); |
2485 | 43 | const World& world = egbase.world(); | 43 | const World& world = egbase.world(); |
2486 | 44 | 44 | ||
2487 | 45 | try { | 45 | try { |
2488 | @@ -63,8 +63,8 @@ | |||
2489 | 63 | smap[id] = res; | 63 | smap[id] = res; |
2490 | 64 | } | 64 | } |
2491 | 65 | 65 | ||
2494 | 66 | for (uint16_t y = 0; y < map.get_height(); ++y) { | 66 | for (uint16_t y = 0; y < map->get_height(); ++y) { |
2495 | 67 | for (uint16_t x = 0; x < map.get_width(); ++x) { | 67 | for (uint16_t x = 0; x < map->get_width(); ++x) { |
2496 | 68 | DescriptionIndex const id = fr.unsigned_8(); | 68 | DescriptionIndex const id = fr.unsigned_8(); |
2497 | 69 | ResourceAmount const found_amount = fr.unsigned_8(); | 69 | ResourceAmount const found_amount = fr.unsigned_8(); |
2498 | 70 | ResourceAmount const amount = found_amount; | 70 | ResourceAmount const amount = found_amount; |
2499 | @@ -85,9 +85,9 @@ | |||
2500 | 85 | 85 | ||
2501 | 86 | if (0xa < set_id) | 86 | if (0xa < set_id) |
2502 | 87 | throw "Unknown resource in map file. It is not in world!\n"; | 87 | throw "Unknown resource in map file. It is not in world!\n"; |
2506 | 88 | const auto fcoords = map.get_fcoords(Coords(x, y)); | 88 | const auto fcoords = map->get_fcoords(Coords(x, y)); |
2507 | 89 | map.initialize_resources(fcoords, set_id, set_start_amount); | 89 | map->initialize_resources(fcoords, set_id, set_start_amount); |
2508 | 90 | map.set_resources(fcoords, set_amount); | 90 | map->set_resources(fcoords, set_amount); |
2509 | 91 | } | 91 | } |
2510 | 92 | } | 92 | } |
2511 | 93 | } else { | 93 | } else { |
2512 | 94 | 94 | ||
2513 | === modified file 'src/map_io/map_roaddata_packet.cc' | |||
2514 | --- src/map_io/map_roaddata_packet.cc 2017-01-25 18:55:59 +0000 | |||
2515 | +++ src/map_io/map_roaddata_packet.cc 2017-08-20 12:33:35 +0000 | |||
2516 | @@ -104,7 +104,7 @@ | |||
2517 | 104 | Path p(road.flags_[0]->get_position()); | 104 | Path p(road.flags_[0]->get_position()); |
2518 | 105 | for (Path::StepVector::size_type i = nr_steps; i; --i) | 105 | for (Path::StepVector::size_type i = nr_steps; i; --i) |
2519 | 106 | try { | 106 | try { |
2521 | 107 | p.append(egbase.map(), read_direction_8(&fr)); | 107 | p.append(map, read_direction_8(&fr)); |
2522 | 108 | } catch (const WException& e) { | 108 | } catch (const WException& e) { |
2523 | 109 | throw GameDataError( | 109 | throw GameDataError( |
2524 | 110 | "step #%lu: %s", static_cast<long unsigned int>(nr_steps - i), e.what()); | 110 | "step #%lu: %s", static_cast<long unsigned int>(nr_steps - i), e.what()); |
2525 | 111 | 111 | ||
2526 | === modified file 'src/map_io/map_saver.cc' | |||
2527 | --- src/map_io/map_saver.cc 2017-01-25 18:55:59 +0000 | |||
2528 | +++ src/map_io/map_saver.cc 2017-08-20 12:33:35 +0000 | |||
2529 | @@ -70,8 +70,9 @@ | |||
2530 | 70 | } | 70 | } |
2531 | 71 | 71 | ||
2532 | 72 | void MapSaver::save() { | 72 | void MapSaver::save() { |
2533 | 73 | const Map& map = egbase_.map(); | ||
2534 | 73 | std::string timer_message = "MapSaver::save() for '"; | 74 | std::string timer_message = "MapSaver::save() for '"; |
2536 | 74 | timer_message += egbase_.map().get_name(); | 75 | timer_message += map.get_name(); |
2537 | 75 | timer_message += "' took %ums"; | 76 | timer_message += "' took %ums"; |
2538 | 76 | ScopedTimer timer(timer_message); | 77 | ScopedTimer timer(timer_message); |
2539 | 77 | 78 | ||
2540 | @@ -160,9 +161,6 @@ | |||
2541 | 160 | 161 | ||
2542 | 161 | // We don't save these when saving a map in the editor. | 162 | // We don't save these when saving a map in the editor. |
2543 | 162 | if (is_game) { | 163 | if (is_game) { |
2544 | 163 | |||
2545 | 164 | const Map& map = egbase_.map(); | ||
2546 | 165 | |||
2547 | 166 | PlayerNumber const nr_players = map.get_nrplayers(); | 164 | PlayerNumber const nr_players = map.get_nrplayers(); |
2548 | 167 | 165 | ||
2549 | 168 | // allowed worker types | 166 | // allowed worker types |
2550 | @@ -285,7 +283,7 @@ | |||
2551 | 285 | log("took %ums\n ", timer.ms_since_last_query()); | 283 | log("took %ums\n ", timer.ms_since_last_query()); |
2552 | 286 | 284 | ||
2553 | 287 | log("Writing map images ... "); | 285 | log("Writing map images ... "); |
2555 | 288 | save_map_images(&fs_, egbase_.map().filesystem()); | 286 | save_map_images(&fs_, map.filesystem()); |
2556 | 289 | log("took %ums\n ", timer.ms_since_last_query()); | 287 | log("took %ums\n ", timer.ms_since_last_query()); |
2557 | 290 | 288 | ||
2558 | 291 | if (is_game) { | 289 | if (is_game) { |
2559 | 292 | 290 | ||
2560 | === modified file 'src/map_io/map_terrain_packet.cc' | |||
2561 | --- src/map_io/map_terrain_packet.cc 2017-01-25 18:55:59 +0000 | |||
2562 | +++ src/map_io/map_terrain_packet.cc 2017-08-20 12:33:35 +0000 | |||
2563 | @@ -41,7 +41,7 @@ | |||
2564 | 41 | FileRead fr; | 41 | FileRead fr; |
2565 | 42 | fr.open(fs, "binary/terrain"); | 42 | fr.open(fs, "binary/terrain"); |
2566 | 43 | 43 | ||
2568 | 44 | Map& map = egbase.map(); | 44 | const Map& map = egbase.map(); |
2569 | 45 | const World& world = egbase.world(); | 45 | const World& world = egbase.world(); |
2570 | 46 | 46 | ||
2571 | 47 | try { | 47 | try { |
2572 | 48 | 48 | ||
2573 | === modified file 'src/map_io/map_version_packet.cc' | |||
2574 | --- src/map_io/map_version_packet.cc 2017-01-25 18:55:59 +0000 | |||
2575 | +++ src/map_io/map_version_packet.cc 2017-08-20 12:33:35 +0000 | |||
2576 | @@ -42,9 +42,9 @@ | |||
2577 | 42 | try { | 42 | try { |
2578 | 43 | prof.read("version", nullptr, fs); | 43 | prof.read("version", nullptr, fs); |
2579 | 44 | } catch (...) { | 44 | } catch (...) { |
2583 | 45 | Map& map = egbase.map(); | 45 | Map* map = egbase.mutable_map(); |
2584 | 46 | map.map_version_.map_version_timestamp = 0; | 46 | map->map_version_.map_version_timestamp = 0; |
2585 | 47 | map.map_version_.map_creator_version = "unknown"; | 47 | map->map_version_.map_creator_version = "unknown"; |
2586 | 48 | return; | 48 | return; |
2587 | 49 | } | 49 | } |
2588 | 50 | 50 | ||
2589 | @@ -55,14 +55,14 @@ | |||
2590 | 55 | if ((packet_version == kCurrentPacketVersion) || | 55 | if ((packet_version == kCurrentPacketVersion) || |
2591 | 56 | (packet_version > kCurrentPacketVersion && | 56 | (packet_version > kCurrentPacketVersion && |
2592 | 57 | forward_compatibility <= kCurrentPacketVersion)) { | 57 | forward_compatibility <= kCurrentPacketVersion)) { |
2599 | 58 | Map& map = egbase.map(); | 58 | Map* map = egbase.mutable_map(); |
2600 | 59 | map.map_version_.map_source_url = globv.get_safe_string("map_source_url"); | 59 | map->map_version_.map_source_url = globv.get_safe_string("map_source_url"); |
2601 | 60 | map.map_version_.map_source_release = globv.get_safe_string("map_release"); | 60 | map->map_version_.map_source_release = globv.get_safe_string("map_release"); |
2602 | 61 | map.map_version_.map_creator_version = globv.get_safe_string("map_creator_version"); | 61 | map->map_version_.map_creator_version = globv.get_safe_string("map_creator_version"); |
2603 | 62 | map.map_version_.map_version_major = globv.get_safe_int("map_version_major"); | 62 | map->map_version_.map_version_major = globv.get_safe_int("map_version_major"); |
2604 | 63 | map.map_version_.map_version_minor = globv.get_safe_int("map_version_minor"); | 63 | map->map_version_.map_version_minor = globv.get_safe_int("map_version_minor"); |
2605 | 64 | uint32_t ts = static_cast<uint32_t>(globv.get_safe_int("map_version_timestamp")); | 64 | uint32_t ts = static_cast<uint32_t>(globv.get_safe_int("map_version_timestamp")); |
2607 | 65 | map.map_version_.map_version_timestamp = ts; | 65 | map->map_version_.map_version_timestamp = ts; |
2608 | 66 | } else { | 66 | } else { |
2609 | 67 | throw UnhandledVersionError("MapVersionPacket", packet_version, kCurrentPacketVersion); | 67 | throw UnhandledVersionError("MapVersionPacket", packet_version, kCurrentPacketVersion); |
2610 | 68 | } | 68 | } |
2611 | @@ -108,7 +108,7 @@ | |||
2612 | 108 | // TODO(unknown): -- we could store the unix time in uint32, as a partial fix to 2038 problem. | 108 | // TODO(unknown): -- we could store the unix time in uint32, as a partial fix to 2038 problem. |
2613 | 109 | // There seems to be a get_safe_natural method, but not corresponding setter. | 109 | // There seems to be a get_safe_natural method, but not corresponding setter. |
2614 | 110 | 110 | ||
2616 | 111 | Map& map = egbase.map(); | 111 | const Map& map = egbase.map(); |
2617 | 112 | globs.set_string("map_source_url", map.map_version_.map_source_url); | 112 | globs.set_string("map_source_url", map.map_version_.map_source_url); |
2618 | 113 | globs.set_string("map_release", map.map_version_.map_source_release); | 113 | globs.set_string("map_release", map.map_version_.map_source_release); |
2619 | 114 | globs.set_string("map_creator_version", map.map_version_.map_creator_version); | 114 | globs.set_string("map_creator_version", map.map_version_.map_creator_version); |
2620 | 115 | 115 | ||
2621 | === modified file 'src/scripting/lua_bases.cc' | |||
2622 | --- src/scripting/lua_bases.cc 2017-01-30 14:40:12 +0000 | |||
2623 | +++ src/scripting/lua_bases.cc 2017-08-20 12:33:35 +0000 | |||
2624 | @@ -458,7 +458,7 @@ | |||
2625 | 458 | */ | 458 | */ |
2626 | 459 | int LuaPlayerBase::place_road(lua_State* L) { | 459 | int LuaPlayerBase::place_road(lua_State* L) { |
2627 | 460 | EditorGameBase& egbase = get_egbase(L); | 460 | EditorGameBase& egbase = get_egbase(L); |
2629 | 461 | Map& map = egbase.map(); | 461 | const Map& map = egbase.map(); |
2630 | 462 | 462 | ||
2631 | 463 | Flag* starting_flag = (*get_user_class<LuaMaps::LuaFlag>(L, 2))->get(L, egbase); | 463 | Flag* starting_flag = (*get_user_class<LuaMaps::LuaFlag>(L, 2))->get(L, egbase); |
2632 | 464 | Coords current = starting_flag->get_position(); | 464 | Coords current = starting_flag->get_position(); |
2633 | 465 | 465 | ||
2634 | === modified file 'src/scripting/lua_game.cc' | |||
2635 | --- src/scripting/lua_game.cc 2017-08-17 15:34:45 +0000 | |||
2636 | +++ src/scripting/lua_game.cc 2017-08-20 12:33:35 +0000 | |||
2637 | @@ -565,8 +565,7 @@ | |||
2638 | 565 | int LuaPlayer::add_objective(lua_State* L) { | 565 | int LuaPlayer::add_objective(lua_State* L) { |
2639 | 566 | Game& game = get_game(L); | 566 | Game& game = get_game(L); |
2640 | 567 | 567 | ||
2643 | 568 | Map* map = game.get_map(); | 568 | Map::Objectives* objectives = game.mutable_map()->mutable_objectives(); |
2642 | 569 | Map::Objectives* objectives = map->mutable_objectives(); | ||
2644 | 570 | 569 | ||
2645 | 571 | const std::string name = luaL_checkstring(L, 2); | 570 | const std::string name = luaL_checkstring(L, 2); |
2646 | 572 | if (objectives->count(name)) | 571 | if (objectives->count(name)) |
2647 | @@ -596,13 +595,13 @@ | |||
2648 | 596 | int LuaPlayer::reveal_fields(lua_State* L) { | 595 | int LuaPlayer::reveal_fields(lua_State* L) { |
2649 | 597 | EditorGameBase& egbase = get_egbase(L); | 596 | EditorGameBase& egbase = get_egbase(L); |
2650 | 598 | Player& p = get(L, egbase); | 597 | Player& p = get(L, egbase); |
2652 | 599 | Map& m = egbase.map(); | 598 | const Map& map = egbase.map(); |
2653 | 600 | 599 | ||
2654 | 601 | luaL_checktype(L, 2, LUA_TTABLE); | 600 | luaL_checktype(L, 2, LUA_TTABLE); |
2655 | 602 | 601 | ||
2656 | 603 | lua_pushnil(L); /* first key */ | 602 | lua_pushnil(L); /* first key */ |
2657 | 604 | while (lua_next(L, 2) != 0) { | 603 | while (lua_next(L, 2) != 0) { |
2659 | 605 | p.see_node(m, m[0], (*get_user_class<LuaField>(L, -1))->fcoords(L), egbase.get_gametime()); | 604 | p.see_node(map, map[0], (*get_user_class<LuaField>(L, -1))->fcoords(L), egbase.get_gametime()); |
2660 | 606 | lua_pop(L, 1); | 605 | lua_pop(L, 1); |
2661 | 607 | } | 606 | } |
2662 | 608 | 607 | ||
2663 | @@ -626,14 +625,13 @@ | |||
2664 | 626 | int LuaPlayer::hide_fields(lua_State* L) { | 625 | int LuaPlayer::hide_fields(lua_State* L) { |
2665 | 627 | EditorGameBase& egbase = get_egbase(L); | 626 | EditorGameBase& egbase = get_egbase(L); |
2666 | 628 | Player& p = get(L, egbase); | 627 | Player& p = get(L, egbase); |
2667 | 629 | Map& m = egbase.map(); | ||
2668 | 630 | 628 | ||
2669 | 631 | luaL_checktype(L, 2, LUA_TTABLE); | 629 | luaL_checktype(L, 2, LUA_TTABLE); |
2670 | 632 | const bool mode = !lua_isnone(L, 3) && luaL_checkboolean(L, 3); | 630 | const bool mode = !lua_isnone(L, 3) && luaL_checkboolean(L, 3); |
2671 | 633 | 631 | ||
2672 | 634 | lua_pushnil(L); /* first key */ | 632 | lua_pushnil(L); /* first key */ |
2673 | 635 | while (lua_next(L, 2) != 0) { | 633 | while (lua_next(L, 2) != 0) { |
2675 | 636 | p.unsee_node((*get_user_class<LuaField>(L, -1))->fcoords(L).field - &m[0], | 634 | p.unsee_node((*get_user_class<LuaField>(L, -1))->fcoords(L).field - &egbase.map()[0], |
2676 | 637 | egbase.get_gametime(), | 635 | egbase.get_gametime(), |
2677 | 638 | mode ? Player::UnseeNodeMode::kUnexplore : Player::UnseeNodeMode::kUnsee); | 636 | mode ? Player::UnseeNodeMode::kUnexplore : Player::UnseeNodeMode::kUnsee); |
2678 | 639 | lua_pop(L, 1); | 637 | lua_pop(L, 1); |
2679 | @@ -691,15 +689,15 @@ | |||
2680 | 691 | */ | 689 | */ |
2681 | 692 | int LuaPlayer::get_ships(lua_State* L) { | 690 | int LuaPlayer::get_ships(lua_State* L) { |
2682 | 693 | EditorGameBase& egbase = get_egbase(L); | 691 | EditorGameBase& egbase = get_egbase(L); |
2684 | 694 | Map* map = egbase.get_map(); | 692 | const Map& map = egbase.map(); |
2685 | 695 | PlayerNumber p = (get(L, egbase)).player_number(); | 693 | PlayerNumber p = (get(L, egbase)).player_number(); |
2686 | 696 | lua_newtable(L); | 694 | lua_newtable(L); |
2687 | 697 | uint32_t cidx = 1; | 695 | uint32_t cidx = 1; |
2688 | 698 | 696 | ||
2689 | 699 | std::set<OPtr<Ship>> found_ships; | 697 | std::set<OPtr<Ship>> found_ships; |
2693 | 700 | for (int16_t y = 0; y < map->get_height(); ++y) { | 698 | for (int16_t y = 0; y < map.get_height(); ++y) { |
2694 | 701 | for (int16_t x = 0; x < map->get_width(); ++x) { | 699 | for (int16_t x = 0; x < map.get_width(); ++x) { |
2695 | 702 | FCoords f = map->get_fcoords(Coords(x, y)); | 700 | FCoords f = map.get_fcoords(Coords(x, y)); |
2696 | 703 | // there are too many bobs on the map so we investigate | 701 | // there are too many bobs on the map so we investigate |
2697 | 704 | // only bobs on water | 702 | // only bobs on water |
2698 | 705 | if (f.field->nodecaps() & MOVECAPS_SWIM) { | 703 | if (f.field->nodecaps() & MOVECAPS_SWIM) { |
2699 | @@ -734,7 +732,6 @@ | |||
2700 | 734 | */ | 732 | */ |
2701 | 735 | int LuaPlayer::get_buildings(lua_State* L) { | 733 | int LuaPlayer::get_buildings(lua_State* L) { |
2702 | 736 | EditorGameBase& egbase = get_egbase(L); | 734 | EditorGameBase& egbase = get_egbase(L); |
2703 | 737 | Map* map = egbase.get_map(); | ||
2704 | 738 | Player& p = get(L, egbase); | 735 | Player& p = get(L, egbase); |
2705 | 739 | 736 | ||
2706 | 740 | // if only one string, convert to array so that we can use | 737 | // if only one string, convert to array so that we can use |
2707 | @@ -770,7 +767,7 @@ | |||
2708 | 770 | continue; | 767 | continue; |
2709 | 771 | 768 | ||
2710 | 772 | lua_pushuint32(L, cidx++); | 769 | lua_pushuint32(L, cidx++); |
2712 | 773 | upcasted_map_object_to_lua(L, (*map)[vec[l].pos].get_immovable()); | 770 | upcasted_map_object_to_lua(L, egbase.map()[vec[l].pos].get_immovable()); |
2713 | 774 | lua_rawset(L, -3); | 771 | lua_rawset(L, -3); |
2714 | 775 | } | 772 | } |
2715 | 776 | 773 | ||
2716 | @@ -1087,7 +1084,7 @@ | |||
2717 | 1087 | std::string filename = _("%1% (%2%)"); | 1084 | std::string filename = _("%1% (%2%)"); |
2718 | 1088 | i18n::Textdomain td("maps"); | 1085 | i18n::Textdomain td("maps"); |
2719 | 1089 | filename = | 1086 | filename = |
2721 | 1090 | (boost::format(filename) % _(get_egbase(L).get_map()->get_name()) % o.descname().c_str()) | 1087 | (boost::format(filename) % _(get_egbase(L).map().get_name()) % o.descname().c_str()) |
2722 | 1091 | .str(); | 1088 | .str(); |
2723 | 1092 | get_game(L).save_handler().request_save(filename); | 1089 | get_game(L).save_handler().request_save(filename); |
2724 | 1093 | } | 1090 | } |
2725 | @@ -1103,7 +1100,7 @@ | |||
2726 | 1103 | Game& g = get_game(L); | 1100 | Game& g = get_game(L); |
2727 | 1104 | // The next call checks if the Objective still exists | 1101 | // The next call checks if the Objective still exists |
2728 | 1105 | get(L, g); | 1102 | get(L, g); |
2730 | 1106 | g.map().mutable_objectives()->erase(name_); | 1103 | g.mutable_map()->mutable_objectives()->erase(name_); |
2731 | 1107 | return 0; | 1104 | return 0; |
2732 | 1108 | } | 1105 | } |
2733 | 1109 | 1106 | ||
2734 | @@ -1125,7 +1122,7 @@ | |||
2735 | 1125 | ========================================================== | 1122 | ========================================================== |
2736 | 1126 | */ | 1123 | */ |
2737 | 1127 | Objective& LuaObjective::get(lua_State* L, Widelands::Game& g) { | 1124 | Objective& LuaObjective::get(lua_State* L, Widelands::Game& g) { |
2739 | 1128 | Map::Objectives* objectives = g.map().mutable_objectives(); | 1125 | Map::Objectives* objectives = g.mutable_map()->mutable_objectives(); |
2740 | 1129 | Map::Objectives::iterator i = objectives->find(name_); | 1126 | Map::Objectives::iterator i = objectives->find(name_); |
2741 | 1130 | if (i == objectives->end()) { | 1127 | if (i == objectives->end()) { |
2742 | 1131 | report_error(L, "Objective with name '%s' doesn't exist!", name_.c_str()); | 1128 | report_error(L, "Objective with name '%s' doesn't exist!", name_.c_str()); |
2743 | 1132 | 1129 | ||
2744 | === modified file 'src/scripting/lua_map.cc' | |||
2745 | --- src/scripting/lua_map.cc 2017-08-16 04:31:56 +0000 | |||
2746 | +++ src/scripting/lua_map.cc 2017-08-20 12:33:35 +0000 | |||
2747 | @@ -1171,10 +1171,10 @@ | |||
2748 | 1171 | for each player defined in the map. | 1171 | for each player defined in the map. |
2749 | 1172 | */ | 1172 | */ |
2750 | 1173 | int LuaMap::get_player_slots(lua_State* L) { | 1173 | int LuaMap::get_player_slots(lua_State* L) { |
2752 | 1174 | Map& m = get_egbase(L).map(); | 1174 | const Map& map = get_egbase(L).map(); |
2753 | 1175 | 1175 | ||
2756 | 1176 | lua_createtable(L, m.get_nrplayers(), 0); | 1176 | lua_createtable(L, map.get_nrplayers(), 0); |
2757 | 1177 | for (Widelands::PlayerNumber i = 0; i < m.get_nrplayers(); i++) { | 1177 | for (Widelands::PlayerNumber i = 0; i < map.get_nrplayers(); i++) { |
2758 | 1178 | lua_pushuint32(L, i + 1); | 1178 | lua_pushuint32(L, i + 1); |
2759 | 1179 | to_lua<LuaMaps::LuaPlayerSlot>(L, new LuaMaps::LuaPlayerSlot(i + 1)); | 1179 | to_lua<LuaMaps::LuaPlayerSlot>(L, new LuaMaps::LuaPlayerSlot(i + 1)); |
2760 | 1180 | lua_settable(L, -3); | 1180 | lua_settable(L, -3); |
2761 | @@ -1252,11 +1252,11 @@ | |||
2762 | 1252 | uint32_t x = luaL_checkuint32(L, 2); | 1252 | uint32_t x = luaL_checkuint32(L, 2); |
2763 | 1253 | uint32_t y = luaL_checkuint32(L, 3); | 1253 | uint32_t y = luaL_checkuint32(L, 3); |
2764 | 1254 | 1254 | ||
2766 | 1255 | Map& m = get_egbase(L).map(); | 1255 | const Map& map = get_egbase(L).map(); |
2767 | 1256 | 1256 | ||
2769 | 1257 | if (x >= static_cast<uint32_t>(m.get_width())) | 1257 | if (x >= static_cast<uint32_t>(map.get_width())) |
2770 | 1258 | report_error(L, "x coordinate out of range!"); | 1258 | report_error(L, "x coordinate out of range!"); |
2772 | 1259 | if (y >= static_cast<uint32_t>(m.get_height())) | 1259 | if (y >= static_cast<uint32_t>(map.get_height())) |
2773 | 1260 | report_error(L, "y coordinate out of range!"); | 1260 | report_error(L, "y coordinate out of range!"); |
2774 | 1261 | 1261 | ||
2775 | 1262 | return to_lua<LuaMaps::LuaField>(L, new LuaMaps::LuaField(x, y)); | 1262 | return to_lua<LuaMaps::LuaField>(L, new LuaMaps::LuaField(x, y)); |
2776 | @@ -1272,7 +1272,7 @@ | |||
2777 | 1272 | // TODO(unknown): do we really want this function? | 1272 | // TODO(unknown): do we really want this function? |
2778 | 1273 | int LuaMap::recalculate(lua_State* L) { | 1273 | int LuaMap::recalculate(lua_State* L) { |
2779 | 1274 | EditorGameBase& egbase = get_egbase(L); | 1274 | EditorGameBase& egbase = get_egbase(L); |
2781 | 1275 | egbase.map().recalc_whole_map(egbase.world()); | 1275 | egbase.mutable_map()->recalc_whole_map(egbase.world()); |
2782 | 1276 | return 0; | 1276 | return 0; |
2783 | 1277 | } | 1277 | } |
2784 | 1278 | 1278 | ||
2785 | @@ -5787,7 +5787,7 @@ | |||
2786 | 5787 | report_error(L, "height must be <= %i", MAX_FIELD_HEIGHT); | 5787 | report_error(L, "height must be <= %i", MAX_FIELD_HEIGHT); |
2787 | 5788 | 5788 | ||
2788 | 5789 | EditorGameBase& egbase = get_egbase(L); | 5789 | EditorGameBase& egbase = get_egbase(L); |
2790 | 5790 | egbase.map().set_height(egbase.world(), f, height); | 5790 | egbase.mutable_map()->set_height(egbase.world(), f, height); |
2791 | 5791 | 5791 | ||
2792 | 5792 | return 0; | 5792 | return 0; |
2793 | 5793 | } | 5793 | } |
2794 | @@ -5865,9 +5865,9 @@ | |||
2795 | 5865 | 5865 | ||
2796 | 5866 | auto c = fcoords(L); | 5866 | auto c = fcoords(L); |
2797 | 5867 | const auto current_amount = c.field->get_resources_amount(); | 5867 | const auto current_amount = c.field->get_resources_amount(); |
2801 | 5868 | auto& map = egbase.map(); | 5868 | auto* map = egbase.mutable_map(); |
2802 | 5869 | map.initialize_resources(c, res, c.field->get_initial_res_amount()); | 5869 | map->initialize_resources(c, res, c.field->get_initial_res_amount()); |
2803 | 5870 | map.set_resources(c, current_amount); | 5870 | map->set_resources(c, current_amount); |
2804 | 5871 | return 0; | 5871 | return 0; |
2805 | 5872 | } | 5872 | } |
2806 | 5873 | 5873 | ||
2807 | @@ -5894,12 +5894,12 @@ | |||
2808 | 5894 | report_error(L, "Illegal amount: %i, must be >= 0 and <= %i", amount, | 5894 | report_error(L, "Illegal amount: %i, must be >= 0 and <= %i", amount, |
2809 | 5895 | static_cast<unsigned int>(max_amount)); | 5895 | static_cast<unsigned int>(max_amount)); |
2810 | 5896 | 5896 | ||
2812 | 5897 | auto& map = egbase.map(); | 5897 | auto* map = egbase.mutable_map(); |
2813 | 5898 | if (is_a(Game, &egbase)) { | 5898 | if (is_a(Game, &egbase)) { |
2815 | 5899 | map.set_resources(c, amount); | 5899 | map->set_resources(c, amount); |
2816 | 5900 | } else { | 5900 | } else { |
2817 | 5901 | // in editor, reset also initial amount | 5901 | // in editor, reset also initial amount |
2819 | 5902 | map.initialize_resources(c, res, amount); | 5902 | map->initialize_resources(c, res, amount); |
2820 | 5903 | } | 5903 | } |
2821 | 5904 | return 0; | 5904 | return 0; |
2822 | 5905 | } | 5905 | } |
2823 | @@ -5972,7 +5972,7 @@ | |||
2824 | 5972 | if (td == static_cast<DescriptionIndex>(-1)) | 5972 | if (td == static_cast<DescriptionIndex>(-1)) |
2825 | 5973 | report_error(L, "Unknown terrain '%s'", name); | 5973 | report_error(L, "Unknown terrain '%s'", name); |
2826 | 5974 | 5974 | ||
2828 | 5975 | egbase.map().change_terrain(world, TCoords<FCoords>(fcoords(L), TCoords<FCoords>::R), td); | 5975 | egbase.mutable_map()->change_terrain(world, TCoords<FCoords>(fcoords(L), TCoords<FCoords>::R), td); |
2829 | 5976 | 5976 | ||
2830 | 5977 | lua_pushstring(L, name); | 5977 | lua_pushstring(L, name); |
2831 | 5978 | return 1; | 5978 | return 1; |
2832 | @@ -5991,7 +5991,8 @@ | |||
2833 | 5991 | if (td == static_cast<DescriptionIndex>(INVALID_INDEX)) | 5991 | if (td == static_cast<DescriptionIndex>(INVALID_INDEX)) |
2834 | 5992 | report_error(L, "Unknown terrain '%s'", name); | 5992 | report_error(L, "Unknown terrain '%s'", name); |
2835 | 5993 | 5993 | ||
2837 | 5994 | egbase.map().change_terrain(world, TCoords<FCoords>(fcoords(L), TCoords<FCoords>::D), td); | 5994 | egbase.mutable_map()->change_terrain( |
2838 | 5995 | world, TCoords<FCoords>(fcoords(L), TCoords<FCoords>::D), td); | ||
2839 | 5995 | 5996 | ||
2840 | 5996 | lua_pushstring(L, name); | 5997 | lua_pushstring(L, name); |
2841 | 5997 | return 1; | 5998 | return 1; |
2842 | @@ -6058,7 +6059,7 @@ | |||
2843 | 6058 | */ | 6059 | */ |
2844 | 6059 | int LuaField::get_claimers(lua_State* L) { | 6060 | int LuaField::get_claimers(lua_State* L) { |
2845 | 6060 | EditorGameBase& egbase = get_egbase(L); | 6061 | EditorGameBase& egbase = get_egbase(L); |
2847 | 6061 | Map& map = egbase.map(); | 6062 | const Map& map = egbase.map(); |
2848 | 6062 | 6063 | ||
2849 | 6063 | std::vector<PlrInfluence> claimers; | 6064 | std::vector<PlrInfluence> claimers; |
2850 | 6064 | 6065 | ||
2851 | @@ -6187,7 +6188,7 @@ | |||
2852 | 6187 | ========================================================== | 6188 | ========================================================== |
2853 | 6188 | */ | 6189 | */ |
2854 | 6189 | int LuaField::region(lua_State* L, uint32_t radius) { | 6190 | int LuaField::region(lua_State* L, uint32_t radius) { |
2856 | 6190 | Map& map = get_egbase(L).map(); | 6191 | const Map& map = get_egbase(L).map(); |
2857 | 6191 | MapRegion<Area<FCoords>> mr(map, Area<FCoords>(fcoords(L), radius)); | 6192 | MapRegion<Area<FCoords>> mr(map, Area<FCoords>(fcoords(L), radius)); |
2858 | 6192 | 6193 | ||
2859 | 6193 | lua_newtable(L); | 6194 | lua_newtable(L); |
2860 | @@ -6203,7 +6204,7 @@ | |||
2861 | 6203 | } | 6204 | } |
2862 | 6204 | 6205 | ||
2863 | 6205 | int LuaField::hollow_region(lua_State* L, uint32_t radius, uint32_t inner_radius) { | 6206 | int LuaField::hollow_region(lua_State* L, uint32_t radius, uint32_t inner_radius) { |
2865 | 6206 | Map& map = get_egbase(L).map(); | 6207 | const Map& map = get_egbase(L).map(); |
2866 | 6207 | HollowArea<Area<>> har(Area<>(coords_, radius), inner_radius); | 6208 | HollowArea<Area<>> har(Area<>(coords_, radius), inner_radius); |
2867 | 6208 | 6209 | ||
2868 | 6209 | MapHollowRegion<Area<>> mr(map, har); | 6210 | MapHollowRegion<Area<>> mr(map, har); |
2869 | @@ -6265,7 +6266,7 @@ | |||
2870 | 6265 | (RO) The name of the tribe suggested for this player in this map | 6266 | (RO) The name of the tribe suggested for this player in this map |
2871 | 6266 | */ | 6267 | */ |
2872 | 6267 | int LuaPlayerSlot::get_tribe_name(lua_State* L) { | 6268 | int LuaPlayerSlot::get_tribe_name(lua_State* L) { |
2874 | 6268 | lua_pushstring(L, get_egbase(L).get_map()->get_scenario_player_tribe(player_number_)); | 6269 | lua_pushstring(L, get_egbase(L).map().get_scenario_player_tribe(player_number_)); |
2875 | 6269 | return 1; | 6270 | return 1; |
2876 | 6270 | } | 6271 | } |
2877 | 6271 | 6272 | ||
2878 | @@ -6275,7 +6276,7 @@ | |||
2879 | 6275 | (RO) The name for this player as suggested in this map | 6276 | (RO) The name for this player as suggested in this map |
2880 | 6276 | */ | 6277 | */ |
2881 | 6277 | int LuaPlayerSlot::get_name(lua_State* L) { | 6278 | int LuaPlayerSlot::get_name(lua_State* L) { |
2883 | 6278 | lua_pushstring(L, get_egbase(L).get_map()->get_scenario_player_name(player_number_)); | 6279 | lua_pushstring(L, get_egbase(L).map().get_scenario_player_name(player_number_)); |
2884 | 6279 | return 1; | 6280 | return 1; |
2885 | 6280 | } | 6281 | } |
2886 | 6281 | 6282 | ||
2887 | 6282 | 6283 | ||
2888 | === modified file 'src/website/map_info.cc' | |||
2889 | --- src/website/map_info.cc 2017-01-25 18:55:59 +0000 | |||
2890 | +++ src/website/map_info.cc 2017-08-20 12:33:35 +0000 | |||
2891 | @@ -75,9 +75,8 @@ | |||
2892 | 75 | FileSystem* in_out_filesystem = &FileSystem::create(map_dir); | 75 | FileSystem* in_out_filesystem = &FileSystem::create(map_dir); |
2893 | 76 | g_fs->add_file_system(in_out_filesystem); | 76 | g_fs->add_file_system(in_out_filesystem); |
2894 | 77 | 77 | ||
2895 | 78 | Map* map = new Map(); | ||
2896 | 79 | EditorGameBase egbase(nullptr); | 78 | EditorGameBase egbase(nullptr); |
2898 | 80 | egbase.set_map(map); | 79 | auto* map = egbase.mutable_map(); |
2899 | 81 | std::unique_ptr<Widelands::MapLoader> ml(map->get_correct_loader(map_file)); | 80 | std::unique_ptr<Widelands::MapLoader> ml(map->get_correct_loader(map_file)); |
2900 | 82 | 81 | ||
2901 | 83 | if (!ml) { | 82 | if (!ml) { |
2902 | 84 | 83 | ||
2903 | === modified file 'src/wui/attack_box.cc' | |||
2904 | --- src/wui/attack_box.cc 2017-02-25 13:27:40 +0000 | |||
2905 | +++ src/wui/attack_box.cc 2017-08-20 12:33:35 +0000 | |||
2906 | @@ -40,17 +40,16 @@ | |||
2907 | 40 | uint32_t const y) | 40 | uint32_t const y) |
2908 | 41 | : UI::Box(parent, x, y, UI::Box::Vertical), | 41 | : UI::Box(parent, x, y, UI::Box::Vertical), |
2909 | 42 | player_(player), | 42 | player_(player), |
2911 | 43 | map_(&player_->egbase().map()), | 43 | map_(player_->egbase().map()), |
2912 | 44 | node_coordinates_(target), | 44 | node_coordinates_(target), |
2913 | 45 | lastupdate_(0) { | 45 | lastupdate_(0) { |
2914 | 46 | init(); | 46 | init(); |
2915 | 47 | } | 47 | } |
2916 | 48 | 48 | ||
2917 | 49 | uint32_t AttackBox::get_max_attackers() { | 49 | uint32_t AttackBox::get_max_attackers() { |
2918 | 50 | assert(map_); | ||
2919 | 51 | assert(player_); | 50 | assert(player_); |
2920 | 52 | 51 | ||
2922 | 53 | if (upcast(Building, building, map_->get_immovable(*node_coordinates_))) | 52 | if (upcast(Building, building, map_.get_immovable(*node_coordinates_))) |
2923 | 54 | return player_->find_attack_soldiers(building->base_flag()); | 53 | return player_->find_attack_soldiers(building->base_flag()); |
2924 | 55 | return 0; | 54 | return 0; |
2925 | 56 | } | 55 | } |
2926 | 57 | 56 | ||
2927 | === modified file 'src/wui/attack_box.h' | |||
2928 | --- src/wui/attack_box.h 2017-05-20 22:42:49 +0000 | |||
2929 | +++ src/wui/attack_box.h 2017-08-20 12:33:35 +0000 | |||
2930 | @@ -80,7 +80,7 @@ | |||
2931 | 80 | 80 | ||
2932 | 81 | private: | 81 | private: |
2933 | 82 | Widelands::Player* player_; | 82 | Widelands::Player* player_; |
2935 | 83 | Widelands::Map* map_; | 83 | const Widelands::Map& map_; |
2936 | 84 | Widelands::FCoords* node_coordinates_; | 84 | Widelands::FCoords* node_coordinates_; |
2937 | 85 | 85 | ||
2938 | 86 | std::unique_ptr<UI::Slider> soldiers_slider_; | 86 | std::unique_ptr<UI::Slider> soldiers_slider_; |
2939 | 87 | 87 | ||
2940 | === modified file 'src/wui/building_statistics_menu.cc' | |||
2941 | --- src/wui/building_statistics_menu.cc 2017-08-17 15:34:45 +0000 | |||
2942 | +++ src/wui/building_statistics_menu.cc 2017-08-20 12:33:35 +0000 | |||
2943 | @@ -540,7 +540,6 @@ | |||
2944 | 540 | void BuildingStatisticsMenu::update() { | 540 | void BuildingStatisticsMenu::update() { |
2945 | 541 | const Player& player = iplayer().player(); | 541 | const Player& player = iplayer().player(); |
2946 | 542 | const TribeDescr& tribe = player.tribe(); | 542 | const TribeDescr& tribe = player.tribe(); |
2947 | 543 | const Map& map = iplayer().game().map(); | ||
2948 | 544 | const DescriptionIndex nr_buildings = iplayer().egbase().tribes().nrbuildings(); | 543 | const DescriptionIndex nr_buildings = iplayer().egbase().tribes().nrbuildings(); |
2949 | 545 | 544 | ||
2950 | 546 | owned_label_.set_visible(false); | 545 | owned_label_.set_visible(false); |
2951 | @@ -581,7 +580,7 @@ | |||
2952 | 581 | ++nr_build; | 580 | ++nr_build; |
2953 | 582 | else { | 581 | else { |
2954 | 583 | ++nr_owned; | 582 | ++nr_owned; |
2956 | 584 | BaseImmovable& immovable = *map[stats_vector[l].pos].get_immovable(); | 583 | BaseImmovable& immovable = *iplayer().game().map()[stats_vector[l].pos].get_immovable(); |
2957 | 585 | if (building.type() == MapObjectType::PRODUCTIONSITE || | 584 | if (building.type() == MapObjectType::PRODUCTIONSITE || |
2958 | 586 | building.type() == MapObjectType::TRAININGSITE) { | 585 | building.type() == MapObjectType::TRAININGSITE) { |
2959 | 587 | ProductionSite& productionsite = dynamic_cast<ProductionSite&>(immovable); | 586 | ProductionSite& productionsite = dynamic_cast<ProductionSite&>(immovable); |
2960 | 588 | 587 | ||
2961 | === modified file 'src/wui/fieldaction.cc' | |||
2962 | --- src/wui/fieldaction.cc 2017-08-17 15:34:45 +0000 | |||
2963 | +++ src/wui/fieldaction.cc 2017-08-20 12:33:35 +0000 | |||
2964 | @@ -195,7 +195,7 @@ | |||
2965 | 195 | void reset_mouse_and_die(); | 195 | void reset_mouse_and_die(); |
2966 | 196 | 196 | ||
2967 | 197 | Widelands::Player* player_; | 197 | Widelands::Player* player_; |
2969 | 198 | Widelands::Map* map_; | 198 | const Widelands::Map& map_; |
2970 | 199 | FieldOverlayManager& field_overlay_manager_; | 199 | FieldOverlayManager& field_overlay_manager_; |
2971 | 200 | 200 | ||
2972 | 201 | Widelands::FCoords node_; | 201 | Widelands::FCoords node_; |
2973 | @@ -246,9 +246,9 @@ | |||
2974 | 246 | UI::UniqueWindow::Registry* const registry) | 246 | UI::UniqueWindow::Registry* const registry) |
2975 | 247 | : UI::UniqueWindow(ib, "field_action", registry, 68, 34, _("Action")), | 247 | : UI::UniqueWindow(ib, "field_action", registry, 68, 34, _("Action")), |
2976 | 248 | player_(plr), | 248 | player_(plr), |
2978 | 249 | map_(&ib->egbase().map()), | 249 | map_(ib->egbase().map()), |
2979 | 250 | field_overlay_manager_(*ib->mutable_field_overlay_manager()), | 250 | field_overlay_manager_(*ib->mutable_field_overlay_manager()), |
2981 | 251 | node_(ib->get_sel_pos().node, &(*map_)[ib->get_sel_pos().node]), | 251 | node_(ib->get_sel_pos().node, &map_[ib->get_sel_pos().node]), |
2982 | 252 | tabpanel_(this, g_gr->images().get("images/ui_basic/but1.png")), | 252 | tabpanel_(this, g_gr->images().get("images/ui_basic/but1.png")), |
2983 | 253 | fastclick_(true), | 253 | fastclick_(true), |
2984 | 254 | best_tab_(0), | 254 | best_tab_(0), |
2985 | @@ -305,7 +305,7 @@ | |||
2986 | 305 | const Widelands::PlayerNumber owner = node_.field->get_owned_by(); | 305 | const Widelands::PlayerNumber owner = node_.field->get_owned_by(); |
2987 | 306 | 306 | ||
2988 | 307 | if (!igbase || igbase->can_see(owner)) { | 307 | if (!igbase || igbase->can_see(owner)) { |
2990 | 308 | Widelands::BaseImmovable* const imm = map_->get_immovable(node_); | 308 | Widelands::BaseImmovable* const imm = map_.get_immovable(node_); |
2991 | 309 | const bool can_act = igbase ? igbase->can_act(owner) : true; | 309 | const bool can_act = igbase ? igbase->can_act(owner) : true; |
2992 | 310 | 310 | ||
2993 | 311 | // The box with road-building buttons | 311 | // The box with road-building buttons |
2994 | @@ -380,7 +380,7 @@ | |||
2995 | 380 | void FieldActionWindow::add_buttons_attack() { | 380 | void FieldActionWindow::add_buttons_attack() { |
2996 | 381 | UI::Box& a_box = *new UI::Box(&tabpanel_, 0, 0, UI::Box::Horizontal); | 381 | UI::Box& a_box = *new UI::Box(&tabpanel_, 0, 0, UI::Box::Horizontal); |
2997 | 382 | 382 | ||
2999 | 383 | if (upcast(Widelands::Building, building, map_->get_immovable(node_))) { | 383 | if (upcast(Widelands::Building, building, map_.get_immovable(node_))) { |
3000 | 384 | if (const Widelands::AttackTarget* attack_target = building->attack_target()) { | 384 | if (const Widelands::AttackTarget* attack_target = building->attack_target()) { |
3001 | 385 | if (player_ && player_->is_hostile(building->owner()) && | 385 | if (player_ && player_->is_hostile(building->owner()) && |
3002 | 386 | attack_target->can_be_attacked()) { | 386 | attack_target->can_be_attacked()) { |
3003 | 387 | 387 | ||
3004 | === modified file 'src/wui/game_debug_ui.cc' | |||
3005 | --- src/wui/game_debug_ui.cc 2017-06-28 07:17:12 +0000 | |||
3006 | +++ src/wui/game_debug_ui.cc 2017-08-20 12:33:35 +0000 | |||
3007 | @@ -198,7 +198,7 @@ | |||
3008 | 198 | void open_bob(uint32_t); | 198 | void open_bob(uint32_t); |
3009 | 199 | 199 | ||
3010 | 200 | private: | 200 | private: |
3012 | 201 | Widelands::Map& map_; | 201 | const Widelands::Map& map_; |
3013 | 202 | Widelands::FCoords const coords_; | 202 | Widelands::FCoords const coords_; |
3014 | 203 | 203 | ||
3015 | 204 | UI::MultilineTextarea ui_field_; | 204 | UI::MultilineTextarea ui_field_; |
3016 | 205 | 205 | ||
3017 | === modified file 'src/wui/game_main_menu_save_game.cc' | |||
3018 | --- src/wui/game_main_menu_save_game.cc 2017-06-24 11:18:12 +0000 | |||
3019 | +++ src/wui/game_main_menu_save_game.cc 2017-08-20 12:33:35 +0000 | |||
3020 | @@ -113,7 +113,7 @@ | |||
3021 | 113 | { | 113 | { |
3022 | 114 | // Try to translate the map name. | 114 | // Try to translate the map name. |
3023 | 115 | i18n::Textdomain td("maps"); | 115 | i18n::Textdomain td("maps"); |
3025 | 116 | mapname_.set_text(_(parent.game().get_map()->get_name())); | 116 | mapname_.set_text(_(parent.game().map().get_name())); |
3026 | 117 | } | 117 | } |
3027 | 118 | uint32_t gametime = parent.game().get_gametime(); | 118 | uint32_t gametime = parent.game().get_gametime(); |
3028 | 119 | gametime_.set_text(gametimestring(gametime)); | 119 | gametime_.set_text(gametimestring(gametime)); |
3029 | 120 | 120 | ||
3030 | === modified file 'src/wui/interactive_base.cc' | |||
3031 | --- src/wui/interactive_base.cc 2017-08-18 02:28:27 +0000 | |||
3032 | +++ src/wui/interactive_base.cc 2017-08-20 12:33:35 +0000 | |||
3033 | @@ -144,7 +144,7 @@ | |||
3034 | 144 | } | 144 | } |
3035 | 145 | 145 | ||
3036 | 146 | void InteractiveBase::set_sel_pos(Widelands::NodeAndTriangle<> const center) { | 146 | void InteractiveBase::set_sel_pos(Widelands::NodeAndTriangle<> const center) { |
3038 | 147 | Map& map = egbase().map(); | 147 | const Map& map = egbase().map(); |
3039 | 148 | 148 | ||
3040 | 149 | // Remove old sel pointer | 149 | // Remove old sel pointer |
3041 | 150 | if (sel_.jobid) | 150 | if (sel_.jobid) |
3042 | @@ -278,7 +278,7 @@ | |||
3043 | 278 | default: | 278 | default: |
3044 | 279 | throw wexception("Encountered unexpected WorkareaInfo size %i", workareas_nrs); | 279 | throw wexception("Encountered unexpected WorkareaInfo size %i", workareas_nrs); |
3045 | 280 | } | 280 | } |
3047 | 281 | Widelands::Map& map = egbase_.map(); | 281 | const Widelands::Map& map = egbase_.map(); |
3048 | 282 | FieldOverlayManager::OverlayId overlay_id = field_overlay_manager_->next_overlay_id(); | 282 | FieldOverlayManager::OverlayId overlay_id = field_overlay_manager_->next_overlay_id(); |
3049 | 283 | 283 | ||
3050 | 284 | Widelands::HollowArea<> hollow_area(Widelands::Area<>(coords, 0), 0); | 284 | Widelands::HollowArea<> hollow_area(Widelands::Area<>(coords, 0), 0); |
3051 | @@ -606,7 +606,7 @@ | |||
3052 | 606 | bool InteractiveBase::append_build_road(Coords const field) { | 606 | bool InteractiveBase::append_build_road(Coords const field) { |
3053 | 607 | assert(buildroad_); | 607 | assert(buildroad_); |
3054 | 608 | 608 | ||
3056 | 609 | Map& map = egbase().map(); | 609 | const Map& map = egbase().map(); |
3057 | 610 | const Widelands::Player& player = egbase().player(road_build_player_); | 610 | const Widelands::Player& player = egbase().player(road_build_player_); |
3058 | 611 | 611 | ||
3059 | 612 | { // find a path to the clicked-on node | 612 | { // find a path to the clicked-on node |
3060 | @@ -708,7 +708,7 @@ | |||
3061 | 708 | assert(buildroad_); | 708 | assert(buildroad_); |
3062 | 709 | assert(road_building_preview_.empty()); | 709 | assert(road_building_preview_.empty()); |
3063 | 710 | 710 | ||
3065 | 711 | Map& map = egbase().map(); | 711 | const Map& map = egbase().map(); |
3066 | 712 | 712 | ||
3067 | 713 | // preview of the road | 713 | // preview of the road |
3068 | 714 | const CoordPath::StepVector::size_type nr_steps = buildroad_->get_nsteps(); | 714 | const CoordPath::StepVector::size_type nr_steps = buildroad_->get_nsteps(); |
3069 | 715 | 715 | ||
3070 | === modified file 'src/wui/interactive_gamebase.cc' | |||
3071 | --- src/wui/interactive_gamebase.cc 2017-08-17 15:34:45 +0000 | |||
3072 | +++ src/wui/interactive_gamebase.cc 2017-08-20 12:33:35 +0000 | |||
3073 | @@ -137,7 +137,6 @@ | |||
3074 | 137 | * during single/multiplayer/scenario). | 137 | * during single/multiplayer/scenario). |
3075 | 138 | */ | 138 | */ |
3076 | 139 | void InteractiveGameBase::postload() { | 139 | void InteractiveGameBase::postload() { |
3077 | 140 | Widelands::Map& map = egbase().map(); | ||
3078 | 141 | auto* overlay_manager = mutable_field_overlay_manager(); | 140 | auto* overlay_manager = mutable_field_overlay_manager(); |
3079 | 142 | show_buildhelp(false); | 141 | show_buildhelp(false); |
3080 | 143 | on_buildhelp_changed(buildhelp()); | 142 | on_buildhelp_changed(buildhelp()); |
3081 | @@ -146,7 +145,7 @@ | |||
3082 | 146 | boost::bind(&InteractiveGameBase::calculate_buildcaps, this, _1)); | 145 | boost::bind(&InteractiveGameBase::calculate_buildcaps, this, _1)); |
3083 | 147 | 146 | ||
3084 | 148 | // Recalc whole map for changed owner stuff | 147 | // Recalc whole map for changed owner stuff |
3086 | 149 | map.recalc_whole_map(egbase().world()); | 148 | egbase().mutable_map()->recalc_whole_map(egbase().world()); |
3087 | 150 | 149 | ||
3088 | 151 | // Close game-relevant UI windows (but keep main menu open) | 150 | // Close game-relevant UI windows (but keep main menu open) |
3089 | 152 | fieldaction_.destroy(); | 151 | fieldaction_.destroy(); |
3090 | @@ -224,7 +223,7 @@ | |||
3091 | 224 | * If so, do it and return true; otherwise, return false. | 223 | * If so, do it and return true; otherwise, return false. |
3092 | 225 | */ | 224 | */ |
3093 | 226 | bool InteractiveGameBase::try_show_ship_window() { | 225 | bool InteractiveGameBase::try_show_ship_window() { |
3095 | 227 | Widelands::Map& map(game().map()); | 226 | const Widelands::Map& map= game().map(); |
3096 | 228 | Widelands::Area<Widelands::FCoords> area(map.get_fcoords(get_sel_pos().node), 1); | 227 | Widelands::Area<Widelands::FCoords> area(map.get_fcoords(get_sel_pos().node), 1); |
3097 | 229 | 228 | ||
3098 | 230 | if (!(area.field->nodecaps() & Widelands::MOVECAPS_SWIM)) | 229 | if (!(area.field->nodecaps() & Widelands::MOVECAPS_SWIM)) |
3099 | 231 | 230 | ||
3100 | === modified file 'src/wui/watchwindow.cc' | |||
3101 | --- src/wui/watchwindow.cc 2017-08-17 15:34:45 +0000 | |||
3102 | +++ src/wui/watchwindow.cc 2017-08-20 12:33:35 +0000 | |||
3103 | @@ -210,11 +210,11 @@ | |||
3104 | 210 | } | 210 | } |
3105 | 211 | 211 | ||
3106 | 212 | if (upcast(Widelands::Bob, bob, views_[cur_index_].tracking.get(game()))) { | 212 | if (upcast(Widelands::Bob, bob, views_[cur_index_].tracking.get(game()))) { |
3107 | 213 | const Widelands::Map& map = game().map(); | ||
3108 | 213 | const Vector2f field_position = | 214 | const Vector2f field_position = |
3110 | 214 | MapviewPixelFunctions::to_map_pixel(game().map(), bob->get_position()); | 215 | MapviewPixelFunctions::to_map_pixel(map, bob->get_position()); |
3111 | 215 | const Vector2f pos = bob->calc_drawpos(game(), field_position, 1.f); | 216 | const Vector2f pos = bob->calc_drawpos(game(), field_position, 1.f); |
3112 | 216 | 217 | ||
3113 | 217 | Widelands::Map& map = game().map(); | ||
3114 | 218 | // Drop the tracking if it leaves our vision range | 218 | // Drop the tracking if it leaves our vision range |
3115 | 219 | InteractivePlayer* ipl = game().get_ipl(); | 219 | InteractivePlayer* ipl = game().get_ipl(); |
3116 | 220 | if (ipl && 1 >= ipl->player().vision(map.get_index(bob->get_position(), map.get_width()))) { | 220 | if (ipl && 1 >= ipl->player().vision(map.get_index(bob->get_position(), map.get_width()))) { |
3117 | @@ -253,7 +253,7 @@ | |||
3118 | 253 | // Find the nearest bob. Other object types can not move and are | 253 | // Find the nearest bob. Other object types can not move and are |
3119 | 254 | // therefore not of interest. | 254 | // therefore not of interest. |
3120 | 255 | Vector2f center_map_pixel = mapview_.view_area().rect().center(); | 255 | Vector2f center_map_pixel = mapview_.view_area().rect().center(); |
3122 | 256 | Widelands::Map& map = g.map(); | 256 | const Widelands::Map& map = g.map(); |
3123 | 257 | MapviewPixelFunctions::normalize_pix(map, ¢er_map_pixel); | 257 | MapviewPixelFunctions::normalize_pix(map, ¢er_map_pixel); |
3124 | 258 | std::vector<Widelands::Bob*> bobs; | 258 | std::vector<Widelands::Bob*> bobs; |
3125 | 259 | // Scan progressively larger circles around the given position for | 259 | // Scan progressively larger circles around the given position for |
Continuous integration builds have changed state:
Travis build 2583. State: failed. Details: https:/ /travis- ci.org/ widelands/ widelands/ builds/ 266392703. /ci.appveyor. com/project/ widelands- dev/widelands/ build/_ widelands_ dev_widelands_ cleanup_ map-2405.
Appveyor build 2405. State: failed. Details: https:/