File tree Expand file tree Collapse file tree 3 files changed +24
-2
lines changed
Expand file tree Collapse file tree 3 files changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -41,12 +41,18 @@ static int currgame = -1;
4141static std::vector<save_t > saves;
4242static bool save_current_replay_games;
4343
44- save_t ::~save_t ()
44+ void save_t::unload ()
4545{
4646 if (this ->game )
4747 delete this ->game ;
4848 else
4949 delete this ->header ;
50+ this ->game = nullptr ;
51+ this ->header = nullptr ;
52+ }
53+ save_t ::~save_t ()
54+ {
55+ unload ();
5056}
5157
5258static fs::path get_legacy_save_file_path ()
@@ -2008,6 +2014,18 @@ void saves_unselect()
20082014 currgame = -1 ;
20092015}
20102016
2017+ void saves_unload (int32_t index)
2018+ {
2019+ if (index == -1 )
2020+ return ;
2021+
2022+ auto & save = saves[index];
2023+ save.unload ();
2024+
2025+ if (currgame == index)
2026+ currgame = -1 ;
2027+ }
2028+
20112029int32_t saves_count ()
20122030{
20132031 return saves.size ();
Original file line number Diff line number Diff line change @@ -35,13 +35,15 @@ struct save_t
3535 save_t (const save_t &) = delete ;
3636 save_t & operator =(const save_t &) = delete ;
3737 ~save_t ();
38+ void unload ();
3839};
3940
4041int32_t saves_init ();
4142int32_t saves_load ();
4243int32_t saves_write ();
4344bool saves_select (int32_t index);
4445void saves_unselect ();
46+ void saves_unload (int32_t index);
4547int32_t saves_count ();
4648int32_t saves_current_selection ();
4749bool saves_create_slot (gamedata* game, bool write_to_disk = true );
Original file line number Diff line number Diff line change @@ -1446,8 +1446,10 @@ void titlescreen(int32_t lsave)
14461446 }
14471447
14481448 if (saves_current_selection () != -1 )
1449+ {
14491450 last_slot_pos = saves_current_selection () % 3 ;
1450- saves_unselect ();
1451+ saves_unload (saves_current_selection ());
1452+ }
14511453
14521454 if (replay_get_mode () == ReplayMode::Record)
14531455 {
You can’t perform that action at this time.
0 commit comments