diff --git a/soh/soh/Enhancements/mods.cpp b/soh/soh/Enhancements/mods.cpp index 6d66ff055..0bbeff8ca 100644 --- a/soh/soh/Enhancements/mods.cpp +++ b/soh/soh/Enhancements/mods.cpp @@ -35,8 +35,6 @@ extern PlayState* gPlayState; extern void Overlay_DisplayText(float duration, const char* text); uint32_t ResourceMgr_IsSceneMasterQuest(s16 sceneNum); } -bool performDelayedSave = false; -bool performSave = false; // TODO: When there's more uses of something like this, create a new GI::RawAction? void ReloadSceneTogglingLinkAge() { @@ -258,14 +256,12 @@ void RegisterOcarinaTimeTravel() { void AutoSave(GetItemEntry itemEntry) { u8 item = itemEntry.itemId; + bool performSave = false; // Don't autosave immediately after buying items from shops to prevent getting them for free! // Don't autosave in the Chamber of Sages since resuming from that map breaks the game // Don't autosave during the Ganon fight when picking up the Master Sword - // Don't autosave in the fishing pond to prevent getting rod on B outside of the pond - // Don't autosave in the bombchu bowling alley to prevent having chus on B outside of the minigame - // Don't autosave in grottos since resuming from grottos breaks the game. if ((CVarGetInteger("gAutosave", AUTOSAVE_OFF) != AUTOSAVE_OFF) && (gPlayState != NULL) && (gSaveContext.pendingSale == ITEM_NONE) && - (gPlayState->gameplayFrames > 60 && gSaveContext.cutsceneIndex < 0xFFF0) && (gPlayState->sceneNum != SCENE_GANON_BOSS)) { + (gPlayState->gameplayFrames > 60 && gSaveContext.cutsceneIndex < 0xFFF0) && (gPlayState->sceneNum != SCENE_GANON_BOSS) && (gPlayState->sceneNum != SCENE_CHAMBER_OF_THE_SAGES)) { if (((CVarGetInteger("gAutosave", AUTOSAVE_OFF) == AUTOSAVE_LOCATION_AND_ALL_ITEMS) || (CVarGetInteger("gAutosave", AUTOSAVE_OFF) == AUTOSAVE_ALL_ITEMS)) && (item != ITEM_NONE)) { // Autosave for all items performSave = true; @@ -326,25 +322,9 @@ void AutoSave(GetItemEntry itemEntry) { CVarGetInteger("gAutosave", AUTOSAVE_OFF) == AUTOSAVE_LOCATION) { performSave = true; } - if (gPlayState->sceneNum == SCENE_FAIRYS_FOUNTAIN || gPlayState->sceneNum == SCENE_GROTTOS || - gPlayState->sceneNum == SCENE_CHAMBER_OF_THE_SAGES || gPlayState->sceneNum == SCENE_FISHING_POND || - gPlayState->sceneNum == SCENE_BOMBCHU_BOWLING_ALLEY) { - if (CVarGetInteger("gAutosave", AUTOSAVE_OFF) == AUTOSAVE_LOCATION_AND_MAJOR_ITEMS || - CVarGetInteger("gAutosave", AUTOSAVE_OFF) == AUTOSAVE_LOCATION_AND_ALL_ITEMS || - CVarGetInteger("gAutosave", AUTOSAVE_OFF) == AUTOSAVE_LOCATION) { - performSave = false; - return; - } - if (performSave) { - performSave = false; - performDelayedSave = true; - } - return; - } - if (performSave || performDelayedSave) { + if (performSave) { Play_PerformSave(gPlayState); performSave = false; - performDelayedSave = false; } } } diff --git a/soh/src/code/z_play.c b/soh/src/code/z_play.c index bf7016884..841de8f13 100644 --- a/soh/src/code/z_play.c +++ b/soh/src/code/z_play.c @@ -2329,8 +2329,28 @@ void Play_PerformSave(PlayState* play) { if (play != NULL && gSaveContext.fileNum != 0xFF) { Play_SaveSceneFlags(play); gSaveContext.savedSceneNum = play->sceneNum; + + // Track values from temp B + uint8_t prevB = gSaveContext.equips.buttonItems[0]; + uint8_t prevStatus = gSaveContext.buttonStatus[0]; + + // Replicate the B button restore from minigames/epona that kaleido does + if (gSaveContext.equips.buttonItems[0] == ITEM_SLINGSHOT || + gSaveContext.equips.buttonItems[0] == ITEM_BOW || + gSaveContext.equips.buttonItems[0] == ITEM_BOMBCHU || + gSaveContext.equips.buttonItems[0] == ITEM_FISHING_POLE || + (gSaveContext.equips.buttonItems[0] == ITEM_NONE && !Flags_GetInfTable(INFTABLE_SWORDLESS))) { + + gSaveContext.equips.buttonItems[0] = gSaveContext.buttonStatus[0]; + Interface_RandoRestoreSwordless(); + } + Save_SaveFile(); + // Restore temp B values back + gSaveContext.equips.buttonItems[0] = prevB; + gSaveContext.buttonStatus[0] = prevStatus; + uint8_t triforceHuntCompleted = IS_RANDO && gSaveContext.triforcePiecesCollected == Randomizer_GetSettingValue(RSK_TRIFORCE_HUNT_PIECES_REQUIRED) &&