summaryrefslogtreecommitdiff
path: root/soh/src/code/z_parameter.c
diff options
context:
space:
mode:
authorMalkierian <malkierian@gmail.com>2023-04-02 01:47:23 -0700
committerGitHub <noreply@github.com>2023-04-02 04:47:23 -0400
commit04d0cd8532c70143511fd09cfca8a1091cc31d4b (patch)
tree4790ed624be8f361676e75ca4ae2c6f78e8a441a /soh/src/code/z_parameter.c
parentb099b5649beb13ec9cce1ce4f9e2de94c518e964 (diff)
Adds `OnTransitionEnd` hook to `GameInteractor`, called at the end of a transition after all mid-transition setup is called. (#2635)
Transitions final autosave location to `OnTransitionEnd`. Adds functionality to autosave to set a delayed save flag if AutoSave is set to Major or All Items and one is obtained in a grotto, to avoid grotto autosaving but still provide for the autosave when location-based saving is off. Fixes small bug with item lookup where sometimes an item's `modIndex` would sometimes be reported one way, but the way Randomizer does things it would be in a the other `modIndex`, and the lookup would fail. Minor variable name clarification in ItemTableManager. Modifies AutoSave to account for item ID overlap from `MOD_RANDOMIZER` table (all items in the randomizer table is considered major for AutoSave purposes except ice traps).
Diffstat (limited to 'soh/src/code/z_parameter.c')
-rw-r--r--soh/src/code/z_parameter.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/soh/src/code/z_parameter.c b/soh/src/code/z_parameter.c
index b3cece3b5..488c9a320 100644
--- a/soh/src/code/z_parameter.c
+++ b/soh/src/code/z_parameter.c
@@ -1704,8 +1704,13 @@ u8 Return_Item_Entry(GetItemEntry itemEntry, ItemID returnItem ) {
}
// Processes Item_Give returns
-u8 Return_Item(u8 item, ModIndex modId, ItemID returnItem) {
- return Return_Item_Entry(ItemTable_RetrieveEntry(modId, item), returnItem);
+u8 Return_Item(u8 itemID, ModIndex modId, ItemID returnItem) {
+ uint32_t get = GetGIID(itemID);
+ if (get == -1) {
+ modId = MOD_RANDOMIZER;
+ get = itemID;
+ }
+ return Return_Item_Entry(ItemTable_RetrieveEntry(modId, get), returnItem);
}
/**
@@ -2313,7 +2318,7 @@ u8 Item_Give(PlayState* play, u8 item) {
}
u16 Randomizer_Item_Give(PlayState* play, GetItemEntry giEntry) {
- uint16_t item = giEntry.itemId;
+ uint16_t item = giEntry.getItemId;
uint16_t temp;
uint16_t i;
uint16_t slot;
@@ -6196,11 +6201,16 @@ void Interface_Update(PlayState* play) {
Audio_PlaySoundGeneral(NA_SE_SY_RUPY_COUNT, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8);
}
if (gSaveContext.rupeeAccumulator == 0) {
- u16 tempSaleItem = gSaveContext.pendingSale;
- u16 tempSaleMod = gSaveContext.pendingSaleMod;
- gSaveContext.pendingSale = ITEM_NONE;
- gSaveContext.pendingSaleMod = MOD_NONE;
- GameInteractor_ExecuteOnSaleEndHooks(ItemTable_RetrieveEntry(tempSaleMod,tempSaleItem));
+ if (gSaveContext.pendingSale != ITEM_NONE) {
+ u16 tempSaleItem = gSaveContext.pendingSale;
+ u16 tempSaleMod = gSaveContext.pendingSaleMod;
+ gSaveContext.pendingSale = ITEM_NONE;
+ gSaveContext.pendingSaleMod = MOD_NONE;
+ if (tempSaleMod == 0) {
+ tempSaleItem = GetGIID(tempSaleItem);
+ }
+ GameInteractor_ExecuteOnSaleEndHooks(ItemTable_RetrieveEntry(tempSaleMod, tempSaleItem));
+ }
}
} else {
gSaveContext.rupeeAccumulator = 0;