From 2bb149b367c04da89ed5b825926d48bda4e00586 Mon Sep 17 00:00:00 2001 From: Archez Date: Mon, 8 Jul 2024 17:57:17 -0400 Subject: Tweak: Improve Save Editor time options (#729) * improve save editor time options * set gPlayState after early returns to avoid dangling ptr * avoid crash with day 0 on daytelop --- mm/src/code/z_play.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'mm/src/code') diff --git a/mm/src/code/z_play.c b/mm/src/code/z_play.c index a939ed217..c9b3a1796 100644 --- a/mm/src/code/z_play.c +++ b/mm/src/code/z_play.c @@ -2184,9 +2184,6 @@ void Play_FillScreen(GameState* thisx, s16 fillScreenOn, u8 red, u8 green, u8 bl void Play_Init(GameState* thisx) { PlayState* this = (PlayState*)thisx; - // #region 2S2H [General] Making gPlayState available - gPlayState = this; - // #endregion GraphicsContext* gfxCtx = this->state.gfxCtx; s32 pad; uintptr_t zAlloc; @@ -2220,6 +2217,11 @@ void Play_Init(GameState* thisx) { return; } + // #region 2S2H [General] Making gPlayState available + // Setting after the early returns, so that Play_Destroy is registered to unset the ptr later + gPlayState = this; + // #endregion + if ((gSaveContext.nextCutsceneIndex == 0xFFEF) || (gSaveContext.nextCutsceneIndex == 0xFFF0)) { scene = ((void)0, gSaveContext.save.entrance) >> 9; spawn = (((void)0, gSaveContext.save.entrance) >> 4) & 0x1F; -- cgit v1.2.3