From f5bcc6dccfb52499da641f8b00e792b259e01bc0 Mon Sep 17 00:00:00 2001 From: Adam Bird Date: Sat, 1 Apr 2023 14:06:53 -0400 Subject: [PATCH] fix crash when fishing rod is cast and scene is reloaded (#2657) --- soh/src/overlays/actors/ovl_Fishing/z_fishing.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/soh/src/overlays/actors/ovl_Fishing/z_fishing.c b/soh/src/overlays/actors/ovl_Fishing/z_fishing.c index 29dc52c7f..e67039659 100644 --- a/soh/src/overlays/actors/ovl_Fishing/z_fishing.c +++ b/soh/src/overlays/actors/ovl_Fishing/z_fishing.c @@ -22,6 +22,7 @@ void Fishing_UpdateFish(Actor* thisx, PlayState* play); void Fishing_UpdateOwner(Actor* thisx, PlayState* play); void Fishing_DrawFish(Actor* thisx, PlayState* play); void Fishing_DrawOwner(Actor* thisx, PlayState* play); +void Fishing_Reset(void); typedef struct { /* 0x00 */ u8 unk_00; @@ -132,7 +133,7 @@ const ActorInit Fishing_InitVars = { (ActorFunc)Fishing_Destroy, (ActorFunc)Fishing_UpdateFish, (ActorFunc)Fishing_DrawFish, - NULL, + (ActorResetFunc)Fishing_Reset, }; static f32 D_80B7A650 = 0.0f; @@ -5888,3 +5889,10 @@ void Fishing_DrawOwner(Actor* thisx, PlayState* play) { CLOSE_DISPS(play->state.gfxCtx); } + +void Fishing_Reset(void) { + // Reset static variables for fishing camera and cinematic state to prevent crashing when dying + // or re-entering the scene while the fishing rod was cast + sCameraId = 0; + D_80B7A6CC = 0; +}