Merge lp:~widelands-dev/widelands/elk_moose into lp:widelands

Proposed by GunChleoc
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
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 WorldLegacyLookupTable
- New map version property "needs_widelands_version_after" for the website

To post a comment you must log in.
Revision history for this message
Klaus Halfmann (klaus-halfmann) wrote :

Some questions inline Code otherwise LGTM.
Will commpile this and the read that code again.

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

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

Revision history for this message
Klaus Halfmann (klaus-halfmann) wrote :

OTOH the code is OK for me, anything more I can / must do?

review: Approve (review, compile, short test)
Revision history for this message
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.

Revision history for this message
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_widelands_version_after": 18,
   "world_name": "",
   "minimap": "/Users/klaus/.widelands/maps/My_Maps/CrossriverA1.wmf.png"
}

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_widelands_version_after": 20,
   "world_name": "",
   "minimap": "/Users/klaus/.widelands/maps/My_Maps/27 zu 3 Inselnx.wmf.png"
}

Trunk gives me:

Exception: map objects: [../src/logic/map_objects/world/critter.cc:323] loading critter:

UnhandledVersionError: This game was saved using an older version of Widelands and cannot be loaded anymore, or it's a new version that can't be handled yet.

Packet Name: Critter
Saved Version: 2
Current Version: 1.

Fine

review: Approve (testing)
Revision history for this message
GunChleoc (gunchleoc) wrote :

Thanks for the review & testing!

@bunnybot merge

Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 5218. State: errored. Details: https://travis-ci.org/widelands/widelands/builds/549145830.
Appveyor build 4997. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_elk_moose-4997.

Revision history for this message
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://travis-ci.org/widelands/widelands/builds/549145830.

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

Revision history for this message
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://bazaar.launchpad.net/~widelands-dev/widelands/trunk/

Revision history for this message
GunChleoc (gunchleoc) wrote :

@bunnybot merge force

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== renamed directory 'data/world/critters/elk' => 'data/world/critters/moose'
=== modified file 'data/world/critters/moose/init.lua'
--- data/world/critters/elk/init.lua 2019-04-21 14:57:55 +0000
+++ data/world/critters/moose/init.lua 2019-06-22 16:21:53 +0000
@@ -15,8 +15,8 @@
15add_directional_animation(animations, "walk", dirname, "walk", {21, 34}, 20)15add_directional_animation(animations, "walk", dirname, "walk", {21, 34}, 20)
1616
17world:new_critter_type{17world:new_critter_type{
18 name = "elk",18 name = "moose",
19 descname = _ "Elk",19 descname = _ "Moose",
20 editor_category = "critters_herbivores",20 editor_category = "critters_herbivores",
21 attributes = { "eatable" },21 attributes = { "eatable" },
22 programs = {22 programs = {
2323
=== modified file 'data/world/init.lua'
--- data/world/init.lua 2017-09-03 10:56:44 +0000
+++ data/world/init.lua 2019-06-22 16:21:53 +0000
@@ -288,7 +288,7 @@
288 include "world/critters/deer/init.lua"288 include "world/critters/deer/init.lua"
289 include "world/critters/reindeer/init.lua"289 include "world/critters/reindeer/init.lua"
290 include "world/critters/stag/init.lua"290 include "world/critters/stag/init.lua"
291 include "world/critters/elk/init.lua"291 include "world/critters/moose/init.lua"
292292
293 -- Carnivores293 -- Carnivores
294 world:new_editor_critter_category {294 world:new_editor_critter_category {
295295
=== modified file 'data/world/map_generation.lua'
--- data/world/map_generation.lua 2017-02-12 09:10:57 +0000
+++ data/world/map_generation.lua 2019-06-22 16:21:53 +0000
@@ -77,17 +77,17 @@
77 "alder_summer_old", "birch_summer_old", "beech_summer_old",77 "alder_summer_old", "birch_summer_old", "beech_summer_old",
78 "larch_summer_old", "rowan_summer_old"78 "larch_summer_old", "rowan_summer_old"
79 },79 },
80 critters = { "brownbear", "chamois", "elk", "lynx", "reindeer", "stag", "wildboar", "wolf" },80 critters = { "brownbear", "chamois", "moose", "lynx", "reindeer", "stag", "wildboar", "wolf" },
81 },81 },
82 {82 {
83 name = "bushes",83 name = "bushes",
84 immovables = { "bush1", "bush2", "bush3", "bush4", "bush5" },84 immovables = { "bush1", "bush2", "bush3", "bush4", "bush5" },
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" },
86 },86 },
87 {87 {
88 name = "grasses",88 name = "grasses",
89 immovables = { "grass1", "grass2", "grass3" },89 immovables = { "grass1", "grass2", "grass3" },
90 critters = { "bunny", "elk", "fox", "lynx", "marten", "sheep", "sheep", "wolf" },90 critters = { "bunny", "moose", "fox", "lynx", "marten", "sheep", "sheep", "wolf" },
91 },91 },
92 {92 {
93 name = "standing_stones",93 name = "standing_stones",
@@ -614,13 +614,13 @@
614 "birch_summer_old", "beech_summer_old",614 "birch_summer_old", "beech_summer_old",
615 "larch_summer_old", "rowan_summer_old",615 "larch_summer_old", "rowan_summer_old",
616 },616 },
617 critters = { "deer", "elk", "lynx", "reindeer", "wolf" },617 critters = { "deer", "moose", "lynx", "reindeer", "wolf" },
618 },618 },
619 {619 {
620 name = "bushes",620 name = "bushes",
621 immovables = { "bush1", "bush2", "bush3", "bush4", "bush5" },621 immovables = { "bush1", "bush2", "bush3", "bush4", "bush5" },
622 critters = {622 critters = {
623 "wisent", "wolf", "bunny", "elk", "fox", "lynx",623 "wisent", "wolf", "bunny", "moose", "fox", "lynx",
624 "wolf", "marten", "sheep"624 "wolf", "marten", "sheep"
625 },625 },
626 },626 },
@@ -628,7 +628,7 @@
628 name = "grasses",628 name = "grasses",
629 immovables = { "grass1", "grass2", "grass3" },629 immovables = { "grass1", "grass2", "grass3" },
630 critters = {630 critters = {
631 "wisent", "wolf", "bunny", "elk", "fox", "lynx",631 "wisent", "wolf", "bunny", "moose", "fox", "lynx",
632 "wolf", "marten", "sheep"632 "wolf", "marten", "sheep"
633 },633 },
634 },634 },
635635
=== modified file 'src/logic/map.cc'
--- src/logic/map.cc 2019-05-16 09:15:03 +0000
+++ src/logic/map.cc 2019-06-22 16:21:53 +0000
@@ -714,6 +714,22 @@
714 pathfieldmgr_->set_size(field_size);714 pathfieldmgr_->set_size(field_size);
715}715}
716716
717int Map::needs_widelands_version_after() const {
718 return map_version_.needs_widelands_version_after;
719}
720
721void Map::calculate_needs_widelands_version_after(bool is_post_one_world) {
722 if (map_version_.needs_widelands_version_after == 0) {
723 if (nrplayers_ > 8) {
724 // We introduced support for 16 players after Build 19
725 map_version_.needs_widelands_version_after = 19;
726 } else if (is_post_one_world) {
727 // We merged the worlds in the engine after Build 18
728 map_version_.needs_widelands_version_after = 18;
729 }
730 }
731}
732
717/*733/*
718 * The scenario get/set functions734 * The scenario get/set functions
719 */735 */
720736
=== modified file 'src/logic/map.h'
--- src/logic/map.h 2019-05-16 09:15:03 +0000
+++ src/logic/map.h 2019-06-22 16:21:53 +0000
@@ -289,6 +289,9 @@
289 return height_;289 return height_;
290 }290 }
291291
292 // Map compatibility information for the website
293 int needs_widelands_version_after() const;
294
292 // The next few functions are only valid when the map is loaded as a295 // The next few functions are only valid when the map is loaded as a
293 // scenario.296 // scenario.
294 const std::string& get_scenario_player_tribe(PlayerNumber) const;297 const std::string& get_scenario_player_tribe(PlayerNumber) const;
@@ -518,6 +521,11 @@
518 std::map<Coords, FieldData>521 std::map<Coords, FieldData>
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);
520523
524protected:
525 /// Calculate map compatibility information for the website if it wasn't defined in the map packet.
526 /// If is_post_one_world is true, this map wasn't created for a specific world (Widelands versions up to Build 18).
527 void calculate_needs_widelands_version_after(bool is_post_one_world);
528
521private:529private:
522 void recalc_border(const FCoords&);530 void recalc_border(const FCoords&);
523 void recalc_brightness(const FCoords&);531 void recalc_brightness(const FCoords&);
524532
=== modified file 'src/logic/map_objects/world/critter.cc'
--- src/logic/map_objects/world/critter.cc 2019-05-25 08:51:42 +0000
+++ src/logic/map_objects/world/critter.cc 2019-06-22 16:21:53 +0000
@@ -268,7 +268,8 @@
268==============================268==============================
269*/269*/
270270
271constexpr 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.
272constexpr uint8_t kCurrentPacketVersion = 2;
272273
273Critter::Loader::Loader() {274Critter::Loader::Loader() {
274}275}
@@ -303,7 +304,7 @@
303 const CritterDescr* descr = nullptr;304 const CritterDescr* descr = nullptr;
304305
305 if (critter_owner == "world") {306 if (critter_owner == "world") {
306 critter_name = lookup_table.lookup_critter(critter_name);307 critter_name = lookup_table.lookup_critter(critter_name, packet_version);
307 descr = egbase.world().get_critter_descr(critter_name);308 descr = egbase.world().get_critter_descr(critter_name);
308 } else {309 } else {
309 throw GameDataError(310 throw GameDataError(
310311
=== modified file 'src/logic/map_revision.h'
--- src/logic/map_revision.h 2019-02-23 11:00:49 +0000
+++ src/logic/map_revision.h 2019-06-22 16:21:53 +0000
@@ -37,6 +37,8 @@
37 int32_t map_version_major;37 int32_t map_version_major;
38 int32_t map_version_minor;38 int32_t map_version_minor;
39 uint32_t map_version_timestamp;39 uint32_t map_version_timestamp;
40 // Map compatibility information for the website
41 int needs_widelands_version_after;
4042
41 MapVersion();43 MapVersion();
42};44};
4345
=== modified file 'src/map_io/map_bob_packet.cc'
--- src/map_io/map_bob_packet.cc 2019-02-23 11:00:49 +0000
+++ src/map_io/map_bob_packet.cc 2019-06-22 16:21:53 +0000
@@ -36,7 +36,7 @@
36 EditorGameBase& egbase,36 EditorGameBase& egbase,
37 MapObjectLoader&,37 MapObjectLoader&,
38 const Coords& coords,38 const Coords& coords,
39 const WorldLegacyLookupTable& lookup_table) {39 const WorldLegacyLookupTable& lookup_table, uint16_t packet_version) {
40 const std::string owner = fr.c_string();40 const std::string owner = fr.c_string();
41 char const* const read_name = fr.c_string();41 char const* const read_name = fr.c_string();
42 uint8_t subtype = fr.unsigned_8();42 uint8_t subtype = fr.unsigned_8();
@@ -47,7 +47,7 @@
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);
48 }48 }
4949
50 const std::string name = lookup_table.lookup_critter(read_name);50 const std::string name = lookup_table.lookup_critter(read_name, packet_version);
51 try {51 try {
52 const World& world = egbase.world();52 const World& world = egbase.world();
53 DescriptionIndex const idx = world.get_critter(name.c_str());53 DescriptionIndex const idx = world.get_critter(name.c_str());
@@ -84,7 +84,7 @@
84 for (uint16_t x = 0; x < map->get_width(); ++x) {84 for (uint16_t x = 0; x < map->get_width(); ++x) {
85 uint32_t const nr_bobs = fr.unsigned_32();85 uint32_t const nr_bobs = fr.unsigned_32();
86 for (uint32_t i = 0; i < nr_bobs; ++i)86 for (uint32_t i = 0; i < nr_bobs; ++i)
87 read_bob(fr, egbase, mol, Coords(x, y), lookup_table);87 read_bob(fr, egbase, mol, Coords(x, y), lookup_table, packet_version);
88 }88 }
89 }89 }
90 else {90 else {
9191
=== modified file 'src/map_io/map_bob_packet.h'
--- src/map_io/map_bob_packet.h 2019-02-23 11:00:49 +0000
+++ src/map_io/map_bob_packet.h 2019-06-22 16:21:53 +0000
@@ -42,7 +42,7 @@
42 EditorGameBase&,42 EditorGameBase&,
43 MapObjectLoader&,43 MapObjectLoader&,
44 const Coords&,44 const Coords&,
45 const WorldLegacyLookupTable& lookup_table);45 const WorldLegacyLookupTable& lookup_table, uint16_t packet_version);
46};46};
47} // namespace Widelands47} // namespace Widelands
4848
4949
=== modified file 'src/map_io/map_saver.cc'
--- src/map_io/map_saver.cc 2019-03-09 10:01:09 +0000
+++ src/map_io/map_saver.cc 2019-06-22 16:21:53 +0000
@@ -156,7 +156,7 @@
156 log("Writing Map Version ... ");156 log("Writing Map Version ... ");
157 {157 {
158 MapVersionPacket p;158 MapVersionPacket p;
159 p.write(fs_, egbase_, *mos_);159 p.write(fs_, egbase_);
160 }160 }
161 log("took %ums\n ", timer.ms_since_last_query());161 log("took %ums\n ", timer.ms_since_last_query());
162162
163163
=== modified file 'src/map_io/map_version_packet.cc'
--- src/map_io/map_version_packet.cc 2019-02-23 11:00:49 +0000
+++ src/map_io/map_version_packet.cc 2019-06-22 16:21:53 +0000
@@ -30,11 +30,17 @@
30namespace Widelands {30namespace Widelands {
3131
32constexpr uint16_t kCurrentPacketVersion = 1;32constexpr uint16_t kCurrentPacketVersion = 1;
33// Map compatibility information for the website
34constexpr int kCurrentNeedsWidelandsVersionAfter = 20;
3335
34void MapVersionPacket::read(FileSystem& fs,36void MapVersionPacket::read(FileSystem& fs,
35 EditorGameBase& egbase,37 EditorGameBase& egbase,
36 bool const skip,38 bool const skip, bool is_post_one_world) {
37 MapObjectLoader&) {39
40 pre_read(fs, egbase.mutable_map(), skip, is_post_one_world);
41}
42
43void MapVersionPacket::pre_read(FileSystem& fs, Map* map, bool skip, bool is_post_one_world) {
38 if (skip)44 if (skip)
39 return;45 return;
4046
@@ -42,7 +48,6 @@
42 try {48 try {
43 prof.read("version", nullptr, fs);49 prof.read("version", nullptr, fs);
44 } catch (...) {50 } catch (...) {
45 Map* map = egbase.mutable_map();
46 map->map_version_.map_version_timestamp = 0;51 map->map_version_.map_version_timestamp = 0;
47 map->map_version_.map_creator_version = "unknown";52 map->map_version_.map_creator_version = "unknown";
48 return;53 return;
@@ -55,7 +60,6 @@
55 if ((packet_version == kCurrentPacketVersion) ||60 if ((packet_version == kCurrentPacketVersion) ||
56 (packet_version > kCurrentPacketVersion &&61 (packet_version > kCurrentPacketVersion &&
57 forward_compatibility <= kCurrentPacketVersion)) {62 forward_compatibility <= kCurrentPacketVersion)) {
58 Map* map = egbase.mutable_map();
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");
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");
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");
@@ -63,6 +67,8 @@
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");
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"));
65 map->map_version_.map_version_timestamp = ts;69 map->map_version_.map_version_timestamp = ts;
70 map->map_version_.needs_widelands_version_after = globv.get_int("needs_widelands_version_after", 0);
71 map->calculate_needs_widelands_version_after(is_post_one_world);
66 } else {72 } else {
67 throw UnhandledVersionError("MapVersionPacket", packet_version, kCurrentPacketVersion);73 throw UnhandledVersionError("MapVersionPacket", packet_version, kCurrentPacketVersion);
68 }74 }
@@ -71,7 +77,7 @@
71 }77 }
72}78}
7379
74void MapVersionPacket::write(FileSystem& fs, EditorGameBase& egbase, MapObjectSaver&) {80void MapVersionPacket::write(FileSystem& fs, EditorGameBase& egbase) {
75 Profile prof;81 Profile prof;
76 Section& globs = prof.create_section("global");82 Section& globs = prof.create_section("global");
7783
@@ -117,6 +123,7 @@
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)));
118 globs.set_int("packet_version", kCurrentPacketVersion);124 globs.set_int("packet_version", kCurrentPacketVersion);
119 globs.set_int("packet_compatibility", kCurrentPacketVersion);125 globs.set_int("packet_compatibility", kCurrentPacketVersion);
126 globs.set_int("needs_widelands_version_after", kCurrentNeedsWidelandsVersionAfter);
120127
121 prof.write("version", false, fs);128 prof.write("version", false, fs);
122}129}
123130
=== modified file 'src/map_io/map_version_packet.h'
--- src/map_io/map_version_packet.h 2019-02-23 11:00:49 +0000
+++ src/map_io/map_version_packet.h 2019-06-22 16:21:53 +0000
@@ -20,11 +20,26 @@
20#ifndef WL_MAP_IO_MAP_VERSION_PACKET_H20#ifndef WL_MAP_IO_MAP_VERSION_PACKET_H
21#define WL_MAP_IO_MAP_VERSION_PACKET_H21#define WL_MAP_IO_MAP_VERSION_PACKET_H
2222
23#include "map_io/map_data_packet.h"23class FileSystem;
24
25namespace Widelands {
26
27class EditorGameBase;
28class Map;
29class MapObjectLoader;
30struct MapObjectSaver;
2431
25/*32/*
26 * This packet contains the version information of the map.33 * This packet contains the version information of the map.
27 */34 */
28MAP_DATA_PACKET(MapVersionPacket)35class MapVersionPacket {
36public:
37 void read(FileSystem&, EditorGameBase&, bool skip, bool is_post_one_world);
38 void write(FileSystem&, EditorGameBase&);
39
40 void pre_read(FileSystem&, Map*, bool skip, bool is_post_one_world);
41};
42
43} // namespace Widelands
2944
30#endif // end of include guard: WL_MAP_IO_MAP_VERSION_PACKET_H45#endif // end of include guard: WL_MAP_IO_MAP_VERSION_PACKET_H
3146
=== modified file 'src/map_io/widelands_map_loader.cc'
--- src/map_io/widelands_map_loader.cc 2019-05-26 03:14:41 +0000
+++ src/map_io/widelands_map_loader.cc 2019-06-22 16:21:53 +0000
@@ -82,6 +82,10 @@
82 mp.pre_read(*fs_, &map_);82 mp.pre_read(*fs_, &map_);
83 old_world_name_ = mp.old_world_name();83 old_world_name_ = mp.old_world_name();
84 }84 }
85 {
86 MapVersionPacket version_packet;
87 version_packet.pre_read(*fs_, &map_, false, old_world_name_.empty());
88 }
8589
86 {90 {
87 MapPlayerNamesAndTribesPacket p;91 MapPlayerNamesAndTribesPacket p;
@@ -198,7 +202,7 @@
198 log("Reading Map Version Data ... ");202 log("Reading Map Version Data ... ");
199 {203 {
200 MapVersionPacket p;204 MapVersionPacket p;
201 p.read(*fs_, egbase, is_game, *mol_);205 p.read(*fs_, egbase, is_game, old_world_name_.empty());
202 }206 }
203 log("took %ums\n ", timer.ms_since_last_query());207 log("took %ums\n ", timer.ms_since_last_query());
204208
205209
=== modified file 'src/map_io/world_legacy_lookup_table.cc'
--- src/map_io/world_legacy_lookup_table.cc 2019-02-23 11:00:49 +0000
+++ src/map_io/world_legacy_lookup_table.cc 2019-06-22 16:21:53 +0000
@@ -33,16 +33,24 @@
33 // Implements OneWorldLegacyLookupTable.33 // Implements OneWorldLegacyLookupTable.
34 std::string lookup_resource(const std::string& resource) const override;34 std::string lookup_resource(const std::string& resource) const override;
35 std::string lookup_terrain(const std::string& terrain) const override;35 std::string lookup_terrain(const std::string& terrain) const override;
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;
37 std::string lookup_immovable(const std::string& immovable) const override;37 std::string lookup_immovable(const std::string& immovable) const override;
3838
39private:39private:
40 // Old name, <packet version when it got changed, new name>
41 const std::map<std::string, std::map<uint16_t, std::string>> critters_;
40 const std::map<std::string, std::string> immovables_;42 const std::map<std::string, std::string> immovables_;
41 const std::map<std::string, std::string> resources_;43 const std::map<std::string, std::string> resources_;
42 const std::map<std::string, std::string> terrains_;44 const std::map<std::string, std::string> terrains_;
43};45};
4446
45PostOneWorldLegacyLookupTable::PostOneWorldLegacyLookupTable() :47PostOneWorldLegacyLookupTable::PostOneWorldLegacyLookupTable() :
48critters_
49{
50 // We need to bump the packet version in Critter every time we rename a critter.
51 // Also, don't forget to edit the OneWorldLegacyLookupTable! You can look up which world had which units in Build 18.
52 {"elk", {{2, "moose"}}},
53},
46immovables_54immovables_
47{55{
48 {"blackland_stones1", "blackland_rocks1"},56 {"blackland_stones1", "blackland_rocks1"},
@@ -113,8 +121,16 @@
113 return i->second;121 return i->second;
114}122}
115123
116std::string PostOneWorldLegacyLookupTable::lookup_critter(const std::string& critter) const {124std::string PostOneWorldLegacyLookupTable::lookup_critter(const std::string& critter, uint16_t packet_version) const {
117 return critter;125 std::string result = critter;
126 if (critters_.count(critter) == 1) {
127 for (const auto& candidate : critters_.at(result)) {
128 if (candidate.first >= packet_version) {
129 result = candidate.second;
130 }
131 }
132 }
133 return result;
118}134}
119135
120std::string PostOneWorldLegacyLookupTable::lookup_immovable(const std::string& immovable) const {136std::string PostOneWorldLegacyLookupTable::lookup_immovable(const std::string& immovable) const {
@@ -132,7 +148,7 @@
132 // Implements OneWorldLegacyLookupTable.148 // Implements OneWorldLegacyLookupTable.
133 std::string lookup_resource(const std::string& resource) const override;149 std::string lookup_resource(const std::string& resource) const override;
134 std::string lookup_terrain(const std::string& terrain) const override;150 std::string lookup_terrain(const std::string& terrain) const override;
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;
136 std::string lookup_immovable(const std::string& immovable) const override;152 std::string lookup_immovable(const std::string& immovable) const override;
137153
138private:154private:
@@ -205,6 +221,7 @@
205 std::make_pair("greenland",221 std::make_pair("greenland",
206 std::map<std::string, std::string>{222 std::map<std::string, std::string>{
207 {"deer", "stag"},223 {"deer", "stag"},
224 {"elk", "moose"},
208 }),225 }),
209 std::make_pair("blackland",226 std::make_pair("blackland",
210 std::map<std::string, std::string>{227 std::map<std::string, std::string>{
@@ -213,6 +230,7 @@
213 std::make_pair("winterland",230 std::make_pair("winterland",
214 std::map<std::string, std::string>{231 std::map<std::string, std::string>{
215 {"deer", "stag"},232 {"deer", "stag"},
233 {"elk", "moose"},
216 }),234 }),
217 std::make_pair("desert",235 std::make_pair("desert",
218 std::map<std::string, std::string>{236 std::map<std::string, std::string>{
@@ -418,7 +436,7 @@
418 return terrain;436 return terrain;
419}437}
420438
421std::string OneWorldLegacyLookupTable::lookup_critter(const std::string& critter) const {439std::string OneWorldLegacyLookupTable::lookup_critter(const std::string& critter, uint16_t) const {
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_);
423 const auto& i = world_critters.find(critter);441 const auto& i = world_critters.find(critter);
424 if (i != world_critters.end()) {442 if (i != world_critters.end()) {
425443
=== modified file 'src/map_io/world_legacy_lookup_table.h'
--- src/map_io/world_legacy_lookup_table.h 2019-02-23 11:00:49 +0000
+++ src/map_io/world_legacy_lookup_table.h 2019-06-22 16:21:53 +0000
@@ -38,7 +38,7 @@
38 virtual std::string lookup_terrain(const std::string& terrain) const = 0;38 virtual std::string lookup_terrain(const std::string& terrain) const = 0;
3939
40 /// Looks up the new name for the 'critter'.40 /// Looks up the new name for the 'critter'.
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;
4242
43 /// Looks up the new name for the 'immovable'.43 /// Looks up the new name for the 'immovable'.
44 virtual std::string lookup_immovable(const std::string& immovable) const = 0;44 virtual std::string lookup_immovable(const std::string& immovable) const = 0;
4545
=== modified file 'src/website/map_info.cc'
--- src/website/map_info.cc 2019-02-23 11:00:49 +0000
+++ src/website/map_info.cc 2019-06-22 16:21:53 +0000
@@ -92,6 +92,7 @@
92 json->add_int("width", map->get_width());92 json->add_int("width", map->get_width());
93 json->add_int("height", map->get_height());93 json->add_int("height", map->get_height());
94 json->add_int("nr_players", map->get_nrplayers());94 json->add_int("nr_players", map->get_nrplayers());
95 json->add_int("needs_widelands_version_after", map->needs_widelands_version_after());
9596
96 const std::string world_name =97 const std::string world_name =
97 static_cast<Widelands::WidelandsMapLoader*>(ml.get())->old_world_name();98 static_cast<Widelands::WidelandsMapLoader*>(ml.get())->old_world_name();

Subscribers

People subscribed via source and target branches

to status/vote changes: