Fix crash when toggling alt assets while paused (#4621)

This commit is contained in:
Archez 2024-12-06 10:36:38 -05:00 committed by GitHub
parent 09f297392f
commit bccd96966f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -12,6 +12,7 @@
#include "soh/Enhancements/enhancementTypes.h" #include "soh/Enhancements/enhancementTypes.h"
#include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h" #include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h"
#include "soh/OTRGlobals.h" #include "soh/OTRGlobals.h"
#include "soh/ResourceManagerHelpers.h"
#include "soh/SaveManager.h" #include "soh/SaveManager.h"
#include "soh/framebuffer_effects.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 // Track render size when paused and that a copy was performed
static u32 lastPauseWidth; static u32 lastPauseWidth;
static u32 lastPauseHeight; static u32 lastPauseHeight;
static u8 hasCapturedPauseBuffer; static bool lastAltAssets;
u8 recapturePauseBuffer = false; 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. // 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) && if ((R_PAUSE_MENU_MODE == 2 || R_PAUSE_MENU_MODE == 3) &&
(lastPauseWidth != OTRGetGameRenderWidth() || lastPauseHeight != OTRGetGameRenderHeight() || (lastPauseWidth != OTRGetGameRenderWidth() || lastPauseHeight != OTRGetGameRenderHeight() ||
!hasCapturedPauseBuffer)) { lastAltAssets != ResourceMgr_IsAltAssetsEnabled() || !hasCapturedPauseBuffer)) {
R_PAUSE_MENU_MODE = 1; R_PAUSE_MENU_MODE = 1;
recapturePauseBuffer = true; recapturePauseBuffer = true;
} }
@ -1594,6 +1596,7 @@ void Play_Draw(PlayState* play) {
// #region SOH [Port] Custom handling for pause prerender background capture // #region SOH [Port] Custom handling for pause prerender background capture
lastPauseWidth = OTRGetGameRenderWidth(); lastPauseWidth = OTRGetGameRenderWidth();
lastPauseHeight = OTRGetGameRenderHeight(); lastPauseHeight = OTRGetGameRenderHeight();
lastAltAssets = ResourceMgr_IsAltAssetsEnabled();
hasCapturedPauseBuffer = false; hasCapturedPauseBuffer = false;
FB_CopyToFramebuffer(&gfxP, 0, gPauseFrameBuffer, false, &hasCapturedPauseBuffer); FB_CopyToFramebuffer(&gfxP, 0, gPauseFrameBuffer, false, &hasCapturedPauseBuffer);