Fixes buying songs crash on Switch (#2899)

This commit is contained in:
Christopher Leggett 2023-05-20 09:24:02 -04:00 committed by GitHub
commit 4d02d89e03
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 48 additions and 35 deletions

View file

@ -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));
}