Fix some situations where trade items spoiled (#4569)

* Fix some situations where trade items reverted

* Update z_game_over.c

* Hopefully fix mac
This commit is contained in:
Pepe20129 2024-11-27 18:33:50 +01:00 committed by GitHub
parent 5b7b38f198
commit a92c08dea1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 15 additions and 11 deletions

View File

@ -1,5 +1,7 @@
#include "global.h" #include "global.h"
#include "soh/OTRGlobals.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) { void GameOver_Init(PlayState* play) {
play->gameOverCtx.state = GAMEOVER_INACTIVE; play->gameOverCtx.state = GAMEOVER_INACTIVE;
@ -34,7 +36,7 @@ void GameOver_Update(PlayState* play) {
gSaveContext.eventInf[1] &= ~1; gSaveContext.eventInf[1] &= ~1;
// search inventory for spoiling items and revert if necessary // 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++) { for (i = 0; i < ARRAY_COUNT(gSpoilingItems); i++) {
if (INV_CONTENT(ITEM_POCKET_EGG) == gSpoilingItems[i]) { if (INV_CONTENT(ITEM_POCKET_EGG) == gSpoilingItems[i]) {
INV_CONTENT(gSpoilingItemReverts[i]) = gSpoilingItemReverts[i]; INV_CONTENT(gSpoilingItemReverts[i]) = gSpoilingItemReverts[i];

View File

@ -5685,17 +5685,19 @@ void Interface_Draw(PlayState* play) {
} }
// Revert any spoiling trade quest items // Revert any spoiling trade quest items
for (svar1 = 0; svar1 < ARRAY_COUNT(gSpoilingItems); svar1++) { if (GameInteractor_Should(VB_REVERT_SPOILING_ITEMS, true)) {
if (INV_CONTENT(ITEM_TRADE_ADULT) == gSpoilingItems[svar1]) { for (svar1 = 0; svar1 < ARRAY_COUNT(gSpoilingItems); svar1++) {
gSaveContext.eventInf[0] &= 0x7F80; if (INV_CONTENT(ITEM_TRADE_ADULT) == gSpoilingItems[svar1]) {
osSyncPrintf("EVENT_INF=%x\n", gSaveContext.eventInf[0]); gSaveContext.eventInf[0] &= 0x7F80;
play->nextEntranceIndex = spoilingItemEntrances[svar1]; osSyncPrintf("EVENT_INF=%x\n", gSaveContext.eventInf[0]);
INV_CONTENT(gSpoilingItemReverts[svar1]) = gSpoilingItemReverts[svar1]; play->nextEntranceIndex = spoilingItemEntrances[svar1];
INV_CONTENT(gSpoilingItemReverts[svar1]) = gSpoilingItemReverts[svar1];
for (svar2 = 1; svar2 < ARRAY_COUNT(gSaveContext.equips.buttonItems); svar2++) { for (svar2 = 1; svar2 < ARRAY_COUNT(gSaveContext.equips.buttonItems); svar2++) {
if (gSaveContext.equips.buttonItems[svar2] == gSpoilingItems[svar1]) { if (gSaveContext.equips.buttonItems[svar2] == gSpoilingItems[svar1]) {
gSaveContext.equips.buttonItems[svar2] = gSpoilingItemReverts[svar1]; gSaveContext.equips.buttonItems[svar2] = gSpoilingItemReverts[svar1];
Interface_LoadItemIcon1(play, svar2); Interface_LoadItemIcon1(play, svar2);
}
} }
} }
} }