Fix some issues with loading saved games
This commit is contained in:
@@ -85,13 +85,6 @@ void finish_load_party(){
|
||||
return;
|
||||
}
|
||||
|
||||
fs::path path;
|
||||
path = progDir/"Blades of Exile Scenarios";
|
||||
path /= univ.party.scen_name;
|
||||
std::cout<<"Searching for scenario at:\n"<<path<<'\n';
|
||||
if(!load_scenario(path, univ.scenario))
|
||||
return;
|
||||
|
||||
// Saved creatures may not have had their monster attributes saved
|
||||
// Make sure that they know what they are!
|
||||
// Cast to cMonster base class and assign, to avoid clobbering other attributes
|
||||
|
@@ -47,8 +47,10 @@ cParty::cParty(cUniverse& univ, long party_preset) : univ(univ) {
|
||||
}
|
||||
|
||||
cParty::~cParty() {
|
||||
for(int i = 0; i < 6; i++)
|
||||
for(int i = 0; i < 6; i++) {
|
||||
delete adven[i];
|
||||
adven[i] = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void cParty::append(legacy::party_record_type& old){
|
||||
@@ -821,8 +823,8 @@ void cParty::readFrom(std::istream& file){
|
||||
} else if(cur == "TOWNSAVE") {
|
||||
int i;
|
||||
std::string str;
|
||||
bin >> i;
|
||||
bin >> creature_save[i].which_town >> str;
|
||||
sin >> i;
|
||||
sin >> creature_save[i].which_town >> str;
|
||||
creature_save[i].hostile = str == "HOSTILE";
|
||||
} else if(cur == "TOWNVISIBLE") {
|
||||
int i;
|
||||
|
@@ -282,6 +282,7 @@ bool load_party_v1(fs::path file_to_load, cUniverse& univ, bool town_restore, bo
|
||||
return true;
|
||||
}
|
||||
|
||||
extern fs::path scenDir;
|
||||
bool load_party_v2(fs::path file_to_load, cUniverse& univ, bool town_restore, bool in_scen, bool maps_there){
|
||||
if(!fs::exists(tempDir)) fs::create_directories(tempDir);
|
||||
fs::path tempPath = tempDir/"loadtemp.exg";
|
||||
@@ -354,7 +355,9 @@ bool load_party_v2(fs::path file_to_load, cUniverse& univ, bool town_restore, bo
|
||||
|
||||
if(in_scen) {
|
||||
fs::path path;
|
||||
path = progDir/"Blades of Exile Scenarios"/univ.party.scen_name;
|
||||
path = scenDir/univ.party.scen_name;
|
||||
if(!fs::exists(path))
|
||||
path = progDir/"Blades of Exile Scenarios"/univ.party.scen_name;
|
||||
|
||||
if(!load_scenario(path, univ.scenario))
|
||||
return false;
|
||||
|
@@ -64,14 +64,14 @@ bool load_scenario(fs::path file_to_load, cScenario& scenario, bool only_header)
|
||||
// Before loading a scenario, we may need to pop scenario resource paths.
|
||||
fs::path graphics_path = ResMgr::popPath<ImageRsrc>();
|
||||
for(auto p : graphics_path) {
|
||||
if(p.string() == "graphics") {
|
||||
if(p.string() == "data") {
|
||||
ResMgr::pushPath<ImageRsrc>(graphics_path);
|
||||
break;
|
||||
}
|
||||
}
|
||||
fs::path sounds_path = ResMgr::popPath<SoundRsrc>();
|
||||
for(auto p : sounds_path) {
|
||||
if(p.string() == "sounds") {
|
||||
if(p.string() == "data") {
|
||||
ResMgr::pushPath<SoundRsrc>(sounds_path);
|
||||
break;
|
||||
}
|
||||
@@ -80,7 +80,10 @@ bool load_scenario(fs::path file_to_load, cScenario& scenario, bool only_header)
|
||||
std::string fname = file_to_load.filename().string();
|
||||
std::transform(fname.begin(), fname.end(), fname.begin(), tolower);
|
||||
size_t dot = fname.find_last_of('.');
|
||||
try {
|
||||
if(dot == std::string::npos) {
|
||||
showError("That is not a Blades of Exile scenario.");
|
||||
return false;
|
||||
} else try {
|
||||
if(fname.substr(dot) == ".boes")
|
||||
return load_scenario_v2(file_to_load, scenario, only_header);
|
||||
else if(fname.substr(dot) == ".exs")
|
||||
|
Reference in New Issue
Block a user