diff --git a/soh/soh/Enhancements/randomizer/3drando/fill.cpp b/soh/soh/Enhancements/randomizer/3drando/fill.cpp index 799b9a344..e0b3b06c8 100644 --- a/soh/soh/Enhancements/randomizer/3drando/fill.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/fill.cpp @@ -3,7 +3,6 @@ #include "../dungeon.h" #include "../SeedContext.h" #include "item_pool.hpp" -#include "random.hpp" #include "starting_inventory.hpp" #include "hints.hpp" #include "shops.hpp" @@ -545,7 +544,7 @@ std::vector ReachabilitySearch(const std::vectorGetItemLocation(loc)->GetPlacedRandomizerGet() != RG_NONE && !calculatingAvailableChecks) { return false; } @@ -988,9 +987,9 @@ static void RandomizeDungeonRewards() { pocketItem = RandomElement(pocketPossibilities); } // erase from rewards so remaining are placed - erase_if(rewards, [&](RandomizerGet r) { return r == pocketItem; }); + std::erase_if(rewards, [&](RandomizerGet r) { return r == pocketItem; }); // and from the item pool so it's not placed twice - FilterAndEraseFromPool(itemPool, [pocketItem](const RandomizerGet i) { return i == pocketItem; }); + std::erase_if(itemPool, [pocketItem](const RandomizerGet i) { return i == pocketItem; }); // and add to the pocket ctx->PlaceItemInLocation(RC_LINKS_POCKET, pocketItem); } @@ -1003,16 +1002,16 @@ static void RandomizeDungeonRewards() { // place it on Gift From Rauru ctx->GetItemLocation(RC_GIFT_FROM_RAURU)->PlaceVanillaItem(); // then erase from rewards so remaining are placed - erase_if(rewards, [&](RandomizerGet r) { return r == RG_LIGHT_MEDALLION; }); + std::erase_if(rewards, [&](RandomizerGet r) { return r == RG_LIGHT_MEDALLION; }); // and from the item pool so it's not placed twice - FilterAndEraseFromPool(itemPool, [](const RandomizerGet i) { return i == RG_LIGHT_MEDALLION; }); + std::erase_if(itemPool, [](const RandomizerGet i) { return i == RG_LIGHT_MEDALLION; }); } if (ctx->GetOption(RSK_SHUFFLE_DUNGEON_REWARDS).Is(RO_DUNGEON_REWARDS_END_OF_DUNGEON)) { // Randomize dungeon rewards with assumed fill AssumedFill(rewards, Rando::StaticData::dungeonRewardLocations); // Then remove them from the item pool - FilterAndEraseFromPool(itemPool, [](const auto i) { + std::erase_if(itemPool, [](const auto i) { return Rando::StaticData::RetrieveItem(i).GetItemType() == ITEMTYPE_DUNGEONREWARD; }); } else if (ctx->GetOption(RSK_SHUFFLE_DUNGEON_REWARDS).Is(RO_DUNGEON_REWARDS_VANILLA)) { @@ -1020,7 +1019,7 @@ static void RandomizeDungeonRewards() { ctx->GetItemLocation(loc)->PlaceVanillaItem(); } // Then remove rewards from the item pool - FilterAndEraseFromPool(itemPool, [](const auto i) { + std::erase_if(itemPool, [](const auto i) { return Rando::StaticData::RetrieveItem(i).GetItemType() == ITEMTYPE_DUNGEONREWARD; }); } @@ -1279,7 +1278,7 @@ int Fill() { } SetAreas(); // erase temporary shop items - FilterAndEraseFromPool(itemPool, [](const auto item) { + std::erase_if(itemPool, [](const auto item) { return Rando::StaticData::RetrieveItem(item).GetItemType() == ITEMTYPE_SHOP; }); StopPerformanceTimer(PT_ENTRANCE_SHUFFLE); @@ -1431,8 +1430,7 @@ int Fill() { StartPerformanceTimer(PT_REMAINING_ITEMS); // Fast fill for the rest of the pool SPDLOG_INFO("Shuffling Remaining Items"); - std::vector remainingPool = FilterAndEraseFromPool(itemPool, [](const auto i) { return true; }); - FastFill(remainingPool, GetAllEmptyLocations(), false); + FastFill(std::move(itemPool), GetAllEmptyLocations(), false); StopPerformanceTimer(PT_REMAINING_ITEMS); StartPerformanceTimer(PT_PLAYTHROUGH_GENERATION); diff --git a/soh/soh/Enhancements/randomizer/3drando/menu.cpp b/soh/soh/Enhancements/randomizer/3drando/menu.cpp index 35f21ce20..0402b1096 100644 --- a/soh/soh/Enhancements/randomizer/3drando/menu.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/menu.cpp @@ -1,14 +1,10 @@ -#include #include #include #include -#include #include #include "menu.hpp" #include "playthrough.hpp" -#include "spoiler_log.hpp" -#include "../location_access.h" #include "soh/Enhancements/debugger/performanceTimer.h" #include #include "../../randomizer/randomizerTypes.h" diff --git a/soh/soh/Enhancements/randomizer/3drando/menu.hpp b/soh/soh/Enhancements/randomizer/3drando/menu.hpp index b40c97c2d..767472b1d 100644 --- a/soh/soh/Enhancements/randomizer/3drando/menu.hpp +++ b/soh/soh/Enhancements/randomizer/3drando/menu.hpp @@ -1,7 +1,6 @@ #pragma once #include -#include #include #include "soh/Enhancements/randomizer/randomizerTypes.h" diff --git a/soh/soh/Enhancements/randomizer/3drando/pool_functions.hpp b/soh/soh/Enhancements/randomizer/3drando/pool_functions.hpp index 5edcb0fda..2a93f40c3 100644 --- a/soh/soh/Enhancements/randomizer/3drando/pool_functions.hpp +++ b/soh/soh/Enhancements/randomizer/3drando/pool_functions.hpp @@ -2,28 +2,19 @@ #include #include -#include #include -template static void erase_if(std::vector& vector, Predicate pred) { - vector.erase(std::remove_if(begin(vector), end(vector), pred), end(vector)); -} - -template -std::vector FilterFromPool(std::vector& vector, Predicate pred, bool eraseAfterFilter = false) { +template std::vector FilterFromPool(std::vector& vector, Predicate pred) { std::vector filteredPool = {}; std::copy_if(vector.begin(), vector.end(), std::back_inserter(filteredPool), pred); - - if (eraseAfterFilter) { - erase_if(vector, pred); - } - return filteredPool; } template std::vector FilterAndEraseFromPool(std::vector& vector, Predicate pred) { - return FilterFromPool(vector, pred, true); + auto filtered = FilterFromPool(vector, pred); + std::erase_if(vector, pred); + return filtered; } template void AddElementsToPool(std::vector& toPool, const FromPool& fromPool) { @@ -33,7 +24,3 @@ template void AddElementsToPool(std::vector& template bool ElementInContainer(T& element, const Container& container) { return std::find(container.begin(), container.end(), element) != container.end(); } - -template bool IsAnyOf(First&& first, T&&... t) { - return ((first == t) || ...); -} diff --git a/soh/soh/Enhancements/randomizer/3drando/rando_main.cpp b/soh/soh/Enhancements/randomizer/3drando/rando_main.cpp deleted file mode 100644 index 76f26f912..000000000 --- a/soh/soh/Enhancements/randomizer/3drando/rando_main.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include "menu.hpp" -#include "../static_data.h" -#include "../item_location.h" -#include "../location_access.h" -#include "rando_main.hpp" -#include "../SeedContext.h" -#include -#include -#include -#include "soh/OTRGlobals.h" -#include "soh/cvar_prefixes.h" - -void RandoMain::GenerateRando(std::set excludedLocations, std::set enabledTricks, - std::string seedString) { - - Rando::Context::GetInstance()->SetSeedGenerated(GenerateRandomizer(excludedLocations, enabledTricks, seedString)); - - Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); -} diff --git a/soh/soh/Enhancements/randomizer/3drando/rando_main.hpp b/soh/soh/Enhancements/randomizer/3drando/rando_main.hpp deleted file mode 100644 index 77e98b2fd..000000000 --- a/soh/soh/Enhancements/randomizer/3drando/rando_main.hpp +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once - -#include "soh/Enhancements/randomizer/item.h" - -#include -namespace RandoMain { -void GenerateRando(std::set excludedLocations, std::set enabledTricks, - std::string seedInput); -} \ No newline at end of file diff --git a/soh/soh/Enhancements/randomizer/3drando/spoiler_log.hpp b/soh/soh/Enhancements/randomizer/3drando/spoiler_log.hpp index 13dae5fa2..f6409ed2c 100644 --- a/soh/soh/Enhancements/randomizer/3drando/spoiler_log.hpp +++ b/soh/soh/Enhancements/randomizer/3drando/spoiler_log.hpp @@ -2,9 +2,6 @@ #include #include -#include -#include -#include "../randomizerTypes.h" using RandomizerHash = std::array; diff --git a/soh/soh/Enhancements/randomizer/entrance.cpp b/soh/soh/Enhancements/randomizer/entrance.cpp index 06a720256..681791105 100644 --- a/soh/soh/Enhancements/randomizer/entrance.cpp +++ b/soh/soh/Enhancements/randomizer/entrance.cpp @@ -655,7 +655,7 @@ BuildOneWayTargets(std::vector typesToInclude, AddElementsToPool(oneWayEntrances, GetShuffleableEntrances(poolType, false)); } // Filter out any that are passed in the exclusion list - FilterAndEraseFromPool(oneWayEntrances, [&exclude](Entrance* entrance) { + std::erase_if(oneWayEntrances, [&exclude](Entrance* entrance) { std::pair entranceBeingChecked(entrance->GetParentRegionKey(), entrance->GetConnectedRegionKey()); return ElementInContainer(entranceBeingChecked, exclude); @@ -1333,7 +1333,7 @@ int EntranceShuffler::ShuffleAllEntrances() { GetShuffleableEntrances(EntranceType::Overworld, excludeOverworldReverse); // Only shuffle GV Lower Stream -> Lake Hylia if decoupled entrances are on if (!ctx->GetOption(RSK_DECOUPLED_ENTRANCES)) { - FilterAndEraseFromPool(entrancePools[EntranceType::Overworld], [](const Entrance* entrance) { + std::erase_if(entrancePools[EntranceType::Overworld], [](const Entrance* entrance) { return entrance->GetParentRegionKey() == RR_GV_LOWER_STREAM && entrance->GetConnectedRegionKey() == RR_LAKE_HYLIA; }); diff --git a/soh/soh/Enhancements/randomizer/fishsanity.cpp b/soh/soh/Enhancements/randomizer/fishsanity.cpp index fd7dffc19..f076e38b6 100644 --- a/soh/soh/Enhancements/randomizer/fishsanity.cpp +++ b/soh/soh/Enhancements/randomizer/fishsanity.cpp @@ -133,9 +133,8 @@ Fishsanity::GetFishingPondLocations(FishsanityOptionsSource optionsSource) { } // NOTE: This only works because we can assume activeFish is already sorted; changes that break this assumption will // also break this - FilterAndEraseFromPool(remainingFish, [&](RandomizerCheck loc) { - return std::binary_search(activeFish.begin(), activeFish.end(), loc); - }); + std::erase_if(remainingFish, + [&](RandomizerCheck loc) { return std::binary_search(activeFish.begin(), activeFish.end(), loc); }); return std::make_pair(activeFish, remainingFish); } diff --git a/soh/soh/Enhancements/randomizer/randomizer.cpp b/soh/soh/Enhancements/randomizer/randomizer.cpp index e6dc71acc..abc75424a 100644 --- a/soh/soh/Enhancements/randomizer/randomizer.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer.cpp @@ -8,7 +8,7 @@ #include #include #include -#include "3drando/rando_main.hpp" +#include "3drando/menu.hpp" #include "soh/ResourceManagerHelpers.h" #include "soh/SohGui/SohGui.hpp" #include @@ -4181,8 +4181,7 @@ void GenerateRandomizerImgui(std::string seed = "") { } } - RandoMain::GenerateRando(excludedLocations, enabledTricks, seed); - + Rando::Context::GetInstance()->SetSeedGenerated(GenerateRandomizer(excludedLocations, enabledTricks, seedString)); CVarSetInteger(CVAR_GENERAL("RandoGenerating"), 0); Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); @@ -4198,7 +4197,6 @@ bool GenerateRandomizer(std::string seed /*= ""*/) { } if (CVarGetInteger(CVAR_GENERAL("RandoGenerating"), 0) == 0) { randoThread = std::thread(&GenerateRandomizerImgui, seed); - return true; } return false;