Skip to content

Commit 8d15352

Browse files
committed
fix(zc): save select screen not showing new hp after save->reset
1 parent ad5694b commit 8d15352

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

src/zc/saves.cpp

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,18 @@ static int currgame = -1;
4141
static std::vector<save_t> saves;
4242
static 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

5258
static 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+
20112029
int32_t saves_count()
20122030
{
20132031
return saves.size();

src/zc/saves.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff 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

4041
int32_t saves_init();
4142
int32_t saves_load();
4243
int32_t saves_write();
4344
bool saves_select(int32_t index);
4445
void saves_unselect();
46+
void saves_unload(int32_t index);
4547
int32_t saves_count();
4648
int32_t saves_current_selection();
4749
bool saves_create_slot(gamedata* game, bool write_to_disk = true);

src/zc/title.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff 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
{

0 commit comments

Comments
 (0)