diff --git a/soh/soh/Enhancements/randomizer/3drando/menu.cpp b/soh/soh/Enhancements/randomizer/3drando/menu.cpp index adc0a9040..752984032 100644 --- a/soh/soh/Enhancements/randomizer/3drando/menu.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/menu.cpp @@ -46,6 +46,7 @@ bool GenerateRandomizer(std::set excludedLocations, std::set{}(ctx->GetSettings()->GetSeedString()); ctx->GetSettings()->SetSeed(seedHash & 0xFFFFFFFF); + ctx->ClearItemLocations(); int ret = Playthrough::Playthrough_Init(ctx->GetSettings()->GetSeed(), excludedLocations, enabledTricks); if (ret < 0) { if (ret == -1) { // Failed to generate after 5 tries diff --git a/soh/soh/Enhancements/randomizer/context.cpp b/soh/soh/Enhancements/randomizer/context.cpp index 82a001024..515d5f029 100644 --- a/soh/soh/Enhancements/randomizer/context.cpp +++ b/soh/soh/Enhancements/randomizer/context.cpp @@ -226,6 +226,12 @@ std::vector Context::GetLocations(const std::vector(i))->ResetVariables(); + } +} + void Context::ItemReset() { for (const RandomizerCheck il : allLocations) { GetItemLocation(il)->ResetVariables(); @@ -524,44 +530,64 @@ void Context::ParseHintJson(nlohmann::json spoilerFileJson) { // Ganondorf and Sheik Light Arrow Hints std::string ganonHintText = FormatJsonHintText(spoilerFileJson["ganonHintText"].get()); RandomizerCheck lightArrowLoc = mSpoilerfileCheckNameToEnum[spoilerFileJson["lightArrowHintLoc"].get()]; - std::string lightArrowRegion = spoilerFileJson["lightArrowHintRegion"].get(); + std::string lightArrowRegion = spoilerFileJson["lightArrowArea"].get(); AddHint(RH_GANONDORF_HINT, Text(ganonHintText), lightArrowLoc, HINT_TYPE_STATIC, "Static", mSpoilerfileAreaNameToEnum[lightArrowRegion]); - std::string sheikText = FormatJsonHintText(spoilerFileJson["sheikText"].get()); - AddHint(RH_SHEIK_LIGHT_ARROWS, Text(sheikText), lightArrowLoc, HINT_TYPE_STATIC, lightArrowRegion); + if (spoilerFileJson.contains("sheikText")) { + std::string sheikText = FormatJsonHintText(spoilerFileJson["sheikText"].get()); + AddHint(RH_SHEIK_LIGHT_ARROWS, Text(sheikText), lightArrowLoc, HINT_TYPE_STATIC, lightArrowRegion); + } std::string ganonText = FormatJsonHintText(spoilerFileJson["ganonText"].get()); AddHint(RH_GANONDORF_NOHINT, Text(ganonText), RC_UNKNOWN_CHECK, HINT_TYPE_JUNK, "Static", RA_GANONS_CASTLE); // Dampe Hookshot Hint - std::string dampeText = FormatJsonHintText(spoilerFileJson["dampeText"].get()); - std::string dampeRegion = spoilerFileJson["dampeRegion"].get(); - RandomizerCheck dampeHintLoc = mSpoilerfileCheckNameToEnum[spoilerFileJson["dampeHintLoc"].get()]; - AddHint(RH_DAMPES_DIARY, Text(dampeText), dampeHintLoc, HINT_TYPE_STATIC, "Static", mSpoilerfileAreaNameToEnum[dampeRegion]); + if (spoilerFileJson.contains("dampeText")) { + std::string dampeText = FormatJsonHintText(spoilerFileJson["dampeText"].get()); + std::string dampeRegion = spoilerFileJson["dampeRegion"].get(); + RandomizerCheck dampeHintLoc = mSpoilerfileCheckNameToEnum[spoilerFileJson["dampeHintLoc"].get()]; + AddHint(RH_DAMPES_DIARY, Text(dampeText), dampeHintLoc, HINT_TYPE_STATIC, "Static", mSpoilerfileAreaNameToEnum[dampeRegion]); + } // Greg Hint - std::string gregText = FormatJsonHintText(spoilerFileJson["gregText"].get()); - std::string gregRegion = spoilerFileJson["gregRegion"].get(); - RandomizerCheck gregLoc = mSpoilerfileCheckNameToEnum[spoilerFileJson["gregLoc"].get()]; - AddHint(RH_GREG_RUPEE, Text(gregText), gregLoc, HINT_TYPE_STATIC, "Static", mSpoilerfileAreaNameToEnum[gregRegion]); + if (spoilerFileJson.contains("gregText")) { + std::string gregText = FormatJsonHintText(spoilerFileJson["gregText"].get()); + std::string gregRegion = spoilerFileJson["gregRegion"].get(); + RandomizerCheck gregLoc = mSpoilerfileCheckNameToEnum[spoilerFileJson["gregLoc"].get()]; + AddHint(RH_GREG_RUPEE, Text(gregText), gregLoc, HINT_TYPE_STATIC, "Static", mSpoilerfileAreaNameToEnum[gregRegion]); + } // Saria Magic Hint - std::string sariaText = FormatJsonHintText(spoilerFileJson["sariaText"].get()); - std::string sariaRegion = spoilerFileJson["sariaRegion"].get(); - RandomizerCheck sariaHintLoc = mSpoilerfileCheckNameToEnum[spoilerFileJson["sariaHintLoc"].get()]; - AddHint(RH_SARIA, Text(sariaText), sariaHintLoc, HINT_TYPE_STATIC, "Static", mSpoilerfileAreaNameToEnum[sariaRegion]); + if (spoilerFileJson.contains("sariaText")) { + std::string sariaText = FormatJsonHintText(spoilerFileJson["sariaText"].get()); + std::string sariaRegion = spoilerFileJson["sariaRegion"].get(); + RandomizerCheck sariaHintLoc = mSpoilerfileCheckNameToEnum[spoilerFileJson["sariaHintLoc"].get()]; + AddHint(RH_SARIA, Text(sariaText), sariaHintLoc, HINT_TYPE_STATIC, "Static", mSpoilerfileAreaNameToEnum[sariaRegion]); + } // Warp Songs - std::string warpMinuetText = FormatJsonHintText(spoilerFileJson["warpMinuetText"].get()); //RANDOTODO fall back for if location is used - AddHint(RH_MINUET_WARP_LOC, Text(warpMinuetText), RC_UNKNOWN_CHECK, HINT_TYPE_STATIC, "Static", mSpoilerfileAreaNameToEnum[warpMinuetText]); - std::string warpBoleroText = FormatJsonHintText(spoilerFileJson["warpBoleroText"].get()); - AddHint(RH_BOLERO_WARP_LOC, Text(warpBoleroText), RC_UNKNOWN_CHECK, HINT_TYPE_STATIC, "Static", mSpoilerfileAreaNameToEnum[warpBoleroText]); - std::string warpSerenadeText = FormatJsonHintText(spoilerFileJson["warpSerenadeText"].get()); - AddHint(RH_SERENADE_WARP_LOC, Text(warpSerenadeText), RC_UNKNOWN_CHECK, HINT_TYPE_STATIC, "Static", mSpoilerfileAreaNameToEnum[warpSerenadeText]); - std::string warpRequiemText = FormatJsonHintText(spoilerFileJson["warpRequiemText"].get()); - AddHint(RH_REQUIEM_WARP_LOC, Text(warpRequiemText), RC_UNKNOWN_CHECK, HINT_TYPE_STATIC, "Static", mSpoilerfileAreaNameToEnum[warpRequiemText]); - std::string warpNocturneText = FormatJsonHintText(spoilerFileJson["warpNocturneText"].get()); - AddHint(RH_NOCTURNE_WARP_LOC, Text(warpNocturneText), RC_UNKNOWN_CHECK, HINT_TYPE_STATIC, "Static", mSpoilerfileAreaNameToEnum[warpNocturneText]); - std::string warpPreludeText = FormatJsonHintText(spoilerFileJson["warpPreludeText"].get()); - AddHint(RH_PRELUDE_WARP_LOC, Text(warpPreludeText), RC_UNKNOWN_CHECK, HINT_TYPE_STATIC, "Static", mSpoilerfileAreaNameToEnum[warpPreludeText]); + if (spoilerFileJson.contains("warpMinuetText")) { + std::string warpMinuetText = FormatJsonHintText(spoilerFileJson["warpMinuetText"].get()); //RANDOTODO fall back for if location is used + AddHint(RH_MINUET_WARP_LOC, Text(warpMinuetText), RC_UNKNOWN_CHECK, HINT_TYPE_STATIC, "Static", mSpoilerfileAreaNameToEnum[warpMinuetText]); + } + if (spoilerFileJson.contains("warpBoleroText")) { + std::string warpBoleroText = FormatJsonHintText(spoilerFileJson["warpBoleroText"].get()); + AddHint(RH_BOLERO_WARP_LOC, Text(warpBoleroText), RC_UNKNOWN_CHECK, HINT_TYPE_STATIC, "Static", mSpoilerfileAreaNameToEnum[warpBoleroText]); + } + if (spoilerFileJson.contains("warpSerenadeText")) { + std::string warpSerenadeText = FormatJsonHintText(spoilerFileJson["warpSerenadeText"].get()); + AddHint(RH_SERENADE_WARP_LOC, Text(warpSerenadeText), RC_UNKNOWN_CHECK, HINT_TYPE_STATIC, "Static", mSpoilerfileAreaNameToEnum[warpSerenadeText]); + } + if (spoilerFileJson.contains("warpRequiemText")) { + std::string warpRequiemText = FormatJsonHintText(spoilerFileJson["warpRequiemText"].get()); + AddHint(RH_REQUIEM_WARP_LOC, Text(warpRequiemText), RC_UNKNOWN_CHECK, HINT_TYPE_STATIC, "Static", mSpoilerfileAreaNameToEnum[warpRequiemText]); + } + if (spoilerFileJson.contains("warpNocturneText")) { + std::string warpNocturneText = FormatJsonHintText(spoilerFileJson["warpNocturneText"].get()); + AddHint(RH_NOCTURNE_WARP_LOC, Text(warpNocturneText), RC_UNKNOWN_CHECK, HINT_TYPE_STATIC, "Static", mSpoilerfileAreaNameToEnum[warpNocturneText]); + } + if (spoilerFileJson.contains("warpPreludeText")) { + std::string warpPreludeText = FormatJsonHintText(spoilerFileJson["warpPreludeText"].get()); + AddHint(RH_PRELUDE_WARP_LOC, Text(warpPreludeText), RC_UNKNOWN_CHECK, HINT_TYPE_STATIC, "Static", mSpoilerfileAreaNameToEnum[warpPreludeText]); + } // Gossip Stones nlohmann::json hintsJson = spoilerFileJson["hints"]; @@ -570,8 +596,8 @@ void Context::ParseHintJson(nlohmann::json spoilerFileJson) { nlohmann::json hintInfo = it.value(); std::string hintText = FormatJsonHintText(hintInfo["hint"].get()); HintType hintType = mSpoilerfileHintTypeNameToEnum[hintInfo["type"].get()]; - RandomizerCheck hintedLocation = mSpoilerfileCheckNameToEnum[hintInfo["location"]]; - std::string hintedArea = hintInfo["area"].get(); + RandomizerCheck hintedLocation = hintInfo.contains("location") ? mSpoilerfileCheckNameToEnum[hintInfo["location"]] : RC_UNKNOWN_CHECK; + std::string hintedArea = hintInfo.contains("area") ? hintInfo["area"].get() : ""; AddHint(static_cast(gossipStoneLoc - RC_COLOSSUS_GOSSIP_STONE + 1), Text(hintText), hintedLocation, hintType, hintedArea); } } diff --git a/soh/soh/Enhancements/randomizer/context.h b/soh/soh/Enhancements/randomizer/context.h index ccea76d98..d477ef3eb 100644 --- a/soh/soh/Enhancements/randomizer/context.h +++ b/soh/soh/Enhancements/randomizer/context.h @@ -50,6 +50,7 @@ class Context { Category categoryInclude, Category categoryExclude = Category::cNull); void AddExcludedOptions(); void LocationReset(); + void ClearItemLocations(); void ItemReset(); void HintReset(); void CreateItemOverrides(); diff --git a/soh/soh/SaveManager.cpp b/soh/soh/SaveManager.cpp index 79e9a043c..328d24be7 100644 --- a/soh/soh/SaveManager.cpp +++ b/soh/soh/SaveManager.cpp @@ -2723,7 +2723,7 @@ extern "C" void Save_SaveGlobal(void) { extern "C" void Save_LoadFile(void) { if (gSaveContext.questId == QUEST_RANDOMIZER) { // Reset rando context for rando saves. - OTRGlobals::Instance->gRandoContext.reset(); + OTRGlobals::Instance->gRandoContext.reset(); OTRGlobals::Instance->gRandoContext = Rando::Context::CreateInstance(); OTRGlobals::Instance->gRandoContext->AddExcludedOptions(); OTRGlobals::Instance->gRandoContext->GetSettings()->CreateOptions(); diff --git a/soh/src/code/z_sram.c b/soh/src/code/z_sram.c index 9a132fa7e..002e95987 100644 --- a/soh/src/code/z_sram.c +++ b/soh/src/code/z_sram.c @@ -241,7 +241,7 @@ void Sram_InitSave(FileChooseContext* fileChooseCtx) { u8 currentQuest = fileChooseCtx->questType[fileChooseCtx->buttonIndex]; - if (Randomizer_IsSeedGenerated()) { + if (Randomizer_IsSeedGenerated() || Randomizer_IsPlandoLoaded()) { gSaveContext.questId = QUEST_RANDOMIZER; Randomizer_InitSaveFile();