Skip to content

Commit

Permalink
feat: Prompt on death quickloads instead of going to main menu (cat…
Browse files Browse the repository at this point in the history
…aclysmbnteam#5823)

* Initial unclear commit.

* Prompt changes.

* Minor grammar issue

* Typo

Co-authored-by: scarf <[email protected]>

* Cleaned `game::quicksave()` by modifying `game::setup()` instead, thank to scarf for the suggestions.
Co-authored-by: scarf <[email protected]>

---------

Co-authored-by: scarf <[email protected]>
  • Loading branch information
Skas8825 and scarf005 authored Dec 20, 2024
1 parent 8fdbce2 commit 35e043e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 19 deletions.
36 changes: 19 additions & 17 deletions src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -470,11 +470,13 @@ void game::reenter_fullscreen()
/*
* Initialize more stuff after mapbuffer is loaded.
*/
void game::setup()
void game::setup( bool load_world_modfiles )
{
loading_ui ui( true );

init::load_world_modfiles( ui, get_active_world(), SAVE_ARTIFACTS );
if( load_world_modfiles ) {
init::load_world_modfiles( ui, get_active_world(), SAVE_ARTIFACTS );
}

m = map();

Expand Down Expand Up @@ -2392,8 +2394,9 @@ bool game::is_game_over()
if( u.is_dead_state() ) {
if( get_option<bool>( "PROMPT_ON_CHARACTER_DEATH" ) &&
!query_yn(
_( "Your character is dead, do you accept this?\n\nSelect Yes to abandon the character to their fate, select No to return to main menu." ) ) ) {
return true;
_( "Your character is dead, do you accept this?\n\nSelect Yes to abandon the character to their fate, select No to try again." ) ) ) {
g->quickload();
return false;
}

Messages::deactivate();
Expand Down Expand Up @@ -2539,8 +2542,6 @@ bool game::load( const save_t &name )
background_pane background;
static_popup popup;
popup.message( "%s", _( "Please wait…\nLoading the save…" ) );
ui_manager::redraw();
refresh_display();

using namespace std::placeholders;

Expand All @@ -2554,7 +2555,9 @@ bool game::load( const save_t &name )
std::bind( &game::unserialize, this, _1 ) ) ) {
return false;
}

// This needs to be here for some reason for quickload() to work
ui_manager::redraw();
refresh_display();
u.load_map_memory();
u.get_avatar_diary()->load();

Expand Down Expand Up @@ -11424,16 +11427,15 @@ void game::quickload()
}

if( active_world->info->save_exists( save_t::from_save_id( u.get_save_id() ) ) ) {
if( moves_since_last_save != 0 ) { // See if we need to reload anything
MAPBUFFER.clear();
overmap_buffer.clear();
try {
setup();
} catch( const std::exception &err ) {
debugmsg( "Error: %s", err.what() );
}
load( save_t::from_save_id( u.get_save_id() ) );
}
MAPBUFFER.clear();
overmap_buffer.clear();
try {
// Doesn't need to load mod files again for the same world
setup( false );
} catch( const std::exception &err ) {
debugmsg( "Error: %s", err.what() );
}
load( save_t::from_save_id( u.get_save_id() ) );
} else {
popup_getkey( _( "No saves for current character yet." ) );
}
Expand Down
2 changes: 1 addition & 1 deletion src/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ class game
void on_options_changed();

public:
void setup();
void setup( bool load_world_modfiles = true );
/** Saving and loading functions. */
void serialize( std::ostream &fout ); // for save
void unserialize( std::istream &fin ); // for load
Expand Down
2 changes: 1 addition & 1 deletion src/options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1222,7 +1222,7 @@ void options_manager::add_options_general()
};

add( "PROMPT_ON_CHARACTER_DEATH", general, translate_marker( "Prompt on character death" ),
translate_marker( "If enabled, when your character dies, the player is given a prompt that gives the option to cancel savefile deletion and other death effects, returning to the main menu without saving instead." ),
translate_marker( "If enabled, when your character dies, the player is given a prompt that gives the option to reload the last saved game instead of dying." ),
false
);

Expand Down

0 comments on commit 35e043e

Please sign in to comment.