From a4c783311a50077153bd685b0a041c6c3f7f84f7 Mon Sep 17 00:00:00 2001 From: Christopher Leggett Date: Sun, 29 May 2022 12:30:15 -0400 Subject: [PATCH] Adds TempClear flag set and check for heart piece. This originally introduced a bug where the player could spawn multiple heart pieces by simply not collecting the one that spawns and continuing to dig up spots. This fixes that by checking a temp clear flag before spawning the heart piece and setting it when the heart piece spawns. Since this is a temp clear flag it will not stay set if the player exits the scene, so this still does fix the bug of locking the player out of the heart piece when spawning it and leaving without picking it up. As far as I can tell this temp clear flag isn't used anywhere else in this scene. The only one used in this scene I could find is that killing the first Poe in this scene sets flag 0x02 (or maybe it's 0x01, not sure if the flags start at 1 or 0). --- soh/src/overlays/actors/ovl_En_Tk/z_en_tk.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/soh/src/overlays/actors/ovl_En_Tk/z_en_tk.c b/soh/src/overlays/actors/ovl_En_Tk/z_en_tk.c index ff4a9a089..c2d1aeee8 100644 --- a/soh/src/overlays/actors/ovl_En_Tk/z_en_tk.c +++ b/soh/src/overlays/actors/ovl_En_Tk/z_en_tk.c @@ -606,7 +606,6 @@ void EnTk_Dig(EnTk* this, GlobalContext* globalCtx) { rewardPos.z += this->actor.world.pos.z; this->currentReward = EnTk_ChooseReward(this); - this->currentReward = 3; if (this->currentReward == 3) { /* * Upgrade the purple rupee reward to the heart piece if this @@ -615,10 +614,12 @@ void EnTk_Dig(EnTk* this, GlobalContext* globalCtx) { // If vanilla itemGetInf flag is not set, it's impossible for the new flag to be set, so return true. // Otherwise if the gGravediggingTourFix is enabled and the new flag hasn't been set, return true. // If true, spawn the heart piece isntead of the purple rupee and set the vanilla itemGetInf flag. - if (!(gSaveContext.itemGetInf[1] & 0x1000) - || CVar_GetS32("gGravediggingTourFix", 0) && !Flags_GetCollectible(globalCtx, 0x19)) { + if (!Flags_GetTempClear(globalCtx, 0x1f) && + (!(gSaveContext.itemGetInf[1] & 0x1000) || + CVar_GetS32("gGravediggingTourFix", 0) && !Flags_GetCollectible(globalCtx, 0x19))) { this->currentReward = 4; gSaveContext.itemGetInf[1] |= 0x1000; + Flags_SetTempClear(globalCtx, 0x1f); } }