From bb6d1d3b4bef74a94248f7364b6d3fa25287d454 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philip=20Dub=C3=A9?= <159546+serprex@users.noreply.github.com> Date: Sat, 29 Aug 2026 21:29:36 +0000 Subject: [PATCH] Cleanup mExcludeLocationsOptionsArea (#7131) --- .../randomizer/3drando/spoiler_log.cpp | 4 ++-- soh/soh/Enhancements/randomizer/SeedContext.cpp | 14 +++++++------- soh/soh/Enhancements/randomizer/settings.cpp | 7 +------ soh/soh/Enhancements/randomizer/settings.h | 8 +++----- 4 files changed, 13 insertions(+), 20 deletions(-) diff --git a/soh/soh/Enhancements/randomizer/3drando/spoiler_log.cpp b/soh/soh/Enhancements/randomizer/3drando/spoiler_log.cpp index 188a225927..4e5a16264f 100644 --- a/soh/soh/Enhancements/randomizer/3drando/spoiler_log.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/spoiler_log.cpp @@ -162,8 +162,8 @@ std::string RemoveLineBreaks(std::string s) { static void WriteExcludedLocations() { auto ctx = Rando::Context::GetInstance(); - for (size_t i = 0; i < Rando::Settings::GetInstance()->GetExcludeLocationsOptions().size(); i++) { - for (const auto& location : Rando::Settings::GetInstance()->GetExcludeLocationsOptions()[i]) { + for (const auto& areaOptions : Rando::Settings::GetInstance()->GetExcludeLocationsOptions()) { + for (const auto* location : areaOptions) { if (ctx->GetLocationOption(static_cast(location->GetKey())).Get() == RO_LOCATION_INCLUDE) { continue; } diff --git a/soh/soh/Enhancements/randomizer/SeedContext.cpp b/soh/soh/Enhancements/randomizer/SeedContext.cpp index 66fc1b38b2..e1db1c4967 100644 --- a/soh/soh/Enhancements/randomizer/SeedContext.cpp +++ b/soh/soh/Enhancements/randomizer/SeedContext.cpp @@ -17,6 +17,7 @@ #include "soh/Enhancements/randomizer/randomizer_check_tracker.h" #include "soh/Enhancements/randomizer/randomizer.h" +#include #include #include @@ -276,14 +277,13 @@ void Context::AddExcludedOptions() { continue; } AddLocation(loc.GetRandomizerCheck(), &everyPossibleLocation); - bool alreadyAdded = false; - for (Option* location : Rando::Settings::GetInstance()->GetExcludeOptionsForArea(loc.GetArea())) { - if (location->GetName() == loc.GetExcludedOption()->GetName()) { - alreadyAdded = true; - } - } + Option* excludedOption = loc.GetExcludedOption(); + auto& areaOptions = Settings::GetInstance()->GetExcludeOptionsForArea(loc.GetArea()); + const bool alreadyAdded = std::any_of(areaOptions.begin(), areaOptions.end(), [&](const Option* option) { + return option->GetName() == excludedOption->GetName(); + }); if (!alreadyAdded) { - Rando::Settings::GetInstance()->GetExcludeOptionsForArea(loc.GetArea()).push_back(loc.GetExcludedOption()); + areaOptions.push_back(excludedOption); } } } diff --git a/soh/soh/Enhancements/randomizer/settings.cpp b/soh/soh/Enhancements/randomizer/settings.cpp index 92a4689efd..2ab5783dde 100644 --- a/soh/soh/Enhancements/randomizer/settings.cpp +++ b/soh/soh/Enhancements/randomizer/settings.cpp @@ -105,9 +105,6 @@ void Settings::HandleShopsanityPriceUI() { } } -Settings::Settings() : mExcludeLocationsOptionsAreas(RCAREA_INVALID) { -} - #define OPT_U8(rsk, ...) mOptions[rsk] = Option::U8(rsk, __VA_ARGS__) #define OPT_BOOL(rsk, ...) mOptions[rsk] = Option::Bool(rsk, __VA_ARGS__) #define OPT_TRICK(rsk, ...) mTrickSettings[rsk] = TrickSetting::LogicTrick(rsk, __VA_ARGS__) @@ -1516,8 +1513,6 @@ void Settings::CreateOptions() { StaticData::optionNameToEnum = PopulateOptionNameToEnum(); - mExcludeLocationsOptionsAreas.reserve(RCAREA_INVALID); - // RANDOTODO sweep trick descriptions and make sure they match a post-refactor, post shuffles reality /* Common abbreviations in name tags - A: Adult @@ -2603,7 +2598,7 @@ std::vector& Settings::GetExcludeOptionsForArea(const RandomizerCheckAr return mExcludeLocationsOptionsAreas[area]; } -const std::vector>& Settings::GetExcludeLocationsOptions() const { +const std::array, RCAREA_INVALID>& Settings::GetExcludeLocationsOptions() const { return mExcludeLocationsOptionsAreas; } diff --git a/soh/soh/Enhancements/randomizer/settings.h b/soh/soh/Enhancements/randomizer/settings.h index b9c1d5797c..310dd40561 100644 --- a/soh/soh/Enhancements/randomizer/settings.h +++ b/soh/soh/Enhancements/randomizer/settings.h @@ -9,8 +9,6 @@ namespace Rando { class Settings { public: - Settings(); - /** * @brief Hides or Unhides the price UI of Shopsanity based on settings. */ @@ -88,9 +86,9 @@ class Settings { /** * @brief Get a reference to all of the Exclude Location `Option` lists. * - * @return const std::vector>& + * @return const std::array, RCAREA_INVALID>& */ - const std::vector>& GetExcludeLocationsOptions() const; + const std::array, RCAREA_INVALID>& GetExcludeLocationsOptions() const; /** * @brief Get the list of `OptionGroup`s. @@ -156,7 +154,7 @@ class Settings { std::array mOptionDescriptions = {}; std::array mOptionGroups = {}; std::array mTrickSettings = {}; - std::vector> mExcludeLocationsOptionsAreas = {}; + std::array, RCAREA_INVALID> mExcludeLocationsOptionsAreas = {}; std::unordered_map mTrickNameToEnum; }; } // namespace Rando