Merge lp:~widelands-dev/widelands/map_packet_loading into lp:widelands
- map_packet_loading
- Merge into trunk
Status: | Merged | ||||
---|---|---|---|---|---|
Merged at revision: | 7770 | ||||
Proposed branch: | lp:~widelands-dev/widelands/map_packet_loading | ||||
Merge into: | lp:widelands | ||||
Diff against target: |
866 lines (+261/-239) 15 files modified
data/maps/MP_Scenarios/Island_Hopping.wmf/player/1/messages (+0/-4) data/maps/MP_Scenarios/Island_Hopping.wmf/scripting/first_island.lua (+1/-1) data/maps/MP_Scenarios/Island_Hopping.wmf/scripting/texts.lua (+38/-36) src/editor/editorinteractive.cc (+2/-1) src/game_io/game_map_packet.cc (+1/-1) src/io/filesystem/layered_filesystem.cc (+7/-6) src/logic/game.cc (+5/-2) src/logic/map_info.cc (+1/-1) src/map_io/map_building_packet.cc (+2/-7) src/map_io/map_loader.h (+7/-1) src/map_io/map_saver.cc (+82/-72) src/map_io/s2map.cc (+1/-1) src/map_io/s2map.h (+1/-1) src/map_io/widelands_map_loader.cc (+112/-104) src/map_io/widelands_map_loader.h (+1/-1) |
||||
To merge this branch: | bzr merge lp:~widelands-dev/widelands/map_packet_loading | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
SirVer | Approve | ||
Review via email: mp+284470@code.launchpad.net |
Commit message
Map compatibility:
- No longer saving or loading unneeded packages in the editor.
- Removed compatibility code from MapBuildingPacket.
Description of the change
Old maps now should load fine again, because the unneeded packets are omitted in the editor both when loading and saving.
I have used "Together We're Strong" from Build 18 and "The Green Plateau" as test cases.
Scenarios still load all available map packets, so I have deleted the unneeded ones and also fixed Island Hopping a bit - the hopping doesn't work, but it's already broken in trunk. Also, Smugglers will crash, especially when not using the zip filesystem, but that bug is also already present in trunk.
bunnybot (widelandsofficial) wrote : | # |
bunnybot (widelandsofficial) wrote : | # |
Continuous integration builds have changed state:
Travis build 445. State: passed. Details: https:/
Appveyor build 342. State: success. Details: https:/
bunnybot (widelandsofficial) wrote : | # |
Continuous integration builds have changed state:
Travis build 482. State: failed. Details: https:/
Appveyor build 354. State: success. Details: https:/
SirVer (sirver) wrote : | # |
> the hopping doesn't work, but it's already broken in trunk.
Is there a bug for that? We should fix it for b19, no point in shipping a broken scenario. Same questions also for Smugglers.
Otherwise lgtm.
@bunnybot merge
GunChleoc (gunchleoc) wrote : | # |
Bug reports created - I didn't get the crash in Smugglers again, but it should be tested just in case.
Preview Diff
1 | === removed file 'data/maps/MP_Scenarios/Island_Hopping.wmf/binary/building' |
2 | Binary files data/maps/MP_Scenarios/Island_Hopping.wmf/binary/building 2010-11-22 11:40:06 +0000 and data/maps/MP_Scenarios/Island_Hopping.wmf/binary/building 1970-01-01 00:00:00 +0000 differ |
3 | === removed file 'data/maps/MP_Scenarios/Island_Hopping.wmf/binary/exploration' |
4 | Binary files data/maps/MP_Scenarios/Island_Hopping.wmf/binary/exploration 2010-11-22 11:40:06 +0000 and data/maps/MP_Scenarios/Island_Hopping.wmf/binary/exploration 1970-01-01 00:00:00 +0000 differ |
5 | === removed file 'data/maps/MP_Scenarios/Island_Hopping.wmf/binary/flag' |
6 | Binary files data/maps/MP_Scenarios/Island_Hopping.wmf/binary/flag 2010-11-22 11:40:06 +0000 and data/maps/MP_Scenarios/Island_Hopping.wmf/binary/flag 1970-01-01 00:00:00 +0000 differ |
7 | === removed file 'data/maps/MP_Scenarios/Island_Hopping.wmf/binary/node_ownership' |
8 | Binary files data/maps/MP_Scenarios/Island_Hopping.wmf/binary/node_ownership 2010-11-22 11:40:06 +0000 and data/maps/MP_Scenarios/Island_Hopping.wmf/binary/node_ownership 1970-01-01 00:00:00 +0000 differ |
9 | === removed file 'data/maps/MP_Scenarios/Island_Hopping.wmf/binary/road' |
10 | Binary files data/maps/MP_Scenarios/Island_Hopping.wmf/binary/road 2010-11-22 11:40:06 +0000 and data/maps/MP_Scenarios/Island_Hopping.wmf/binary/road 1970-01-01 00:00:00 +0000 differ |
11 | === removed directory 'data/maps/MP_Scenarios/Island_Hopping.wmf/player' |
12 | === removed directory 'data/maps/MP_Scenarios/Island_Hopping.wmf/player/1' |
13 | === removed directory 'data/maps/MP_Scenarios/Island_Hopping.wmf/player/1/binary' |
14 | === removed file 'data/maps/MP_Scenarios/Island_Hopping.wmf/player/1/binary/areawatchers' |
15 | Binary files data/maps/MP_Scenarios/Island_Hopping.wmf/player/1/binary/areawatchers 2010-11-22 11:40:06 +0000 and data/maps/MP_Scenarios/Island_Hopping.wmf/player/1/binary/areawatchers 1970-01-01 00:00:00 +0000 differ |
16 | === removed file 'data/maps/MP_Scenarios/Island_Hopping.wmf/player/1/messages' |
17 | --- data/maps/MP_Scenarios/Island_Hopping.wmf/player/1/messages 2010-11-22 11:40:06 +0000 |
18 | +++ data/maps/MP_Scenarios/Island_Hopping.wmf/player/1/messages 1970-01-01 00:00:00 +0000 |
19 | @@ -1,4 +0,0 @@ |
20 | -# Automatically created by Widelands bzr5747[widelands] (Debug) |
21 | - |
22 | -[global] |
23 | -packet_version="1" |
24 | |
25 | === removed directory 'data/maps/MP_Scenarios/Island_Hopping.wmf/player/1/view' |
26 | === removed file 'data/maps/MP_Scenarios/Island_Hopping.wmf/player/1/view/node_immovable_kinds_1' |
27 | === removed file 'data/maps/MP_Scenarios/Island_Hopping.wmf/player/1/view/node_immovables_1' |
28 | === removed file 'data/maps/MP_Scenarios/Island_Hopping.wmf/player/1/view/owners_0' |
29 | === removed file 'data/maps/MP_Scenarios/Island_Hopping.wmf/player/1/view/roads_1' |
30 | === removed file 'data/maps/MP_Scenarios/Island_Hopping.wmf/player/1/view/survey_amounts_1' |
31 | === removed file 'data/maps/MP_Scenarios/Island_Hopping.wmf/player/1/view/survey_times_1' |
32 | === removed file 'data/maps/MP_Scenarios/Island_Hopping.wmf/player/1/view/surveys_1' |
33 | === removed file 'data/maps/MP_Scenarios/Island_Hopping.wmf/player/1/view/terrains_1' |
34 | === removed file 'data/maps/MP_Scenarios/Island_Hopping.wmf/player/1/view/triangle_immovable_kinds_1' |
35 | === removed file 'data/maps/MP_Scenarios/Island_Hopping.wmf/player/1/view/triangle_immovables_1' |
36 | === removed file 'data/maps/MP_Scenarios/Island_Hopping.wmf/player/1/view/unseen_times_1' |
37 | === removed file 'data/maps/MP_Scenarios/Island_Hopping.wmf/player/1/view/vision_1' |
38 | Binary files data/maps/MP_Scenarios/Island_Hopping.wmf/player/1/view/vision_1 2010-11-22 11:40:06 +0000 and data/maps/MP_Scenarios/Island_Hopping.wmf/player/1/view/vision_1 1970-01-01 00:00:00 +0000 differ |
39 | === modified file 'data/maps/MP_Scenarios/Island_Hopping.wmf/scripting/first_island.lua' |
40 | --- data/maps/MP_Scenarios/Island_Hopping.wmf/scripting/first_island.lua 2015-10-31 12:11:44 +0000 |
41 | +++ data/maps/MP_Scenarios/Island_Hopping.wmf/scripting/first_island.lua 2016-02-01 17:51:32 +0000 |
42 | @@ -3,7 +3,7 @@ |
43 | -- ========================== |
44 | function _wait_for_castle_on_finish_area(plr, island_idx) |
45 | local finish_area = _finish_areas[island_idx][plr.number] |
46 | - while not check_for_buildings(plr, {castle=1}, finish_area) do |
47 | + while not check_for_buildings(plr, {atlanteans_castle=1}, finish_area) do |
48 | sleep(1237) |
49 | end |
50 | end |
51 | |
52 | === modified file 'data/maps/MP_Scenarios/Island_Hopping.wmf/scripting/texts.lua' |
53 | --- data/maps/MP_Scenarios/Island_Hopping.wmf/scripting/texts.lua 2015-11-21 11:34:10 +0000 |
54 | +++ data/maps/MP_Scenarios/Island_Hopping.wmf/scripting/texts.lua 2016-02-01 17:51:32 +0000 |
55 | @@ -1,42 +1,44 @@ |
56 | -- ======================================================================= |
57 | -- Texts for this scenario |
58 | -- ======================================================================= |
59 | -welcome_msg = rt( |
60 | - h1(_"Welcome to Island Hopping") .. |
61 | - h2(_"Rules") .. |
62 | - p(_( |
63 | -[[Island Hopping is a traditional tournament in Atlantean culture. ]] .. |
64 | -[[The rules of the game are simple: you start with a headquarters on an island. ]] .. |
65 | -[[When you finish a castle at the end of the first island, you are granted a ]] .. |
66 | -[[second headquarters on a second island, which will contain all wares from your ]] .. |
67 | -[[first headquarters.]] |
68 | -)) .. |
69 | - p(_( |
70 | -[[If you finish a castle in the target area on the second island, you will get ]] .. |
71 | -[[a third headquarters on the third island. You must build a castle at ]] .. |
72 | -[[the center of the third island and hold it for 20 minutes to win the game.]] |
73 | -)) .. |
74 | - p(_( |
75 | -[[Whenever you finish an island, you will get bonus wares, depending on how many players ]] .. |
76 | -[[have finished the island before you. The earlier you finish, the fewer wares you will get. ]] .. |
77 | -[[See below for the details.]])) .. p(_( |
78 | -[[The point is that the first island only provides rocks and trees, the second only meadows and resources. The economies you leave behind will continue to work for you, but you will only reap the benefits at the moment you reach a new island.]]) |
79 | -) .. |
80 | -p(_ |
81 | -[[Finally, be careful not to waste your quartz and diamonds.]] |
82 | -) .. |
83 | -h2(_"Finish Rewards") .. |
84 | -h3(_"First Island") .. |
85 | -h4(_"1st to finish") .. p(format_rewards(_finish_rewards[1][1])) .. |
86 | -h4(_"2nd to finish") .. p(format_rewards(_finish_rewards[1][2])) .. |
87 | -h4(_"3rd to finish") .. p(format_rewards(_finish_rewards[1][3])) .. |
88 | -h4(_"4th to finish") .. p(format_rewards(_finish_rewards[1][4])) .. |
89 | -h3(_"Second Island") .. |
90 | -h4(_"1st to finish") .. p(format_rewards(_finish_rewards[2][1])) .. |
91 | -h4(_"2nd to finish") .. p(format_rewards(_finish_rewards[2][2])) .. |
92 | -h4(_"3rd to finish") .. p(format_rewards(_finish_rewards[2][3])) .. |
93 | -h4(_"4th to finish") .. p(format_rewards(_finish_rewards[2][4])) |
94 | -) |
95 | +welcome_msg = { |
96 | + heading = _"Welcome to Island Hopping", |
97 | + body = rt( |
98 | + h2(_"Rules") .. |
99 | + p(_( |
100 | + [[Island Hopping is a traditional tournament in Atlantean culture. ]] .. |
101 | + [[The rules of the game are simple: you start with a headquarters on an island. ]] .. |
102 | + [[When you finish a castle at the end of the first island, you are granted a ]] .. |
103 | + [[second headquarters on a second island, which will contain all wares from your ]] .. |
104 | + [[first headquarters.]] |
105 | + )) .. |
106 | + p(_( |
107 | + [[If you finish a castle in the target area on the second island, you will get ]] .. |
108 | + [[a third headquarters on the third island. You must build a castle at ]] .. |
109 | + [[the center of the third island and hold it for 20 minutes to win the game.]] |
110 | + )) .. |
111 | + p(_( |
112 | + [[Whenever you finish an island, you will get bonus wares, depending on how many players ]] .. |
113 | + [[have finished the island before you. The earlier you finish, the fewer wares you will get. ]] .. |
114 | + [[See below for the details.]])) .. p(_( |
115 | + [[The point is that the first island only provides rocks and trees, the second only meadows and resources. The economies you leave behind will continue to work for you, but you will only reap the benefits at the moment you reach a new island.]]) |
116 | + ) .. |
117 | + p(_ |
118 | + [[Finally, be careful not to waste your quartz and diamonds.]] |
119 | + ) .. |
120 | + h2(_"Finish Rewards") .. |
121 | + h3(_"First Island") .. |
122 | + h4(_"1st to finish") .. p(format_rewards(_finish_rewards[1][1])) .. |
123 | + h4(_"2nd to finish") .. p(format_rewards(_finish_rewards[1][2])) .. |
124 | + h4(_"3rd to finish") .. p(format_rewards(_finish_rewards[1][3])) .. |
125 | + h4(_"4th to finish") .. p(format_rewards(_finish_rewards[1][4])) .. |
126 | + h3(_"Second Island") .. |
127 | + h4(_"1st to finish") .. p(format_rewards(_finish_rewards[2][1])) .. |
128 | + h4(_"2nd to finish") .. p(format_rewards(_finish_rewards[2][2])) .. |
129 | + h4(_"3rd to finish") .. p(format_rewards(_finish_rewards[2][3])) .. |
130 | + h4(_"4th to finish") .. p(format_rewards(_finish_rewards[2][4])) |
131 | + ) |
132 | +} |
133 | |
134 | msgs_finished_island = { |
135 | _"%1$s was the first to reach Island number %2$i.", |
136 | |
137 | === removed file 'data/maps/MP_Scenarios/Smugglers.wmf/binary/building' |
138 | Binary files data/maps/MP_Scenarios/Smugglers.wmf/binary/building 2012-04-25 07:39:44 +0000 and data/maps/MP_Scenarios/Smugglers.wmf/binary/building 1970-01-01 00:00:00 +0000 differ |
139 | === removed file 'data/maps/MP_Scenarios/Smugglers.wmf/binary/exploration' |
140 | Binary files data/maps/MP_Scenarios/Smugglers.wmf/binary/exploration 2012-04-25 07:39:44 +0000 and data/maps/MP_Scenarios/Smugglers.wmf/binary/exploration 1970-01-01 00:00:00 +0000 differ |
141 | === removed file 'data/maps/MP_Scenarios/Smugglers.wmf/binary/flag' |
142 | Binary files data/maps/MP_Scenarios/Smugglers.wmf/binary/flag 2012-04-25 07:39:44 +0000 and data/maps/MP_Scenarios/Smugglers.wmf/binary/flag 1970-01-01 00:00:00 +0000 differ |
143 | === removed file 'data/maps/MP_Scenarios/Smugglers.wmf/binary/node_ownership' |
144 | Binary files data/maps/MP_Scenarios/Smugglers.wmf/binary/node_ownership 2012-04-25 07:39:44 +0000 and data/maps/MP_Scenarios/Smugglers.wmf/binary/node_ownership 1970-01-01 00:00:00 +0000 differ |
145 | === removed file 'data/maps/MP_Scenarios/Smugglers.wmf/binary/road' |
146 | Binary files data/maps/MP_Scenarios/Smugglers.wmf/binary/road 2011-10-01 10:13:21 +0000 and data/maps/MP_Scenarios/Smugglers.wmf/binary/road 1970-01-01 00:00:00 +0000 differ |
147 | === removed file 'data/maps/Trident_of_Fire.wmf/binary/building' |
148 | Binary files data/maps/Trident_of_Fire.wmf/binary/building 2013-08-15 16:00:17 +0000 and data/maps/Trident_of_Fire.wmf/binary/building 1970-01-01 00:00:00 +0000 differ |
149 | === removed file 'data/maps/Trident_of_Fire.wmf/binary/exploration' |
150 | Binary files data/maps/Trident_of_Fire.wmf/binary/exploration 2013-08-15 16:00:17 +0000 and data/maps/Trident_of_Fire.wmf/binary/exploration 1970-01-01 00:00:00 +0000 differ |
151 | === removed file 'data/maps/Trident_of_Fire.wmf/binary/flag' |
152 | Binary files data/maps/Trident_of_Fire.wmf/binary/flag 2013-08-15 16:00:17 +0000 and data/maps/Trident_of_Fire.wmf/binary/flag 1970-01-01 00:00:00 +0000 differ |
153 | === removed file 'data/maps/Trident_of_Fire.wmf/binary/node_ownership' |
154 | Binary files data/maps/Trident_of_Fire.wmf/binary/node_ownership 2013-08-15 16:00:17 +0000 and data/maps/Trident_of_Fire.wmf/binary/node_ownership 1970-01-01 00:00:00 +0000 differ |
155 | === removed file 'data/maps/Trident_of_Fire.wmf/binary/road' |
156 | Binary files data/maps/Trident_of_Fire.wmf/binary/road 2013-08-15 16:00:17 +0000 and data/maps/Trident_of_Fire.wmf/binary/road 1970-01-01 00:00:00 +0000 differ |
157 | === modified file 'src/editor/editorinteractive.cc' |
158 | --- src/editor/editorinteractive.cc 2016-01-29 08:37:22 +0000 |
159 | +++ src/editor/editorinteractive.cc 2016-02-01 17:51:32 +0000 |
160 | @@ -42,6 +42,7 @@ |
161 | #include "logic/map_objects/world/resource_description.h" |
162 | #include "logic/map_objects/world/world.h" |
163 | #include "logic/player.h" |
164 | +#include "map_io/map_loader.h" |
165 | #include "map_io/widelands_map_loader.h" |
166 | #include "scripting/lua_interface.h" |
167 | #include "scripting/lua_table.h" |
168 | @@ -233,7 +234,7 @@ |
169 | egbase().add_player(p, 0, map.get_scenario_player_tribe(p), map.get_scenario_player_name(p)); |
170 | } |
171 | |
172 | - ml->load_map_complete(egbase(), true); |
173 | + ml->load_map_complete(egbase(), Widelands::MapLoader::LoadType::kEditor); |
174 | egbase().load_graphics(loader_ui); |
175 | map_changed(MapWas::kReplaced); |
176 | } |
177 | |
178 | === modified file 'src/game_io/game_map_packet.cc' |
179 | --- src/game_io/game_map_packet.cc 2014-09-20 09:37:47 +0000 |
180 | +++ src/game_io/game_map_packet.cc 2016-02-01 17:51:32 +0000 |
181 | @@ -54,7 +54,7 @@ |
182 | |
183 | |
184 | void GameMapPacket::read_complete(Game & game) { |
185 | - m_wml->load_map_complete(game, true); |
186 | + m_wml->load_map_complete(game, MapLoader::LoadType::kScenario); |
187 | m_mol = m_wml->get_map_object_loader(); |
188 | } |
189 | |
190 | |
191 | === modified file 'src/io/filesystem/layered_filesystem.cc' |
192 | --- src/io/filesystem/layered_filesystem.cc 2014-11-28 16:40:55 +0000 |
193 | +++ src/io/filesystem/layered_filesystem.cc 2016-02-01 17:51:32 +0000 |
194 | @@ -159,7 +159,7 @@ |
195 | if ((*it)->is_writable()) |
196 | return (*it)->write(fname, data, length); |
197 | |
198 | - throw wexception("LayeredFileSystem: No writable filesystem!"); |
199 | + throw wexception("LayeredFileSystem: No writable filesystem for %s!", fname.c_str()); |
200 | } |
201 | |
202 | /** |
203 | @@ -188,7 +188,7 @@ |
204 | if ((*it)->is_writable()) |
205 | return (*it)->open_stream_write(fname); |
206 | |
207 | - throw wexception("LayeredFileSystem: No writable filesystem!"); |
208 | + throw wexception("LayeredFileSystem: No writable filesystem for %s!", fname.c_str()); |
209 | } |
210 | |
211 | /** |
212 | @@ -202,7 +202,7 @@ |
213 | if ((*it)->is_writable()) |
214 | return (*it)->make_directory(dirname); |
215 | |
216 | - throw wexception("LayeredFileSystem: No writable filesystem!"); |
217 | + throw wexception("LayeredFileSystem: No writable filesystem for dir: %s!", dirname.c_str()); |
218 | } |
219 | |
220 | /** |
221 | @@ -216,7 +216,7 @@ |
222 | if ((*it)->is_writable()) |
223 | return (*it)->ensure_directory_exists(dirname); |
224 | |
225 | - throw wexception("LayeredFileSystem: No writable filesystem!"); |
226 | + throw wexception("LayeredFileSystem: No writable filesystem for dir: %s!", dirname.c_str()); |
227 | } |
228 | |
229 | /** |
230 | @@ -231,7 +231,8 @@ |
231 | if ((*it)->is_writable() && (*it)->file_exists(dirname)) |
232 | return (*it)->make_sub_file_system(dirname); |
233 | |
234 | - throw wexception("LayeredFileSystem: unable to create sub filesystem"); |
235 | + throw wexception("LayeredFileSystem: unable to create sub filesystem for existing dir: %s", |
236 | + dirname.c_str()); |
237 | } |
238 | |
239 | /** |
240 | @@ -246,7 +247,7 @@ |
241 | if ((*it)->is_writable() && !(*it)->file_exists(dirname)) |
242 | return (*it)->create_sub_file_system(dirname, type); |
243 | |
244 | - throw wexception("LayeredFileSystem: unable to create sub filesystem"); |
245 | + throw wexception("LayeredFileSystem: unable to create sub filesystem for new dir: %s", dirname.c_str()); |
246 | } |
247 | |
248 | /** |
249 | |
250 | === modified file 'src/logic/game.cc' |
251 | --- src/logic/game.cc 2016-01-08 21:00:39 +0000 |
252 | +++ src/logic/game.cc 2016-02-01 17:51:32 +0000 |
253 | @@ -254,7 +254,7 @@ |
254 | (*this, g_options.pull_section("global"), 1, false)); |
255 | |
256 | loaderUI.step(_("Loading map")); |
257 | - maploader->load_map_complete(*this, true); |
258 | + maploader->load_map_complete(*this, Widelands::MapLoader::LoadType::kScenario); |
259 | maploader.reset(); |
260 | |
261 | set_game_controller(new SinglePlayerGameController(*this, true, 1)); |
262 | @@ -340,7 +340,10 @@ |
263 | |
264 | if (loaderUI) |
265 | loaderUI->step(_("Loading map")); |
266 | - maploader->load_map_complete(*this, settings.scenario); |
267 | + maploader->load_map_complete(*this, |
268 | + settings.scenario ? |
269 | + Widelands::MapLoader::LoadType::kScenario : |
270 | + Widelands::MapLoader::LoadType::kGame); |
271 | |
272 | // Check for win_conditions |
273 | if (!settings.scenario) { |
274 | |
275 | === modified file 'src/logic/map_info.cc' |
276 | --- src/logic/map_info.cc 2016-01-24 12:43:26 +0000 |
277 | +++ src/logic/map_info.cc 2016-02-01 17:51:32 +0000 |
278 | @@ -85,7 +85,7 @@ |
279 | } |
280 | |
281 | ml->preload_map(true); |
282 | - ml->load_map_complete(egbase, true); |
283 | + ml->load_map_complete(egbase, Widelands::MapLoader::LoadType::kScenario); |
284 | |
285 | std::unique_ptr<Texture> minimap( |
286 | draw_minimap(egbase, nullptr, Point(0, 0), MiniMapLayer::Terrain)); |
287 | |
288 | === modified file 'src/map_io/map_building_packet.cc' |
289 | --- src/map_io/map_building_packet.cc 2015-11-28 22:29:26 +0000 |
290 | +++ src/map_io/map_building_packet.cc 2016-02-01 17:51:32 +0000 |
291 | @@ -38,8 +38,6 @@ |
292 | namespace Widelands { |
293 | |
294 | constexpr uint16_t kCurrentPacketVersion = 3; |
295 | -constexpr uint16_t kLowestSupportedVersion = 1; |
296 | -constexpr uint16_t kPrioritiesIntroducedInVersion = 2; |
297 | |
298 | // constants to handle special building types |
299 | constexpr uint8_t kTypeBuilding = 0; |
300 | @@ -57,7 +55,7 @@ |
301 | InteractiveBase & ibase = *egbase.get_ibase(); |
302 | try { |
303 | uint16_t const packet_version = fr.unsigned_16(); |
304 | - if (packet_version >= kLowestSupportedVersion && packet_version <= kCurrentPacketVersion) { |
305 | + if (packet_version == kCurrentPacketVersion) { |
306 | Map & map = egbase.map(); |
307 | uint16_t const width = map.get_width (); |
308 | uint16_t const height = map.get_height(); |
309 | @@ -98,10 +96,7 @@ |
310 | } |
311 | |
312 | mol.register_object<Building> (serial, *building); |
313 | - |
314 | - if (packet_version >= kPrioritiesIntroducedInVersion) { |
315 | - read_priorities (*building, fr); |
316 | - } |
317 | + read_priorities (*building, fr); |
318 | |
319 | // Reference the players tribe if in editor. |
320 | if (g_gr) // but not on dedicated servers ;) |
321 | |
322 | === modified file 'src/map_io/map_loader.h' |
323 | --- src/map_io/map_loader.h 2014-10-04 09:40:18 +0000 |
324 | +++ src/map_io/map_loader.h 2016-02-01 17:51:32 +0000 |
325 | @@ -36,12 +36,18 @@ |
326 | /// must be selected. |
327 | class MapLoader { |
328 | public: |
329 | + enum class LoadType { |
330 | + kGame, |
331 | + kScenario, |
332 | + kEditor |
333 | + }; |
334 | + |
335 | MapLoader(const std::string& filename, Map & M) |
336 | : m_map(M), m_s(STATE_INIT) {m_map.set_filename(filename);} |
337 | virtual ~MapLoader() {} |
338 | |
339 | virtual int32_t preload_map(bool as_scenario) = 0; |
340 | - virtual int32_t load_map_complete(EditorGameBase &, bool as_scenario) = 0; |
341 | + virtual int32_t load_map_complete(EditorGameBase &, MapLoader::LoadType) = 0; |
342 | |
343 | Map & map() {return m_map;} |
344 | |
345 | |
346 | === modified file 'src/map_io/map_saver.cc' |
347 | --- src/map_io/map_saver.cc 2016-01-18 19:08:41 +0000 |
348 | +++ src/map_io/map_saver.cc 2016-02-01 17:51:32 +0000 |
349 | @@ -76,6 +76,8 @@ |
350 | delete m_mos; |
351 | m_mos = new MapObjectSaver(); |
352 | |
353 | + bool is_game = is_a(Game, &m_egbase); |
354 | + |
355 | // The binary data is saved in an own directory |
356 | // to keep it hidden from the poor debuggers |
357 | m_fs.ensure_directory_exists("binary"); |
358 | @@ -88,8 +90,7 @@ |
359 | log("took %ums\n ", timer.ms_since_last_query()); |
360 | |
361 | log("Writing Player Names And Tribe Data ... "); |
362 | - {MapPlayerNamesAndTribesPacket p; p.write(m_fs, m_egbase, *m_mos); |
363 | - } |
364 | + {MapPlayerNamesAndTribesPacket p; p.write(m_fs, m_egbase, *m_mos);} |
365 | log("took %ums\n ", timer.ms_since_last_query()); |
366 | // PRELOAD DATA END |
367 | |
368 | @@ -109,12 +110,15 @@ |
369 | {MapPlayerPositionPacket p; p.write(m_fs, m_egbase, *m_mos);} |
370 | log("took %ums\n ", timer.ms_since_last_query()); |
371 | |
372 | - // This must come before anything that references messages, such as: |
373 | - // * command queue (PlayerMessageCommand, inherited by |
374 | - // Cmd_MessageSetStatusRead and Cmd_MessageSetStatusArchived) |
375 | - log("Writing Player Message Data ... "); |
376 | - {MapPlayersMessagesPacket p; p.write(m_fs, m_egbase, *m_mos);} |
377 | - log("took %ums\n ", timer.ms_since_last_query()); |
378 | + // We don't save these when saving a map in the editor. |
379 | + if (is_game) { |
380 | + // This must come before anything that references messages, such as: |
381 | + // * command queue (PlayerMessageCommand, inherited by |
382 | + // Cmd_MessageSetStatusRead and Cmd_MessageSetStatusArchived) |
383 | + log("Writing Player Message Data ... "); |
384 | + {MapPlayersMessagesPacket p; p.write(m_fs, m_egbase, *m_mos);} |
385 | + log("took %ums\n ", timer.ms_since_last_query()); |
386 | + } |
387 | |
388 | log("Writing Resources Data ... "); |
389 | {MapResourcesPacket p; p.write(m_fs, m_egbase);} |
390 | @@ -129,20 +133,19 @@ |
391 | {MapVersionPacket p; p.write(m_fs, m_egbase, *m_mos);} |
392 | log("took %ums\n ", timer.ms_since_last_query()); |
393 | |
394 | - |
395 | - const Map & map = m_egbase.map(); |
396 | - |
397 | - PlayerNumber const nr_players = map.get_nrplayers(); |
398 | - |
399 | - // allowed worker types |
400 | - log("Writing Allowed Worker Types Data ... "); |
401 | - {MapAllowedWorkerTypesPacket p; p.write(m_fs, m_egbase, *m_mos);} |
402 | - log("took %ums\n ", timer.ms_since_last_query()); |
403 | - |
404 | - // allowed building types |
405 | - // Not saving this when in editor - it causes issues when changing tribe |
406 | - // after next load in editor |
407 | - if (is_a(Game, &m_egbase)) { |
408 | + // We don't save these when saving a map in the editor. |
409 | + if (is_game) { |
410 | + |
411 | + const Map & map = m_egbase.map(); |
412 | + |
413 | + PlayerNumber const nr_players = map.get_nrplayers(); |
414 | + |
415 | + // allowed worker types |
416 | + log("Writing Allowed Worker Types Data ... "); |
417 | + {MapAllowedWorkerTypesPacket p; p.write(m_fs, m_egbase, *m_mos);} |
418 | + log("took %ums\n ", timer.ms_since_last_query()); |
419 | + |
420 | + // allowed building types |
421 | iterate_players_existing_const(plnum, nr_players, m_egbase, player) { |
422 | for (DescriptionIndex i = 0; i < m_egbase.tribes().nrbuildings(); ++i) { |
423 | if (!player->is_building_type_allowed(i)) { |
424 | @@ -154,59 +157,64 @@ |
425 | } |
426 | } |
427 | } end_find_a_forbidden_building_type_loop:; |
428 | + |
429 | + // !!!!!!!!!! NOTE |
430 | + // This packet must be written before any building or road packet. So do not |
431 | + // change this order unless you know what you are doing |
432 | + // EXISTING PACKETS |
433 | + log("Writing Flag Data ... "); |
434 | + {MapFlagPacket p; p.write(m_fs, m_egbase, *m_mos);} |
435 | + log("took %ums\n ", timer.ms_since_last_query()); |
436 | + |
437 | + log("Writing Road Data ... "); |
438 | + {MapRoadPacket p; p.write(m_fs, m_egbase, *m_mos);} |
439 | + log("took %ums\n ", timer.ms_since_last_query()); |
440 | + |
441 | + log("Writing Building Data ... "); |
442 | + {MapBuildingPacket p; p.write(m_fs, m_egbase, *m_mos);} |
443 | + log("took %ums\n ", timer.ms_since_last_query()); |
444 | + |
445 | } |
446 | |
447 | - // !!!!!!!!!! NOTE |
448 | - // This packet must be before any building or road packet. So do not |
449 | - // change this order without knowing what you do |
450 | - // EXISTENT PACKETS |
451 | - log("Writing Flag Data ... "); |
452 | - {MapFlagPacket p; p.write(m_fs, m_egbase, *m_mos);} |
453 | - log("took %ums\n ", timer.ms_since_last_query()); |
454 | - |
455 | - log("Writing Road Data ... "); |
456 | - {MapRoadPacket p; p.write(m_fs, m_egbase, *m_mos);} |
457 | - log("took %ums\n ", timer.ms_since_last_query()); |
458 | - |
459 | - log("Writing Building Data ... "); |
460 | - {MapBuildingPacket p; p.write(m_fs, m_egbase, *m_mos);} |
461 | - log("took %ums\n ", timer.ms_since_last_query()); |
462 | - |
463 | + // We do need to save this one in the editor! |
464 | log("Writing Map Objects ... "); |
465 | {MapObjectPacket p; p.write(m_fs, m_egbase, *m_mos);} |
466 | log("took %ums\n ", timer.ms_since_last_query()); |
467 | |
468 | - // DATA PACKETS |
469 | - if (m_mos->get_nr_flags()) { |
470 | - log("Writing Flagdata Data ... "); |
471 | - {MapFlagdataPacket p; p.write(m_fs, m_egbase, *m_mos);} |
472 | - log("took %ums\n ", timer.ms_since_last_query()); |
473 | - } |
474 | - |
475 | - if (m_mos->get_nr_roads()) { |
476 | - log("Writing Roaddata Data ... "); |
477 | - {MapRoaddataPacket p; p.write(m_fs, m_egbase, *m_mos);} |
478 | - log("took %ums\n ", timer.ms_since_last_query()); |
479 | - } |
480 | - |
481 | - if (m_mos->get_nr_buildings()) { |
482 | - log("Writing Buildingdata Data ... "); |
483 | - {MapBuildingdataPacket p; p.write(m_fs, m_egbase, *m_mos);} |
484 | - log("took %ums\n ", timer.ms_since_last_query()); |
485 | - } |
486 | - |
487 | - log("Writing Node Ownership Data ... "); |
488 | - {MapNodeOwnershipPacket p; p.write(m_fs, m_egbase, *m_mos);} |
489 | - log("took %ums\n ", timer.ms_since_last_query()); |
490 | - |
491 | - log("Writing Exploration Data ... "); |
492 | - {MapExplorationPacket p; p.write(m_fs, m_egbase, *m_mos);} |
493 | - log("took %ums\n ", timer.ms_since_last_query()); |
494 | - |
495 | - log("Writing Players Unseen Data ... "); |
496 | - {MapPlayersViewPacket p; p.write(m_fs, m_egbase, *m_mos);} |
497 | - log("took %ums\n ", timer.ms_since_last_query()); |
498 | - |
499 | + if (is_game) { |
500 | + // DATA PACKETS |
501 | + if (m_mos->get_nr_flags()) { |
502 | + log("Writing Flagdata Data ... "); |
503 | + {MapFlagdataPacket p; p.write(m_fs, m_egbase, *m_mos);} |
504 | + log("took %ums\n ", timer.ms_since_last_query()); |
505 | + } |
506 | + |
507 | + if (m_mos->get_nr_roads()) { |
508 | + log("Writing Roaddata Data ... "); |
509 | + {MapRoaddataPacket p; p.write(m_fs, m_egbase, *m_mos);} |
510 | + log("took %ums\n ", timer.ms_since_last_query()); |
511 | + } |
512 | + |
513 | + if (m_mos->get_nr_buildings()) { |
514 | + log("Writing Buildingdata Data ... "); |
515 | + {MapBuildingdataPacket p; p.write(m_fs, m_egbase, *m_mos);} |
516 | + log("took %ums\n ", timer.ms_since_last_query()); |
517 | + } |
518 | + |
519 | + log("Writing Node Ownership Data ... "); |
520 | + {MapNodeOwnershipPacket p; p.write(m_fs, m_egbase, *m_mos);} |
521 | + log("took %ums\n ", timer.ms_since_last_query()); |
522 | + |
523 | + log("Writing Exploration Data ... "); |
524 | + {MapExplorationPacket p; p.write(m_fs, m_egbase, *m_mos);} |
525 | + log("took %ums\n ", timer.ms_since_last_query()); |
526 | + |
527 | + log("Writing Players Unseen Data ... "); |
528 | + {MapPlayersViewPacket p; p.write(m_fs, m_egbase, *m_mos);} |
529 | + log("took %ums\n ", timer.ms_since_last_query()); |
530 | + } |
531 | + |
532 | + // We also want to write these in the editor. |
533 | log("Writing Scripting Data ... "); |
534 | {MapScriptingPacket p; p.write(m_fs, m_egbase, *m_mos);} |
535 | log("took %ums\n ", timer.ms_since_last_query()); |
536 | @@ -215,9 +223,11 @@ |
537 | {MapObjectivePacket p; p.write(m_fs, m_egbase, *m_mos);} |
538 | log("took %ums\n ", timer.ms_since_last_query()); |
539 | |
540 | -#ifndef NDEBUG |
541 | - m_mos->detect_unsaved_objects(); |
542 | -#endif |
543 | + if (is_game) { |
544 | + #ifndef NDEBUG |
545 | + m_mos->detect_unsaved_objects(); |
546 | + #endif |
547 | + } |
548 | |
549 | // Write minimap |
550 | { |
551 | |
552 | === modified file 'src/map_io/s2map.cc' |
553 | --- src/map_io/s2map.cc 2016-01-17 20:04:07 +0000 |
554 | +++ src/map_io/s2map.cc 2016-02-01 17:51:32 +0000 |
555 | @@ -359,7 +359,7 @@ |
556 | * From now on the Map* can't be set to another one. |
557 | */ |
558 | int32_t S2MapLoader::load_map_complete |
559 | - (Widelands::EditorGameBase & egbase, bool) |
560 | + (Widelands::EditorGameBase& egbase, MapLoader::LoadType) |
561 | { |
562 | ScopedTimer timer("S2MapLoader::load_map_complete() took %ums"); |
563 | |
564 | |
565 | === modified file 'src/map_io/s2map.h' |
566 | --- src/map_io/s2map.h 2014-10-04 09:40:18 +0000 |
567 | +++ src/map_io/s2map.h 2016-02-01 17:51:32 +0000 |
568 | @@ -38,7 +38,7 @@ |
569 | |
570 | int32_t preload_map(bool) override; |
571 | virtual int32_t load_map_complete |
572 | - (Widelands::EditorGameBase &, bool scenario) override; |
573 | + (Widelands::EditorGameBase&, Widelands::MapLoader::LoadType) override; |
574 | |
575 | private: |
576 | const std::string m_filename; |
577 | |
578 | === modified file 'src/map_io/widelands_map_loader.cc' |
579 | --- src/map_io/widelands_map_loader.cc 2016-01-06 19:11:20 +0000 |
580 | +++ src/map_io/widelands_map_loader.cc 2016-02-01 17:51:32 +0000 |
581 | @@ -106,11 +106,13 @@ |
582 | * Load the complete map and make sure that it runs without problems |
583 | */ |
584 | int32_t WidelandsMapLoader::load_map_complete |
585 | - (EditorGameBase & egbase, bool const scenario) |
586 | + (EditorGameBase & egbase, MapLoader::LoadType load_type) |
587 | { |
588 | ScopedTimer timer("WidelandsMapLoader::load_map_complete() took %ums"); |
589 | |
590 | - preload_map(scenario); |
591 | + bool is_game = load_type == MapLoader::LoadType::kGame; |
592 | + |
593 | + preload_map(!is_game); |
594 | m_map.set_size(m_map.m_width, m_map.m_height); |
595 | m_mol.reset(new MapObjectLoader()); |
596 | |
597 | @@ -118,7 +120,7 @@ |
598 | // PRELOAD DATA BEGIN |
599 | log("Reading Elemental Data ... "); |
600 | MapElementalPacket elemental_data_packet; |
601 | - elemental_data_packet.read(*m_fs, egbase, !scenario, *m_mol); |
602 | + elemental_data_packet.read(*m_fs, egbase, is_game, *m_mol); |
603 | log("took %ums\n ", timer.ms_since_last_query()); |
604 | |
605 | egbase.allocate_player_maps(); // Can do this now that map size is known. |
606 | @@ -127,7 +129,7 @@ |
607 | log("Reading Player Names And Tribe Data ... "); |
608 | { |
609 | MapPlayerNamesAndTribesPacket p; |
610 | - p.read(*m_fs, egbase, !scenario, *m_mol); |
611 | + p.read(*m_fs, egbase, is_game, *m_mol); |
612 | } |
613 | log("took %ums\n ", timer.ms_since_last_query()); |
614 | // PRELOAD DATA END |
615 | @@ -136,13 +138,13 @@ |
616 | log("Reading Port Spaces Data ... "); |
617 | |
618 | MapPortSpacesPacket p; |
619 | - p.read(*m_fs, egbase, !scenario, *m_mol); |
620 | + p.read(*m_fs, egbase, is_game, *m_mol); |
621 | |
622 | log("took %ums\n ", timer.ms_since_last_query()); |
623 | } |
624 | |
625 | log("Reading Heights Data ... "); |
626 | - {MapHeightsPacket p; p.read(*m_fs, egbase, !scenario, *m_mol);} |
627 | + {MapHeightsPacket p; p.read(*m_fs, egbase, is_game, *m_mol);} |
628 | log("took %ums\n ", timer.ms_since_last_query()); |
629 | |
630 | std::unique_ptr<WorldLegacyLookupTable> world_lookup_table |
631 | @@ -161,7 +163,7 @@ |
632 | log("Reading Player Start Position Data ... "); |
633 | { |
634 | MapPlayerPositionPacket p; |
635 | - p.read(*m_fs, egbase, !scenario, *m_mol); |
636 | + p.read(*m_fs, egbase, is_game, *m_mol); |
637 | } |
638 | log("took %ums\n ", timer.ms_since_last_query()); |
639 | |
640 | @@ -182,111 +184,117 @@ |
641 | log("took %ums\n ", timer.ms_since_last_query()); |
642 | |
643 | // NON MANDATORY PACKETS BELOW THIS POINT |
644 | - log("Reading Map Extra Data ... "); |
645 | - {MapExtradataPacket p; p.read(*m_fs, !scenario);} |
646 | - log("took %ums\n ", timer.ms_since_last_query()); |
647 | - |
648 | - log("Reading Map Version Data ... "); |
649 | - {MapVersionPacket p; p.read(*m_fs, egbase, !scenario, *m_mol);} |
650 | - log("took %ums\n ", timer.ms_since_last_query()); |
651 | - |
652 | - |
653 | - log("Reading Allowed Worker Types Data ... "); |
654 | - { |
655 | - MapAllowedWorkerTypesPacket p; |
656 | - p.read(*m_fs, egbase, !scenario, *m_mol); |
657 | - } |
658 | - log("took %ums\n ", timer.ms_since_last_query()); |
659 | - |
660 | - log("Reading Allowed Building Types Data ... "); |
661 | - { |
662 | - MapAllowedBuildingTypesPacket p; |
663 | - p.read(*m_fs, egbase, !scenario, *m_mol); |
664 | - } |
665 | - log("took %ums\n ", timer.ms_since_last_query()); |
666 | - |
667 | - log("Reading Node Ownership Data ... "); |
668 | - {MapNodeOwnershipPacket p; p.read(*m_fs, egbase, !scenario, *m_mol);} |
669 | - log("took %ums\n ", timer.ms_since_last_query()); |
670 | - |
671 | - log("Reading Exploration Data ... "); |
672 | - {MapExplorationPacket p; p.read(*m_fs, egbase, !scenario, *m_mol);} |
673 | - log("took %ums\n ", timer.ms_since_last_query()); |
674 | - |
675 | - // !!!!!!!!!! NOTE |
676 | - // This packet must be before any building or road packet. So do not change |
677 | - // this order without knowing what you do |
678 | - // EXISTENT PACKETS |
679 | - log("Reading Flag Data ... "); |
680 | - {MapFlagPacket p; p.read(*m_fs, egbase, !scenario, *m_mol);} |
681 | - log("took %ums\n ", timer.ms_since_last_query()); |
682 | - |
683 | - log("Reading Road Data ... "); |
684 | - {MapRoadPacket p; p.read(*m_fs, egbase, !scenario, *m_mol);} |
685 | - log("took %ums\n ", timer.ms_since_last_query()); |
686 | - |
687 | - log("Reading Building Data ... "); |
688 | - {MapBuildingPacket p; p.read(*m_fs, egbase, !scenario, *m_mol);} |
689 | - log("took %ums\n ", timer.ms_since_last_query()); |
690 | - |
691 | - // DATA PACKETS |
692 | - log("Reading Flagdata Data ... "); |
693 | - {MapFlagdataPacket p; p.read(*m_fs, egbase, !scenario, *m_mol);} |
694 | - log("took %ums\n ", timer.ms_since_last_query()); |
695 | - |
696 | - log("Reading Roaddata Data ... "); |
697 | - {MapRoaddataPacket p; p.read(*m_fs, egbase, !scenario, *m_mol);} |
698 | - log("took %ums\n ", timer.ms_since_last_query()); |
699 | - |
700 | - log("Reading Buildingdata Data ... "); |
701 | - {MapBuildingdataPacket p; p.read(*m_fs, egbase, !scenario, *m_mol);} |
702 | - log("took %ums\n ", timer.ms_since_last_query()); |
703 | - |
704 | - log("Second and third phase loading Map Objects ... "); |
705 | - mapobjects.load_finish(); |
706 | - { |
707 | - const Field & fields_end = map()[map().max_index()]; |
708 | - for (Field * field = &map()[0]; field < &fields_end; ++field) |
709 | - if (BaseImmovable * const imm = field->get_immovable()) { |
710 | - if (upcast(Building const, building, imm)) |
711 | - if (field != &map()[building->get_position()]) |
712 | - continue; // not the building's main position |
713 | - imm->load_finish(egbase); |
714 | - } |
715 | - } |
716 | - log("took %ums\n ", timer.ms_since_last_query()); |
717 | - |
718 | - // This should be at least after loading Soldiers (Bobs). |
719 | - // NOTE DO NOT CHANGE THE PLACE UNLESS YOU KNOW WHAT ARE YOU DOING |
720 | - // Must be loaded after every kind of object that can see. |
721 | - log("Reading Players View Data ... "); |
722 | - {MapPlayersViewPacket p; p.read(*m_fs, egbase, !scenario, *m_mol);} |
723 | - log("took %ums\n ", timer.ms_since_last_query()); |
724 | - |
725 | - // This must come before anything that references messages, such as: |
726 | - // * command queue (PlayerMessageCommand, inherited by |
727 | - // Cmd_MessageSetStatusRead and Cmd_MessageSetStatusArchived) |
728 | - log("Reading Player Message Data ... "); |
729 | - { |
730 | - MapPlayersMessagesPacket p; |
731 | - p.read(*m_fs, egbase, !scenario, *m_mol); |
732 | - } |
733 | - log("took %ums\n ", timer.ms_since_last_query()); |
734 | + // Do not load unneeded packages in the editor |
735 | + if (load_type != MapLoader::LoadType::kEditor) { |
736 | + log("Reading Map Extra Data ... "); |
737 | + {MapExtradataPacket p; p.read(*m_fs, is_game);} |
738 | + log("took %ums\n ", timer.ms_since_last_query()); |
739 | + |
740 | + log("Reading Map Version Data ... "); |
741 | + {MapVersionPacket p; p.read(*m_fs, egbase, is_game, *m_mol);} |
742 | + log("took %ums\n ", timer.ms_since_last_query()); |
743 | + |
744 | + |
745 | + log("Reading Allowed Worker Types Data ... "); |
746 | + { |
747 | + MapAllowedWorkerTypesPacket p; |
748 | + p.read(*m_fs, egbase, is_game, *m_mol); |
749 | + } |
750 | + log("took %ums\n ", timer.ms_since_last_query()); |
751 | + |
752 | + log("Reading Allowed Building Types Data ... "); |
753 | + { |
754 | + MapAllowedBuildingTypesPacket p; |
755 | + p.read(*m_fs, egbase, is_game, *m_mol); |
756 | + } |
757 | + log("took %ums\n ", timer.ms_since_last_query()); |
758 | + |
759 | + log("Reading Node Ownership Data ... "); |
760 | + {MapNodeOwnershipPacket p; p.read(*m_fs, egbase, is_game, *m_mol);} |
761 | + log("took %ums\n ", timer.ms_since_last_query()); |
762 | + |
763 | + log("Reading Exploration Data ... "); |
764 | + {MapExplorationPacket p; p.read(*m_fs, egbase, is_game, *m_mol);} |
765 | + log("took %ums\n ", timer.ms_since_last_query()); |
766 | + |
767 | + // !!!!!!!!!! NOTE |
768 | + // This packet must be before any building or road packet. So do not change |
769 | + // this order without knowing what you do |
770 | + // EXISTENT PACKETS |
771 | + log("Reading Flag Data ... "); |
772 | + {MapFlagPacket p; p.read(*m_fs, egbase, is_game, *m_mol);} |
773 | + log("took %ums\n ", timer.ms_since_last_query()); |
774 | + |
775 | + log("Reading Road Data ... "); |
776 | + {MapRoadPacket p; p.read(*m_fs, egbase, is_game, *m_mol);} |
777 | + log("took %ums\n ", timer.ms_since_last_query()); |
778 | + |
779 | + log("Reading Building Data ... "); |
780 | + {MapBuildingPacket p; p.read(*m_fs, egbase, is_game, *m_mol);} |
781 | + log("took %ums\n ", timer.ms_since_last_query()); |
782 | + |
783 | + // DATA PACKETS |
784 | + log("Reading Flagdata Data ... "); |
785 | + {MapFlagdataPacket p; p.read(*m_fs, egbase, is_game, *m_mol);} |
786 | + log("took %ums\n ", timer.ms_since_last_query()); |
787 | + |
788 | + log("Reading Roaddata Data ... "); |
789 | + {MapRoaddataPacket p; p.read(*m_fs, egbase, is_game, *m_mol);} |
790 | + log("took %ums\n ", timer.ms_since_last_query()); |
791 | + |
792 | + log("Reading Buildingdata Data ... "); |
793 | + {MapBuildingdataPacket p; p.read(*m_fs, egbase, is_game, *m_mol);} |
794 | + log("took %ums\n ", timer.ms_since_last_query()); |
795 | + |
796 | + log("Second and third phase loading Map Objects ... "); |
797 | + mapobjects.load_finish(); |
798 | + { |
799 | + const Field & fields_end = map()[map().max_index()]; |
800 | + for (Field * field = &map()[0]; field < &fields_end; ++field) |
801 | + if (BaseImmovable * const imm = field->get_immovable()) { |
802 | + if (upcast(Building const, building, imm)) |
803 | + if (field != &map()[building->get_position()]) |
804 | + continue; // not the building's main position |
805 | + imm->load_finish(egbase); |
806 | + } |
807 | + } |
808 | + log("took %ums\n ", timer.ms_since_last_query()); |
809 | + |
810 | + // This should be at least after loading Soldiers (Bobs). |
811 | + // NOTE DO NOT CHANGE THE PLACE UNLESS YOU KNOW WHAT ARE YOU DOING |
812 | + // Must be loaded after every kind of object that can see. |
813 | + log("Reading Players View Data ... "); |
814 | + {MapPlayersViewPacket p; p.read(*m_fs, egbase, is_game, *m_mol);} |
815 | + log("took %ums\n ", timer.ms_since_last_query()); |
816 | + |
817 | + // This must come before anything that references messages, such as: |
818 | + // * command queue (PlayerMessageCommand, inherited by |
819 | + // Cmd_MessageSetStatusRead and Cmd_MessageSetStatusArchived) |
820 | + log("Reading Player Message Data ... "); |
821 | + { |
822 | + MapPlayersMessagesPacket p; |
823 | + p.read(*m_fs, egbase, is_game, *m_mol); |
824 | + } |
825 | + log("took %ums\n ", timer.ms_since_last_query()); |
826 | + } // load_type != MapLoader::LoadType::kEditor |
827 | |
828 | // Objectives |
829 | log("Reading Objective Data ... "); |
830 | - {MapObjectivePacket p; p.read(*m_fs, egbase, !scenario, *m_mol);} |
831 | + {MapObjectivePacket p; p.read(*m_fs, egbase, is_game, *m_mol);} |
832 | log("took %ums\n ", timer.ms_since_last_query()); |
833 | |
834 | log("Reading Scripting Data ... "); |
835 | - {MapScriptingPacket p; p.read(*m_fs, egbase, !scenario, *m_mol);} |
836 | + {MapScriptingPacket p; p.read(*m_fs, egbase, is_game, *m_mol);} |
837 | log("took %ums\n ", timer.ms_since_last_query()); |
838 | |
839 | - if (m_mol->get_nr_unloaded_objects()) |
840 | - log |
841 | - ("WARNING: There are %i unloaded objects. This is a bug, please " |
842 | - "consider committing!\n", |
843 | - m_mol->get_nr_unloaded_objects()); |
844 | + if (load_type != MapLoader::LoadType::kEditor) { |
845 | + if (m_mol->get_nr_unloaded_objects()) { |
846 | + log |
847 | + ("WARNING: There are %i unloaded objects. This is a bug, please " |
848 | + "consider committing!\n", |
849 | + m_mol->get_nr_unloaded_objects()); |
850 | + } |
851 | + } // load_type != MapLoader::LoadType::kEditor |
852 | |
853 | m_map.recalc_whole_map(egbase.world()); |
854 | |
855 | |
856 | === modified file 'src/map_io/widelands_map_loader.h' |
857 | --- src/map_io/widelands_map_loader.h 2015-01-27 20:43:52 +0000 |
858 | +++ src/map_io/widelands_map_loader.h 2016-02-01 17:51:32 +0000 |
859 | @@ -41,7 +41,7 @@ |
860 | virtual ~WidelandsMapLoader(); |
861 | |
862 | int32_t preload_map(bool) override; |
863 | - int32_t load_map_complete(EditorGameBase &, bool) override; |
864 | + int32_t load_map_complete(EditorGameBase &, MapLoader::LoadType load_type) override; |
865 | |
866 | MapObjectLoader * get_map_object_loader() {return m_mol.get();} |
867 |
Hi, I am bunnybot (https:/ /github. com/widelands/ bunnybot).
I am keeping the source branch lp:~widelands-dev/widelands/map_packet_loading mirrored to https:/ /github. com/widelands/ widelands/ tree/_widelands _dev_widelands_ map_packet_ loading
You can give me commands by starting a line with @bunnybot <command>. I understand:
merge: Merges the source branch into the target branch, closing the merge proposal. I will use the proposed commit message if it is set.