Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Prompt on death quickloads instead of going to main menu #5823

Merged
merged 5 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
/*
* 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 @@ -928,7 +930,7 @@
// Add a timestamp for uniqueness.
char buffer[suffix_len] {};
std::time_t t = std::time( nullptr );
std::strftime( buffer, suffix_len, "%Y-%m-%d-%H-%M-%S", std::localtime( &t ) );

Check warning on line 933 in src/game.cpp

View workflow job for this annotation

GitHub Actions / build

the value returned by this function should not be disregarded; neglecting it may lead to errors [cert-err33-c]
memorial_file_path << buffer;

return memorial_file_path.str();
Expand Down Expand Up @@ -2392,8 +2394,9 @@
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 @@
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 @@
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 @@ -4315,7 +4318,7 @@
targ->apply_damage( source, bodypart_id( "torso" ), dam_mult * force_remaining );
targ->check_dead_state();
}
m.bash( traj[i], 2 * dam_mult * force_remaining );

Check warning on line 4321 in src/game.cpp

View workflow job for this annotation

GitHub Actions / build

performing an implicit widening conversion to type 'std::size_t' (aka 'unsigned long') of a multiplication performed in type 'int' [bugprone-implicit-widening-of-multiplication-result]
break;
} else if( critter_at( traj[i] ) ) {
targ->setpos( traj[i - 1] );
Expand Down Expand Up @@ -4395,7 +4398,7 @@
}
targ->check_dead_state();
}
m.bash( traj[i], 2 * dam_mult * force_remaining );

Check warning on line 4401 in src/game.cpp

View workflow job for this annotation

GitHub Actions / build

performing an implicit widening conversion to type 'std::size_t' (aka 'unsigned long') of a multiplication performed in type 'int' [bugprone-implicit-widening-of-multiplication-result]
break;
} else if( critter_at( traj[i] ) ) {
targ->setpos( traj[i - 1] );
Expand Down Expand Up @@ -4478,7 +4481,7 @@
}
u.check_dead_state();
}
m.bash( traj[i], 2 * dam_mult * force_remaining );

Check warning on line 4484 in src/game.cpp

View workflow job for this annotation

GitHub Actions / build

performing an implicit widening conversion to type 'std::size_t' (aka 'unsigned long') of a multiplication performed in type 'int' [bugprone-implicit-widening-of-multiplication-result]
break;
} else if( critter_at( traj[i] ) ) {
u.setpos( traj[i - 1] );
Expand Down Expand Up @@ -11424,16 +11427,15 @@
}

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 All @@ -11442,7 +11444,7 @@
void game::autosave()
{
//Don't autosave if the min-autosave interval has not passed since the last autosave/quicksave.
if( time( nullptr ) < last_save_timestamp + 60 * get_option<int>( "AUTOSAVE_MINUTES" ) ) {

Check warning on line 11447 in src/game.cpp

View workflow job for this annotation

GitHub Actions / build

performing an implicit widening conversion to type 'time_t' (aka 'long') of a multiplication performed in type 'int' [bugprone-implicit-widening-of-multiplication-result]
return;
}
quicksave(); //Driving checks are handled by quicksave()
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
Loading