From 350479ddbb23777a53dbc94ac6c9300dc2c5007d Mon Sep 17 00:00:00 2001 From: Celtic Minstrel Date: Mon, 14 Sep 2015 15:51:04 -0400 Subject: [PATCH] Fix some issues with loading saved games --- src/boe.fileio.cpp | 7 ------- src/classes/party.cpp | 8 +++++--- src/tools/fileio_party.cpp | 5 ++++- src/tools/fileio_scen.cpp | 9 ++++++--- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/boe.fileio.cpp b/src/boe.fileio.cpp index cc953e0e..6e9fef3b 100644 --- a/src/boe.fileio.cpp +++ b/src/boe.fileio.cpp @@ -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"<> 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; diff --git a/src/tools/fileio_party.cpp b/src/tools/fileio_party.cpp index a5411dee..a5cd5d06 100644 --- a/src/tools/fileio_party.cpp +++ b/src/tools/fileio_party.cpp @@ -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; diff --git a/src/tools/fileio_scen.cpp b/src/tools/fileio_scen.cpp index ef1ae18e..fb86167b 100644 --- a/src/tools/fileio_scen.cpp +++ b/src/tools/fileio_scen.cpp @@ -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(); for(auto p : graphics_path) { - if(p.string() == "graphics") { + if(p.string() == "data") { ResMgr::pushPath(graphics_path); break; } } fs::path sounds_path = ResMgr::popPath(); for(auto p : sounds_path) { - if(p.string() == "sounds") { + if(p.string() == "data") { ResMgr::pushPath(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")