From 4d02d89e03727c8e4d71541ff8eb9a5cdf260e8f Mon Sep 17 00:00:00 2001 From: Christopher Leggett Date: Sat, 20 May 2023 09:24:02 -0400 Subject: Fixes buying songs crash on Switch (#2899) --- soh/src/code/z_parameter.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'soh/src/code') diff --git a/soh/src/code/z_parameter.c b/soh/src/code/z_parameter.c index 954ce1190..42bdbd77a 100644 --- a/soh/src/code/z_parameter.c +++ b/soh/src/code/z_parameter.c @@ -15,6 +15,7 @@ #endif #include "soh/Enhancements/game-interactor/GameInteractor.h" +#include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h" #define DO_ACTION_TEX_WIDTH() 48 @@ -1706,7 +1707,7 @@ u8 Return_Item_Entry(GetItemEntry itemEntry, ItemID returnItem ) { // Processes Item_Give returns u8 Return_Item(u8 itemID, ModIndex modId, ItemID returnItem) { - uint32_t get = GetGIID(itemID); + int32_t get = GetGIID(itemID); if (get == -1) { modId = MOD_RANDOMIZER; get = itemID; @@ -6158,8 +6159,13 @@ void Interface_Update(PlayState* play) { u16 tempSaleMod = gSaveContext.pendingSaleMod; gSaveContext.pendingSale = ITEM_NONE; gSaveContext.pendingSaleMod = MOD_NONE; - if (tempSaleMod == 0) { - tempSaleItem = GetGIID(tempSaleItem); + if (tempSaleMod == MOD_NONE) { + s16 giid = GetGIID(tempSaleItem); + if (giid == -1) { + tempSaleMod = MOD_RANDOMIZER; + } else { + tempSaleItem = giid; + } } GameInteractor_ExecuteOnSaleEndHooks(ItemTable_RetrieveEntry(tempSaleMod, tempSaleItem)); } -- cgit v1.2.3 From 0b47a19c2c6e17c45349a2f47e07d75024249701 Mon Sep 17 00:00:00 2001 From: Malkierian Date: Sat, 20 May 2023 09:05:47 -0700 Subject: Mask Sale Fix (#2900) --- soh/src/code/z_parameter.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'soh/src/code') diff --git a/soh/src/code/z_parameter.c b/soh/src/code/z_parameter.c index 42bdbd77a..410fd22a4 100644 --- a/soh/src/code/z_parameter.c +++ b/soh/src/code/z_parameter.c @@ -1707,6 +1707,11 @@ u8 Return_Item_Entry(GetItemEntry itemEntry, ItemID returnItem ) { // Processes Item_Give returns u8 Return_Item(u8 itemID, ModIndex modId, ItemID returnItem) { + // ITEM_SOLD_OUT doesn't have an ItemTable entry, so pass custom entry instead + if (itemID == ITEM_SOLD_OUT) { + GetItemEntry gie = { ITEM_SOLD_OUT, 0, 0, 0, 0, 0, 0, 0, false, ITEM_FROM_NPC, ITEM_CATEGORY_LESSER, NULL }; + return Return_Item_Entry(gie, returnItem); + } int32_t get = GetGIID(itemID); if (get == -1) { modId = MOD_RANDOMIZER; -- cgit v1.2.3 From cf711d916408f9355ca8c6507d559802318dfe44 Mon Sep 17 00:00:00 2001 From: Malkierian Date: Sun, 21 May 2023 09:13:38 -0700 Subject: Initialize `gSlotAgeReqs[SLOT_TRADE_CHILD]` and `gItemAgeReqs[ITEM_MASK_BUNNY]` on load initialization according to `gMMBunnyHood` and `gTimelessEquipment` to prevent bunny hood from being unequipped from adult equips on first load. (#2904) Move the code to change those values based on the child trade slot item to the selecting mask loop to not be setting them every frame just because you're in the inventory. --- soh/src/code/z_play.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'soh/src/code') diff --git a/soh/src/code/z_play.c b/soh/src/code/z_play.c index 9ac45cdcc..3804b5bfc 100644 --- a/soh/src/code/z_play.c +++ b/soh/src/code/z_play.c @@ -604,6 +604,15 @@ void Play_Init(GameState* thisx) { (s32)(zAllocAligned + zAllocSize) - (s32)(zAllocAligned - zAlloc)); Fault_AddClient(&D_801614B8, ZeldaArena_Display, NULL, NULL); + // In order to keep bunny hood equipped on first load, we need to pre-set the age reqs for the item and slot + if (CVarGetInteger("gMMBunnyHood", 0) || CVarGetInteger("gTimelessEquipment", 0)) { + gItemAgeReqs[ITEM_MASK_BUNNY] = 9; + if(INV_CONTENT(ITEM_TRADE_CHILD) == ITEM_MASK_BUNNY) + gSlotAgeReqs[SLOT_TRADE_CHILD] = 9; + } + else { + gItemAgeReqs[ITEM_MASK_BUNNY] = gSlotAgeReqs[SLOT_TRADE_CHILD] = 1; + } func_800304DC(play, &play->actorCtx, play->linkActorEntry); while (!func_800973FC(play, &play->roomCtx)) { -- cgit v1.2.3