From 0afffe24feeb681a90656c24e309dc6d40af685e Mon Sep 17 00:00:00 2001 From: Malkierian Date: Wed, 18 Dec 2024 21:42:36 -0700 Subject: [PATCH] Fix Dungeon Type Spoiling (#4719) * Make new `SpoilAreaFromCheck` function to spoil areas when getting maps or a first check in a dungeon that isn't spoiled by entrance. * Add scummed check dungeon spoiling on load. --- .../Enhancements/randomizer/hook_handlers.cpp | 1 + .../randomizer/randomizer_check_tracker.cpp | 30 ++++++++++++++++++- .../randomizer/randomizer_check_tracker.h | 1 + 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/soh/soh/Enhancements/randomizer/hook_handlers.cpp b/soh/soh/Enhancements/randomizer/hook_handlers.cpp index 0bdd2b0cc..f3cb9f743 100644 --- a/soh/soh/Enhancements/randomizer/hook_handlers.cpp +++ b/soh/soh/Enhancements/randomizer/hook_handlers.cpp @@ -328,6 +328,7 @@ void RandomizerOnItemReceiveHandler(GetItemEntry receivedItemEntry) { if (randomizerQueuedItemEntry.modIndex == receivedItemEntry.modIndex && randomizerQueuedItemEntry.itemId == receivedItemEntry.itemId) { SPDLOG_INFO("Item received mod {} item {} from RC {}", receivedItemEntry.modIndex, receivedItemEntry.itemId, static_cast(randomizerQueuedCheck)); loc->SetCheckStatus(RCSHOW_COLLECTED); + CheckTracker::SpoilAreaFromCheck(randomizerQueuedCheck); CheckTracker::RecalculateAllAreaTotals(); SaveManager::Instance->SaveSection(gSaveContext.fileNum, SECTION_ID_TRACKER_DATA, true); randomizerQueuedCheck = RC_UNKNOWN_CHECK; diff --git a/soh/soh/Enhancements/randomizer/randomizer_check_tracker.cpp b/soh/soh/Enhancements/randomizer/randomizer_check_tracker.cpp index 846fc7026..1f0358592 100644 --- a/soh/soh/Enhancements/randomizer/randomizer_check_tracker.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer_check_tracker.cpp @@ -259,6 +259,33 @@ void RecalculateAreaTotals(RandomizerCheckArea rcArea) { CalculateTotals(); } +std::map MapRGtoRandomizerCheckArea = { + { RG_DEKU_TREE_MAP, RCAREA_DEKU_TREE}, + { RG_DODONGOS_CAVERN_MAP, RCAREA_DODONGOS_CAVERN }, + { RG_JABU_JABUS_BELLY_MAP, RCAREA_JABU_JABUS_BELLY }, + { RG_FOREST_TEMPLE_MAP, RCAREA_FOREST_TEMPLE }, + { RG_FIRE_TEMPLE_MAP, RCAREA_FIRE_TEMPLE }, + { RG_WATER_TEMPLE_MAP, RCAREA_WATER_TEMPLE }, + { RG_SPIRIT_TEMPLE_MAP, RCAREA_SPIRIT_TEMPLE }, + { RG_SHADOW_TEMPLE_MAP, RCAREA_SHADOW_TEMPLE }, + { RG_BOTTOM_OF_THE_WELL_MAP, RCAREA_BOTTOM_OF_THE_WELL }, + { RG_ICE_CAVERN_MAP, RCAREA_ICE_CAVERN } +}; + +void SpoilAreaFromCheck(RandomizerCheck rc) { + Rando::Location* loc = Rando::StaticData::GetLocation(rc); + Rando::ItemLocation* itemLoc = Rando::Context::GetInstance()->GetItemLocation(rc); + if (itemLoc->GetPlacedItem().GetItemType() == ItemType::ITEMTYPE_MAP) { + RandomizerCheckArea area = MapRGtoRandomizerCheckArea[itemLoc->GetPlacedRandomizerGet()]; + if (!IsAreaSpoiled(area)) { + SetAreaSpoiled(area); + } + } + if (!IsAreaSpoiled(loc->GetArea())) { + SetAreaSpoiled(loc->GetArea()); + } +} + void RecalculateAllAreaTotals() { for (auto& [rcArea, checks] : checksByArea) { if (rcArea == RCAREA_INVALID) { @@ -437,7 +464,8 @@ void CheckTrackerLoadGame(int32_t fileNum) { } } - if (areaChecksGotten[entry2->GetArea()] != 0 || RandomizerCheckObjects::AreaIsOverworld(entry2->GetArea())) { + if (areaChecksGotten[entry2->GetArea()] != 0 || RandomizerCheckObjects::AreaIsOverworld(entry2->GetArea()) || + loc->GetCheckStatus() == RCSHOW_SCUMMED) { areasSpoiled |= (1 << entry2->GetArea()); } diff --git a/soh/soh/Enhancements/randomizer/randomizer_check_tracker.h b/soh/soh/Enhancements/randomizer/randomizer_check_tracker.h index 96aee4dde..851910489 100644 --- a/soh/soh/Enhancements/randomizer/randomizer_check_tracker.h +++ b/soh/soh/Enhancements/randomizer/randomizer_check_tracker.h @@ -59,4 +59,5 @@ void UpdateAreas(RandomizerCheckArea area); void UpdateAllOrdering(); void UpdateAllAreas(); void RecalculateAllAreaTotals(); +void SpoilAreaFromCheck(RandomizerCheck rc); } // namespace CheckTracker