diff options
| author | Malkierian <malkierian@gmail.com> | 2023-04-02 01:47:23 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-04-02 04:47:23 -0400 |
| commit | 04d0cd8532c70143511fd09cfca8a1091cc31d4b (patch) | |
| tree | 4790ed624be8f361676e75ca4ae2c6f78e8a441a /soh/src/code | |
| parent | b099b5649beb13ec9cce1ce4f9e2de94c518e964 (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')
| -rw-r--r-- | soh/src/code/z_parameter.c | 26 | ||||
| -rw-r--r-- | soh/src/code/z_play.c | 11 |
2 files changed, 20 insertions, 17 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; diff --git a/soh/src/code/z_play.c b/soh/src/code/z_play.c index 418eff501..5d280ca0b 100644 --- a/soh/src/code/z_play.c +++ b/soh/src/code/z_play.c @@ -869,15 +869,8 @@ void Play_Update(PlayState* play) { gTrnsnUnkState = 0; R_UPDATE_RATE = 3; } - - // Autosave on area transition unless you're in a cutscene or a grotto since resuming from grottos breaks the game - // Also don't save when you first load a file to prevent consumables like magic from being lost - // Also don't save if there's a pending shop sale to prevent getting the item for a discount! - if ((CVarGetInteger("gAutosave", 0) >= 1) && (CVarGetInteger("gAutosave", 0) <= 3) && - (gSaveContext.cutsceneIndex < 0xFFF0) && (play->gameplayFrames > 60) && (gSaveContext.pendingSale == ITEM_NONE) && - (play->sceneNum != SCENE_YOUSEI_IZUMI_TATE) && (play->sceneNum != SCENE_KAKUSIANA) && (play->sceneNum != SCENE_KENJYANOMA)) { - Play_PerformSave(play); - } + + GameInteractor_ExecuteOnTransitionEndHooks(play->sceneNum); } play->sceneLoadFlag = 0; } else { |
