allow loading party without overwrite global cCustomGraphics

This commit is contained in:
2025-05-17 19:52:12 -05:00
parent 2d8e77b9e2
commit f2492d6fb4
6 changed files with 18 additions and 11 deletions

View File

@@ -16,6 +16,7 @@
#include <sstream>
#include <SFML/System/InputStream.hpp>
#include <boost/filesystem/path.hpp>
#include "gfx/gfxsheets.hpp"
class cScenario;
class cUniverse;
@@ -42,7 +43,7 @@ const std::set<fs::path> save_extensions = {".exg", ".boe", ".SAV", ".mac"};
// Return a directory's files sorted by last modified time
std::vector<std::pair<fs::path, std::time_t>> sorted_file_mtimes(fs::path dir, std::set<fs::path> valid_extensions = save_extensions);
bool load_party(fs::path file_to_load, cUniverse& univ, bool preview = false);
bool load_party(fs::path file_to_load, cUniverse& univ, cCustomGraphics& graphics, bool preview = false);
bool save_party(cUniverse& univ, bool save_as = false);
bool save_party_force(cUniverse& univ, fs::path file);

View File

@@ -29,7 +29,7 @@ extern cCustomGraphics spec_scen_g;
// Load saved games
static bool load_party_v1(fs::path file_to_load, cUniverse& univ, bool town_restore, bool in_scen, bool maps_there, bool must_port, bool preview);
static bool load_party_v2(fs::path file_to_load, cUniverse& univ, bool preview);
static bool load_party_v2(fs::path file_to_load, cUniverse& univ, cCustomGraphics& graphics, bool preview);
extern fs::path nav_get_party();
extern fs::path nav_put_party(fs::path def);
@@ -61,7 +61,7 @@ fs::path os_file_picker(bool saving) {
return nav_get_or_decode_party();
}
bool load_party(fs::path file_to_load, cUniverse& univ, bool preview){
bool load_party(fs::path file_to_load, cUniverse& univ, cCustomGraphics& graphics, bool preview){
bool town_restore = false;
bool maps_there = false;
bool in_scen = false;
@@ -161,7 +161,7 @@ bool load_party(fs::path file_to_load, cUniverse& univ, bool preview){
result = load_party_v1(file_to_load, univ, town_restore, in_scen, maps_there, !mac_is_intel(), preview);
break;
case new_oboe:
result = load_party_v2(file_to_load, univ, preview);
result = load_party_v2(file_to_load, univ, graphics, preview);
break;
case unknown:
if(!preview) showError("This is not a Blades of Exile save file.");
@@ -319,7 +319,7 @@ bool load_party_v1(fs::path file_to_load, cUniverse& real_univ, bool town_restor
return true;
}
bool load_party_v2(fs::path file_to_load, cUniverse& real_univ, bool preview){
bool load_party_v2(fs::path file_to_load, cUniverse& real_univ, cCustomGraphics& graphics, bool preview){
igzstream zin(file_to_load.string().c_str());
tarball partyIn;
partyIn.readFrom(zin);

View File

@@ -102,6 +102,7 @@ extern short store_spell_target,pc_casting;
extern eSpell store_mage, store_priest;
extern std::vector<int> spec_item_array;
extern cUniverse univ;
extern cCustomGraphics spec_scen_g;
extern std::vector<word_rect_t> talk_words;
extern bool talk_end_forced;
@@ -3139,7 +3140,7 @@ void do_load() {
fs::path file_to_load = run_file_picker(false);
if(file_to_load.empty()) return;
set_cursor(watch_curs);
if(!load_party(file_to_load, univ))
if(!load_party(file_to_load, univ, spec_scen_g))
return;
finish_load_party();
if(overall_mode != MODE_STARTUP)
@@ -3675,7 +3676,7 @@ void handle_death() {
}
fs::path file_to_load = run_file_picker(false);
if(!file_to_load.empty()){
if(load_party(file_to_load, univ)){
if(load_party(file_to_load, univ, spec_scen_g)){
finish_load_party();
if(overall_mode != MODE_STARTUP)
post_load();

View File

@@ -12,6 +12,7 @@
#include <algorithm>
#include <iostream>
#include "fileio/fileio.hpp"
#include "gfx/gfxsheets.hpp"
#include "boe.global.hpp"
#include "dialogxml/dialogs/choicedlog.hpp"
#include "replay.hpp"
@@ -24,6 +25,7 @@ extern void queue_fake_event(const sf::Event&);
extern bool ae_loading, All_Done, party_in_memory, finished_init;
extern eGameMode overall_mode;
extern cUniverse univ;
extern cCustomGraphics& spec_scen_g;
typedef NSAppleEventDescriptor AEDescr;
@@ -59,7 +61,7 @@ void set_up_apple_events() {
return FALSE;
}
if(!load_party(fileName, univ))
if(!load_party(fileName, univ, spec_scen_g))
return FALSE;
if(!finished_init) {

View File

@@ -2076,7 +2076,8 @@ class cFilePicker {
while(saves_loaded < parties_needed){
fs::path next_file = save_file_mtimes[saves_loaded].first;
cUniverse party_univ;
if(!load_party(next_file, save_files[saves_loaded], true)){
cCustomGraphics graphics;
if(!load_party(next_file, save_files[saves_loaded], graphics, true)){
// Below, we check the load_failed flag to display when a party is corrupt
}
saves_loaded++;

View File

@@ -47,6 +47,7 @@
#include "tools/enum_map.hpp"
#include "tools/event_listener.hpp"
#include "tools/drawable_manager.hpp"
#include "gfx/gfxsheets.hpp"
using clara::ParserResult;
using clara::ParseResultType;
@@ -65,6 +66,7 @@ extern const rectangle item_sbar_rect = {148,560,255,576};
bool bgm_on = false,bgm_init = false;
location store_anim_ul;
cUniverse univ;
extern cCustomGraphics spec_scen_g;
bool flushingInput = false, ae_loading = false;
long start_time;
@@ -458,7 +460,7 @@ static void process_args(int argc, char* argv[]) {
}
if(saved_game){
if(!load_party(*saved_game, univ)) {
if(!load_party(*saved_game, univ, spec_scen_g)) {
std::cout << "Failed to load save file: " << *saved_game << std::endl;
return;
}
@@ -635,7 +637,7 @@ static void replay_action(Element& action) {
fancy_file_picker(saving);
}else if(t == "load_party"){
decode_file(action.GetText(), tempDir / "temp.exg");
load_party(tempDir / "temp.exg", univ);
load_party(tempDir / "temp.exg", univ, spec_scen_g);
finish_load_party();