From fe413fd6759ecada7c0679762e7c3010a870c994 Mon Sep 17 00:00:00 2001 From: aMannus Date: Sun, 4 Sep 2022 23:09:17 +0200 Subject: [PATCH 01/10] Set key colors to be on by default --- libultraship/libultraship/ImGuiImpl.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/libultraship/libultraship/ImGuiImpl.cpp b/libultraship/libultraship/ImGuiImpl.cpp index 13e8ac078..4883f5a0e 100644 --- a/libultraship/libultraship/ImGuiImpl.cpp +++ b/libultraship/libultraship/ImGuiImpl.cpp @@ -329,6 +329,7 @@ namespace SohImGui { statsWindowOpen = CVar_GetS32("gStatsEnabled", 0); CVar_RegisterS32("gRandomizeRupeeNames", 1); CVar_RegisterS32("gRandoRelevantNavi", 1); + CVar_RegisterS32("gRandoMatchKeyColors", 1); #ifdef __SWITCH__ Ship::Switch::SetupFont(io->Fonts); #endif From 983ab139d5a088c022ee4571c224e74d15237dff Mon Sep 17 00:00:00 2001 From: aMannus Date: Mon, 5 Sep 2022 00:35:56 +0200 Subject: [PATCH 02/10] Add another flag to skip mask shop --- soh/src/code/z_sram.c | 1 + 1 file changed, 1 insertion(+) diff --git a/soh/src/code/z_sram.c b/soh/src/code/z_sram.c index 9a9407277..524fe353f 100644 --- a/soh/src/code/z_sram.c +++ b/soh/src/code/z_sram.c @@ -521,6 +521,7 @@ void Sram_InitSave(FileChooseContext* fileChooseCtx) { // complete mask quest if (Randomizer_GetSettingValue(RSK_COMPLETE_MASK_QUEST)) { + gSaveContext.infTable[7] |= 0x80; // Soldier Wears Keaton Mask gSaveContext.itemGetInf[3] |= 0x100; // Sold Keaton Mask gSaveContext.itemGetInf[3] |= 0x200; // Sold Skull Mask gSaveContext.itemGetInf[3] |= 0x400; // Sold Spooky Mask From 39852c927879484269070dc8a7929b73fd848d04 Mon Sep 17 00:00:00 2001 From: aMannus Date: Mon, 5 Sep 2022 11:46:50 +0200 Subject: [PATCH 03/10] Fix Sold Out bug --- soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_item.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_item.c b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_item.c index 2fc3e3e15..8e776e407 100644 --- a/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_item.c +++ b/soh/src/overlays/misc/ovl_kaleido_scope/z_kaleido_item.c @@ -381,7 +381,11 @@ void KaleidoScope_DrawItemSelect(GlobalContext* globalCtx) { --INV_CONTENT(ITEM_TRADE_CHILD); } else if ((pauseCtx->stickRelX < -30 || pauseCtx->stickRelX > 30 || pauseCtx->stickRelY < -30 || pauseCtx->stickRelY > 30) || dpad && CHECK_BTN_ANY(input->press.button, BTN_DUP | BTN_DDOWN | BTN_DLEFT | BTN_DRIGHT)) { - INV_CONTENT(ITEM_TRADE_CHILD) ^= ITEM_MASK_KEATON ^ ITEM_MASK_TRUTH; + if (INV_CONTENT(ITEM_TRADE_CHILD) == ITEM_LETTER_ZELDA) { + INV_CONTENT(ITEM_TRADE_CHILD) = ITEM_MASK_KEATON; + } else { + INV_CONTENT(ITEM_TRADE_CHILD) ^= ITEM_MASK_KEATON ^ ITEM_MASK_TRUTH; + } Audio_PlaySoundGeneral(NA_SE_SY_CURSOR, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); } for (uint16_t cSlotIndex = 0; cSlotIndex < ARRAY_COUNT(gSaveContext.equips.cButtonSlots); cSlotIndex++) { From 9afe3ca746a11f75e95c4dbacf6d98334310cf16 Mon Sep 17 00:00:00 2001 From: aMannus Date: Mon, 5 Sep 2022 16:48:59 +0200 Subject: [PATCH 04/10] Fix gerudo keys, add disabled checkbox --- soh/soh/Enhancements/randomizer/randomizer.cpp | 1 + soh/soh/GameMenuBar.cpp | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/soh/soh/Enhancements/randomizer/randomizer.cpp b/soh/soh/Enhancements/randomizer/randomizer.cpp index 0187d5486..8a619801d 100644 --- a/soh/soh/Enhancements/randomizer/randomizer.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer.cpp @@ -907,6 +907,7 @@ void Randomizer::ParseRandomizerSettingsFile(const char* spoilerFileName) { } else if (it.value() == "Anywhere") { gSaveContext.randoSettings[index].value = 3; } + break; case RSK_KEYSANITY: if(it.value() == "Start With") { gSaveContext.randoSettings[index].value = 0; diff --git a/soh/soh/GameMenuBar.cpp b/soh/soh/GameMenuBar.cpp index b202b6a05..8fede76b8 100644 --- a/soh/soh/GameMenuBar.cpp +++ b/soh/soh/GameMenuBar.cpp @@ -1392,7 +1392,22 @@ namespace GameMenuBar { UIWidgets::Tooltip( "When obtaining rupees, randomize what the rupee is called in the textbox." ); - UIWidgets::PaddedEnhancementCheckbox("Key Colors Match Dungeon", "gRandoMatchKeyColors", true, false); + + // Only disable the key colors checkbox when none of the keysanity settings are set to "Any Dungeon", "Overworld" or "Anywhere" + bool disableKeyColors = true; + + if (OTRGlobals::Instance->gRandomizer->GetRandoSettingValue(RSK_KEYSANITY) > 2 || + OTRGlobals::Instance->gRandomizer->GetRandoSettingValue(RSK_GERUDO_KEYS) > 0 || + OTRGlobals::Instance->gRandomizer->GetRandoSettingValue(RSK_BOSS_KEYSANITY) > 2 || + OTRGlobals::Instance->gRandomizer->GetRandoSettingValue(RSK_GANONS_BOSS_KEY) > 2 || + !gSaveContext.n64ddFlag) { + disableKeyColors = false; + } + + const char* disableKeyColorsText = "This setting is disabled because a savefile is loaded without any key shuffle settings set to \"Any Dungeon\", \"Overworld\" or \"Anywhere\""; + + UIWidgets::PaddedEnhancementCheckbox("Key Colors Match Dungeon", "gRandoMatchKeyColors", true, false, + disableKeyColors, disableKeyColorsText); UIWidgets::Tooltip( "Matches the color of small keys and boss keys to the dungeon they belong to. " "This helps identify keys from afar and adds a little bit of flair.\n\nThis only " From fb5aff393aa97a0136635f93e34b45567b123947 Mon Sep 17 00:00:00 2001 From: aMannus Date: Mon, 5 Sep 2022 16:54:02 +0200 Subject: [PATCH 05/10] tooltip line break --- soh/soh/GameMenuBar.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/soh/soh/GameMenuBar.cpp b/soh/soh/GameMenuBar.cpp index 8fede76b8..13a945cfc 100644 --- a/soh/soh/GameMenuBar.cpp +++ b/soh/soh/GameMenuBar.cpp @@ -1404,7 +1404,9 @@ namespace GameMenuBar { disableKeyColors = false; } - const char* disableKeyColorsText = "This setting is disabled because a savefile is loaded without any key shuffle settings set to \"Any Dungeon\", \"Overworld\" or \"Anywhere\""; + const char* disableKeyColorsText = + "This setting is disabled because a savefile is loaded without any key\n" + "shuffle settings set to \"Any Dungeon\", \"Overworld\" or \"Anywhere\""; UIWidgets::PaddedEnhancementCheckbox("Key Colors Match Dungeon", "gRandoMatchKeyColors", true, false, disableKeyColors, disableKeyColorsText); From 1c13fdec5ff5eff4a1e7ca7b72617e22ef6ef9f9 Mon Sep 17 00:00:00 2001 From: Garrett Cox Date: Mon, 5 Sep 2022 14:55:34 -0500 Subject: [PATCH 06/10] Add trials required and merchant prices to save file instead of loading from active spoiler log --- soh/include/macros.h | 1 + .../Enhancements/randomizer/randomizer.cpp | 8 ++-- soh/soh/Enhancements/randomizer/randomizer.h | 6 ++- soh/soh/SaveManager.cpp | 44 +++++++++++++++++++ soh/src/code/z_sram.c | 1 - 5 files changed, 53 insertions(+), 7 deletions(-) diff --git a/soh/include/macros.h b/soh/include/macros.h index 5c441dad9..6360e7970 100644 --- a/soh/include/macros.h +++ b/soh/include/macros.h @@ -261,5 +261,6 @@ extern GraphicsContext* __gfxCtx; #define SEG_ADDR(seg, addr) (addr | (seg << 24) | 1) #define NUM_TRIALS 6 +#define NUM_SCRUBS 35 #endif diff --git a/soh/soh/Enhancements/randomizer/randomizer.cpp b/soh/soh/Enhancements/randomizer/randomizer.cpp index 0187d5486..f62079130 100644 --- a/soh/soh/Enhancements/randomizer/randomizer.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer.cpp @@ -110,7 +110,7 @@ Sprite* Randomizer::GetSeedTexture(uint8_t index) { Randomizer::~Randomizer() { this->randoSettings.clear(); this->itemLocations.clear(); - this->randomizerMerchantPrices.clear(); + this->merchantPrices.clear(); } std::unordered_map spoilerFileTrialToEnum = { @@ -1205,7 +1205,7 @@ void Randomizer::ParseItemLocationsFile(const char* spoilerFileName, bool silent gSaveContext.itemLocations[index].check = SpoilerfileCheckNameToEnum[it.key()]; gSaveContext.itemLocations[index].get = SpoilerfileGetNameToEnum[itemit.value()]; } else if (itemit.key() == "price") { - randomizerMerchantPrices[gSaveContext.itemLocations[index].check] = itemit.value(); + merchantPrices[gSaveContext.itemLocations[index].check] = itemit.value(); } } } else { @@ -2416,8 +2416,8 @@ ScrubIdentity Randomizer::IdentifyScrub(s32 sceneNum, s32 actorParams, s32 respa break; } - if (randomizerMerchantPrices.find(scrubIdentity.randomizerCheck) != randomizerMerchantPrices.end()) { - scrubIdentity.itemPrice = randomizerMerchantPrices[scrubIdentity.randomizerCheck]; + if (merchantPrices.find(scrubIdentity.randomizerCheck) != merchantPrices.end()) { + scrubIdentity.itemPrice = merchantPrices[scrubIdentity.randomizerCheck]; } return scrubIdentity; diff --git a/soh/soh/Enhancements/randomizer/randomizer.h b/soh/soh/Enhancements/randomizer/randomizer.h index 0ebb8d694..c91b28b1d 100644 --- a/soh/soh/Enhancements/randomizer/randomizer.h +++ b/soh/soh/Enhancements/randomizer/randomizer.h @@ -14,13 +14,11 @@ class Randomizer { private: std::unordered_map itemLocations; std::unordered_map hintLocations; - std::unordered_map trialsRequired; std::string childAltarText; std::string adultAltarText; std::string ganonHintText; std::string ganonText; std::unordered_map randoSettings; - std::unordered_map randomizerMerchantPrices; void ParseRandomizerSettingsFile(const char* spoilerFileName); void ParseHintLocationsFile(const char* spoilerFileName); void ParseRequiredTrialsFile(const char* spoilerFileName); @@ -38,6 +36,10 @@ class Randomizer { static const std::string rupeeMessageTableID; static const std::string NaviRandoMessageTableID; + // Public for now to be accessed by SaveManager, will be made private again soon :tm: + std::unordered_map trialsRequired; + std::unordered_map merchantPrices; + static Sprite* GetSeedTexture(uint8_t index); s16 GetItemModelFromId(s16 itemId); s32 GetItemIDFromGetItemID(s32 getItemId); diff --git a/soh/soh/SaveManager.cpp b/soh/soh/SaveManager.cpp index 3305f1d70..a932f31a4 100644 --- a/soh/soh/SaveManager.cpp +++ b/soh/soh/SaveManager.cpp @@ -91,6 +91,28 @@ void SaveManager::LoadRandomizerVersion1() { } SaveManager::Instance->LoadData("adultTradeItems", gSaveContext.adultTradeItems); + + std::shared_ptr randomizer = OTRGlobals::Instance->gRandomizer; + + SaveManager::Instance->LoadArray("merchantPrices", NUM_SCRUBS, [&](size_t i) { + SaveManager::Instance->LoadStruct("", [&]() { + RandomizerCheck rc; + SaveManager::Instance->LoadData("check", rc); + uint32_t price; + SaveManager::Instance->LoadData("price", price); + randomizer->merchantPrices[rc] = price; + }); + }); + + SaveManager::Instance->LoadArray("trialsRequired", NUM_TRIALS, [&](size_t i) { + SaveManager::Instance->LoadStruct("", [&]() { + RandomizerInf inf; + SaveManager::Instance->LoadData("inf", inf); + bool required; + SaveManager::Instance->LoadData("price", required); + randomizer->trialsRequired[inf] = required; + }); + }); } void SaveManager::SaveRandomizer() { @@ -135,6 +157,28 @@ void SaveManager::SaveRandomizer() { } SaveManager::Instance->SaveData("adultTradeItems", gSaveContext.adultTradeItems); + + std::shared_ptr randomizer = OTRGlobals::Instance->gRandomizer; + + std::vector> merchantPrices; + for (const auto & [ check, price ] : randomizer->merchantPrices) { + merchantPrices.push_back(std::make_pair(check, price)); + } + + SaveManager::Instance->SaveArray("merchantPrices", NUM_SCRUBS, [&](size_t i) { + SaveManager::Instance->SaveStruct("", [&]() { + SaveManager::Instance->SaveData("check", merchantPrices[i].first); + SaveManager::Instance->SaveData("price", merchantPrices[i].second); + }); + }); + + SaveManager::Instance->SaveArray("trialsRequired", NUM_TRIALS, [&](size_t i) { + SaveManager::Instance->SaveStruct("", [&]() { + RandomizerInf inf = RandomizerInf(RAND_INF_TRIALS_DONE_LIGHT_TRIAL - i); + SaveManager::Instance->SaveData("inf", inf); + SaveManager::Instance->SaveData("required", randomizer->trialsRequired[inf]); + }); + }); } void SaveManager::Init() { diff --git a/soh/src/code/z_sram.c b/soh/src/code/z_sram.c index 9a9407277..c16e5ef48 100644 --- a/soh/src/code/z_sram.c +++ b/soh/src/code/z_sram.c @@ -8,7 +8,6 @@ #define NUM_DUNGEONS 8 #define NUM_COWS 10 -#define NUM_SCRUBS 35 /** * Initialize new save. From 96a3354d4557758a5fe2ecedcdfe7a85a95712ab Mon Sep 17 00:00:00 2001 From: Garrett Cox Date: Mon, 5 Sep 2022 15:12:30 -0500 Subject: [PATCH 07/10] Remove trialsRequired persisting in save manager --- soh/soh/SaveManager.cpp | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/soh/soh/SaveManager.cpp b/soh/soh/SaveManager.cpp index a932f31a4..1fea00767 100644 --- a/soh/soh/SaveManager.cpp +++ b/soh/soh/SaveManager.cpp @@ -103,16 +103,6 @@ void SaveManager::LoadRandomizerVersion1() { randomizer->merchantPrices[rc] = price; }); }); - - SaveManager::Instance->LoadArray("trialsRequired", NUM_TRIALS, [&](size_t i) { - SaveManager::Instance->LoadStruct("", [&]() { - RandomizerInf inf; - SaveManager::Instance->LoadData("inf", inf); - bool required; - SaveManager::Instance->LoadData("price", required); - randomizer->trialsRequired[inf] = required; - }); - }); } void SaveManager::SaveRandomizer() { @@ -171,14 +161,6 @@ void SaveManager::SaveRandomizer() { SaveManager::Instance->SaveData("price", merchantPrices[i].second); }); }); - - SaveManager::Instance->SaveArray("trialsRequired", NUM_TRIALS, [&](size_t i) { - SaveManager::Instance->SaveStruct("", [&]() { - RandomizerInf inf = RandomizerInf(RAND_INF_TRIALS_DONE_LIGHT_TRIAL - i); - SaveManager::Instance->SaveData("inf", inf); - SaveManager::Instance->SaveData("required", randomizer->trialsRequired[inf]); - }); - }); } void SaveManager::Init() { From 0ab4f21382e0bbee7446d8505f57c0e49b6f9de4 Mon Sep 17 00:00:00 2001 From: Garrett Cox Date: Mon, 5 Sep 2022 22:14:39 -0500 Subject: [PATCH 08/10] Fix issue when merchantPrices is empty --- soh/soh/SaveManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/soh/soh/SaveManager.cpp b/soh/soh/SaveManager.cpp index 1fea00767..a3a3ccd64 100644 --- a/soh/soh/SaveManager.cpp +++ b/soh/soh/SaveManager.cpp @@ -155,7 +155,7 @@ void SaveManager::SaveRandomizer() { merchantPrices.push_back(std::make_pair(check, price)); } - SaveManager::Instance->SaveArray("merchantPrices", NUM_SCRUBS, [&](size_t i) { + SaveManager::Instance->SaveArray("merchantPrices", merchantPrices.size(), [&](size_t i) { SaveManager::Instance->SaveStruct("", [&]() { SaveManager::Instance->SaveData("check", merchantPrices[i].first); SaveManager::Instance->SaveData("price", merchantPrices[i].second); From c9c648322d9aeaf0557b69fa5432ae0627f0ec57 Mon Sep 17 00:00:00 2001 From: Garrett Cox Date: Mon, 5 Sep 2022 22:30:39 -0500 Subject: [PATCH 09/10] Fix for a single zeroed merchantPrice entry --- soh/soh/SaveManager.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/soh/soh/SaveManager.cpp b/soh/soh/SaveManager.cpp index a3a3ccd64..1fef30214 100644 --- a/soh/soh/SaveManager.cpp +++ b/soh/soh/SaveManager.cpp @@ -94,7 +94,13 @@ void SaveManager::LoadRandomizerVersion1() { std::shared_ptr randomizer = OTRGlobals::Instance->gRandomizer; - SaveManager::Instance->LoadArray("merchantPrices", NUM_SCRUBS, [&](size_t i) { + size_t merchantPricesSize = 0; + if (randomizer->GetRandoSettingValue(RSK_SHUFFLE_SCRUBS) > 0) { + merchantPricesSize += NUM_SCRUBS; + } + // TODO: Add shop item count when shopsanity is enabled + + SaveManager::Instance->LoadArray("merchantPrices", merchantPricesSize, [&](size_t i) { SaveManager::Instance->LoadStruct("", [&]() { RandomizerCheck rc; SaveManager::Instance->LoadData("check", rc); From a99330a8a51661620a638401f5f8817617a1e350 Mon Sep 17 00:00:00 2001 From: Garrett Cox Date: Mon, 5 Sep 2022 23:28:32 -0500 Subject: [PATCH 10/10] Fix #1417 --- soh/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/soh/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c b/soh/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c index a6ddb5844..c6709e144 100644 --- a/soh/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c +++ b/soh/src/overlays/actors/ovl_En_Syateki_Man/z_en_syateki_man.c @@ -349,6 +349,7 @@ void EnSyatekiMan_EndGame(EnSyatekiMan* this, GlobalContext* globalCtx) { this->getItemId = GI_BULLET_BAG_50; } } else { + this->getItemEntry = (GetItemEntry)GET_ITEM_NONE; this->getItemId = GI_RUPEE_PURPLE; } } else { @@ -371,6 +372,7 @@ void EnSyatekiMan_EndGame(EnSyatekiMan* this, GlobalContext* globalCtx) { break; } } else { + this->getItemEntry = (GetItemEntry)GET_ITEM_NONE; this->getItemId = GI_RUPEE_PURPLE; } }