From bccd96966fa9339f3d85dad39c7fbc00a34a2246 Mon Sep 17 00:00:00 2001 From: Archez Date: Fri, 6 Dec 2024 10:36:38 -0500 Subject: [PATCH] Fix crash when toggling alt assets while paused (#4621) --- soh/src/code/z_play.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/soh/src/code/z_play.c b/soh/src/code/z_play.c index 219b3a448..df1314e71 100644 --- a/soh/src/code/z_play.c +++ b/soh/src/code/z_play.c @@ -12,6 +12,7 @@ #include "soh/Enhancements/enhancementTypes.h" #include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h" #include "soh/OTRGlobals.h" +#include "soh/ResourceManagerHelpers.h" #include "soh/SaveManager.h" #include "soh/framebuffer_effects.h" @@ -1327,15 +1328,16 @@ void Play_Draw(PlayState* play) { // Track render size when paused and that a copy was performed static u32 lastPauseWidth; static u32 lastPauseHeight; - static u8 hasCapturedPauseBuffer; - u8 recapturePauseBuffer = false; + static bool lastAltAssets; + static bool hasCapturedPauseBuffer; + bool recapturePauseBuffer = false; - // If the size has changed or dropped frames leading to the buffer not being copied, + // If the size has changed, alt assets toggled, or dropped frames leading to the buffer not being copied, // set the prerender state back to setup to copy a new frame. - // This requires not rendering kaleido during this copy to avoid kaleido being copied + // This requires not rendering kaleido during this copy to avoid kaleido itself being copied too. if ((R_PAUSE_MENU_MODE == 2 || R_PAUSE_MENU_MODE == 3) && (lastPauseWidth != OTRGetGameRenderWidth() || lastPauseHeight != OTRGetGameRenderHeight() || - !hasCapturedPauseBuffer)) { + lastAltAssets != ResourceMgr_IsAltAssetsEnabled() || !hasCapturedPauseBuffer)) { R_PAUSE_MENU_MODE = 1; recapturePauseBuffer = true; } @@ -1594,6 +1596,7 @@ void Play_Draw(PlayState* play) { // #region SOH [Port] Custom handling for pause prerender background capture lastPauseWidth = OTRGetGameRenderWidth(); lastPauseHeight = OTRGetGameRenderHeight(); + lastAltAssets = ResourceMgr_IsAltAssetsEnabled(); hasCapturedPauseBuffer = false; FB_CopyToFramebuffer(&gfxP, 0, gPauseFrameBuffer, false, &hasCapturedPauseBuffer);