From d62c5879aaf4b64d68f6069cc2413c9d5f2eac92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philip=20Dub=C3=A9?= <159546+serprex@users.noreply.github.com> Date: Wed, 22 Jul 2026 12:24:31 +0000 Subject: [PATCH] Fix problems with Zelda's Letter & Weird Egg hatching (#6962) --- soh/include/functions.h | 1 + .../game-interactor/GameInteractor_HookTable.h | 1 - .../game-interactor/GameInteractor_Hooks.cpp | 4 ---- .../game-interactor/GameInteractor_Hooks.h | 1 - .../Enhancements/randomizer/hook_handlers.cpp | 17 ----------------- soh/src/code/z_kankyo.c | 7 ++----- soh/src/code/z_parameter.c | 17 +++++++++++++++++ soh/src/code/z_play.c | 3 +-- 8 files changed, 21 insertions(+), 30 deletions(-) diff --git a/soh/include/functions.h b/soh/include/functions.h index af88ca2d90..c96f3b23fb 100644 --- a/soh/include/functions.h +++ b/soh/include/functions.h @@ -1080,6 +1080,7 @@ bool Inventory_HasEmptyBottleSlot(void); s32 Inventory_HasSpecificBottle(u8 bottleItem); void Inventory_UpdateBottleItem(PlayState* play, u8 item, u8 cButton); s32 Inventory_ConsumeFairy(PlayState* play); +bool Inventory_HatchWeirdEgg(PlayState* play); bool Inventory_HatchPocketCucco(PlayState* play); void Interface_SetDoAction(PlayState* play, u16 action); void Interface_SetNaviCall(PlayState* play, u16 naviCallState); diff --git a/soh/soh/Enhancements/game-interactor/GameInteractor_HookTable.h b/soh/soh/Enhancements/game-interactor/GameInteractor_HookTable.h index 59faf32de8..3448ebc08f 100644 --- a/soh/soh/Enhancements/game-interactor/GameInteractor_HookTable.h +++ b/soh/soh/Enhancements/game-interactor/GameInteractor_HookTable.h @@ -30,7 +30,6 @@ DEFINE_HOOK(OnSetDoAction, (uint16_t action)); DEFINE_HOOK(OnPlayerSfx, (u16 sfxId)); DEFINE_HOOK(OnOcarinaSongAction, ()); DEFINE_HOOK(OnOcarinaNote, (uint8_t note, float modulator, int8_t bend)); -DEFINE_HOOK(OnCuccoOrChickenHatch, ()); DEFINE_HOOK(OnShopSlotChange, (uint8_t cursorIndex, int16_t price)); DEFINE_HOOK(OnDungeonKeyUsed, (uint16_t mapIndex)); DEFINE_HOOK(ShouldActorInit, (void* actor, bool* result)); diff --git a/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.cpp b/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.cpp index b754e9c949..d58a52440b 100644 --- a/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.cpp +++ b/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.cpp @@ -118,10 +118,6 @@ void GameInteractor_ExecuteOnOcarinaNote(uint8_t note, float modulator, int8_t b GameInteractor::Instance->ExecuteHooks(note, modulator, bend); } -void GameInteractor_ExecuteOnCuccoOrChickenHatch() { - GameInteractor::Instance->ExecuteHooks(); -} - void GameInteractor_ExecuteOnShopSlotChangeHooks(uint8_t cursorIndex, int16_t price) { GameInteractor::Instance->ExecuteHooks(cursorIndex, price); } diff --git a/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.h b/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.h index 85a9bb57f2..39a1f35544 100644 --- a/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.h +++ b/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.h @@ -32,7 +32,6 @@ void GameInteractor_ExecuteOnSetDoAction(uint16_t action); void GameInteractor_ExecuteOnPlayerSfx(u16 sfxId); void GameInteractor_ExecuteOnOcarinaSongAction(); void GameInteractor_ExecuteOnOcarinaNote(uint8_t note, float modulator, int8_t bend); -void GameInteractor_ExecuteOnCuccoOrChickenHatch(); bool GameInteractor_ShouldActorInit(void* actor); void GameInteractor_ExecuteOnActorInit(void* actor); void GameInteractor_ExecuteOnActorSpawn(void* actor); diff --git a/soh/soh/Enhancements/randomizer/hook_handlers.cpp b/soh/soh/Enhancements/randomizer/hook_handlers.cpp index 15ac164ab1..b856cecdfc 100644 --- a/soh/soh/Enhancements/randomizer/hook_handlers.cpp +++ b/soh/soh/Enhancements/randomizer/hook_handlers.cpp @@ -297,11 +297,6 @@ void RandomizerOnFlagSetHandler(int16_t flagType, int16_t flag) { Flags_UnsetRandomizerInf(RAND_INF_CHILD_TRADES_HAS_CHICKEN); } - if (flagType == FLAG_EVENT_CHECK_INF && flag == EVENTCHKINF_OBTAINED_ZELDAS_LETTER && - !RAND_GET_OPTION(RSK_SHUFFLE_ZELDAS_LETTER)) { - Flags_SetRandomizerInf(RAND_INF_ZELDAS_LETTER); - } - if (flagType == FLAG_EVENT_CHECK_INF && flag == EVENTCHKINF_TALON_RETURNED_FROM_CASTLE) { if (Flags_GetEventChkInf(EVENTCHKINF_OBTAINED_POCKET_EGG)) { Flags_SetRandomizerInf(RAND_INF_TALON_SENT_MALON_HOME); @@ -2913,13 +2908,6 @@ void RandomizerOnKaleidoscopeUpdateHandler(int16_t inDungeonScene) { prevKaleidoState = gPlayState->pauseCtx.state; } -void RandomizerOnCuccoOrChickenHatch() { - if (LINK_IS_CHILD) { - Flags_UnsetRandomizerInf(RAND_INF_CHILD_TRADES_HAS_WEIRD_EGG); - Flags_SetRandomizerInf(RAND_INF_CHILD_TRADES_HAS_CHICKEN); - } -} - static void RandomizerRegisterHooks() { static uint32_t onFlagSetHook = 0; static uint32_t onSceneFlagSetHook = 0; @@ -2938,7 +2926,6 @@ static void RandomizerRegisterHooks() { static uint32_t onPlayDestroyHook = 0; static uint32_t onExitGameHook = 0; static uint32_t onKaleidoUpdateHook = 0; - static uint32_t onCuccoOrChickenHatchHook = 0; // register this outside OnLoadGame as VB is invoked before OnLoadGame COND_VB_SHOULD(VB_REVERT_SPOILING_ITEMS, true, { @@ -2971,7 +2958,6 @@ static void RandomizerRegisterHooks() { GameInteractor::Instance->UnregisterGameHook(onPlayDestroyHook); GameInteractor::Instance->UnregisterGameHook(onExitGameHook); GameInteractor::Instance->UnregisterGameHook(onKaleidoUpdateHook); - GameInteractor::Instance->UnregisterGameHook(onCuccoOrChickenHatchHook); onFlagSetHook = 0; onSceneFlagSetHook = 0; @@ -2990,7 +2976,6 @@ static void RandomizerRegisterHooks() { onPlayDestroyHook = 0; onExitGameHook = 0; onKaleidoUpdateHook = 0; - onCuccoOrChickenHatchHook = 0; if (!IS_RANDO) return; @@ -3038,8 +3023,6 @@ static void RandomizerRegisterHooks() { GameInteractor::Instance->RegisterGameHook(RandomizerOnExitGameHandler); onKaleidoUpdateHook = GameInteractor::Instance->RegisterGameHook( RandomizerOnKaleidoscopeUpdateHandler); - onCuccoOrChickenHatchHook = GameInteractor::Instance->RegisterGameHook( - RandomizerOnCuccoOrChickenHatch); if (RAND_GET_OPTION(RSK_FISHSANITY).IsNot(RO_FISHSANITY_OFF)) { OTRGlobals::Instance->gRandoContext->GetFishsanity()->InitializeFromSave(); diff --git a/soh/src/code/z_kankyo.c b/soh/src/code/z_kankyo.c index da6b29ce20..dc25416a67 100644 --- a/soh/src/code/z_kankyo.c +++ b/soh/src/code/z_kankyo.c @@ -6,8 +6,6 @@ #include "soh/frame_interpolation.h" #include "soh/OTRGlobals.h" #include "soh/ResourceManagerHelpers.h" -#include "soh/Enhancements/game-interactor/GameInteractor.h" -#include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h" #include "soh/Enhancements/savestate_serialize.h" typedef enum { @@ -2097,9 +2095,8 @@ void func_80075B44(PlayState* play) { gSaveContext.bgsDayCount++; gSaveContext.dogIsLost = true; Sfx_PlaySfxCentered(NA_SE_EV_CHICKEN_CRY_M); - if ((Inventory_ReplaceItem(play, ITEM_WEIRD_EGG, ITEM_CHICKEN) || Inventory_HatchPocketCucco(play)) && - play->csCtx.state == 0 && !Player_InCsMode(play)) { - GameInteractor_ExecuteOnCuccoOrChickenHatch(); + if ((Inventory_HatchWeirdEgg(play) || Inventory_HatchPocketCucco(play)) && play->csCtx.state == 0 && + !Player_InCsMode(play)) { Message_StartTextbox(play, 0x3066, NULL); } play->envCtx.unk_E0++; diff --git a/soh/src/code/z_parameter.c b/soh/src/code/z_parameter.c index 8196faef9d..34037b6661 100644 --- a/soh/src/code/z_parameter.c +++ b/soh/src/code/z_parameter.c @@ -2721,6 +2721,23 @@ s32 Inventory_ConsumeFairy(PlayState* play) { return 0; } +// SOH helper +bool Inventory_HatchWeirdEgg(PlayState* play) { + if (!IS_RANDO) { + return Inventory_ReplaceItem(play, ITEM_WEIRD_EGG, ITEM_CHICKEN); + } + + if (!LINK_IS_CHILD || !Flags_GetRandomizerInf(RAND_INF_CHILD_TRADES_HAS_WEIRD_EGG)) { + return 0; + } + + Flags_UnsetRandomizerInf(RAND_INF_CHILD_TRADES_HAS_WEIRD_EGG); + Flags_SetRandomizerInf(RAND_INF_CHILD_TRADES_HAS_CHICKEN); + Inventory_ReplaceItem(play, ITEM_WEIRD_EGG, ITEM_CHICKEN); + return 1; +} + +// SOH helper bool Inventory_HatchPocketCucco(PlayState* play) { if (!IS_RANDO) { return Inventory_ReplaceItem(play, ITEM_POCKET_EGG, ITEM_POCKET_CUCCO); diff --git a/soh/src/code/z_play.c b/soh/src/code/z_play.c index db5c8cb0ea..843fa301ee 100644 --- a/soh/src/code/z_play.c +++ b/soh/src/code/z_play.c @@ -500,8 +500,7 @@ void Play_Init(GameState* thisx) { gSaveContext.bgsDayCount++; gSaveContext.dogIsLost = true; - if (Inventory_ReplaceItem(play, ITEM_WEIRD_EGG, ITEM_CHICKEN) || Inventory_HatchPocketCucco(play)) { - GameInteractor_ExecuteOnCuccoOrChickenHatch(); + if (Inventory_HatchWeirdEgg(play) || Inventory_HatchPocketCucco(play)) { Message_StartTextbox(play, 0x3066, NULL); }