From a92c08dea1948481647a1d1061175162edd431f4 Mon Sep 17 00:00:00 2001 From: Pepe20129 <72659707+Pepe20129@users.noreply.github.com> Date: Wed, 27 Nov 2024 18:33:50 +0100 Subject: [PATCH] Fix some situations where trade items spoiled (#4569) * Fix some situations where trade items reverted * Update z_game_over.c * Hopefully fix mac --- soh/src/code/z_game_over.c | 4 +++- soh/src/code/z_parameter.c | 22 ++++++++++++---------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/soh/src/code/z_game_over.c b/soh/src/code/z_game_over.c index a2bdfc1a5..1850133aa 100644 --- a/soh/src/code/z_game_over.c +++ b/soh/src/code/z_game_over.c @@ -1,5 +1,7 @@ #include "global.h" #include "soh/OTRGlobals.h" +#include "soh/Enhancements/game-interactor/GameInteractor.h" +#include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h" void GameOver_Init(PlayState* play) { play->gameOverCtx.state = GAMEOVER_INACTIVE; @@ -34,7 +36,7 @@ void GameOver_Update(PlayState* play) { gSaveContext.eventInf[1] &= ~1; // search inventory for spoiling items and revert if necessary - if (!(IS_RANDO && Randomizer_GetSettingValue(RSK_SHUFFLE_ADULT_TRADE))) { + if (GameInteractor_Should(VB_REVERT_SPOILING_ITEMS, true)) { for (i = 0; i < ARRAY_COUNT(gSpoilingItems); i++) { if (INV_CONTENT(ITEM_POCKET_EGG) == gSpoilingItems[i]) { INV_CONTENT(gSpoilingItemReverts[i]) = gSpoilingItemReverts[i]; diff --git a/soh/src/code/z_parameter.c b/soh/src/code/z_parameter.c index 0792e71cf..754e40ae2 100644 --- a/soh/src/code/z_parameter.c +++ b/soh/src/code/z_parameter.c @@ -5685,17 +5685,19 @@ void Interface_Draw(PlayState* play) { } // Revert any spoiling trade quest items - for (svar1 = 0; svar1 < ARRAY_COUNT(gSpoilingItems); svar1++) { - if (INV_CONTENT(ITEM_TRADE_ADULT) == gSpoilingItems[svar1]) { - gSaveContext.eventInf[0] &= 0x7F80; - osSyncPrintf("EVENT_INF=%x\n", gSaveContext.eventInf[0]); - play->nextEntranceIndex = spoilingItemEntrances[svar1]; - INV_CONTENT(gSpoilingItemReverts[svar1]) = gSpoilingItemReverts[svar1]; + if (GameInteractor_Should(VB_REVERT_SPOILING_ITEMS, true)) { + for (svar1 = 0; svar1 < ARRAY_COUNT(gSpoilingItems); svar1++) { + if (INV_CONTENT(ITEM_TRADE_ADULT) == gSpoilingItems[svar1]) { + gSaveContext.eventInf[0] &= 0x7F80; + osSyncPrintf("EVENT_INF=%x\n", gSaveContext.eventInf[0]); + play->nextEntranceIndex = spoilingItemEntrances[svar1]; + INV_CONTENT(gSpoilingItemReverts[svar1]) = gSpoilingItemReverts[svar1]; - for (svar2 = 1; svar2 < ARRAY_COUNT(gSaveContext.equips.buttonItems); svar2++) { - if (gSaveContext.equips.buttonItems[svar2] == gSpoilingItems[svar1]) { - gSaveContext.equips.buttonItems[svar2] = gSpoilingItemReverts[svar1]; - Interface_LoadItemIcon1(play, svar2); + for (svar2 = 1; svar2 < ARRAY_COUNT(gSaveContext.equips.buttonItems); svar2++) { + if (gSaveContext.equips.buttonItems[svar2] == gSpoilingItems[svar1]) { + gSaveContext.equips.buttonItems[svar2] = gSpoilingItemReverts[svar1]; + Interface_LoadItemIcon1(play, svar2); + } } } }