Merge lp:~widelands-dev/widelands/elk_moose into lp:widelands
- elk_moose
- Merge into trunk
Status: | Merged |
---|---|
Merged at revision: | 9155 |
Proposed branch: | lp:~widelands-dev/widelands/elk_moose |
Merge into: | lp:widelands |
Diff against target: |
455 lines (+102/-30) 16 files modified
data/world/critters/moose/init.lua (+2/-2) data/world/init.lua (+1/-1) data/world/map_generation.lua (+6/-6) src/logic/map.cc (+16/-0) src/logic/map.h (+8/-0) src/logic/map_objects/world/critter.cc (+3/-2) src/logic/map_revision.h (+2/-0) src/map_io/map_bob_packet.cc (+3/-3) src/map_io/map_bob_packet.h (+1/-1) src/map_io/map_saver.cc (+1/-1) src/map_io/map_version_packet.cc (+12/-5) src/map_io/map_version_packet.h (+17/-2) src/map_io/widelands_map_loader.cc (+5/-1) src/map_io/world_legacy_lookup_table.cc (+23/-5) src/map_io/world_legacy_lookup_table.h (+1/-1) src/website/map_info.cc (+1/-0) |
To merge this branch: | bzr merge lp:~widelands-dev/widelands/elk_moose |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Klaus Halfmann | testing | Approve | |
Review via email: mp+369201@code.launchpad.net |
Commit message
Rename "elk" to "moose" and add map compatibility code
- Add support for critter renamings depending on packet version to WorldLegacyLook
- New map version property "needs_
Description of the change
Klaus Halfmann (klaus-halfmann) wrote : | # |
Klaus Halfmann (klaus-halfmann) wrote : | # |
I expect some followup change on the website then.
Widelands will always read older Maps.
Did another review with a look into the complete code.
(We need some Widelands historian for all this legacy :-)
A bit more documentation would help.
Klaus Halfmann (klaus-halfmann) wrote : | # |
I openend some buitin and a new Map,
how can I see this new value in a map?
I am missing some info about wl_map_info / wl_map_object_info
Klaus Halfmann (klaus-halfmann) wrote : | # |
OTOH the code is OK for me, anything more I can / must do?
GunChleoc (gunchleoc) wrote : | # |
I have added comments.
If you run ./wl_map_info without parameters, it will give you command line help. It results in a JSON file for the website.
Klaus Halfmann (klaus-halfmann) wrote : | # |
Ahh, the json file is created in thee same dir as the wmf file, e.g.
{
"name": "CrossriverA",
"author": "Hasi50",
"description": "A nice River flows through this land and water can be found there. Metal in the hills nearby, but you are not alone",
"hint": "",
"width": 64,
"height": 64,
"nr_players": 2,
"needs_
"world_name": "",
"minimap": "/Users/
}
A map saved with the new version
{
"name": "27 zu 3 Inseln",
"author": "Björn alias the-x",
"description": "Starting with 27 Islands falling together when you find Ways to pass through the rocks to 3 huge Island. Are you unstoppable to manage all 3 Islands under your control? Tipps: Start to find your dream Island real fast and you wont find Iron on your main Island.",
"hint": "",
"width": 144,
"height": 144,
"nr_players": 4,
"needs_
"world_name": "",
"minimap": "/Users/
}
Trunk gives me:
Exception: map objects: [../src/
UnhandledVersio
Packet Name: Critter
Saved Version: 2
Current Version: 1.
Fine
GunChleoc (gunchleoc) wrote : | # |
Thanks for the review & testing!
@bunnybot merge
bunnybot (widelandsofficial) wrote : | # |
Continuous integration builds have changed state:
Travis build 5218. State: errored. Details: https:/
Appveyor build 4997. State: success. Details: https:/
bunnybot (widelandsofficial) wrote : | # |
Refusing to merge, since Travis is not green. Use @bunnybot merge force for merging anyways.
Travis build 5218. State: errored. Details: https:/
Klaus Halfmann (klaus-halfmann) wrote : | # |
Travis:
1 x curl: (6) Could not resolve host: deb.debian.org
Error: An exception occurred within a child process:
DownloadError: Failed to download resource "isl"
3 x Loading savegame: inputqueues ...
No output has been received in the last 10m0s
-> Adressed elsewhere
All other Builds are fine
@bunnybot merge force
bunnybot (widelandsofficial) wrote : | # |
Error merging this proposal:
Output:
stdout:
stderr:
Unable to obtain lock held by <email address hidden> on taotie (process #21580), acquired 37 hours, 41 minutes ago.
See "bzr help break-lock" for more.
bzr: ERROR: Could not acquire lock "(remote lock)": bzr+ssh:
GunChleoc (gunchleoc) wrote : | # |
@bunnybot merge force
Preview Diff
1 | === renamed directory 'data/world/critters/elk' => 'data/world/critters/moose' | |||
2 | === modified file 'data/world/critters/moose/init.lua' | |||
3 | --- data/world/critters/elk/init.lua 2019-04-21 14:57:55 +0000 | |||
4 | +++ data/world/critters/moose/init.lua 2019-06-22 16:21:53 +0000 | |||
5 | @@ -15,8 +15,8 @@ | |||
6 | 15 | add_directional_animation(animations, "walk", dirname, "walk", {21, 34}, 20) | 15 | add_directional_animation(animations, "walk", dirname, "walk", {21, 34}, 20) |
7 | 16 | 16 | ||
8 | 17 | world:new_critter_type{ | 17 | world:new_critter_type{ |
11 | 18 | name = "elk", | 18 | name = "moose", |
12 | 19 | descname = _ "Elk", | 19 | descname = _ "Moose", |
13 | 20 | editor_category = "critters_herbivores", | 20 | editor_category = "critters_herbivores", |
14 | 21 | attributes = { "eatable" }, | 21 | attributes = { "eatable" }, |
15 | 22 | programs = { | 22 | programs = { |
16 | 23 | 23 | ||
17 | === modified file 'data/world/init.lua' | |||
18 | --- data/world/init.lua 2017-09-03 10:56:44 +0000 | |||
19 | +++ data/world/init.lua 2019-06-22 16:21:53 +0000 | |||
20 | @@ -288,7 +288,7 @@ | |||
21 | 288 | include "world/critters/deer/init.lua" | 288 | include "world/critters/deer/init.lua" |
22 | 289 | include "world/critters/reindeer/init.lua" | 289 | include "world/critters/reindeer/init.lua" |
23 | 290 | include "world/critters/stag/init.lua" | 290 | include "world/critters/stag/init.lua" |
25 | 291 | include "world/critters/elk/init.lua" | 291 | include "world/critters/moose/init.lua" |
26 | 292 | 292 | ||
27 | 293 | -- Carnivores | 293 | -- Carnivores |
28 | 294 | world:new_editor_critter_category { | 294 | world:new_editor_critter_category { |
29 | 295 | 295 | ||
30 | === modified file 'data/world/map_generation.lua' | |||
31 | --- data/world/map_generation.lua 2017-02-12 09:10:57 +0000 | |||
32 | +++ data/world/map_generation.lua 2019-06-22 16:21:53 +0000 | |||
33 | @@ -77,17 +77,17 @@ | |||
34 | 77 | "alder_summer_old", "birch_summer_old", "beech_summer_old", | 77 | "alder_summer_old", "birch_summer_old", "beech_summer_old", |
35 | 78 | "larch_summer_old", "rowan_summer_old" | 78 | "larch_summer_old", "rowan_summer_old" |
36 | 79 | }, | 79 | }, |
38 | 80 | critters = { "brownbear", "chamois", "elk", "lynx", "reindeer", "stag", "wildboar", "wolf" }, | 80 | critters = { "brownbear", "chamois", "moose", "lynx", "reindeer", "stag", "wildboar", "wolf" }, |
39 | 81 | }, | 81 | }, |
40 | 82 | { | 82 | { |
41 | 83 | name = "bushes", | 83 | name = "bushes", |
42 | 84 | immovables = { "bush1", "bush2", "bush3", "bush4", "bush5" }, | 84 | immovables = { "bush1", "bush2", "bush3", "bush4", "bush5" }, |
44 | 85 | critters = { "bunny", "elk", "fox", "lynx", "marten", "sheep", "sheep", "wildboar", "wisent", "wolf", "wolf" }, | 85 | critters = { "bunny", "moose", "fox", "lynx", "marten", "sheep", "sheep", "wildboar", "wisent", "wolf", "wolf" }, |
45 | 86 | }, | 86 | }, |
46 | 87 | { | 87 | { |
47 | 88 | name = "grasses", | 88 | name = "grasses", |
48 | 89 | immovables = { "grass1", "grass2", "grass3" }, | 89 | immovables = { "grass1", "grass2", "grass3" }, |
50 | 90 | critters = { "bunny", "elk", "fox", "lynx", "marten", "sheep", "sheep", "wolf" }, | 90 | critters = { "bunny", "moose", "fox", "lynx", "marten", "sheep", "sheep", "wolf" }, |
51 | 91 | }, | 91 | }, |
52 | 92 | { | 92 | { |
53 | 93 | name = "standing_stones", | 93 | name = "standing_stones", |
54 | @@ -614,13 +614,13 @@ | |||
55 | 614 | "birch_summer_old", "beech_summer_old", | 614 | "birch_summer_old", "beech_summer_old", |
56 | 615 | "larch_summer_old", "rowan_summer_old", | 615 | "larch_summer_old", "rowan_summer_old", |
57 | 616 | }, | 616 | }, |
59 | 617 | critters = { "deer", "elk", "lynx", "reindeer", "wolf" }, | 617 | critters = { "deer", "moose", "lynx", "reindeer", "wolf" }, |
60 | 618 | }, | 618 | }, |
61 | 619 | { | 619 | { |
62 | 620 | name = "bushes", | 620 | name = "bushes", |
63 | 621 | immovables = { "bush1", "bush2", "bush3", "bush4", "bush5" }, | 621 | immovables = { "bush1", "bush2", "bush3", "bush4", "bush5" }, |
64 | 622 | critters = { | 622 | critters = { |
66 | 623 | "wisent", "wolf", "bunny", "elk", "fox", "lynx", | 623 | "wisent", "wolf", "bunny", "moose", "fox", "lynx", |
67 | 624 | "wolf", "marten", "sheep" | 624 | "wolf", "marten", "sheep" |
68 | 625 | }, | 625 | }, |
69 | 626 | }, | 626 | }, |
70 | @@ -628,7 +628,7 @@ | |||
71 | 628 | name = "grasses", | 628 | name = "grasses", |
72 | 629 | immovables = { "grass1", "grass2", "grass3" }, | 629 | immovables = { "grass1", "grass2", "grass3" }, |
73 | 630 | critters = { | 630 | critters = { |
75 | 631 | "wisent", "wolf", "bunny", "elk", "fox", "lynx", | 631 | "wisent", "wolf", "bunny", "moose", "fox", "lynx", |
76 | 632 | "wolf", "marten", "sheep" | 632 | "wolf", "marten", "sheep" |
77 | 633 | }, | 633 | }, |
78 | 634 | }, | 634 | }, |
79 | 635 | 635 | ||
80 | === modified file 'src/logic/map.cc' | |||
81 | --- src/logic/map.cc 2019-05-16 09:15:03 +0000 | |||
82 | +++ src/logic/map.cc 2019-06-22 16:21:53 +0000 | |||
83 | @@ -714,6 +714,22 @@ | |||
84 | 714 | pathfieldmgr_->set_size(field_size); | 714 | pathfieldmgr_->set_size(field_size); |
85 | 715 | } | 715 | } |
86 | 716 | 716 | ||
87 | 717 | int Map::needs_widelands_version_after() const { | ||
88 | 718 | return map_version_.needs_widelands_version_after; | ||
89 | 719 | } | ||
90 | 720 | |||
91 | 721 | void Map::calculate_needs_widelands_version_after(bool is_post_one_world) { | ||
92 | 722 | if (map_version_.needs_widelands_version_after == 0) { | ||
93 | 723 | if (nrplayers_ > 8) { | ||
94 | 724 | // We introduced support for 16 players after Build 19 | ||
95 | 725 | map_version_.needs_widelands_version_after = 19; | ||
96 | 726 | } else if (is_post_one_world) { | ||
97 | 727 | // We merged the worlds in the engine after Build 18 | ||
98 | 728 | map_version_.needs_widelands_version_after = 18; | ||
99 | 729 | } | ||
100 | 730 | } | ||
101 | 731 | } | ||
102 | 732 | |||
103 | 717 | /* | 733 | /* |
104 | 718 | * The scenario get/set functions | 734 | * The scenario get/set functions |
105 | 719 | */ | 735 | */ |
106 | 720 | 736 | ||
107 | === modified file 'src/logic/map.h' | |||
108 | --- src/logic/map.h 2019-05-16 09:15:03 +0000 | |||
109 | +++ src/logic/map.h 2019-06-22 16:21:53 +0000 | |||
110 | @@ -289,6 +289,9 @@ | |||
111 | 289 | return height_; | 289 | return height_; |
112 | 290 | } | 290 | } |
113 | 291 | 291 | ||
114 | 292 | // Map compatibility information for the website | ||
115 | 293 | int needs_widelands_version_after() const; | ||
116 | 294 | |||
117 | 292 | // The next few functions are only valid when the map is loaded as a | 295 | // The next few functions are only valid when the map is loaded as a |
118 | 293 | // scenario. | 296 | // scenario. |
119 | 294 | const std::string& get_scenario_player_tribe(PlayerNumber) const; | 297 | const std::string& get_scenario_player_tribe(PlayerNumber) const; |
120 | @@ -518,6 +521,11 @@ | |||
121 | 518 | std::map<Coords, FieldData> | 521 | std::map<Coords, FieldData> |
122 | 519 | resize(EditorGameBase& egbase, const Coords coords, int32_t w, int32_t h); | 522 | resize(EditorGameBase& egbase, const Coords coords, int32_t w, int32_t h); |
123 | 520 | 523 | ||
124 | 524 | protected: | ||
125 | 525 | /// Calculate map compatibility information for the website if it wasn't defined in the map packet. | ||
126 | 526 | /// If is_post_one_world is true, this map wasn't created for a specific world (Widelands versions up to Build 18). | ||
127 | 527 | void calculate_needs_widelands_version_after(bool is_post_one_world); | ||
128 | 528 | |||
129 | 521 | private: | 529 | private: |
130 | 522 | void recalc_border(const FCoords&); | 530 | void recalc_border(const FCoords&); |
131 | 523 | void recalc_brightness(const FCoords&); | 531 | void recalc_brightness(const FCoords&); |
132 | 524 | 532 | ||
133 | === modified file 'src/logic/map_objects/world/critter.cc' | |||
134 | --- src/logic/map_objects/world/critter.cc 2019-05-25 08:51:42 +0000 | |||
135 | +++ src/logic/map_objects/world/critter.cc 2019-06-22 16:21:53 +0000 | |||
136 | @@ -268,7 +268,8 @@ | |||
137 | 268 | ============================== | 268 | ============================== |
138 | 269 | */ | 269 | */ |
139 | 270 | 270 | ||
141 | 271 | constexpr uint8_t kCurrentPacketVersion = 1; | 271 | // We need to bump this packet version every time we rename a critter, so that the world legacy lookup table will work. |
142 | 272 | constexpr uint8_t kCurrentPacketVersion = 2; | ||
143 | 272 | 273 | ||
144 | 273 | Critter::Loader::Loader() { | 274 | Critter::Loader::Loader() { |
145 | 274 | } | 275 | } |
146 | @@ -303,7 +304,7 @@ | |||
147 | 303 | const CritterDescr* descr = nullptr; | 304 | const CritterDescr* descr = nullptr; |
148 | 304 | 305 | ||
149 | 305 | if (critter_owner == "world") { | 306 | if (critter_owner == "world") { |
151 | 306 | critter_name = lookup_table.lookup_critter(critter_name); | 307 | critter_name = lookup_table.lookup_critter(critter_name, packet_version); |
152 | 307 | descr = egbase.world().get_critter_descr(critter_name); | 308 | descr = egbase.world().get_critter_descr(critter_name); |
153 | 308 | } else { | 309 | } else { |
154 | 309 | throw GameDataError( | 310 | throw GameDataError( |
155 | 310 | 311 | ||
156 | === modified file 'src/logic/map_revision.h' | |||
157 | --- src/logic/map_revision.h 2019-02-23 11:00:49 +0000 | |||
158 | +++ src/logic/map_revision.h 2019-06-22 16:21:53 +0000 | |||
159 | @@ -37,6 +37,8 @@ | |||
160 | 37 | int32_t map_version_major; | 37 | int32_t map_version_major; |
161 | 38 | int32_t map_version_minor; | 38 | int32_t map_version_minor; |
162 | 39 | uint32_t map_version_timestamp; | 39 | uint32_t map_version_timestamp; |
163 | 40 | // Map compatibility information for the website | ||
164 | 41 | int needs_widelands_version_after; | ||
165 | 40 | 42 | ||
166 | 41 | MapVersion(); | 43 | MapVersion(); |
167 | 42 | }; | 44 | }; |
168 | 43 | 45 | ||
169 | === modified file 'src/map_io/map_bob_packet.cc' | |||
170 | --- src/map_io/map_bob_packet.cc 2019-02-23 11:00:49 +0000 | |||
171 | +++ src/map_io/map_bob_packet.cc 2019-06-22 16:21:53 +0000 | |||
172 | @@ -36,7 +36,7 @@ | |||
173 | 36 | EditorGameBase& egbase, | 36 | EditorGameBase& egbase, |
174 | 37 | MapObjectLoader&, | 37 | MapObjectLoader&, |
175 | 38 | const Coords& coords, | 38 | const Coords& coords, |
177 | 39 | const WorldLegacyLookupTable& lookup_table) { | 39 | const WorldLegacyLookupTable& lookup_table, uint16_t packet_version) { |
178 | 40 | const std::string owner = fr.c_string(); | 40 | const std::string owner = fr.c_string(); |
179 | 41 | char const* const read_name = fr.c_string(); | 41 | char const* const read_name = fr.c_string(); |
180 | 42 | uint8_t subtype = fr.unsigned_8(); | 42 | uint8_t subtype = fr.unsigned_8(); |
181 | @@ -47,7 +47,7 @@ | |||
182 | 47 | throw GameDataError("unknown legacy bob %s/%s", owner.c_str(), read_name); | 47 | throw GameDataError("unknown legacy bob %s/%s", owner.c_str(), read_name); |
183 | 48 | } | 48 | } |
184 | 49 | 49 | ||
186 | 50 | const std::string name = lookup_table.lookup_critter(read_name); | 50 | const std::string name = lookup_table.lookup_critter(read_name, packet_version); |
187 | 51 | try { | 51 | try { |
188 | 52 | const World& world = egbase.world(); | 52 | const World& world = egbase.world(); |
189 | 53 | DescriptionIndex const idx = world.get_critter(name.c_str()); | 53 | DescriptionIndex const idx = world.get_critter(name.c_str()); |
190 | @@ -84,7 +84,7 @@ | |||
191 | 84 | for (uint16_t x = 0; x < map->get_width(); ++x) { | 84 | for (uint16_t x = 0; x < map->get_width(); ++x) { |
192 | 85 | uint32_t const nr_bobs = fr.unsigned_32(); | 85 | uint32_t const nr_bobs = fr.unsigned_32(); |
193 | 86 | for (uint32_t i = 0; i < nr_bobs; ++i) | 86 | for (uint32_t i = 0; i < nr_bobs; ++i) |
195 | 87 | read_bob(fr, egbase, mol, Coords(x, y), lookup_table); | 87 | read_bob(fr, egbase, mol, Coords(x, y), lookup_table, packet_version); |
196 | 88 | } | 88 | } |
197 | 89 | } | 89 | } |
198 | 90 | else { | 90 | else { |
199 | 91 | 91 | ||
200 | === modified file 'src/map_io/map_bob_packet.h' | |||
201 | --- src/map_io/map_bob_packet.h 2019-02-23 11:00:49 +0000 | |||
202 | +++ src/map_io/map_bob_packet.h 2019-06-22 16:21:53 +0000 | |||
203 | @@ -42,7 +42,7 @@ | |||
204 | 42 | EditorGameBase&, | 42 | EditorGameBase&, |
205 | 43 | MapObjectLoader&, | 43 | MapObjectLoader&, |
206 | 44 | const Coords&, | 44 | const Coords&, |
208 | 45 | const WorldLegacyLookupTable& lookup_table); | 45 | const WorldLegacyLookupTable& lookup_table, uint16_t packet_version); |
209 | 46 | }; | 46 | }; |
210 | 47 | } // namespace Widelands | 47 | } // namespace Widelands |
211 | 48 | 48 | ||
212 | 49 | 49 | ||
213 | === modified file 'src/map_io/map_saver.cc' | |||
214 | --- src/map_io/map_saver.cc 2019-03-09 10:01:09 +0000 | |||
215 | +++ src/map_io/map_saver.cc 2019-06-22 16:21:53 +0000 | |||
216 | @@ -156,7 +156,7 @@ | |||
217 | 156 | log("Writing Map Version ... "); | 156 | log("Writing Map Version ... "); |
218 | 157 | { | 157 | { |
219 | 158 | MapVersionPacket p; | 158 | MapVersionPacket p; |
221 | 159 | p.write(fs_, egbase_, *mos_); | 159 | p.write(fs_, egbase_); |
222 | 160 | } | 160 | } |
223 | 161 | log("took %ums\n ", timer.ms_since_last_query()); | 161 | log("took %ums\n ", timer.ms_since_last_query()); |
224 | 162 | 162 | ||
225 | 163 | 163 | ||
226 | === modified file 'src/map_io/map_version_packet.cc' | |||
227 | --- src/map_io/map_version_packet.cc 2019-02-23 11:00:49 +0000 | |||
228 | +++ src/map_io/map_version_packet.cc 2019-06-22 16:21:53 +0000 | |||
229 | @@ -30,11 +30,17 @@ | |||
230 | 30 | namespace Widelands { | 30 | namespace Widelands { |
231 | 31 | 31 | ||
232 | 32 | constexpr uint16_t kCurrentPacketVersion = 1; | 32 | constexpr uint16_t kCurrentPacketVersion = 1; |
233 | 33 | // Map compatibility information for the website | ||
234 | 34 | constexpr int kCurrentNeedsWidelandsVersionAfter = 20; | ||
235 | 33 | 35 | ||
236 | 34 | void MapVersionPacket::read(FileSystem& fs, | 36 | void MapVersionPacket::read(FileSystem& fs, |
237 | 35 | EditorGameBase& egbase, | 37 | EditorGameBase& egbase, |
240 | 36 | bool const skip, | 38 | bool const skip, bool is_post_one_world) { |
241 | 37 | MapObjectLoader&) { | 39 | |
242 | 40 | pre_read(fs, egbase.mutable_map(), skip, is_post_one_world); | ||
243 | 41 | } | ||
244 | 42 | |||
245 | 43 | void MapVersionPacket::pre_read(FileSystem& fs, Map* map, bool skip, bool is_post_one_world) { | ||
246 | 38 | if (skip) | 44 | if (skip) |
247 | 39 | return; | 45 | return; |
248 | 40 | 46 | ||
249 | @@ -42,7 +48,6 @@ | |||
250 | 42 | try { | 48 | try { |
251 | 43 | prof.read("version", nullptr, fs); | 49 | prof.read("version", nullptr, fs); |
252 | 44 | } catch (...) { | 50 | } catch (...) { |
253 | 45 | Map* map = egbase.mutable_map(); | ||
254 | 46 | map->map_version_.map_version_timestamp = 0; | 51 | map->map_version_.map_version_timestamp = 0; |
255 | 47 | map->map_version_.map_creator_version = "unknown"; | 52 | map->map_version_.map_creator_version = "unknown"; |
256 | 48 | return; | 53 | return; |
257 | @@ -55,7 +60,6 @@ | |||
258 | 55 | if ((packet_version == kCurrentPacketVersion) || | 60 | if ((packet_version == kCurrentPacketVersion) || |
259 | 56 | (packet_version > kCurrentPacketVersion && | 61 | (packet_version > kCurrentPacketVersion && |
260 | 57 | forward_compatibility <= kCurrentPacketVersion)) { | 62 | forward_compatibility <= kCurrentPacketVersion)) { |
261 | 58 | Map* map = egbase.mutable_map(); | ||
262 | 59 | map->map_version_.map_source_url = globv.get_safe_string("map_source_url"); | 63 | map->map_version_.map_source_url = globv.get_safe_string("map_source_url"); |
263 | 60 | map->map_version_.map_source_release = globv.get_safe_string("map_release"); | 64 | map->map_version_.map_source_release = globv.get_safe_string("map_release"); |
264 | 61 | map->map_version_.map_creator_version = globv.get_safe_string("map_creator_version"); | 65 | map->map_version_.map_creator_version = globv.get_safe_string("map_creator_version"); |
265 | @@ -63,6 +67,8 @@ | |||
266 | 63 | map->map_version_.map_version_minor = globv.get_safe_int("map_version_minor"); | 67 | map->map_version_.map_version_minor = globv.get_safe_int("map_version_minor"); |
267 | 64 | uint32_t ts = static_cast<uint32_t>(globv.get_safe_int("map_version_timestamp")); | 68 | uint32_t ts = static_cast<uint32_t>(globv.get_safe_int("map_version_timestamp")); |
268 | 65 | map->map_version_.map_version_timestamp = ts; | 69 | map->map_version_.map_version_timestamp = ts; |
269 | 70 | map->map_version_.needs_widelands_version_after = globv.get_int("needs_widelands_version_after", 0); | ||
270 | 71 | map->calculate_needs_widelands_version_after(is_post_one_world); | ||
271 | 66 | } else { | 72 | } else { |
272 | 67 | throw UnhandledVersionError("MapVersionPacket", packet_version, kCurrentPacketVersion); | 73 | throw UnhandledVersionError("MapVersionPacket", packet_version, kCurrentPacketVersion); |
273 | 68 | } | 74 | } |
274 | @@ -71,7 +77,7 @@ | |||
275 | 71 | } | 77 | } |
276 | 72 | } | 78 | } |
277 | 73 | 79 | ||
279 | 74 | void MapVersionPacket::write(FileSystem& fs, EditorGameBase& egbase, MapObjectSaver&) { | 80 | void MapVersionPacket::write(FileSystem& fs, EditorGameBase& egbase) { |
280 | 75 | Profile prof; | 81 | Profile prof; |
281 | 76 | Section& globs = prof.create_section("global"); | 82 | Section& globs = prof.create_section("global"); |
282 | 77 | 83 | ||
283 | @@ -117,6 +123,7 @@ | |||
284 | 117 | globs.set_int("map_version_timestamp", static_cast<uint32_t>(time(nullptr))); | 123 | globs.set_int("map_version_timestamp", static_cast<uint32_t>(time(nullptr))); |
285 | 118 | globs.set_int("packet_version", kCurrentPacketVersion); | 124 | globs.set_int("packet_version", kCurrentPacketVersion); |
286 | 119 | globs.set_int("packet_compatibility", kCurrentPacketVersion); | 125 | globs.set_int("packet_compatibility", kCurrentPacketVersion); |
287 | 126 | globs.set_int("needs_widelands_version_after", kCurrentNeedsWidelandsVersionAfter); | ||
288 | 120 | 127 | ||
289 | 121 | prof.write("version", false, fs); | 128 | prof.write("version", false, fs); |
290 | 122 | } | 129 | } |
291 | 123 | 130 | ||
292 | === modified file 'src/map_io/map_version_packet.h' | |||
293 | --- src/map_io/map_version_packet.h 2019-02-23 11:00:49 +0000 | |||
294 | +++ src/map_io/map_version_packet.h 2019-06-22 16:21:53 +0000 | |||
295 | @@ -20,11 +20,26 @@ | |||
296 | 20 | #ifndef WL_MAP_IO_MAP_VERSION_PACKET_H | 20 | #ifndef WL_MAP_IO_MAP_VERSION_PACKET_H |
297 | 21 | #define WL_MAP_IO_MAP_VERSION_PACKET_H | 21 | #define WL_MAP_IO_MAP_VERSION_PACKET_H |
298 | 22 | 22 | ||
300 | 23 | #include "map_io/map_data_packet.h" | 23 | class FileSystem; |
301 | 24 | |||
302 | 25 | namespace Widelands { | ||
303 | 26 | |||
304 | 27 | class EditorGameBase; | ||
305 | 28 | class Map; | ||
306 | 29 | class MapObjectLoader; | ||
307 | 30 | struct MapObjectSaver; | ||
308 | 24 | 31 | ||
309 | 25 | /* | 32 | /* |
310 | 26 | * This packet contains the version information of the map. | 33 | * This packet contains the version information of the map. |
311 | 27 | */ | 34 | */ |
313 | 28 | MAP_DATA_PACKET(MapVersionPacket) | 35 | class MapVersionPacket { |
314 | 36 | public: | ||
315 | 37 | void read(FileSystem&, EditorGameBase&, bool skip, bool is_post_one_world); | ||
316 | 38 | void write(FileSystem&, EditorGameBase&); | ||
317 | 39 | |||
318 | 40 | void pre_read(FileSystem&, Map*, bool skip, bool is_post_one_world); | ||
319 | 41 | }; | ||
320 | 42 | |||
321 | 43 | } // namespace Widelands | ||
322 | 29 | 44 | ||
323 | 30 | #endif // end of include guard: WL_MAP_IO_MAP_VERSION_PACKET_H | 45 | #endif // end of include guard: WL_MAP_IO_MAP_VERSION_PACKET_H |
324 | 31 | 46 | ||
325 | === modified file 'src/map_io/widelands_map_loader.cc' | |||
326 | --- src/map_io/widelands_map_loader.cc 2019-05-26 03:14:41 +0000 | |||
327 | +++ src/map_io/widelands_map_loader.cc 2019-06-22 16:21:53 +0000 | |||
328 | @@ -82,6 +82,10 @@ | |||
329 | 82 | mp.pre_read(*fs_, &map_); | 82 | mp.pre_read(*fs_, &map_); |
330 | 83 | old_world_name_ = mp.old_world_name(); | 83 | old_world_name_ = mp.old_world_name(); |
331 | 84 | } | 84 | } |
332 | 85 | { | ||
333 | 86 | MapVersionPacket version_packet; | ||
334 | 87 | version_packet.pre_read(*fs_, &map_, false, old_world_name_.empty()); | ||
335 | 88 | } | ||
336 | 85 | 89 | ||
337 | 86 | { | 90 | { |
338 | 87 | MapPlayerNamesAndTribesPacket p; | 91 | MapPlayerNamesAndTribesPacket p; |
339 | @@ -198,7 +202,7 @@ | |||
340 | 198 | log("Reading Map Version Data ... "); | 202 | log("Reading Map Version Data ... "); |
341 | 199 | { | 203 | { |
342 | 200 | MapVersionPacket p; | 204 | MapVersionPacket p; |
344 | 201 | p.read(*fs_, egbase, is_game, *mol_); | 205 | p.read(*fs_, egbase, is_game, old_world_name_.empty()); |
345 | 202 | } | 206 | } |
346 | 203 | log("took %ums\n ", timer.ms_since_last_query()); | 207 | log("took %ums\n ", timer.ms_since_last_query()); |
347 | 204 | 208 | ||
348 | 205 | 209 | ||
349 | === modified file 'src/map_io/world_legacy_lookup_table.cc' | |||
350 | --- src/map_io/world_legacy_lookup_table.cc 2019-02-23 11:00:49 +0000 | |||
351 | +++ src/map_io/world_legacy_lookup_table.cc 2019-06-22 16:21:53 +0000 | |||
352 | @@ -33,16 +33,24 @@ | |||
353 | 33 | // Implements OneWorldLegacyLookupTable. | 33 | // Implements OneWorldLegacyLookupTable. |
354 | 34 | std::string lookup_resource(const std::string& resource) const override; | 34 | std::string lookup_resource(const std::string& resource) const override; |
355 | 35 | std::string lookup_terrain(const std::string& terrain) const override; | 35 | std::string lookup_terrain(const std::string& terrain) const override; |
357 | 36 | std::string lookup_critter(const std::string& critter) const override; | 36 | std::string lookup_critter(const std::string& critter, uint16_t packet_version) const override; |
358 | 37 | std::string lookup_immovable(const std::string& immovable) const override; | 37 | std::string lookup_immovable(const std::string& immovable) const override; |
359 | 38 | 38 | ||
360 | 39 | private: | 39 | private: |
361 | 40 | // Old name, <packet version when it got changed, new name> | ||
362 | 41 | const std::map<std::string, std::map<uint16_t, std::string>> critters_; | ||
363 | 40 | const std::map<std::string, std::string> immovables_; | 42 | const std::map<std::string, std::string> immovables_; |
364 | 41 | const std::map<std::string, std::string> resources_; | 43 | const std::map<std::string, std::string> resources_; |
365 | 42 | const std::map<std::string, std::string> terrains_; | 44 | const std::map<std::string, std::string> terrains_; |
366 | 43 | }; | 45 | }; |
367 | 44 | 46 | ||
368 | 45 | PostOneWorldLegacyLookupTable::PostOneWorldLegacyLookupTable() : | 47 | PostOneWorldLegacyLookupTable::PostOneWorldLegacyLookupTable() : |
369 | 48 | critters_ | ||
370 | 49 | { | ||
371 | 50 | // We need to bump the packet version in Critter every time we rename a critter. | ||
372 | 51 | // Also, don't forget to edit the OneWorldLegacyLookupTable! You can look up which world had which units in Build 18. | ||
373 | 52 | {"elk", {{2, "moose"}}}, | ||
374 | 53 | }, | ||
375 | 46 | immovables_ | 54 | immovables_ |
376 | 47 | { | 55 | { |
377 | 48 | {"blackland_stones1", "blackland_rocks1"}, | 56 | {"blackland_stones1", "blackland_rocks1"}, |
378 | @@ -113,8 +121,16 @@ | |||
379 | 113 | return i->second; | 121 | return i->second; |
380 | 114 | } | 122 | } |
381 | 115 | 123 | ||
384 | 116 | std::string PostOneWorldLegacyLookupTable::lookup_critter(const std::string& critter) const { | 124 | std::string PostOneWorldLegacyLookupTable::lookup_critter(const std::string& critter, uint16_t packet_version) const { |
385 | 117 | return critter; | 125 | std::string result = critter; |
386 | 126 | if (critters_.count(critter) == 1) { | ||
387 | 127 | for (const auto& candidate : critters_.at(result)) { | ||
388 | 128 | if (candidate.first >= packet_version) { | ||
389 | 129 | result = candidate.second; | ||
390 | 130 | } | ||
391 | 131 | } | ||
392 | 132 | } | ||
393 | 133 | return result; | ||
394 | 118 | } | 134 | } |
395 | 119 | 135 | ||
396 | 120 | std::string PostOneWorldLegacyLookupTable::lookup_immovable(const std::string& immovable) const { | 136 | std::string PostOneWorldLegacyLookupTable::lookup_immovable(const std::string& immovable) const { |
397 | @@ -132,7 +148,7 @@ | |||
398 | 132 | // Implements OneWorldLegacyLookupTable. | 148 | // Implements OneWorldLegacyLookupTable. |
399 | 133 | std::string lookup_resource(const std::string& resource) const override; | 149 | std::string lookup_resource(const std::string& resource) const override; |
400 | 134 | std::string lookup_terrain(const std::string& terrain) const override; | 150 | std::string lookup_terrain(const std::string& terrain) const override; |
402 | 135 | std::string lookup_critter(const std::string& critter) const override; | 151 | std::string lookup_critter(const std::string& critter, uint16_t packet_version) const override; |
403 | 136 | std::string lookup_immovable(const std::string& immovable) const override; | 152 | std::string lookup_immovable(const std::string& immovable) const override; |
404 | 137 | 153 | ||
405 | 138 | private: | 154 | private: |
406 | @@ -205,6 +221,7 @@ | |||
407 | 205 | std::make_pair("greenland", | 221 | std::make_pair("greenland", |
408 | 206 | std::map<std::string, std::string>{ | 222 | std::map<std::string, std::string>{ |
409 | 207 | {"deer", "stag"}, | 223 | {"deer", "stag"}, |
410 | 224 | {"elk", "moose"}, | ||
411 | 208 | }), | 225 | }), |
412 | 209 | std::make_pair("blackland", | 226 | std::make_pair("blackland", |
413 | 210 | std::map<std::string, std::string>{ | 227 | std::map<std::string, std::string>{ |
414 | @@ -213,6 +230,7 @@ | |||
415 | 213 | std::make_pair("winterland", | 230 | std::make_pair("winterland", |
416 | 214 | std::map<std::string, std::string>{ | 231 | std::map<std::string, std::string>{ |
417 | 215 | {"deer", "stag"}, | 232 | {"deer", "stag"}, |
418 | 233 | {"elk", "moose"}, | ||
419 | 216 | }), | 234 | }), |
420 | 217 | std::make_pair("desert", | 235 | std::make_pair("desert", |
421 | 218 | std::map<std::string, std::string>{ | 236 | std::map<std::string, std::string>{ |
422 | @@ -418,7 +436,7 @@ | |||
423 | 418 | return terrain; | 436 | return terrain; |
424 | 419 | } | 437 | } |
425 | 420 | 438 | ||
427 | 421 | std::string OneWorldLegacyLookupTable::lookup_critter(const std::string& critter) const { | 439 | std::string OneWorldLegacyLookupTable::lookup_critter(const std::string& critter, uint16_t) const { |
428 | 422 | const std::map<std::string, std::string>& world_critters = critters_.at(old_world_name_); | 440 | const std::map<std::string, std::string>& world_critters = critters_.at(old_world_name_); |
429 | 423 | const auto& i = world_critters.find(critter); | 441 | const auto& i = world_critters.find(critter); |
430 | 424 | if (i != world_critters.end()) { | 442 | if (i != world_critters.end()) { |
431 | 425 | 443 | ||
432 | === modified file 'src/map_io/world_legacy_lookup_table.h' | |||
433 | --- src/map_io/world_legacy_lookup_table.h 2019-02-23 11:00:49 +0000 | |||
434 | +++ src/map_io/world_legacy_lookup_table.h 2019-06-22 16:21:53 +0000 | |||
435 | @@ -38,7 +38,7 @@ | |||
436 | 38 | virtual std::string lookup_terrain(const std::string& terrain) const = 0; | 38 | virtual std::string lookup_terrain(const std::string& terrain) const = 0; |
437 | 39 | 39 | ||
438 | 40 | /// Looks up the new name for the 'critter'. | 40 | /// Looks up the new name for the 'critter'. |
440 | 41 | virtual std::string lookup_critter(const std::string& critter) const = 0; | 41 | virtual std::string lookup_critter(const std::string& critter, uint16_t packet_version) const = 0; |
441 | 42 | 42 | ||
442 | 43 | /// Looks up the new name for the 'immovable'. | 43 | /// Looks up the new name for the 'immovable'. |
443 | 44 | virtual std::string lookup_immovable(const std::string& immovable) const = 0; | 44 | virtual std::string lookup_immovable(const std::string& immovable) const = 0; |
444 | 45 | 45 | ||
445 | === modified file 'src/website/map_info.cc' | |||
446 | --- src/website/map_info.cc 2019-02-23 11:00:49 +0000 | |||
447 | +++ src/website/map_info.cc 2019-06-22 16:21:53 +0000 | |||
448 | @@ -92,6 +92,7 @@ | |||
449 | 92 | json->add_int("width", map->get_width()); | 92 | json->add_int("width", map->get_width()); |
450 | 93 | json->add_int("height", map->get_height()); | 93 | json->add_int("height", map->get_height()); |
451 | 94 | json->add_int("nr_players", map->get_nrplayers()); | 94 | json->add_int("nr_players", map->get_nrplayers()); |
452 | 95 | json->add_int("needs_widelands_version_after", map->needs_widelands_version_after()); | ||
453 | 95 | 96 | ||
454 | 96 | const std::string world_name = | 97 | const std::string world_name = |
455 | 97 | static_cast<Widelands::WidelandsMapLoader*>(ml.get())->old_world_name(); | 98 | static_cast<Widelands::WidelandsMapLoader*>(ml.get())->old_world_name(); |
Some questions inline Code otherwise LGTM.
Will commpile this and the read that code again.