rename and invert the 'manual' arg to 'preview' in load_party()

This commit is contained in:
2025-03-14 13:45:07 -05:00
committed by Celtic Minstrel
parent 7c9b9ee255
commit 2053381ea9
3 changed files with 22 additions and 22 deletions

View File

@@ -37,7 +37,7 @@ const std::set<fs::path> save_extensions = {".exg", ".boe", ".SAV", ".mac"};
// Return a directory's files sorted by last modified time // 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); 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 manual = true); bool load_party(fs::path file_to_load, cUniverse& univ, bool preview = false);
bool save_party(cUniverse& univ, bool save_as = false); bool save_party(cUniverse& univ, bool save_as = false);
bool save_party_force(cUniverse& univ, fs::path file); bool save_party_force(cUniverse& univ, fs::path file);

View File

@@ -28,8 +28,8 @@ extern fs::path progDir, tempDir;
extern cCustomGraphics spec_scen_g; extern cCustomGraphics spec_scen_g;
// Load saved games // 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 manual); 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 manual); static bool load_party_v2(fs::path file_to_load, cUniverse& univ, bool preview);
extern fs::path nav_get_party(); extern fs::path nav_get_party();
extern fs::path nav_put_party(fs::path def); 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(); return nav_get_or_decode_party();
} }
bool load_party(fs::path file_to_load, cUniverse& univ, bool manual){ bool load_party(fs::path file_to_load, cUniverse& univ, bool preview){
bool town_restore = false; bool town_restore = false;
bool maps_there = false; bool maps_there = false;
bool in_scen = false; bool in_scen = false;
@@ -88,7 +88,7 @@ bool load_party(fs::path file_to_load, cUniverse& univ, bool manual){
FILE* file_id = fopen(file_to_load.string().c_str(), "rb"); FILE* file_id = fopen(file_to_load.string().c_str(), "rb");
if(file_id == nullptr) { if(file_id == nullptr) {
univ.party.load_failed = true; univ.party.load_failed = true;
if(manual) showError("Loading Blades of Exile save file failed."); if(!preview) showError("Loading Blades of Exile save file failed.");
return false; return false;
} }
@@ -98,7 +98,7 @@ bool load_party(fs::path file_to_load, cUniverse& univ, bool manual){
if(n < 1) { if(n < 1) {
fclose(file_id); fclose(file_id);
univ.party.load_failed = true; univ.party.load_failed = true;
if(manual) showError("This is not a Blades of Exile save file."); if(!preview) showError("This is not a Blades of Exile save file.");
return false; return false;
} }
@@ -155,28 +155,28 @@ bool load_party(fs::path file_to_load, cUniverse& univ, bool manual){
bool result = false; bool result = false;
switch(format){ switch(format){
case old_mac: case old_mac:
result = load_party_v1(file_to_load, univ, town_restore, in_scen, maps_there, mac_is_intel(), manual); result = load_party_v1(file_to_load, univ, town_restore, in_scen, maps_there, mac_is_intel(), preview);
break; break;
case old_win: case old_win:
result = load_party_v1(file_to_load, univ, town_restore, in_scen, maps_there, !mac_is_intel(), manual); result = load_party_v1(file_to_load, univ, town_restore, in_scen, maps_there, !mac_is_intel(), preview);
break; break;
case new_oboe: case new_oboe:
result = load_party_v2(file_to_load, univ, manual); result = load_party_v2(file_to_load, univ, preview);
break; break;
case unknown: case unknown:
if(manual) showError("This is not a Blades of Exile save file."); if(!preview) showError("This is not a Blades of Exile save file.");
result = false; result = false;
break; break;
} }
if(recording && manual && result){ if(recording && !preview && result){
record_action("load_party", encode_file(file_to_load), true); record_action("load_party", encode_file(file_to_load), true);
} }
if(!result) univ.party.load_failed = true; if(!result) univ.party.load_failed = true;
return result; return result;
} }
bool load_party_v1(fs::path file_to_load, cUniverse& real_univ, bool town_restore, bool in_scen, bool maps_there, bool must_port, bool manual){ bool load_party_v1(fs::path file_to_load, cUniverse& real_univ, bool town_restore, bool in_scen, bool maps_there, bool must_port, bool preview){
std::ifstream fin(file_to_load.string().c_str(), std::ios_base::binary); std::ifstream fin(file_to_load.string().c_str(), std::ios_base::binary);
fin.seekg(3*sizeof(short),std::ios_base::beg); // skip the header, which is 6 bytes in the old format fin.seekg(3*sizeof(short),std::ios_base::beg); // skip the header, which is 6 bytes in the old format
@@ -269,7 +269,7 @@ bool load_party_v1(fs::path file_to_load, cUniverse& real_univ, bool town_restor
if(in_scen){ if(in_scen){
fs::path path = locate_scenario(store_party.scen_name); fs::path path = locate_scenario(store_party.scen_name);
if(path.empty()) { if(path.empty()) {
if(manual){ if(!preview){
std::ostringstream msg; std::ostringstream msg;
msg << "The scenario that this party was in (\"" << store_party.scen_name; msg << "The scenario that this party was in (\"" << store_party.scen_name;
msg << "\") could not be found. Most likely, it is not installed in the Scenarios directory."; msg << "\") could not be found. Most likely, it is not installed in the Scenarios directory.";
@@ -319,7 +319,7 @@ bool load_party_v1(fs::path file_to_load, cUniverse& real_univ, bool town_restor
return true; return true;
} }
bool load_party_v2(fs::path file_to_load, cUniverse& real_univ, bool manual){ bool load_party_v2(fs::path file_to_load, cUniverse& real_univ, bool preview){
igzstream zin(file_to_load.string().c_str()); igzstream zin(file_to_load.string().c_str());
tarball partyIn; tarball partyIn;
partyIn.readFrom(zin); partyIn.readFrom(zin);
@@ -331,7 +331,7 @@ bool load_party_v2(fs::path file_to_load, cUniverse& real_univ, bool manual){
{ // Load main party data first { // Load main party data first
std::istream& fin = partyIn.getFile("save/party.txt"); std::istream& fin = partyIn.getFile("save/party.txt");
if(!fin) { if(!fin) {
if(manual) showError("Loading Blades of Exile save file failed."); if(!preview) showError("Loading Blades of Exile save file failed.");
return false; return false;
} }
file.readFrom(fin); file.readFrom(fin);
@@ -344,7 +344,7 @@ bool load_party_v2(fs::path file_to_load, cUniverse& real_univ, bool manual){
fname[7] = i + '1'; fname[7] = i + '1';
std::istream& fin = partyIn.getFile(fname); std::istream& fin = partyIn.getFile(fname);
if(!fin) { if(!fin) {
if(manual) showError("Loading Blades of Exile save file failed."); if(!preview) showError("Loading Blades of Exile save file failed.");
return false; return false;
} }
file.readFrom(fin); file.readFrom(fin);
@@ -366,7 +366,7 @@ bool load_party_v2(fs::path file_to_load, cUniverse& real_univ, bool manual){
if(!univ.party.scen_name.empty()) { if(!univ.party.scen_name.empty()) {
fs::path path = locate_scenario(univ.party.scen_name); fs::path path = locate_scenario(univ.party.scen_name);
if(path.empty()) { if(path.empty()) {
if(manual){ if(!preview){
std::ostringstream msg; std::ostringstream msg;
msg << "The scenario that this party was in (\"" << univ.party.scen_name; msg << "The scenario that this party was in (\"" << univ.party.scen_name;
msg << "\") could not be found. Most likely, it is not installed in the Scenarios directory."; msg << "\") could not be found. Most likely, it is not installed in the Scenarios directory.";
@@ -382,7 +382,7 @@ bool load_party_v2(fs::path file_to_load, cUniverse& real_univ, bool manual){
// Load scenario data // Load scenario data
std::istream& fin = partyIn.getFile("save/scenario.txt"); std::istream& fin = partyIn.getFile("save/scenario.txt");
if(!fin) { if(!fin) {
if(manual) showError("Loading Blades of Exile save file failed."); if(!preview) showError("Loading Blades of Exile save file failed.");
return false; return false;
} }
file.readFrom(fin); file.readFrom(fin);
@@ -392,7 +392,7 @@ bool load_party_v2(fs::path file_to_load, cUniverse& real_univ, bool manual){
{ // Then the "setup" array { // Then the "setup" array
std::istream& fin = partyIn.getFile("save/setup.dat"); std::istream& fin = partyIn.getFile("save/setup.dat");
if(!fin) { if(!fin) {
if(manual) showError("Loading Blades of Exile save file failed."); if(!preview) showError("Loading Blades of Exile save file failed.");
return false; return false;
} }
file.readFrom(fin); file.readFrom(fin);
@@ -406,7 +406,7 @@ bool load_party_v2(fs::path file_to_load, cUniverse& real_univ, bool manual){
// Load town data // Load town data
std::istream& fin = partyIn.getFile("save/town.txt"); std::istream& fin = partyIn.getFile("save/town.txt");
if(!fin) { if(!fin) {
if(manual) showError("Loading Blades of Exile save file failed."); if(!preview) showError("Loading Blades of Exile save file failed.");
return false; return false;
} }
file.readFrom(fin); file.readFrom(fin);
@@ -425,7 +425,7 @@ bool load_party_v2(fs::path file_to_load, cUniverse& real_univ, bool manual){
// Load outdoors data // Load outdoors data
std::istream& fin = partyIn.getFile("save/out.txt"); std::istream& fin = partyIn.getFile("save/out.txt");
if(!fin) { if(!fin) {
if(manual) showError("Loading Blades of Exile save file failed."); if(!preview) showError("Loading Blades of Exile save file failed.");
return false; return false;
} }
univ.out.readFrom(fin); univ.out.readFrom(fin);

View File

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