pool_functions cleanup (#6536)

remove 3drando/rando_main
This commit is contained in:
Philip Dubé 2026-04-21 15:29:36 +00:00 committed by GitHub
parent 94a5311cba
commit fa875596f2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 19 additions and 73 deletions

View file

@ -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<RandomizerCheck> ReachabilitySearch(const std::vector<RandomizerChec
ProcessRegion(RegionTable(gals.regionPool[i]), gals, ignore);
}
} while (gals.logicUpdated);
erase_if(gals.accessibleLocations, [&targetLocations, ctx, calculatingAvailableChecks](RandomizerCheck loc) {
std::erase_if(gals.accessibleLocations, [&targetLocations, ctx, calculatingAvailableChecks](RandomizerCheck loc) {
if (ctx->GetItemLocation(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<RandomizerGet> 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);

View file

@ -1,14 +1,10 @@
#include <algorithm>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <sstream>
#include <ctime>
#include "menu.hpp"
#include "playthrough.hpp"
#include "spoiler_log.hpp"
#include "../location_access.h"
#include "soh/Enhancements/debugger/performanceTimer.h"
#include <spdlog/spdlog.h>
#include "../../randomizer/randomizerTypes.h"

View file

@ -1,7 +1,6 @@
#pragma once
#include <string>
#include <unordered_map>
#include <set>
#include "soh/Enhancements/randomizer/randomizerTypes.h"

View file

@ -2,28 +2,19 @@
#include <algorithm>
#include <vector>
#include <iostream>
#include <iterator>
template <typename T, typename Predicate> static void erase_if(std::vector<T>& vector, Predicate pred) {
vector.erase(std::remove_if(begin(vector), end(vector), pred), end(vector));
}
template <typename T, typename Predicate>
std::vector<T> FilterFromPool(std::vector<T>& vector, Predicate pred, bool eraseAfterFilter = false) {
template <typename T, typename Predicate> std::vector<T> FilterFromPool(std::vector<T>& vector, Predicate pred) {
std::vector<T> filteredPool = {};
std::copy_if(vector.begin(), vector.end(), std::back_inserter(filteredPool), pred);
if (eraseAfterFilter) {
erase_if(vector, pred);
}
return filteredPool;
}
template <typename T, typename Predicate>
std::vector<T> FilterAndEraseFromPool(std::vector<T>& vector, Predicate pred) {
return FilterFromPool(vector, pred, true);
auto filtered = FilterFromPool(vector, pred);
std::erase_if(vector, pred);
return filtered;
}
template <typename T, typename FromPool> void AddElementsToPool(std::vector<T>& toPool, const FromPool& fromPool) {
@ -33,7 +24,3 @@ template <typename T, typename FromPool> void AddElementsToPool(std::vector<T>&
template <typename T, typename Container> bool ElementInContainer(T& element, const Container& container) {
return std::find(container.begin(), container.end(), element) != container.end();
}
template <typename First, typename... T> bool IsAnyOf(First&& first, T&&... t) {
return ((first == t) || ...);
}

View file

@ -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 <libultraship/bridge.h>
#include <ship/Context.h>
#include <libultraship/libultra/types.h>
#include "soh/OTRGlobals.h"
#include "soh/cvar_prefixes.h"
void RandoMain::GenerateRando(std::set<RandomizerCheck> excludedLocations, std::set<RandomizerTrick> enabledTricks,
std::string seedString) {
Rando::Context::GetInstance()->SetSeedGenerated(GenerateRandomizer(excludedLocations, enabledTricks, seedString));
Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame();
}

View file

@ -1,9 +0,0 @@
#pragma once
#include "soh/Enhancements/randomizer/item.h"
#include <set>
namespace RandoMain {
void GenerateRando(std::set<RandomizerCheck> excludedLocations, std::set<RandomizerTrick> enabledTricks,
std::string seedInput);
}

View file

@ -2,9 +2,6 @@
#include <array>
#include <string>
#include <string_view>
#include <cstdint>
#include "../randomizerTypes.h"
using RandomizerHash = std::array<std::string, 5>;

View file

@ -655,7 +655,7 @@ BuildOneWayTargets(std::vector<EntranceType> 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<RandomizerRegion, RandomizerRegion> 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;
});

View file

@ -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);
}

View file

@ -8,7 +8,7 @@
#include <libultraship/libultraship.h>
#include <textures/icon_item_static/icon_item_static.h>
#include <textures/icon_item_24_static/icon_item_24_static.h>
#include "3drando/rando_main.hpp"
#include "3drando/menu.hpp"
#include "soh/ResourceManagerHelpers.h"
#include "soh/SohGui/SohGui.hpp"
#include <imgui.h>
@ -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;