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).
This commit is contained in:
Christopher Leggett 2022-05-29 12:30:15 -04:00
commit a4c783311a
No known key found for this signature in database
GPG key ID: 7093AE5FF7037D79

View file

@ -606,7 +606,6 @@ void EnTk_Dig(EnTk* this, GlobalContext* globalCtx) {
rewardPos.z += this->actor.world.pos.z; rewardPos.z += this->actor.world.pos.z;
this->currentReward = EnTk_ChooseReward(this); this->currentReward = EnTk_ChooseReward(this);
this->currentReward = 3;
if (this->currentReward == 3) { if (this->currentReward == 3) {
/* /*
* Upgrade the purple rupee reward to the heart piece if this * 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. // 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. // 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 true, spawn the heart piece isntead of the purple rupee and set the vanilla itemGetInf flag.
if (!(gSaveContext.itemGetInf[1] & 0x1000) if (!Flags_GetTempClear(globalCtx, 0x1f) &&
|| CVar_GetS32("gGravediggingTourFix", 0) && !Flags_GetCollectible(globalCtx, 0x19)) { (!(gSaveContext.itemGetInf[1] & 0x1000) ||
CVar_GetS32("gGravediggingTourFix", 0) && !Flags_GetCollectible(globalCtx, 0x19))) {
this->currentReward = 4; this->currentReward = 4;
gSaveContext.itemGetInf[1] |= 0x1000; gSaveContext.itemGetInf[1] |= 0x1000;
Flags_SetTempClear(globalCtx, 0x1f);
} }
} }