Skip to content

Commit

Permalink
Fix crash when toggling alt assets while paused (HarbourMasters#4621)
Browse files Browse the repository at this point in the history
  • Loading branch information
Archez authored Dec 6, 2024
1 parent 09f2973 commit bccd969
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions soh/src/code/z_play.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit bccd969

Please sign in to comment.