From 17a7f33c3be5b463fbf5b7b5cb93fd7379d67a80 Mon Sep 17 00:00:00 2001 From: Malkierian Date: Sun, 12 Nov 2023 15:19:16 -0700 Subject: [PATCH] Restore temp B when B item is none, bow, slingshot, bombchu, or fishing rod, on save (affecting only local SaveContext in SaveBase). Should be swordless safe. --- soh/soh/SaveManager.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/soh/soh/SaveManager.cpp b/soh/soh/SaveManager.cpp index 14ab736dced..562b8628ba0 100644 --- a/soh/soh/SaveManager.cpp +++ b/soh/soh/SaveManager.cpp @@ -1858,7 +1858,25 @@ void SaveManager::LoadBaseVersion4() { SaveManager::Instance->LoadData("dogParams", gSaveContext.dogParams); } +#define SWORDLESS_STATUS ITEM_NONE_FE + void SaveManager::SaveBase(SaveContext* saveContext, int sectionID, bool fullSave) { + // Restore temp B on local context before saving + if ((saveContext->equips.buttonItems[0] == ITEM_SLINGSHOT) || + (saveContext->equips.buttonItems[0] == ITEM_BOW) || + (saveContext->equips.buttonItems[0] == ITEM_BOMBCHU) || + (saveContext->equips.buttonItems[0] == ITEM_FISHING_POLE) || + (saveContext->equips.buttonItems[0] == ITEM_NONE)) { + if ((saveContext->equips.buttonItems[0] != ITEM_NONE) || (saveContext->infTable[29] == 0) || + IS_RANDO && saveContext->buttonStatus[0] == SWORDLESS_STATUS) { + saveContext->equips.buttonItems[0] = saveContext->buttonStatus[0]; + + if (IS_RANDO && gSaveContext.buttonStatus[0] == SWORDLESS_STATUS) { + gSaveContext.equips.buttonItems[0] = ITEM_NONE; + gSaveContext.buttonStatus[0] = BTN_ENABLED; + } + } + } SaveManager::Instance->SaveData("entranceIndex", saveContext->entranceIndex); SaveManager::Instance->SaveData("linkAge", saveContext->linkAge); SaveManager::Instance->SaveData("cutsceneIndex", saveContext->cutsceneIndex);