From 5c3a96c69c305e08f30e8fd9133e031455b50f9c Mon Sep 17 00:00:00 2001 From: Celtic Minstrel Date: Fri, 2 Sep 2016 19:28:25 -0400 Subject: [PATCH] Fix several issues when loading legacy saves --- src/classes/party.cpp | 4 +++- src/classes/universe.cpp | 2 +- src/tools/fileio_party.cpp | 20 ++++++++++---------- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/classes/party.cpp b/src/classes/party.cpp index 4f9b47fa..3cdb7374 100644 --- a/src/classes/party.cpp +++ b/src/classes/party.cpp @@ -192,6 +192,7 @@ void cParty::swap(cParty& other) { } void cParty::import_legacy(legacy::party_record_type& old, cUniverse& univ){ + scen_name = old.scen_name; age = old.age; gold = old.gold; food = old.food; @@ -220,6 +221,8 @@ void cParty::import_legacy(legacy::party_record_type& old, cUniverse& univ){ left_in = -1; } party_event_timers.reserve(30); + boats.resize(30); + horses.resize(30); for(short i = 0; i < 30; i++){ boats[i].import_legacy(old.boats[i]); horses[i].import_legacy(old.horses[i]); @@ -274,7 +277,6 @@ void cParty::import_legacy(legacy::party_record_type& old, cUniverse& univ){ total_dam_done = old.total_dam_done; total_xp_gained = old.total_xp_gained; total_dam_taken = old.total_dam_taken; - scen_name = old.scen_name; } void cParty::import_legacy(legacy::stored_items_list_type& old,short which_list){ diff --git a/src/classes/universe.cpp b/src/classes/universe.cpp index 1bc7f181..ac2b39ca 100644 --- a/src/classes/universe.cpp +++ b/src/classes/universe.cpp @@ -63,7 +63,7 @@ void cCurTown::import_legacy(legacy::town_item_list& old){ } void cUniverse::import_legacy(legacy::stored_town_maps_type& old){ - for(int n = 0; n < 200; n++) + for(int n = 0; n < scenario.towns.size(); n++) for(int i = 0; i < 64; i++) for(int j = 0; j < 64; j++) scenario.towns[n]->maps[j][i] = old.town_maps[n][i / 8][j] & (1 << (i % 8)); diff --git a/src/tools/fileio_party.cpp b/src/tools/fileio_party.cpp index 860e9329..bb18a999 100644 --- a/src/tools/fileio_party.cpp +++ b/src/tools/fileio_party.cpp @@ -223,7 +223,7 @@ bool load_party_v1(fs::path file_to_load, cUniverse& real_univ, bool town_restor if(in_scen){ fs::path path; - path = progDir/"Blades of Exile Scenarios"/univ.party.scen_name; + path = progDir/"Blades of Exile Scenarios"/store_party.scen_name; if(!load_scenario(path, univ.scenario)) return false; @@ -247,18 +247,18 @@ bool load_party_v1(fs::path file_to_load, cUniverse& real_univ, bool town_restor univ.import_legacy(town_maps); univ.import_legacy(o_maps); univ.town.import_legacy(sfx, misc_i); - if(!town_restore) univ.party.town_num = 200; - // Check items in crates/barrels - for(int i = 0; i < univ.town->max_dim(); i++) { - for(int j = 0; j < univ.town->max_dim(); j++) { - if(univ.town.is_barrel(i,j) || univ.town.is_crate(i,j)) { - for(cItem item : univ.town.items) { - if(item.item_loc == loc(i,j) && item.contained) - item.held = true; + if(town_restore) // Check items in crates/barrels + for(int i = 0; i < univ.town->max_dim(); i++) { + for(int j = 0; j < univ.town->max_dim(); j++) { + if(univ.town.is_barrel(i,j) || univ.town.is_crate(i,j)) { + for(cItem item : univ.town.items) { + if(item.item_loc == loc(i,j) && item.contained) + item.held = true; + } } } } - } + else univ.party.town_num = 200; } real_univ = std::move(univ);