mirror of
https://github.com/HarbourMasters/Shipwright
synced 2026-04-23 08:14:31 +00:00
parent
94a5311cba
commit
fa875596f2
|
|
@ -3,7 +3,6 @@
|
||||||
#include "../dungeon.h"
|
#include "../dungeon.h"
|
||||||
#include "../SeedContext.h"
|
#include "../SeedContext.h"
|
||||||
#include "item_pool.hpp"
|
#include "item_pool.hpp"
|
||||||
#include "random.hpp"
|
|
||||||
#include "starting_inventory.hpp"
|
#include "starting_inventory.hpp"
|
||||||
#include "hints.hpp"
|
#include "hints.hpp"
|
||||||
#include "shops.hpp"
|
#include "shops.hpp"
|
||||||
|
|
@ -545,7 +544,7 @@ std::vector<RandomizerCheck> ReachabilitySearch(const std::vector<RandomizerChec
|
||||||
ProcessRegion(RegionTable(gals.regionPool[i]), gals, ignore);
|
ProcessRegion(RegionTable(gals.regionPool[i]), gals, ignore);
|
||||||
}
|
}
|
||||||
} while (gals.logicUpdated);
|
} 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) {
|
if (ctx->GetItemLocation(loc)->GetPlacedRandomizerGet() != RG_NONE && !calculatingAvailableChecks) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -988,9 +987,9 @@ static void RandomizeDungeonRewards() {
|
||||||
pocketItem = RandomElement(pocketPossibilities);
|
pocketItem = RandomElement(pocketPossibilities);
|
||||||
}
|
}
|
||||||
// erase from rewards so remaining are placed
|
// 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
|
// 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
|
// and add to the pocket
|
||||||
ctx->PlaceItemInLocation(RC_LINKS_POCKET, pocketItem);
|
ctx->PlaceItemInLocation(RC_LINKS_POCKET, pocketItem);
|
||||||
}
|
}
|
||||||
|
|
@ -1003,16 +1002,16 @@ static void RandomizeDungeonRewards() {
|
||||||
// place it on Gift From Rauru
|
// place it on Gift From Rauru
|
||||||
ctx->GetItemLocation(RC_GIFT_FROM_RAURU)->PlaceVanillaItem();
|
ctx->GetItemLocation(RC_GIFT_FROM_RAURU)->PlaceVanillaItem();
|
||||||
// then erase from rewards so remaining are placed
|
// 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
|
// 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)) {
|
if (ctx->GetOption(RSK_SHUFFLE_DUNGEON_REWARDS).Is(RO_DUNGEON_REWARDS_END_OF_DUNGEON)) {
|
||||||
// Randomize dungeon rewards with assumed fill
|
// Randomize dungeon rewards with assumed fill
|
||||||
AssumedFill(rewards, Rando::StaticData::dungeonRewardLocations);
|
AssumedFill(rewards, Rando::StaticData::dungeonRewardLocations);
|
||||||
// Then remove them from the item pool
|
// 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;
|
return Rando::StaticData::RetrieveItem(i).GetItemType() == ITEMTYPE_DUNGEONREWARD;
|
||||||
});
|
});
|
||||||
} else if (ctx->GetOption(RSK_SHUFFLE_DUNGEON_REWARDS).Is(RO_DUNGEON_REWARDS_VANILLA)) {
|
} else if (ctx->GetOption(RSK_SHUFFLE_DUNGEON_REWARDS).Is(RO_DUNGEON_REWARDS_VANILLA)) {
|
||||||
|
|
@ -1020,7 +1019,7 @@ static void RandomizeDungeonRewards() {
|
||||||
ctx->GetItemLocation(loc)->PlaceVanillaItem();
|
ctx->GetItemLocation(loc)->PlaceVanillaItem();
|
||||||
}
|
}
|
||||||
// Then remove rewards from the item pool
|
// 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;
|
return Rando::StaticData::RetrieveItem(i).GetItemType() == ITEMTYPE_DUNGEONREWARD;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -1279,7 +1278,7 @@ int Fill() {
|
||||||
}
|
}
|
||||||
SetAreas();
|
SetAreas();
|
||||||
// erase temporary shop items
|
// erase temporary shop items
|
||||||
FilterAndEraseFromPool(itemPool, [](const auto item) {
|
std::erase_if(itemPool, [](const auto item) {
|
||||||
return Rando::StaticData::RetrieveItem(item).GetItemType() == ITEMTYPE_SHOP;
|
return Rando::StaticData::RetrieveItem(item).GetItemType() == ITEMTYPE_SHOP;
|
||||||
});
|
});
|
||||||
StopPerformanceTimer(PT_ENTRANCE_SHUFFLE);
|
StopPerformanceTimer(PT_ENTRANCE_SHUFFLE);
|
||||||
|
|
@ -1431,8 +1430,7 @@ int Fill() {
|
||||||
StartPerformanceTimer(PT_REMAINING_ITEMS);
|
StartPerformanceTimer(PT_REMAINING_ITEMS);
|
||||||
// Fast fill for the rest of the pool
|
// Fast fill for the rest of the pool
|
||||||
SPDLOG_INFO("Shuffling Remaining Items");
|
SPDLOG_INFO("Shuffling Remaining Items");
|
||||||
std::vector<RandomizerGet> remainingPool = FilterAndEraseFromPool(itemPool, [](const auto i) { return true; });
|
FastFill(std::move(itemPool), GetAllEmptyLocations(), false);
|
||||||
FastFill(remainingPool, GetAllEmptyLocations(), false);
|
|
||||||
StopPerformanceTimer(PT_REMAINING_ITEMS);
|
StopPerformanceTimer(PT_REMAINING_ITEMS);
|
||||||
|
|
||||||
StartPerformanceTimer(PT_PLAYTHROUGH_GENERATION);
|
StartPerformanceTimer(PT_PLAYTHROUGH_GENERATION);
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,10 @@
|
||||||
#include <algorithm>
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <sstream>
|
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
|
|
||||||
#include "menu.hpp"
|
#include "menu.hpp"
|
||||||
#include "playthrough.hpp"
|
#include "playthrough.hpp"
|
||||||
#include "spoiler_log.hpp"
|
|
||||||
#include "../location_access.h"
|
|
||||||
#include "soh/Enhancements/debugger/performanceTimer.h"
|
#include "soh/Enhancements/debugger/performanceTimer.h"
|
||||||
#include <spdlog/spdlog.h>
|
#include <spdlog/spdlog.h>
|
||||||
#include "../../randomizer/randomizerTypes.h"
|
#include "../../randomizer/randomizerTypes.h"
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <unordered_map>
|
|
||||||
#include <set>
|
#include <set>
|
||||||
#include "soh/Enhancements/randomizer/randomizerTypes.h"
|
#include "soh/Enhancements/randomizer/randomizerTypes.h"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,28 +2,19 @@
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <iostream>
|
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
|
|
||||||
template <typename T, typename Predicate> static void erase_if(std::vector<T>& vector, Predicate pred) {
|
template <typename T, typename Predicate> std::vector<T> FilterFromPool(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) {
|
|
||||||
std::vector<T> filteredPool = {};
|
std::vector<T> filteredPool = {};
|
||||||
std::copy_if(vector.begin(), vector.end(), std::back_inserter(filteredPool), pred);
|
std::copy_if(vector.begin(), vector.end(), std::back_inserter(filteredPool), pred);
|
||||||
|
|
||||||
if (eraseAfterFilter) {
|
|
||||||
erase_if(vector, pred);
|
|
||||||
}
|
|
||||||
|
|
||||||
return filteredPool;
|
return filteredPool;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, typename Predicate>
|
template <typename T, typename Predicate>
|
||||||
std::vector<T> FilterAndEraseFromPool(std::vector<T>& vector, Predicate pred) {
|
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) {
|
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) {
|
template <typename T, typename Container> bool ElementInContainer(T& element, const Container& container) {
|
||||||
return std::find(container.begin(), container.end(), element) != container.end();
|
return std::find(container.begin(), container.end(), element) != container.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename First, typename... T> bool IsAnyOf(First&& first, T&&... t) {
|
|
||||||
return ((first == t) || ...);
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -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();
|
|
||||||
}
|
|
||||||
|
|
@ -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);
|
|
||||||
}
|
|
||||||
|
|
@ -2,9 +2,6 @@
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <string_view>
|
|
||||||
#include <cstdint>
|
|
||||||
#include "../randomizerTypes.h"
|
|
||||||
|
|
||||||
using RandomizerHash = std::array<std::string, 5>;
|
using RandomizerHash = std::array<std::string, 5>;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -655,7 +655,7 @@ BuildOneWayTargets(std::vector<EntranceType> typesToInclude,
|
||||||
AddElementsToPool(oneWayEntrances, GetShuffleableEntrances(poolType, false));
|
AddElementsToPool(oneWayEntrances, GetShuffleableEntrances(poolType, false));
|
||||||
}
|
}
|
||||||
// Filter out any that are passed in the exclusion list
|
// 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(),
|
std::pair<RandomizerRegion, RandomizerRegion> entranceBeingChecked(entrance->GetParentRegionKey(),
|
||||||
entrance->GetConnectedRegionKey());
|
entrance->GetConnectedRegionKey());
|
||||||
return ElementInContainer(entranceBeingChecked, exclude);
|
return ElementInContainer(entranceBeingChecked, exclude);
|
||||||
|
|
@ -1333,7 +1333,7 @@ int EntranceShuffler::ShuffleAllEntrances() {
|
||||||
GetShuffleableEntrances(EntranceType::Overworld, excludeOverworldReverse);
|
GetShuffleableEntrances(EntranceType::Overworld, excludeOverworldReverse);
|
||||||
// Only shuffle GV Lower Stream -> Lake Hylia if decoupled entrances are on
|
// Only shuffle GV Lower Stream -> Lake Hylia if decoupled entrances are on
|
||||||
if (!ctx->GetOption(RSK_DECOUPLED_ENTRANCES)) {
|
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 &&
|
return entrance->GetParentRegionKey() == RR_GV_LOWER_STREAM &&
|
||||||
entrance->GetConnectedRegionKey() == RR_LAKE_HYLIA;
|
entrance->GetConnectedRegionKey() == RR_LAKE_HYLIA;
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -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
|
// NOTE: This only works because we can assume activeFish is already sorted; changes that break this assumption will
|
||||||
// also break this
|
// also break this
|
||||||
FilterAndEraseFromPool(remainingFish, [&](RandomizerCheck loc) {
|
std::erase_if(remainingFish,
|
||||||
return std::binary_search(activeFish.begin(), activeFish.end(), loc);
|
[&](RandomizerCheck loc) { return std::binary_search(activeFish.begin(), activeFish.end(), loc); });
|
||||||
});
|
|
||||||
|
|
||||||
return std::make_pair(activeFish, remainingFish);
|
return std::make_pair(activeFish, remainingFish);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
#include <libultraship/libultraship.h>
|
#include <libultraship/libultraship.h>
|
||||||
#include <textures/icon_item_static/icon_item_static.h>
|
#include <textures/icon_item_static/icon_item_static.h>
|
||||||
#include <textures/icon_item_24_static/icon_item_24_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/ResourceManagerHelpers.h"
|
||||||
#include "soh/SohGui/SohGui.hpp"
|
#include "soh/SohGui/SohGui.hpp"
|
||||||
#include <imgui.h>
|
#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);
|
CVarSetInteger(CVAR_GENERAL("RandoGenerating"), 0);
|
||||||
Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame();
|
Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame();
|
||||||
|
|
||||||
|
|
@ -4198,7 +4197,6 @@ bool GenerateRandomizer(std::string seed /*= ""*/) {
|
||||||
}
|
}
|
||||||
if (CVarGetInteger(CVAR_GENERAL("RandoGenerating"), 0) == 0) {
|
if (CVarGetInteger(CVAR_GENERAL("RandoGenerating"), 0) == 0) {
|
||||||
randoThread = std::thread(&GenerateRandomizerImgui, seed);
|
randoThread = std::thread(&GenerateRandomizerImgui, seed);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue