Skip to content

Commit 8362c1e

Browse files
committed
refactor(zc): only check already loaded saves for 4th qst red easter egg
Otherwise, it takes noticeable time to load every save file when the file select screen loads.
1 parent ec1a383 commit 8362c1e

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

src/zc/saves.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2153,6 +2153,15 @@ int32_t saves_current_selection()
21532153
return currgame;
21542154
}
21552155

2156+
bool saves_is_slot_loaded(int32_t index, bool full_data)
2157+
{
2158+
if (saves.size() <= index)
2159+
return false;
2160+
if (full_data && saves[index].game == nullptr)
2161+
return false;
2162+
return saves[index].header != nullptr;
2163+
}
2164+
21562165
const save_t* saves_get_slot(int32_t index, bool full_data)
21572166
{
21582167
save_t* save;

src/zc/saves.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ int32_t saves_count();
4545
int32_t saves_current_selection();
4646
bool saves_create_slot(gamedata* game, bool save_to_disk = true);
4747
bool saves_create_slot(fs::path path);
48+
bool saves_is_slot_loaded(int32_t index, bool full_data = false);
4849
const save_t* saves_get_slot(int32_t index, bool full_data = false);
4950
const save_t* saves_get_current_slot();
5051
void saves_delete(int32_t index);

src/zc/title.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,11 +283,25 @@ static void list_saves()
283283
{
284284
// Fourth Quest turns the menu red.
285285
bool red = false;
286-
286+
287+
// First, make sure the presently listed quests are loaded.
287288
int savecnt = saves_count();
289+
for(int32_t i=0; i<3; i++)
290+
{
291+
int j = listpos+i;
292+
if (j < savecnt)
293+
saves_get_slot(j);
294+
}
295+
296+
// Check if any loaded quests is the 4th quest.
288297
for(int32_t i=0; i<savecnt; i++)
289-
if (saves_get_slot(i)->header && saves_get_slot(i)->header->quest == 4)
298+
{
299+
if (saves_is_slot_loaded(i) && saves_get_slot(i)->header->quest == 4)
300+
{
290301
red = true;
302+
break;
303+
}
304+
}
291305

292306
loadpalset(0,red ? pSprite(spPILE) : 0);
293307

0 commit comments

Comments
 (0)