Merge lp:~widelands-dev/widelands/reed-compatibility into lp:widelands

Proposed by GunChleoc
Status: Merged
Merged at revision: 9146
Proposed branch: lp:~widelands-dev/widelands/reed-compatibility
Merge into: lp:widelands
Diff against target: 823 lines (+122/-91)
19 files modified
src/economy/expedition_bootstrap.cc (+3/-3)
src/economy/expedition_bootstrap.h (+1/-1)
src/economy/input_queue.cc (+7/-6)
src/economy/input_queue.h (+1/-1)
src/economy/request.cc (+3/-3)
src/economy/request.h (+2/-1)
src/game_io/game_player_info_packet.cc (+2/-2)
src/map_io/map_buildingdata_packet.cc (+42/-38)
src/map_io/map_buildingdata_packet.h (+9/-8)
src/map_io/map_flagdata_packet.cc (+2/-2)
src/map_io/map_flagdata_packet.h (+8/-1)
src/map_io/map_object_packet.cc (+4/-4)
src/map_io/map_object_packet.h (+1/-1)
src/map_io/map_players_view_packet.cc (+9/-9)
src/map_io/map_players_view_packet.h (+10/-1)
src/map_io/map_roaddata_packet.cc (+2/-2)
src/map_io/map_roaddata_packet.h (+8/-1)
src/map_io/tribes_legacy_lookup_table.cc (+2/-1)
src/map_io/widelands_map_loader.cc (+6/-6)
To merge this branch: bzr merge lp:~widelands-dev/widelands/reed-compatibility
Reviewer Review Type Date Requested Status
hessenfarmer Approve
Review via email: mp+367935@code.launchpad.net

Commit message

Fix savegame compatibility for reed, buildings, players view and economy requests.

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

Continuous integration builds have changed state:

Travis build 5058. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/537337141.
Appveyor build 4838. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_reed_compatibility-4838.

Revision history for this message
Notabilis (notabilis27) wrote :

So ... you created a diff of 800 lines by passing objects around so you can call a method in only a handful of places?? I like it! :)
The changes are mostly looking good to me. Replacing the GOTO might be broken, though, see my diff comment below.

I haven't tested the changes, mostly because I have no sensible idea how to do so. But based on the code I guess it shouldn't break anything.

Revision history for this message
GunChleoc (gunchleoc) wrote :

> So ... you created a diff of 800 lines by passing objects around so you can call a method in only a handful of places?? I like it! :)

Lol yep. It will save a bit of memory though if the objects are created only once.

For triggering the bug, you need a savegame created with bzr9118 or older that has reed or wheat fields on it.

Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 5154. State: errored. Details: https://travis-ci.org/widelands/widelands/builds/541619525.
Appveyor build 4936. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_reed_compatibility-4936.

Revision history for this message
GunChleoc (gunchleoc) wrote :

I have added a second if statement for the test variable to simulate the effect of the goto and break out of the outer loop. Thanks for the review!

@bunybot merge

Revision history for this message
Notabilis (notabilis27) wrote :

Sorry, I am having second thoughts about the goto-part. Actually, I am not only unsure about the goto-replacement but over the whole code part independent of your changes. :-/
If I understand it right, the code iterates over the possible jobs in the production site. If there is a job the loaded worker can work on, we iterate over all working positions of the site and check if *any* of these is empty, so we can assign the worker. Shouldn't we only check the working positions that are for the required job? Otherwise, the code could break with production sites which have multiple types of worker positions (Mines probably? These need a miner and a master miner).

Maybe I am just confused and the code is fine, but it would be good if someone could check it.

Revision history for this message
GunChleoc (gunchleoc) wrote :

This code is pretty old, so I'm sure we would have had bug reports for it in the past if it was broken. It should be fine if iterating starts with the most advanced working position, because then we won't put a master miner i a miner's slot and end up stumped when we have to put a miner in a master miner's slot, which is not allowed.

I'll reinstate the goto to make sure we can't possibly have any accidental semantic changes, so that we can get this bugfix in.

Revision history for this message
GunChleoc (gunchleoc) wrote :

Done. Thanks for the review!

@bunnybot merge

Revision history for this message
GunChleoc (gunchleoc) wrote :

Inputqueues again

@bunnybot merge force

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 5164. State: errored. Details: https://travis-ci.org/widelands/widelands/builds/542121335.

Revision history for this message
hessenfarmer (stephan-lutz) wrote :

@bunnybot merge force

Revision history for this message
hessenfarmer (stephan-lutz) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/economy/expedition_bootstrap.cc'
--- src/economy/expedition_bootstrap.cc 2019-02-23 11:00:49 +0000
+++ src/economy/expedition_bootstrap.cc 2019-06-08 16:55:17 +0000
@@ -203,7 +203,7 @@
203}203}
204204
205void ExpeditionBootstrap::load(205void ExpeditionBootstrap::load(
206 Warehouse& warehouse, FileRead& fr, Game& game, MapObjectLoader& mol, uint16_t packet_version) {206 Warehouse& warehouse, FileRead& fr, Game& game, MapObjectLoader& mol, const TribesLegacyLookupTable& tribes_lookup_table, uint16_t packet_version) {
207207
208 static const uint16_t kCurrentPacketVersion = 7;208 static const uint16_t kCurrentPacketVersion = 7;
209 assert(queues_.empty());209 assert(queues_.empty());
@@ -214,7 +214,7 @@
214 uint8_t num_queues = fr.unsigned_8();214 uint8_t num_queues = fr.unsigned_8();
215 for (uint8_t i = 0; i < num_queues; ++i) {215 for (uint8_t i = 0; i < num_queues; ++i) {
216 WorkersQueue* wq = new WorkersQueue(warehouse, INVALID_INDEX, 0);216 WorkersQueue* wq = new WorkersQueue(warehouse, INVALID_INDEX, 0);
217 wq->read(fr, game, mol);217 wq->read(fr, game, mol, tribes_lookup_table);
218 wq->set_callback(input_callback, this);218 wq->set_callback(input_callback, this);
219219
220 if (wq->get_index() == INVALID_INDEX) {220 if (wq->get_index() == INVALID_INDEX) {
@@ -232,7 +232,7 @@
232 uint8_t num_queues = fr.unsigned_8();232 uint8_t num_queues = fr.unsigned_8();
233 for (uint8_t i = 0; i < num_queues; ++i) {233 for (uint8_t i = 0; i < num_queues; ++i) {
234 WaresQueue* wq = new WaresQueue(warehouse, INVALID_INDEX, 0);234 WaresQueue* wq = new WaresQueue(warehouse, INVALID_INDEX, 0);
235 wq->read(fr, game, mol);235 wq->read(fr, game, mol, tribes_lookup_table);
236 wq->set_callback(input_callback, this);236 wq->set_callback(input_callback, this);
237237
238 if (wq->get_index() == INVALID_INDEX) {238 if (wq->get_index() == INVALID_INDEX) {
239239
=== modified file 'src/economy/expedition_bootstrap.h'
--- src/economy/expedition_bootstrap.h 2019-02-23 11:00:49 +0000
+++ src/economy/expedition_bootstrap.h 2019-06-08 16:55:17 +0000
@@ -88,7 +88,7 @@
88 * packet, and there in the warehouse data packet.88 * packet, and there in the warehouse data packet.
89 */89 */
90 void90 void
91 load(Warehouse& warehouse, FileRead& fr, Game& game, MapObjectLoader& mol, uint16_t version);91 load(Warehouse& warehouse, FileRead& fr, Game& game, MapObjectLoader& mol, const TribesLegacyLookupTable& tribes_lookup_table, uint16_t version);
9292
93 /** Save this into a file.93 /** Save this into a file.
94 *94 *
9595
=== modified file 'src/economy/input_queue.cc'
--- src/economy/input_queue.cc 2019-02-23 11:00:49 +0000
+++ src/economy/input_queue.cc 2019-06-08 16:55:17 +0000
@@ -130,7 +130,7 @@
130130
131constexpr uint16_t kCurrentPacketVersion = 3;131constexpr uint16_t kCurrentPacketVersion = 3;
132132
133void InputQueue::read(FileRead& fr, Game& game, MapObjectLoader& mol) {133void InputQueue::read(FileRead& fr, Game& game, MapObjectLoader& mol, const TribesLegacyLookupTable& tribes_lookup_table) {
134134
135 uint16_t const packet_version = fr.unsigned_16();135 uint16_t const packet_version = fr.unsigned_16();
136 try {136 try {
@@ -140,25 +140,26 @@
140 if (packet_version == 1 || packet_version == kCurrentPacketVersion) {140 if (packet_version == 1 || packet_version == kCurrentPacketVersion) {
141 if (fr.unsigned_8() == 0) {141 if (fr.unsigned_8() == 0) {
142 assert(type_ == wwWARE);142 assert(type_ == wwWARE);
143 index_ = owner().tribe().ware_index(fr.c_string());143 index_ = owner().tribe().ware_index(tribes_lookup_table.lookup_ware(fr.c_string()));
144 } else {144 } else {
145 assert(type_ == wwWORKER);145 assert(type_ == wwWORKER);
146 index_ = owner().tribe().worker_index(fr.c_string());146 index_ = owner().tribe().worker_index(tribes_lookup_table.lookup_worker(fr.c_string()));
147 }147 }
148 max_size_ = fr.unsigned_32();148 max_size_ = fr.unsigned_32();
149 max_fill_ = fr.signed_32();149 max_fill_ = fr.signed_32();
150 consume_interval_ = fr.unsigned_32();150 consume_interval_ = fr.unsigned_32();
151 if (fr.unsigned_8()) {151 if (fr.unsigned_8()) {
152 request_.reset(new Request(owner_, 0, InputQueue::request_callback, type_));152 request_.reset(new Request(owner_, 0, InputQueue::request_callback, type_));
153 request_->read(fr, game, mol);153 request_->read(fr, game, mol, tribes_lookup_table);
154 } else {154 } else {
155 request_.reset();155 request_.reset();
156 }156 }
157157
158 read_child(fr, game, mol);158 read_child(fr, game, mol);
159 } else if (packet_version == 2) {159 } else if (packet_version == 2) {
160 // TODO(GunChleoc): Savegame compatibility, get rid after Build 21
160 assert(type_ == wwWARE);161 assert(type_ == wwWARE);
161 index_ = owner().tribe().ware_index(fr.c_string());162 index_ = owner().tribe().ware_index(tribes_lookup_table.lookup_ware(fr.c_string()));
162 max_size_ = fr.unsigned_32();163 max_size_ = fr.unsigned_32();
163 max_fill_ = fr.signed_32();164 max_fill_ = fr.signed_32();
164 // No read_child() call here, doing it manually since there is no child-version number165 // No read_child() call here, doing it manually since there is no child-version number
@@ -166,7 +167,7 @@
166 consume_interval_ = fr.unsigned_32();167 consume_interval_ = fr.unsigned_32();
167 if (fr.unsigned_8()) {168 if (fr.unsigned_8()) {
168 request_.reset(new Request(owner_, 0, InputQueue::request_callback, type_));169 request_.reset(new Request(owner_, 0, InputQueue::request_callback, type_));
169 request_->read(fr, game, mol);170 request_->read(fr, game, mol, tribes_lookup_table);
170 } else {171 } else {
171 request_.reset();172 request_.reset();
172 }173 }
173174
=== modified file 'src/economy/input_queue.h'
--- src/economy/input_queue.h 2019-02-27 19:00:36 +0000
+++ src/economy/input_queue.h 2019-06-08 16:55:17 +0000
@@ -184,7 +184,7 @@
184 * @param game The game this queue will be part of.184 * @param game The game this queue will be part of.
185 * @param mol The game/map loader that handles the lading. Required to pass to Request::read().185 * @param mol The game/map loader that handles the lading. Required to pass to Request::read().
186 */186 */
187 void read(FileRead& f, Game& g, MapObjectLoader& mol);187 void read(FileRead& f, Game& g, MapObjectLoader& mol, const TribesLegacyLookupTable& tribes_lookup_table);
188188
189 /**189 /**
190 * Writes the state of this class.190 * Writes the state of this class.
191191
=== modified file 'src/economy/request.cc'
--- src/economy/request.cc 2019-02-23 11:00:49 +0000
+++ src/economy/request.cc 2019-06-08 16:55:17 +0000
@@ -98,18 +98,18 @@
98 * might have been initialized. We have to kill them and replace98 * might have been initialized. We have to kill them and replace
99 * them through the data in the file99 * them through the data in the file
100 */100 */
101void Request::read(FileRead& fr, Game& game, MapObjectLoader& mol) {101void Request::read(FileRead& fr, Game& game, MapObjectLoader& mol, const TribesLegacyLookupTable& tribes_lookup_table) {
102 try {102 try {
103 uint16_t const packet_version = fr.unsigned_16();103 uint16_t const packet_version = fr.unsigned_16();
104 if (packet_version == kCurrentPacketVersion) {104 if (packet_version == kCurrentPacketVersion) {
105 const TribeDescr& tribe = target_.owner().tribe();105 const TribeDescr& tribe = target_.owner().tribe();
106 char const* const type_name = fr.c_string();106 char const* const type_name = fr.c_string();
107 DescriptionIndex const wai = tribe.ware_index(type_name);107 DescriptionIndex const wai = tribe.ware_index(tribes_lookup_table.lookup_ware(type_name));
108 if (tribe.has_ware(wai)) {108 if (tribe.has_ware(wai)) {
109 type_ = wwWARE;109 type_ = wwWARE;
110 index_ = wai;110 index_ = wai;
111 } else {111 } else {
112 DescriptionIndex const woi = tribe.worker_index(type_name);112 DescriptionIndex const woi = tribe.worker_index(tribes_lookup_table.lookup_worker(type_name));
113 if (tribe.has_worker(woi)) {113 if (tribe.has_worker(woi)) {
114 type_ = wwWORKER;114 type_ = wwWORKER;
115 index_ = woi;115 index_ = woi;
116116
=== modified file 'src/economy/request.h'
--- src/economy/request.h 2019-02-23 11:00:49 +0000
+++ src/economy/request.h 2019-06-08 16:55:17 +0000
@@ -24,6 +24,7 @@
24#include "logic/map_objects/tribes/requirements.h"24#include "logic/map_objects/tribes/requirements.h"
25#include "logic/map_objects/tribes/wareworker.h"25#include "logic/map_objects/tribes/wareworker.h"
26#include "logic/widelands.h"26#include "logic/widelands.h"
27#include "map_io/tribes_legacy_lookup_table.h"
2728
28class FileRead;29class FileRead;
29class FileWrite;30class FileWrite;
@@ -116,7 +117,7 @@
116117
117 void start_transfer(Game&, Supply&);118 void start_transfer(Game&, Supply&);
118119
119 void read(FileRead&, Game&, MapObjectLoader&);120 void read(FileRead&, Game&, MapObjectLoader&, const TribesLegacyLookupTable& tribes_lookup_table);
120 void write(FileWrite&, Game&, MapObjectSaver&) const;121 void write(FileWrite&, Game&, MapObjectSaver&) const;
121 Worker* get_transfer_worker();122 Worker* get_transfer_worker();
122123
123124
=== modified file 'src/game_io/game_player_info_packet.cc'
--- src/game_io/game_player_info_packet.cc 2019-05-19 12:25:24 +0000
+++ src/game_io/game_player_info_packet.cc 2019-06-08 16:55:17 +0000
@@ -37,7 +37,7 @@
3737
38void GamePlayerInfoPacket::read(FileSystem& fs, Game& game, MapObjectLoader*) {38void GamePlayerInfoPacket::read(FileSystem& fs, Game& game, MapObjectLoader*) {
39 try {39 try {
40 std::unique_ptr<TribesLegacyLookupTable> tribe_lookup_table(new TribesLegacyLookupTable());40 std::unique_ptr<TribesLegacyLookupTable> tribes_lookup_table(new TribesLegacyLookupTable());
41 FileRead fr;41 FileRead fr;
42 fr.open(fs, "binary/player_info");42 fr.open(fs, "binary/player_info");
43 uint16_t const packet_version = fr.unsigned_16();43 uint16_t const packet_version = fr.unsigned_16();
@@ -72,7 +72,7 @@
72 }72 }
73 }73 }
7474
75 player->read_statistics(fr, packet_version, *tribe_lookup_table.get());75 player->read_statistics(fr, packet_version, *tribes_lookup_table.get());
76 player->read_remaining_shipnames(fr);76 player->read_remaining_shipnames(fr);
7777
78 player->casualties_ = fr.unsigned_32();78 player->casualties_ = fr.unsigned_32();
7979
=== modified file 'src/map_io/map_buildingdata_packet.cc'
--- src/map_io/map_buildingdata_packet.cc 2019-05-28 21:04:36 +0000
+++ src/map_io/map_buildingdata_packet.cc 2019-06-08 16:55:17 +0000
@@ -71,7 +71,7 @@
71void MapBuildingdataPacket::read(FileSystem& fs,71void MapBuildingdataPacket::read(FileSystem& fs,
72 EditorGameBase& egbase,72 EditorGameBase& egbase,
73 bool const skip,73 bool const skip,
74 MapObjectLoader& mol) {74 MapObjectLoader& mol, const TribesLegacyLookupTable& tribes_lookup_table) {
75 if (skip)75 if (skip)
76 return;76 return;
7777
@@ -180,18 +180,18 @@
180 Game& game = dynamic_cast<Game&>(egbase);180 Game& game = dynamic_cast<Game&>(egbase);
181181
182 if (upcast(ConstructionSite, constructionsite, &building)) {182 if (upcast(ConstructionSite, constructionsite, &building)) {
183 read_constructionsite(*constructionsite, fr, game, mol);183 read_constructionsite(*constructionsite, fr, game, mol, tribes_lookup_table);
184 } else if (upcast(DismantleSite, dms, &building)) {184 } else if (upcast(DismantleSite, dms, &building)) {
185 read_dismantlesite(*dms, fr, game, mol);185 read_dismantlesite(*dms, fr, game, mol, tribes_lookup_table);
186 } else if (upcast(MilitarySite, militarysite, &building)) {186 } else if (upcast(MilitarySite, militarysite, &building)) {
187 read_militarysite(*militarysite, fr, game, mol);187 read_militarysite(*militarysite, fr, game, mol, tribes_lookup_table);
188 } else if (upcast(Warehouse, warehouse, &building)) {188 } else if (upcast(Warehouse, warehouse, &building)) {
189 read_warehouse(*warehouse, fr, game, mol);189 read_warehouse(*warehouse, fr, game, mol, tribes_lookup_table);
190 } else if (upcast(ProductionSite, productionsite, &building)) {190 } else if (upcast(ProductionSite, productionsite, &building)) {
191 if (upcast(TrainingSite, trainingsite, productionsite)) {191 if (upcast(TrainingSite, trainingsite, productionsite)) {
192 read_trainingsite(*trainingsite, fr, game, mol);192 read_trainingsite(*trainingsite, fr, game, mol, tribes_lookup_table);
193 } else {193 } else {
194 read_productionsite(*productionsite, fr, game, mol);194 read_productionsite(*productionsite, fr, game, mol, tribes_lookup_table);
195 }195 }
196 } else {196 } else {
197 // type of building is not one of (or derived from)197 // type of building is not one of (or derived from)
@@ -215,7 +215,7 @@
215void MapBuildingdataPacket::read_partially_finished_building(PartiallyFinishedBuilding& pfb,215void MapBuildingdataPacket::read_partially_finished_building(PartiallyFinishedBuilding& pfb,
216 FileRead& fr,216 FileRead& fr,
217 Game& game,217 Game& game,
218 MapObjectLoader& mol) {218 MapObjectLoader& mol, const TribesLegacyLookupTable& tribes_lookup_table) {
219 try {219 try {
220 uint16_t const packet_version = fr.unsigned_16();220 uint16_t const packet_version = fr.unsigned_16();
221 if (packet_version == kCurrentPacketPFBuilding) {221 if (packet_version == kCurrentPacketPFBuilding) {
@@ -226,7 +226,7 @@
226 if (fr.unsigned_8()) {226 if (fr.unsigned_8()) {
227 pfb.builder_request_ =227 pfb.builder_request_ =
228 new Request(pfb, 0, PartiallyFinishedBuilding::request_builder_callback, wwWORKER);228 new Request(pfb, 0, PartiallyFinishedBuilding::request_builder_callback, wwWORKER);
229 pfb.builder_request_->read(fr, game, mol);229 pfb.builder_request_->read(fr, game, mol, tribes_lookup_table);
230 } else230 } else
231 pfb.builder_request_ = nullptr;231 pfb.builder_request_ = nullptr;
232232
@@ -244,7 +244,7 @@
244 pfb.wares_.resize(size);244 pfb.wares_.resize(size);
245 for (uint16_t i = 0; i < pfb.wares_.size(); ++i) {245 for (uint16_t i = 0; i < pfb.wares_.size(); ++i) {
246 pfb.wares_[i] = new WaresQueue(pfb, INVALID_INDEX, 0);246 pfb.wares_[i] = new WaresQueue(pfb, INVALID_INDEX, 0);
247 pfb.wares_[i]->read(fr, game, mol);247 pfb.wares_[i]->read(fr, game, mol, tribes_lookup_table);
248 }248 }
249 } catch (const WException& e) {249 } catch (const WException& e) {
250 throw GameDataError("wares: %s", e.what());250 throw GameDataError("wares: %s", e.what());
@@ -266,11 +266,11 @@
266void MapBuildingdataPacket::read_constructionsite(ConstructionSite& constructionsite,266void MapBuildingdataPacket::read_constructionsite(ConstructionSite& constructionsite,
267 FileRead& fr,267 FileRead& fr,
268 Game& game,268 Game& game,
269 MapObjectLoader& mol) {269 MapObjectLoader& mol, const TribesLegacyLookupTable& tribes_lookup_table) {
270 try {270 try {
271 uint16_t const packet_version = fr.unsigned_16();271 uint16_t const packet_version = fr.unsigned_16();
272 if (packet_version >= kCurrentPacketVersionConstructionsite) {272 if (packet_version >= kCurrentPacketVersionConstructionsite) {
273 read_partially_finished_building(constructionsite, fr, game, mol);273 read_partially_finished_building(constructionsite, fr, game, mol, tribes_lookup_table);
274274
275 for (ConstructionSite::Wares::iterator wares_iter = constructionsite.wares_.begin();275 for (ConstructionSite::Wares::iterator wares_iter = constructionsite.wares_.begin();
276 wares_iter != constructionsite.wares_.end(); ++wares_iter) {276 wares_iter != constructionsite.wares_.end(); ++wares_iter) {
@@ -291,11 +291,11 @@
291void MapBuildingdataPacket::read_dismantlesite(DismantleSite& dms,291void MapBuildingdataPacket::read_dismantlesite(DismantleSite& dms,
292 FileRead& fr,292 FileRead& fr,
293 Game& game,293 Game& game,
294 MapObjectLoader& mol) {294 MapObjectLoader& mol, const TribesLegacyLookupTable& tribes_lookup_table) {
295 try {295 try {
296 uint16_t const packet_version = fr.unsigned_16();296 uint16_t const packet_version = fr.unsigned_16();
297 if (packet_version == kCurrentPacketVersionDismantlesite) {297 if (packet_version == kCurrentPacketVersionDismantlesite) {
298 read_partially_finished_building(dms, fr, game, mol);298 read_partially_finished_building(dms, fr, game, mol, tribes_lookup_table);
299299
300 // Nothing to do300 // Nothing to do
301 } else {301 } else {
@@ -310,7 +310,7 @@
310void MapBuildingdataPacket::read_warehouse(Warehouse& warehouse,310void MapBuildingdataPacket::read_warehouse(Warehouse& warehouse,
311 FileRead& fr,311 FileRead& fr,
312 Game& game,312 Game& game,
313 MapObjectLoader& mol) {313 MapObjectLoader& mol, const TribesLegacyLookupTable& tribes_lookup_table) {
314 try {314 try {
315 uint16_t const packet_version = fr.unsigned_16();315 uint16_t const packet_version = fr.unsigned_16();
316 if (packet_version >= 6) {316 if (packet_version >= 6) {
@@ -319,7 +319,7 @@
319 const TribeDescr& tribe = player->tribe();319 const TribeDescr& tribe = player->tribe();
320320
321 while (fr.unsigned_8()) {321 while (fr.unsigned_8()) {
322 const DescriptionIndex& id = tribe.ware_index(fr.c_string());322 const DescriptionIndex& id = tribe.ware_index(tribes_lookup_table.lookup_ware(fr.c_string()));
323 Quantity amount = fr.unsigned_32();323 Quantity amount = fr.unsigned_32();
324 Warehouse::StockPolicy policy = static_cast<Warehouse::StockPolicy>(fr.unsigned_8());324 Warehouse::StockPolicy policy = static_cast<Warehouse::StockPolicy>(fr.unsigned_8());
325325
@@ -329,7 +329,7 @@
329 }329 }
330 }330 }
331 while (fr.unsigned_8()) {331 while (fr.unsigned_8()) {
332 const DescriptionIndex& id = tribe.worker_index(fr.c_string());332 const DescriptionIndex& id = tribe.worker_index(tribes_lookup_table.lookup_worker(fr.c_string()));
333 uint32_t amount = fr.unsigned_32();333 uint32_t amount = fr.unsigned_32();
334 Warehouse::StockPolicy policy = static_cast<Warehouse::StockPolicy>(fr.unsigned_8());334 Warehouse::StockPolicy policy = static_cast<Warehouse::StockPolicy>(fr.unsigned_8());
335335
@@ -364,15 +364,16 @@
364 tribe.worker_types_without_cost();364 tribe.worker_types_without_cost();
365365
366 for (;;) {366 for (;;) {
367 char const* const worker_typename = fr.c_string();367 const std::string worker_typename = tribes_lookup_table.lookup_worker(fr.c_string());
368 if (!*worker_typename) // encountered the terminator ("")368 if (worker_typename.empty()) { // No more workers found
369 break;369 break;
370 }
370 uint32_t const next_spawn = fr.unsigned_32();371 uint32_t const next_spawn = fr.unsigned_32();
371 DescriptionIndex const worker_index = tribe.safe_worker_index(worker_typename);372 DescriptionIndex const worker_index = tribe.safe_worker_index(worker_typename);
372 if (!game.tribes().worker_exists(worker_index)) {373 if (!game.tribes().worker_exists(worker_index)) {
373 log("WARNING: %s %u has a next_spawn time for nonexistent "374 log("WARNING: %s %u has a next_spawn time for nonexistent "
374 "worker type \"%s\" set to %u, ignoring\n",375 "worker type \"%s\" set to %u, ignoring\n",
375 warehouse.descr().name().c_str(), warehouse.serial(), worker_typename,376 warehouse.descr().name().c_str(), warehouse.serial(), worker_typename.c_str(),
376 next_spawn);377 next_spawn);
377 continue;378 continue;
378 }379 }
@@ -380,7 +381,7 @@
380 log("WARNING: %s %u has a next_spawn time for worker type "381 log("WARNING: %s %u has a next_spawn time for worker type "
381 "\"%s\", that costs something to build, set to %u, "382 "\"%s\", that costs something to build, set to %u, "
382 "ignoring\n",383 "ignoring\n",
383 warehouse.descr().name().c_str(), warehouse.serial(), worker_typename,384 warehouse.descr().name().c_str(), warehouse.serial(), worker_typename.c_str(),
384 next_spawn);385 next_spawn);
385 continue;386 continue;
386 }387 }
@@ -392,7 +393,7 @@
392 "\"%s\" set to %u, but it was previously set "393 "\"%s\" set to %u, but it was previously set "
393 "to %u\n",394 "to %u\n",
394 warehouse.descr().name().c_str(), warehouse.serial(),395 warehouse.descr().name().c_str(), warehouse.serial(),
395 worker_typename, next_spawn,396 worker_typename.c_str(), next_spawn,
396 warehouse.next_worker_without_cost_spawn_[i]);397 warehouse.next_worker_without_cost_spawn_[i]);
397 warehouse.next_worker_without_cost_spawn_[i] = next_spawn;398 warehouse.next_worker_without_cost_spawn_[i] = next_spawn;
398 break;399 break;
@@ -409,13 +410,13 @@
409 while (nr_planned_workers--) {410 while (nr_planned_workers--) {
410 warehouse.planned_workers_.push_back(Warehouse::PlannedWorkers());411 warehouse.planned_workers_.push_back(Warehouse::PlannedWorkers());
411 Warehouse::PlannedWorkers& pw = warehouse.planned_workers_.back();412 Warehouse::PlannedWorkers& pw = warehouse.planned_workers_.back();
412 pw.index = tribe.worker_index(fr.c_string());413 pw.index = tribe.worker_index(tribes_lookup_table.lookup_worker(fr.c_string()));
413 pw.amount = fr.unsigned_32();414 pw.amount = fr.unsigned_32();
414415
415 uint32_t nr_requests = fr.unsigned_32();416 uint32_t nr_requests = fr.unsigned_32();
416 while (nr_requests--) {417 while (nr_requests--) {
417 pw.requests.push_back(new Request(warehouse, 0, &Warehouse::request_cb, wwWORKER));418 pw.requests.push_back(new Request(warehouse, 0, &Warehouse::request_cb, wwWORKER));
418 pw.requests.back()->read(fr, game, mol);419 pw.requests.back()->read(fr, game, mol, tribes_lookup_table);
419 }420 }
420 }421 }
421422
@@ -430,7 +431,7 @@
430 // doesn't lend itself to request and other stuff.431 // doesn't lend itself to request and other stuff.
431 if (warehouse.portdock_->expedition_started()) {432 if (warehouse.portdock_->expedition_started()) {
432 warehouse.portdock_->expedition_bootstrap()->load(433 warehouse.portdock_->expedition_bootstrap()->load(
433 warehouse, fr, game, mol, packet_version);434 warehouse, fr, game, mol, tribes_lookup_table, packet_version);
434 }435 }
435 }436 }
436 }437 }
@@ -463,7 +464,7 @@
463void MapBuildingdataPacket::read_militarysite(MilitarySite& militarysite,464void MapBuildingdataPacket::read_militarysite(MilitarySite& militarysite,
464 FileRead& fr,465 FileRead& fr,
465 Game& game,466 Game& game,
466 MapObjectLoader& mol) {467 MapObjectLoader& mol, const TribesLegacyLookupTable& tribes_lookup_table) {
467 try {468 try {
468 uint16_t const packet_version = fr.unsigned_16();469 uint16_t const packet_version = fr.unsigned_16();
469 if (packet_version >= 5 && packet_version <= kCurrentPacketVersionMilitarysite) {470 if (packet_version >= 5 && packet_version <= kCurrentPacketVersionMilitarysite) {
@@ -472,18 +473,20 @@
472 if (fr.unsigned_8()) {473 if (fr.unsigned_8()) {
473 militarysite.normal_soldier_request_.reset(474 militarysite.normal_soldier_request_.reset(
474 new Request(militarysite, 0, MilitarySite::request_soldier_callback, wwWORKER));475 new Request(militarysite, 0, MilitarySite::request_soldier_callback, wwWORKER));
475 militarysite.normal_soldier_request_->read(fr, game, mol);476 militarysite.normal_soldier_request_->read(fr, game, mol, tribes_lookup_table);
476 } else477 } else {
477 militarysite.normal_soldier_request_.reset();478 militarysite.normal_soldier_request_.reset();
479 }
478480
479 if (fr.unsigned_8()) {481 if (fr.unsigned_8()) {
480 militarysite.upgrade_soldier_request_.reset(new Request(482 militarysite.upgrade_soldier_request_.reset(new Request(
481 militarysite,483 militarysite,
482 (!militarysite.normal_soldier_request_) ? 0 : militarysite.owner().tribe().soldier(),484 (!militarysite.normal_soldier_request_) ? 0 : militarysite.owner().tribe().soldier(),
483 MilitarySite::request_soldier_callback, wwWORKER));485 MilitarySite::request_soldier_callback, wwWORKER));
484 militarysite.upgrade_soldier_request_->read(fr, game, mol);486 militarysite.upgrade_soldier_request_->read(fr, game, mol, tribes_lookup_table);
485 } else487 } else {
486 militarysite.upgrade_soldier_request_.reset();488 militarysite.upgrade_soldier_request_.reset();
489 }
487490
488 if ((militarysite.didconquer_ = fr.unsigned_8())) {491 if ((militarysite.didconquer_ = fr.unsigned_8())) {
489 // Add to map of military influence.492 // Add to map of military influence.
@@ -549,7 +552,7 @@
549void MapBuildingdataPacket::read_productionsite(ProductionSite& productionsite,552void MapBuildingdataPacket::read_productionsite(ProductionSite& productionsite,
550 FileRead& fr,553 FileRead& fr,
551 Game& game,554 Game& game,
552 MapObjectLoader& mol) {555 MapObjectLoader& mol, const TribesLegacyLookupTable& tribes_lookup_table) {
553 try {556 try {
554 uint16_t const packet_version = fr.unsigned_16();557 uint16_t const packet_version = fr.unsigned_16();
555 // TODO(GunChleoc): Savegame compatibility, remove after Build 21.558 // TODO(GunChleoc): Savegame compatibility, remove after Build 21.
@@ -562,7 +565,7 @@
562 for (uint16_t i = nr_worker_requests; i; --i) {565 for (uint16_t i = nr_worker_requests; i; --i) {
563 Request& req =566 Request& req =
564 *new Request(productionsite, 0, ProductionSite::request_worker_callback, wwWORKER);567 *new Request(productionsite, 0, ProductionSite::request_worker_callback, wwWORKER);
565 req.read(fr, game, mol);568 req.read(fr, game, mol, tribes_lookup_table);
566 const DescriptionIndex& worker_index = req.get_index();569 const DescriptionIndex& worker_index = req.get_index();
567570
568 // Find a working position that matches this request.571 // Find a working position that matches this request.
@@ -587,8 +590,9 @@
587 }590 }
588 found_working_position = true;591 found_working_position = true;
589 break;592 break;
590 } else593 } else {
591 wp += count;594 wp += count;
595 }
592 }596 }
593597
594 if (!found_working_position)598 if (!found_working_position)
@@ -682,7 +686,7 @@
682 assert(!productionsite.input_queues_.size());686 assert(!productionsite.input_queues_.size());
683 for (uint16_t i = 0; i < nr_queues; ++i) {687 for (uint16_t i = 0; i < nr_queues; ++i) {
684 WaresQueue* wq = new WaresQueue(productionsite, INVALID_INDEX, 0);688 WaresQueue* wq = new WaresQueue(productionsite, INVALID_INDEX, 0);
685 wq->read(fr, game, mol);689 wq->read(fr, game, mol, tribes_lookup_table);
686690
687 if (!game.tribes().ware_exists(wq->get_index())) {691 if (!game.tribes().ware_exists(wq->get_index())) {
688 delete wq;692 delete wq;
@@ -695,7 +699,7 @@
695 nr_queues = fr.unsigned_16();699 nr_queues = fr.unsigned_16();
696 for (uint16_t i = 0; i < nr_queues; ++i) {700 for (uint16_t i = 0; i < nr_queues; ++i) {
697 WorkersQueue* wq = new WorkersQueue(productionsite, INVALID_INDEX, 0);701 WorkersQueue* wq = new WorkersQueue(productionsite, INVALID_INDEX, 0);
698 wq->read(fr, game, mol);702 wq->read(fr, game, mol, tribes_lookup_table);
699703
700 if (!game.tribes().worker_exists(wq->get_index())) {704 if (!game.tribes().worker_exists(wq->get_index())) {
701 delete wq;705 delete wq;
@@ -732,18 +736,18 @@
732void MapBuildingdataPacket::read_trainingsite(TrainingSite& trainingsite,736void MapBuildingdataPacket::read_trainingsite(TrainingSite& trainingsite,
733 FileRead& fr,737 FileRead& fr,
734 Game& game,738 Game& game,
735 MapObjectLoader& mol) {739 MapObjectLoader& mol, const TribesLegacyLookupTable& tribes_lookup_table) {
736 try {740 try {
737 uint16_t const packet_version = fr.unsigned_16();741 uint16_t const packet_version = fr.unsigned_16();
738 if (packet_version == kCurrentPacketVersionTrainingsite) {742 if (packet_version == kCurrentPacketVersionTrainingsite) {
739 read_productionsite(trainingsite, fr, game, mol);743 read_productionsite(trainingsite, fr, game, mol, tribes_lookup_table);
740744
741 delete trainingsite.soldier_request_;745 delete trainingsite.soldier_request_;
742 trainingsite.soldier_request_ = nullptr;746 trainingsite.soldier_request_ = nullptr;
743 if (fr.unsigned_8()) {747 if (fr.unsigned_8()) {
744 trainingsite.soldier_request_ =748 trainingsite.soldier_request_ =
745 new Request(trainingsite, 0, TrainingSite::request_soldier_callback, wwWORKER);749 new Request(trainingsite, 0, TrainingSite::request_soldier_callback, wwWORKER);
746 trainingsite.soldier_request_->read(fr, game, mol);750 trainingsite.soldier_request_->read(fr, game, mol, tribes_lookup_table);
747 }751 }
748752
749 trainingsite.capacity_ = fr.unsigned_8();753 trainingsite.capacity_ = fr.unsigned_8();
750754
=== modified file 'src/map_io/map_buildingdata_packet.h'
--- src/map_io/map_buildingdata_packet.h 2019-02-23 11:00:49 +0000
+++ src/map_io/map_buildingdata_packet.h 2019-06-08 16:55:17 +0000
@@ -21,6 +21,7 @@
21#define WL_MAP_IO_MAP_BUILDINGDATA_PACKET_H21#define WL_MAP_IO_MAP_BUILDINGDATA_PACKET_H
2222
23#include "map_io/map_data_packet.h"23#include "map_io/map_data_packet.h"
24#include "map_io/tribes_legacy_lookup_table.h"
2425
25class FileRead;26class FileRead;
26class FileWrite;27class FileWrite;
@@ -42,18 +43,18 @@
42 */43 */
43class MapBuildingdataPacket {44class MapBuildingdataPacket {
44public:45public:
45 void read(FileSystem&, EditorGameBase&, bool, MapObjectLoader&);46 void read(FileSystem&, EditorGameBase&, bool, MapObjectLoader&, const TribesLegacyLookupTable& tribes_lookup_table);
46 void write(FileSystem&, EditorGameBase&, MapObjectSaver&);47 void write(FileSystem&, EditorGameBase&, MapObjectSaver&);
4748
48private:49private:
49 void read_constructionsite(ConstructionSite&, FileRead&, Game&, MapObjectLoader&);50 void read_constructionsite(ConstructionSite&, FileRead&, Game&, MapObjectLoader&, const TribesLegacyLookupTable& tribes_lookup_table);
50 void read_dismantlesite(DismantleSite&, FileRead&, Game&, MapObjectLoader&);51 void read_dismantlesite(DismantleSite&, FileRead&, Game&, MapObjectLoader&, const TribesLegacyLookupTable& tribes_lookup_table);
51 void52 void
52 read_partially_finished_building(PartiallyFinishedBuilding&, FileRead&, Game&, MapObjectLoader&);53 read_partially_finished_building(PartiallyFinishedBuilding&, FileRead&, Game&, MapObjectLoader&, const TribesLegacyLookupTable& tribes_lookup_table);
53 void read_warehouse(Warehouse&, FileRead&, Game&, MapObjectLoader&);54 void read_warehouse(Warehouse&, FileRead&, Game&, MapObjectLoader&, const TribesLegacyLookupTable& tribes_lookup_table);
54 void read_militarysite(MilitarySite&, FileRead&, Game&, MapObjectLoader&);55 void read_militarysite(MilitarySite&, FileRead&, Game&, MapObjectLoader&, const TribesLegacyLookupTable& tribes_lookup_table);
55 void read_trainingsite(TrainingSite&, FileRead&, Game&, MapObjectLoader&);56 void read_trainingsite(TrainingSite&, FileRead&, Game&, MapObjectLoader&, const TribesLegacyLookupTable& tribes_lookup_table);
56 void read_productionsite(ProductionSite&, FileRead&, Game&, MapObjectLoader&);57 void read_productionsite(ProductionSite&, FileRead&, Game&, MapObjectLoader&, const TribesLegacyLookupTable& tribes_lookup_table);
5758
58 void write_constructionsite(const ConstructionSite&, FileWrite&, Game&, MapObjectSaver&);59 void write_constructionsite(const ConstructionSite&, FileWrite&, Game&, MapObjectSaver&);
59 void write_dismantlesite(const DismantleSite&, FileWrite&, Game&, MapObjectSaver&);60 void write_dismantlesite(const DismantleSite&, FileWrite&, Game&, MapObjectSaver&);
6061
=== modified file 'src/map_io/map_flagdata_packet.cc'
--- src/map_io/map_flagdata_packet.cc 2019-02-23 11:00:49 +0000
+++ src/map_io/map_flagdata_packet.cc 2019-06-08 16:55:17 +0000
@@ -43,7 +43,7 @@
43void MapFlagdataPacket::read(FileSystem& fs,43void MapFlagdataPacket::read(FileSystem& fs,
44 EditorGameBase& egbase,44 EditorGameBase& egbase,
45 bool const skip,45 bool const skip,
46 MapObjectLoader& mol) {46 MapObjectLoader& mol, const TribesLegacyLookupTable& tribes_lookup_table) {
47 if (skip)47 if (skip)
48 return;48 return;
4949
@@ -131,7 +131,7 @@
131 Flag::FlagJob f;131 Flag::FlagJob f;
132 if (fr.unsigned_8()) {132 if (fr.unsigned_8()) {
133 f.request = new Request(flag, 0, Flag::flag_job_request_callback, wwWORKER);133 f.request = new Request(flag, 0, Flag::flag_job_request_callback, wwWORKER);
134 f.request->read(fr, dynamic_cast<Game&>(egbase), mol);134 f.request->read(fr, dynamic_cast<Game&>(egbase), mol, tribes_lookup_table);
135 } else {135 } else {
136 f.request = nullptr;136 f.request = nullptr;
137 }137 }
138138
=== modified file 'src/map_io/map_flagdata_packet.h'
--- src/map_io/map_flagdata_packet.h 2019-02-23 11:00:49 +0000
+++ src/map_io/map_flagdata_packet.h 2019-06-08 16:55:17 +0000
@@ -21,7 +21,14 @@
21#define WL_MAP_IO_MAP_FLAGDATA_PACKET_H21#define WL_MAP_IO_MAP_FLAGDATA_PACKET_H
2222
23#include "map_io/map_data_packet.h"23#include "map_io/map_data_packet.h"
24#include "map_io/tribes_legacy_lookup_table.h"
2425
25MAP_DATA_PACKET(MapFlagdataPacket)26namespace Widelands {
27class MapFlagdataPacket {
28public:
29 void read(FileSystem&, EditorGameBase&, bool, MapObjectLoader&, const TribesLegacyLookupTable& tribes_lookup_table);
30 void write(FileSystem&, EditorGameBase&, MapObjectSaver&);
31};
32}
2633
27#endif // end of include guard: WL_MAP_IO_MAP_FLAGDATA_PACKET_H34#endif // end of include guard: WL_MAP_IO_MAP_FLAGDATA_PACKET_H
2835
=== modified file 'src/map_io/map_object_packet.cc'
--- src/map_io/map_object_packet.cc 2019-02-23 11:00:49 +0000
+++ src/map_io/map_object_packet.cc 2019-06-08 16:55:17 +0000
@@ -49,7 +49,7 @@
49 EditorGameBase& egbase,49 EditorGameBase& egbase,
50 MapObjectLoader& mol,50 MapObjectLoader& mol,
51 const WorldLegacyLookupTable& world_lookup_table,51 const WorldLegacyLookupTable& world_lookup_table,
52 const TribesLegacyLookupTable& tribe_lookup_table) {52 const TribesLegacyLookupTable& tribes_lookup_table) {
53 try {53 try {
54 FileRead fr;54 FileRead fr;
55 fr.open(fs, "binary/mapobjects");55 fr.open(fs, "binary/mapobjects");
@@ -66,7 +66,7 @@
66 return;66 return;
67 case MapObject::HeaderImmovable:67 case MapObject::HeaderImmovable:
68 loaders.insert(68 loaders.insert(
69 Immovable::load(egbase, mol, fr, world_lookup_table, tribe_lookup_table));69 Immovable::load(egbase, mol, fr, world_lookup_table, tribes_lookup_table));
70 break;70 break;
7171
72 case MapObject::HeaderBattle:72 case MapObject::HeaderBattle:
@@ -81,11 +81,11 @@
81 // We can't use the worker's savegame version, because some stuff is loaded before81 // We can't use the worker's savegame version, because some stuff is loaded before
82 // that82 // that
83 // packet version, and we removed the tribe name.83 // packet version, and we removed the tribe name.
84 loaders.insert(Worker::load(egbase, mol, fr, tribe_lookup_table, packet_version));84 loaders.insert(Worker::load(egbase, mol, fr, tribes_lookup_table, packet_version));
85 break;85 break;
8686
87 case MapObject::HeaderWareInstance:87 case MapObject::HeaderWareInstance:
88 loaders.insert(WareInstance::load(egbase, mol, fr, tribe_lookup_table));88 loaders.insert(WareInstance::load(egbase, mol, fr, tribes_lookup_table));
89 break;89 break;
9090
91 case MapObject::HeaderShip:91 case MapObject::HeaderShip:
9292
=== modified file 'src/map_io/map_object_packet.h'
--- src/map_io/map_object_packet.h 2019-02-23 11:00:49 +0000
+++ src/map_io/map_object_packet.h 2019-06-08 16:55:17 +0000
@@ -57,7 +57,7 @@
57 EditorGameBase&,57 EditorGameBase&,
58 MapObjectLoader&,58 MapObjectLoader&,
59 const WorldLegacyLookupTable& world_lookup_table,59 const WorldLegacyLookupTable& world_lookup_table,
60 const TribesLegacyLookupTable& tribe_lookup_table);60 const TribesLegacyLookupTable& tribes_lookup_table);
6161
62 void load_finish();62 void load_finish();
6363
6464
=== modified file 'src/map_io/map_players_view_packet.cc'
--- src/map_io/map_players_view_packet.cc 2019-04-09 16:43:49 +0000
+++ src/map_io/map_players_view_packet.cc 2019-06-08 16:55:17 +0000
@@ -192,17 +192,17 @@
192};192};
193193
194// reads an immovable depending on whether it is a tribe or world immovable194// reads an immovable depending on whether it is a tribe or world immovable
195const ImmovableDescr& read_immovable_type(StreamRead* fr, const EditorGameBase& egbase) {195const ImmovableDescr& read_immovable_type(StreamRead* fr, const EditorGameBase& egbase, const TribesLegacyLookupTable& tribes_lookup_table, const WorldLegacyLookupTable& world_lookup_table) {
196 uint8_t owner = fr->unsigned_8();196 uint8_t owner = fr->unsigned_8();
197 char const* const name = fr->c_string();197 char const* const name = fr->c_string();
198 if (owner == static_cast<uint8_t>(MapObjectDescr::OwnerType::kWorld)) {198 if (owner == static_cast<uint8_t>(MapObjectDescr::OwnerType::kWorld)) {
199 DescriptionIndex const index = egbase.world().get_immovable_index(name);199 DescriptionIndex const index = egbase.world().get_immovable_index(world_lookup_table.lookup_immovable(name));
200 if (index == Widelands::INVALID_INDEX)200 if (index == Widelands::INVALID_INDEX)
201 throw WorldImmovableNonexistent(name);201 throw WorldImmovableNonexistent(name);
202 return *egbase.world().get_immovable_descr(index);202 return *egbase.world().get_immovable_descr(index);
203 } else {203 } else {
204 assert(owner == static_cast<uint8_t>(MapObjectDescr::OwnerType::kTribe));204 assert(owner == static_cast<uint8_t>(MapObjectDescr::OwnerType::kTribe));
205 DescriptionIndex const index = egbase.tribes().immovable_index(name);205 DescriptionIndex const index = egbase.tribes().immovable_index(tribes_lookup_table.lookup_immovable(name));
206 if (index == Widelands::INVALID_INDEX)206 if (index == Widelands::INVALID_INDEX)
207 throw TribeImmovableNonexistent(name);207 throw TribeImmovableNonexistent(name);
208 return *egbase.tribes().get_immovable_descr(index);208 return *egbase.tribes().get_immovable_descr(index);
@@ -238,7 +238,7 @@
238238
239inline static MapObjectData read_unseen_immovable(const EditorGameBase& egbase,239inline static MapObjectData read_unseen_immovable(const EditorGameBase& egbase,
240 uint8_t& immovable_kind,240 uint8_t& immovable_kind,
241 FileRead& immovables_file,241 FileRead& immovables_file, const TribesLegacyLookupTable& tribes_lookup_table, const WorldLegacyLookupTable& world_lookup_table,
242 uint8_t& version) {242 uint8_t& version) {
243 MapObjectData m;243 MapObjectData m;
244 try {244 try {
@@ -247,7 +247,7 @@
247 m.map_object_descr = nullptr;247 m.map_object_descr = nullptr;
248 break;248 break;
249 case UNSEEN_TRIBEORWORLD: // The player sees a tribe or world immovable.249 case UNSEEN_TRIBEORWORLD: // The player sees a tribe or world immovable.
250 m.map_object_descr = &read_immovable_type(&immovables_file, egbase);250 m.map_object_descr = &read_immovable_type(&immovables_file, egbase, tribes_lookup_table, world_lookup_table);
251 break;251 break;
252 case UNSEEN_FLAG: // The player sees a flag.252 case UNSEEN_FLAG: // The player sees a flag.
253 m.map_object_descr = &g_flag_descr;253 m.map_object_descr = &g_flag_descr;
@@ -284,7 +284,7 @@
284void MapPlayersViewPacket::read(FileSystem& fs,284void MapPlayersViewPacket::read(FileSystem& fs,
285 EditorGameBase& egbase,285 EditorGameBase& egbase,
286 bool const skip,286 bool const skip,
287 MapObjectLoader&)287 MapObjectLoader&, const TribesLegacyLookupTable& tribes_lookup_table, const WorldLegacyLookupTable& world_lookup_table)
288288
289{289{
290 if (skip)290 if (skip)
@@ -559,7 +559,7 @@
559 kCurrentPacketVersionImmovableKinds);559 kCurrentPacketVersionImmovableKinds);
560 }560 }
561 MapObjectData mod = read_unseen_immovable(561 MapObjectData mod = read_unseen_immovable(
562 egbase, imm_kind, node_immovables_file, node_immovables_file_version);562 egbase, imm_kind, node_immovables_file, tribes_lookup_table, world_lookup_table, node_immovables_file_version);
563 f_player_field.map_object_descr = mod.map_object_descr;563 f_player_field.map_object_descr = mod.map_object_descr;
564 f_player_field.constructionsite = mod.csi;564 f_player_field.constructionsite = mod.csi;
565565
@@ -633,7 +633,7 @@
633 // TODO(sirver): Remove this logic the next time we break633 // TODO(sirver): Remove this logic the next time we break
634 // savegame compatibility.634 // savegame compatibility.
635 read_unseen_immovable(635 read_unseen_immovable(
636 egbase, im_kind, triangle_immovables_file, triangle_immovables_file_version);636 egbase, im_kind, triangle_immovables_file, tribes_lookup_table, world_lookup_table, triangle_immovables_file_version);
637 }637 }
638 if (f_seen | br_seen | r_seen) {638 if (f_seen | br_seen | r_seen) {
639 // The player currently sees the R triangle. Therefore his639 // The player currently sees the R triangle. Therefore his
@@ -662,7 +662,7 @@
662 // suporting immovables on the triangles instead as on the662 // suporting immovables on the triangles instead as on the
663 // nodes.663 // nodes.
664 read_unseen_immovable(664 read_unseen_immovable(
665 egbase, im_kind, triangle_immovables_file, triangle_immovables_file_version);665 egbase, im_kind, triangle_immovables_file, tribes_lookup_table, world_lookup_table, triangle_immovables_file_version);
666 }666 }
667667
668 { // edges668 { // edges
669669
=== modified file 'src/map_io/map_players_view_packet.h'
--- src/map_io/map_players_view_packet.h 2019-02-23 11:00:49 +0000
+++ src/map_io/map_players_view_packet.h 2019-06-08 16:55:17 +0000
@@ -21,6 +21,10 @@
21#define WL_MAP_IO_MAP_PLAYERS_VIEW_PACKET_H21#define WL_MAP_IO_MAP_PLAYERS_VIEW_PACKET_H
2222
23#include "map_io/map_data_packet.h"23#include "map_io/map_data_packet.h"
24#include "map_io/tribes_legacy_lookup_table.h"
25#include "map_io/world_legacy_lookup_table.h"
26
27namespace Widelands {
2428
25/// For each player, its view of each node, edge and triangle that he has seen29/// For each player, its view of each node, edge and triangle that he has seen
26/// but does not see currently. Information that he currently sees is not30/// but does not see currently. Information that he currently sees is not
@@ -31,6 +35,11 @@
31/// This information can not be loaded before the terrains, roads, immovables35/// This information can not be loaded before the terrains, roads, immovables
32/// and players' vision maps are loaded. The vision maps are completely loaded36/// and players' vision maps are loaded. The vision maps are completely loaded
33/// after MapBobdataPacket has been loaded.37/// after MapBobdataPacket has been loaded.
34MAP_DATA_PACKET(MapPlayersViewPacket)38class MapPlayersViewPacket {
39public:
40 void read(FileSystem&, EditorGameBase&, bool, MapObjectLoader&, const TribesLegacyLookupTable& tribes_lookup_table, const WorldLegacyLookupTable& world_lookup_table);
41 void write(FileSystem&, EditorGameBase&, MapObjectSaver&);
42};
43}
3544
36#endif // end of include guard: WL_MAP_IO_MAP_PLAYERS_VIEW_PACKET_H45#endif // end of include guard: WL_MAP_IO_MAP_PLAYERS_VIEW_PACKET_H
3746
=== modified file 'src/map_io/map_roaddata_packet.cc'
--- src/map_io/map_roaddata_packet.cc 2019-02-23 11:00:49 +0000
+++ src/map_io/map_roaddata_packet.cc 2019-06-08 16:55:17 +0000
@@ -44,7 +44,7 @@
44void MapRoaddataPacket::read(FileSystem& fs,44void MapRoaddataPacket::read(FileSystem& fs,
45 EditorGameBase& egbase,45 EditorGameBase& egbase,
46 bool const skip,46 bool const skip,
47 MapObjectLoader& mol) {47 MapObjectLoader& mol, const TribesLegacyLookupTable& tribes_lookup_table) {
48 if (skip)48 if (skip)
49 return;49 return;
5050
@@ -136,7 +136,7 @@
136 if (fr.unsigned_8()) {136 if (fr.unsigned_8()) {
137 (carrier_request =137 (carrier_request =
138 new Request(road, 0, Road::request_carrier_callback, wwWORKER))138 new Request(road, 0, Road::request_carrier_callback, wwWORKER))
139 ->read(fr, game, mol);139 ->read(fr, game, mol, tribes_lookup_table);
140 } else {140 } else {
141 carrier_request = nullptr;141 carrier_request = nullptr;
142 }142 }
143143
=== modified file 'src/map_io/map_roaddata_packet.h'
--- src/map_io/map_roaddata_packet.h 2019-02-23 11:00:49 +0000
+++ src/map_io/map_roaddata_packet.h 2019-06-08 16:55:17 +0000
@@ -21,11 +21,18 @@
21#define WL_MAP_IO_MAP_ROADDATA_PACKET_H21#define WL_MAP_IO_MAP_ROADDATA_PACKET_H
2222
23#include "map_io/map_data_packet.h"23#include "map_io/map_data_packet.h"
24#include "map_io/tribes_legacy_lookup_table.h"
2425
25/*26/*
26 * This parses the roads data (where it is, where it belongs to27 * This parses the roads data (where it is, where it belongs to
27 * and so on)28 * and so on)
28 */29 */
29MAP_DATA_PACKET(MapRoaddataPacket)30namespace Widelands {
31class MapRoaddataPacket {
32public:
33 void read(FileSystem&, EditorGameBase&, bool, MapObjectLoader&, const TribesLegacyLookupTable& tribes_lookup_table);
34 void write(FileSystem&, EditorGameBase&, MapObjectSaver&);
35};
36}
3037
31#endif // end of include guard: WL_MAP_IO_MAP_ROADDATA_PACKET_H38#endif // end of include guard: WL_MAP_IO_MAP_ROADDATA_PACKET_H
3239
=== modified file 'src/map_io/tribes_legacy_lookup_table.cc'
--- src/map_io/tribes_legacy_lookup_table.cc 2019-05-25 10:47:18 +0000
+++ src/map_io/tribes_legacy_lookup_table.cc 2019-06-08 16:55:17 +0000
@@ -18,6 +18,7 @@
18 */18 */
1919
20#include "map_io/tribes_legacy_lookup_table.h"20#include "map_io/tribes_legacy_lookup_table.h"
21
21// Whenever we break savegame compatibility, we can empty these maps22// Whenever we break savegame compatibility, we can empty these maps
22TribesLegacyLookupTable::TribesLegacyLookupTable()23TribesLegacyLookupTable::TribesLegacyLookupTable()
23 : // Workers24 : // Workers
@@ -36,7 +37,7 @@
36 {"reed_medium", "reedfield_medium"},37 {"reed_medium", "reedfield_medium"},
37 {"reed_small", "reedfield_small"},38 {"reed_small", "reedfield_small"},
38 {"reed_tiny", "reedfield_tiny"},39 {"reed_tiny", "reedfield_tiny"},
39 {"reed_tiny", "reedfield_ripe"},40 {"reed_ripe", "reedfield_ripe"},
40 } {41 } {
41}42}
4243
4344
=== modified file 'src/map_io/widelands_map_loader.cc'
--- src/map_io/widelands_map_loader.cc 2019-03-09 10:01:09 +0000
+++ src/map_io/widelands_map_loader.cc 2019-06-08 16:55:17 +0000
@@ -152,7 +152,7 @@
152152
153 std::unique_ptr<WorldLegacyLookupTable> world_lookup_table(153 std::unique_ptr<WorldLegacyLookupTable> world_lookup_table(
154 create_world_legacy_lookup_table(old_world_name_));154 create_world_legacy_lookup_table(old_world_name_));
155 std::unique_ptr<TribesLegacyLookupTable> tribe_lookup_table(new TribesLegacyLookupTable());155 std::unique_ptr<TribesLegacyLookupTable> tribes_lookup_table(new TribesLegacyLookupTable());
156 log("Reading Terrain Data ... ");156 log("Reading Terrain Data ... ");
157 {157 {
158 MapTerrainPacket p;158 MapTerrainPacket p;
@@ -163,7 +163,7 @@
163 MapObjectPacket mapobjects;163 MapObjectPacket mapobjects;
164164
165 log("Reading Map Objects ... ");165 log("Reading Map Objects ... ");
166 mapobjects.read(*fs_, egbase, *mol_, *world_lookup_table, *tribe_lookup_table);166 mapobjects.read(*fs_, egbase, *mol_, *world_lookup_table, *tribes_lookup_table);
167 log("took %ums\n ", timer.ms_since_last_query());167 log("took %ums\n ", timer.ms_since_last_query());
168168
169 log("Reading Player Start Position Data ... ");169 log("Reading Player Start Position Data ... ");
@@ -259,21 +259,21 @@
259 log("Reading Flagdata Data ... ");259 log("Reading Flagdata Data ... ");
260 {260 {
261 MapFlagdataPacket p;261 MapFlagdataPacket p;
262 p.read(*fs_, egbase, is_game, *mol_);262 p.read(*fs_, egbase, is_game, *mol_, *tribes_lookup_table);
263 }263 }
264 log("took %ums\n ", timer.ms_since_last_query());264 log("took %ums\n ", timer.ms_since_last_query());
265265
266 log("Reading Roaddata Data ... ");266 log("Reading Roaddata Data ... ");
267 {267 {
268 MapRoaddataPacket p;268 MapRoaddataPacket p;
269 p.read(*fs_, egbase, is_game, *mol_);269 p.read(*fs_, egbase, is_game, *mol_, *tribes_lookup_table);
270 }270 }
271 log("took %ums\n ", timer.ms_since_last_query());271 log("took %ums\n ", timer.ms_since_last_query());
272272
273 log("Reading Buildingdata Data ... ");273 log("Reading Buildingdata Data ... ");
274 {274 {
275 MapBuildingdataPacket p;275 MapBuildingdataPacket p;
276 p.read(*fs_, egbase, is_game, *mol_);276 p.read(*fs_, egbase, is_game, *mol_, *tribes_lookup_table);
277 }277 }
278 log("took %ums\n ", timer.ms_since_last_query());278 log("took %ums\n ", timer.ms_since_last_query());
279279
@@ -297,7 +297,7 @@
297 log("Reading Players View Data ... ");297 log("Reading Players View Data ... ");
298 {298 {
299 MapPlayersViewPacket p;299 MapPlayersViewPacket p;
300 p.read(*fs_, egbase, is_game, *mol_);300 p.read(*fs_, egbase, is_game, *mol_, *tribes_lookup_table, *world_lookup_table);
301 }301 }
302 log("took %ums\n ", timer.ms_since_last_query());302 log("took %ums\n ", timer.ms_since_last_query());
303303

Subscribers

People subscribed via source and target branches

to status/vote changes: