From e66be83eb789cbdd3a4891aafd61ae34909bd876 Mon Sep 17 00:00:00 2001 From: Adam Bird Date: Thu, 5 Oct 2023 15:35:49 -0400 Subject: [PATCH] Fix quest type bleeding through saves (#3241) --- soh/soh/SaveManager.cpp | 9 +++++++-- soh/src/code/z_sram.c | 5 +++-- .../overlays/gamestates/ovl_file_choose/z_file_choose.c | 5 +++-- .../misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c | 2 +- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/soh/soh/SaveManager.cpp b/soh/soh/SaveManager.cpp index 651c9563c..e41c6b8ca 100644 --- a/soh/soh/SaveManager.cpp +++ b/soh/soh/SaveManager.cpp @@ -520,7 +520,7 @@ void SaveManager::InitFileNormal() { } gSaveContext.adultEquips.equipment = 0; gSaveContext.unk_54 = 0; - gSaveContext.savedSceneNum = 0x34; + gSaveContext.savedSceneNum = SCENE_LINKS_HOUSE; // Equipment for (int button = 0; button < ARRAY_COUNT(gSaveContext.equips.buttonItems); button++) { @@ -568,7 +568,6 @@ void SaveManager::InitFileNormal() { gSaveContext.fw.set = 0; gSaveContext.fw.tempSwchFlags = 0; gSaveContext.fw.tempCollectFlags = 0; - gSaveContext.backupFW = gSaveContext.fw; for (int flag = 0; flag < ARRAY_COUNT(gSaveContext.gsFlags); flag++) { gSaveContext.gsFlags[flag] = 0; } @@ -614,11 +613,17 @@ void SaveManager::InitFileNormal() { gSaveContext.magicLevel = 0; gSaveContext.infTable[29] = 1; gSaveContext.sceneFlags[5].swch = 0x40000000; + + // SoH specific + gSaveContext.backupFW = gSaveContext.fw; gSaveContext.pendingSale = ITEM_NONE; gSaveContext.pendingSaleMod = MOD_NONE; + // Boss Rush is set ahead of time in z_file_choose, otherwise init the save with the normal quest if (IS_BOSS_RUSH) { BossRush_InitSave(); + } else { + gSaveContext.questId = QUEST_NORMAL; } //RANDOTODO (ADD ITEMLOCATIONS TO GSAVECONTEXT) diff --git a/soh/src/code/z_sram.c b/soh/src/code/z_sram.c index fd2b5ebd9..1612c0fdc 100644 --- a/soh/src/code/z_sram.c +++ b/soh/src/code/z_sram.c @@ -220,8 +220,9 @@ void Sram_InitSave(FileChooseContext* fileChooseCtx) { gSaveContext.n64ddFlag = fileChooseCtx->n64ddFlag; - if (fileChooseCtx->questType[fileChooseCtx->buttonIndex] == 2 && strnlen(CVarGetString("gSpoilerLog", ""), 1) != 0) { - gSaveContext.questId = 2; + if (fileChooseCtx->questType[fileChooseCtx->buttonIndex] == QUEST_RANDOMIZER && + strnlen(CVarGetString("gSpoilerLog", ""), 1) != 0) { + gSaveContext.questId = QUEST_RANDOMIZER; Randomizer_InitSaveFile(); } diff --git a/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c b/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c index ef95b6a71..630a1159a 100644 --- a/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c +++ b/soh/src/overlays/gamestates/ovl_file_choose/z_file_choose.c @@ -989,7 +989,8 @@ void DrawSeedHashSprites(FileChooseContext* this) { gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 0xFF, 0xFF, 0xFF, alpha); // Draw Seed Icons for spoiler log - if (this->configMode == CM_QUEST_MENU && this->questType[this->buttonIndex] == QUEST_RANDOMIZER && strnlen(CVarGetString("gSpoilerLog", ""), 1) != 0 && fileSelectSpoilerFileLoaded) { + if (this->configMode == CM_QUEST_MENU && this->questType[this->buttonIndex] == QUEST_RANDOMIZER && + strnlen(CVarGetString("gSpoilerLog", ""), 1) != 0 && fileSelectSpoilerFileLoaded) { u16 xStart = 64; for (unsigned int i = 0; i < 5; i++) { SpriteLoad(this, GetSeedTexture(gSaveContext.seedIcons[i])); @@ -2818,7 +2819,7 @@ void FileChoose_ConfirmFile(GameState* thisx) { Audio_PlaySoundGeneral(NA_SE_SY_FSEL_DECIDE_L, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); // Reset Boss Rush because it's only ever saved in memory. if (IS_BOSS_RUSH) { - gSaveContext.questId = 0; + gSaveContext.questId = QUEST_NORMAL; } this->selectMode = SM_FADE_OUT; func_800F6964(0xF); diff --git a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c index 284f65e69..642fec066 100644 --- a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c +++ b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope_PAL.c @@ -4181,7 +4181,7 @@ void KaleidoScope_Update(PlayState* play) } else { play->state.running = 0; if (IS_BOSS_RUSH) { - gSaveContext.questId = 0; + gSaveContext.questId = QUEST_NORMAL; } SET_NEXT_GAMESTATE(&play->state, Opening_Init, OpeningContext); GameInteractor_ExecuteOnExitGame(gSaveContext.fileNum);