@@ -22,6 +22,7 @@ use falling_tetromino_engine::{
2222 ExtDuration , GameEndCause , InGameTime , Notification , NotificationFeed , Stat , Tetromino ,
2323} ;
2424
25+ use crate :: savefile_logic:: SavefileResult ;
2526use crate :: {
2627 game_mode_presets:: GameModePreset ,
2728 game_restoration:: {
@@ -388,7 +389,8 @@ pub struct TemporaryAppData {
388389 pub renderer_used : usize ,
389390 pub save_on_exit : SavefileGranularity ,
390391 pub savefile_path : PathBuf , // This should technically be the same for a given compiled binary, but we compute it at runtime.
391- pub loadfile_result : savefile_logic:: SavefileResult < ( ) > ,
392+ pub loadfile_result : SavefileResult < ( ) > ,
393+ pub storefile_result : SavefileResult < ( ) > ,
392394}
393395
394396#[ derive( Debug ) ]
@@ -413,21 +415,8 @@ impl<T: Write> Drop for Application<T> {
413415 // (Try to) undo terminal setup. Ignore errors cuz atp it's too late to take any flak from Crossterm.
414416 let _ = self . deinitialize_terminal_state ( ) ;
415417
416- if self . temp_data . save_on_exit != SavefileGranularity :: NoSavefile {
417- // If the user wants any of their data stored, try to do so.
418- if let Err ( e) = self . store_to_savefile ( ) {
419- eprintln ! ( "Error storing savefile: {e}" ) ;
420- }
421- } else if self
422- . temp_data
423- . savefile_path
424- . try_exists ( )
425- . is_ok_and ( |exists| exists)
426- {
427- // Otherwise explicitly check for savefile and try to make sure we don't leave it around.
428- if let Err ( e) = std:: fs:: remove_file ( self . temp_data . savefile_path . clone ( ) ) {
429- eprintln ! ( "Error removing old savefile: {e}" ) ;
430- }
418+ if let Err ( e) = self . savefile_store ( ) {
419+ eprintln ! ( "Error on savefile store: {e}" ) ;
431420 }
432421 }
433422}
@@ -562,6 +551,7 @@ impl<T: Write> Application<T> {
562551 save_on_exit : SavefileGranularity :: default ( ) ,
563552 savefile_path : savefile_logic:: savefile_path ( ) ,
564553 loadfile_result : Ok ( ( ) ) ,
554+ storefile_result : Ok ( ( ) ) ,
565555 } ;
566556
567557 let mut new = Self {
@@ -574,7 +564,7 @@ impl<T: Write> Application<T> {
574564 } ;
575565
576566 // Load in actual settings.
577- new. temp_data . loadfile_result = new. load_from_savefile ( ) ;
567+ new. temp_data . loadfile_result = new. savefile_load ( ) ;
578568
579569 // Special: Overwrite specifically requested cmdline flags.
580570
0 commit comments