summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosh Bodner <30329717+jbodner09@users.noreply.github.com>2023-11-14 14:08:45 -0800
committerGitHub <noreply@github.com>2023-11-14 17:08:45 -0500
commitfb45b66903b2c7449a4673a331c2117a94ce02cb (patch)
tree2bda1a833cd18f8ac2705f46cee9419013c47d5a
parentba987c49e2e4bfaaccdcff740709489bf59b34d5 (diff)
Fix magic being zeroed out when using fast file select (#3389)
* Move to frame counter init to a place that fast file select also touches * Undo removing old fix * Reset on gameover
-rw-r--r--soh/soh/Enhancements/debugconsole.cpp1
-rw-r--r--soh/src/code/z_play.c7
-rw-r--r--soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c2
3 files changed, 10 insertions, 0 deletions
diff --git a/soh/soh/Enhancements/debugconsole.cpp b/soh/soh/Enhancements/debugconsole.cpp
index 3e61505b2..88a23718e 100644
--- a/soh/soh/Enhancements/debugconsole.cpp
+++ b/soh/soh/Enhancements/debugconsole.cpp
@@ -207,6 +207,7 @@ static bool ResetHandler(std::shared_ptr<LUS::Console> Console, std::vector<std:
return 1;
}
+ gPlayState->gameplayFrames = 0;
SET_NEXT_GAMESTATE(&gPlayState->state, TitleSetup_Init, GameState);
gPlayState->state.running = false;
GameInteractor::Instance->ExecuteHooks<GameInteractor::OnExitGame>(gSaveContext.fileNum);
diff --git a/soh/src/code/z_play.c b/soh/src/code/z_play.c
index 841de8f13..59a5d0619 100644
--- a/soh/src/code/z_play.c
+++ b/soh/src/code/z_play.c
@@ -33,6 +33,7 @@ u64 D_801614D0[0xA00];
#endif
PlayState* gPlayState;
+s16 firstInit = 0;
s16 gEnPartnerId;
@@ -490,6 +491,12 @@ void Play_Init(GameState* thisx) {
}
}
+ // Properly initialize the frame counter so it doesn't use garbage data
+ if (!firstInit) {
+ play->gameplayFrames = 0;
+ firstInit = 1;
+ }
+
// Invalid entrance, so immediately exit the game to opening title
if (gSaveContext.entranceIndex == -1) {
gSaveContext.entranceIndex = 0;
diff --git a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c
index 55a5075a6..35490f079 100644
--- a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c
+++ b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c
@@ -4290,6 +4290,8 @@ void KaleidoScope_Update(PlayState* play)
if (IS_RANDO && Randomizer_GetSettingValue(RSK_SHUFFLE_ENTRANCES)) {
Grotto_ForceGrottoReturn();
}
+ // Reset frame counter to prevent autosave on respawn
+ play->gameplayFrames = 0;
gSaveContext.nextTransitionType = 2;
gSaveContext.health = CVarGetInteger("gFullHealthSpawn", 0) ? gSaveContext.healthCapacity : 0x30;
Audio_QueueSeqCmd(0xF << 28 | SEQ_PLAYER_BGM_MAIN << 24 | 0xA);