Fix multiple inconsistencies when saving (#550)
* debug_leave_town use same logic as normal town exit. fix #549 * Standardize all save party code paths Fix #480 Fix #204 Fix #267 * remove file_in_mem now that it is redundant * Print message when save file not chosen
This commit is contained in:
@@ -1252,9 +1252,7 @@ void handle_victory(bool force, bool record) {
|
||||
menu_activate();
|
||||
univ.party.scen_name = ""; // should be harmless...
|
||||
if(!force && cChoiceDlog("congrats-save",{"cancel","save"}).show() == "save"){
|
||||
// TODO: Wait, this shouldn't be a "save as" action, should it? It should save without asking for a location.
|
||||
fs::path file = nav_put_or_temp_party();
|
||||
if(!file.empty()) save_party(file, univ);
|
||||
do_save();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1450,9 +1448,7 @@ bool handle_action(const sf::Event& event, cFramerateLimiter& fps_limiter) {
|
||||
|
||||
case TOOLBAR_SAVE:
|
||||
if(overall_mode == MODE_OUTDOORS) {
|
||||
save_party(univ.file, univ);
|
||||
need_redraw = true;
|
||||
current_switch = 6;
|
||||
do_save();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
@@ -2023,14 +2019,10 @@ void debug_leave_town() {
|
||||
print_buf();
|
||||
return;
|
||||
}
|
||||
univ.party.end_split(0);
|
||||
overall_mode = MODE_OUTDOORS;
|
||||
position_party(univ.party.outdoor_corner.x,univ.party.outdoor_corner.y,univ.party.out_loc.x,univ.party.out_loc.y);
|
||||
clear_map();
|
||||
add_string_to_buf("Debug: Reunite party and leave town.");
|
||||
ASB("Debug: Reunite party and leave town.");
|
||||
print_buf();
|
||||
update_explored(univ.party.out_loc);
|
||||
redraw_screen(REFRESH_ALL);
|
||||
univ.party.end_split(0);
|
||||
end_town_mode(false, {0,0}, true);
|
||||
}
|
||||
|
||||
void debug_kill() {
|
||||
@@ -2777,25 +2769,24 @@ void post_load() {
|
||||
}
|
||||
|
||||
//mode; // 0 - normal 1 - save as
|
||||
void do_save(short mode) {
|
||||
void do_save(bool save_as) {
|
||||
if(overall_mode != MODE_TOWN && overall_mode != MODE_OUTDOORS && overall_mode != MODE_STARTUP) {
|
||||
add_string_to_buf("Save: Only while outdoors, or in town and not looking/casting.", 2);
|
||||
print_buf();
|
||||
return;
|
||||
}
|
||||
|
||||
if(univ.party.is_in_scenario()) save_outdoor_maps();
|
||||
fs::path file = univ.file;
|
||||
if(mode == 1 || file.empty())
|
||||
file = nav_put_or_temp_party(file);
|
||||
bool saved = false;
|
||||
if(!file.empty()) {
|
||||
univ.file = file;
|
||||
saved = save_party(univ.file, univ);
|
||||
}
|
||||
|
||||
if(saved)
|
||||
if(save_party(univ, save_as)){
|
||||
add_string_to_buf("Save: Game saved");
|
||||
|
||||
}else{
|
||||
add_string_to_buf("Save: Save not completed");
|
||||
}
|
||||
|
||||
// Cancel switching PC order
|
||||
current_switch = 6;
|
||||
|
||||
pause(6);
|
||||
redraw_screen(REFRESH_TEXT);
|
||||
}
|
||||
@@ -3307,9 +3298,7 @@ void start_new_game(bool force) {
|
||||
}
|
||||
party_in_memory = true;
|
||||
if(force) return;
|
||||
fs::path file = nav_put_or_temp_party();
|
||||
if(!file.empty()) save_party(file, univ);
|
||||
univ.file = file;
|
||||
do_save(true);
|
||||
}
|
||||
|
||||
void start_tutorial() {
|
||||
|
@@ -20,7 +20,7 @@ bool handle_keystroke(const sf::Event& event, cFramerateLimiter& fps_limiter);
|
||||
bool handle_scroll(const sf::Event& event);
|
||||
void do_load();
|
||||
void post_load();
|
||||
void do_save(short mode);
|
||||
void do_save(bool save_as = false);
|
||||
void do_abort();
|
||||
void increase_age();
|
||||
void handle_hunting();
|
||||
|
@@ -1140,9 +1140,7 @@ void handle_quit_event() {
|
||||
std::string choice = cChoiceDlog("quit-confirm-save", {"save","quit","cancel"}).show();
|
||||
if(choice == "cancel") return;
|
||||
if(choice == "save") {
|
||||
fs::path file = nav_put_or_temp_party();
|
||||
if(file.empty()) return;
|
||||
save_party(file, univ);
|
||||
do_save();
|
||||
}
|
||||
}
|
||||
All_Done = true;
|
||||
@@ -1151,7 +1149,7 @@ void handle_quit_event() {
|
||||
if(choice == "cancel")
|
||||
return;
|
||||
if(choice == "save")
|
||||
save_party(univ.file, univ);
|
||||
do_save();
|
||||
} else {
|
||||
std::string choice = cChoiceDlog("quit-confirm-nosave", {"quit", "cancel"}).show();
|
||||
if(choice == "cancel")
|
||||
@@ -1329,10 +1327,10 @@ void handle_menu_choice(eMenu item_hit) {
|
||||
do_load();
|
||||
break;
|
||||
case eMenu::FILE_SAVE:
|
||||
do_save(0);
|
||||
do_save();
|
||||
break;
|
||||
case eMenu::FILE_SAVE_AS:
|
||||
do_save(1);
|
||||
do_save(true);
|
||||
break;
|
||||
case eMenu::FILE_NEW:
|
||||
new_party();
|
||||
|
@@ -513,7 +513,7 @@ void start_town_mode(short which_town, short entry_dir) {
|
||||
}
|
||||
|
||||
|
||||
location end_town_mode(short switching_level,location destination) { // returns new party location
|
||||
location end_town_mode(bool switching_level,location destination, bool debug_leave) { // returns new party location
|
||||
location to_return;
|
||||
bool data_saved = false,combat_end = false;
|
||||
|
||||
@@ -576,7 +576,7 @@ location end_town_mode(short switching_level,location destination) { // returns
|
||||
|
||||
|
||||
// Check for exit specials, if leaving town
|
||||
if(switching_level == 0) {
|
||||
if(!switching_level && !debug_leave) {
|
||||
to_return = univ.party.out_loc;
|
||||
|
||||
if(is_town()) {
|
||||
@@ -612,7 +612,7 @@ location end_town_mode(short switching_level,location destination) { // returns
|
||||
}
|
||||
}
|
||||
|
||||
if(switching_level == 0) {
|
||||
if(!switching_level) {
|
||||
overall_mode = MODE_OUTDOORS;
|
||||
|
||||
erase_out_specials();
|
||||
|
@@ -4,7 +4,7 @@
|
||||
|
||||
void force_town_enter(short which_town,location where_start);
|
||||
void start_town_mode(short which_town, short entry_dir);
|
||||
location end_town_mode(short switching_level,location destination); // returns new party location
|
||||
location end_town_mode(bool switching_level,location destination,bool debug_leave=false); // returns new party location
|
||||
void handle_leave_town_specials(short town_number, short which_spec,location start_loc) ;
|
||||
void handle_town_specials(short town_number, bool town_dead,location start_loc) ;
|
||||
bool abil_exists(eItemAbil abil);
|
||||
|
Reference in New Issue
Block a user