EntranceShuffler ApplyEntranceOverrides.

This commit is contained in:
Anthony Stewart 2025-04-04 20:03:23 -05:00
commit 4e17050e0c
3 changed files with 348 additions and 311 deletions

View file

@ -851,12 +851,6 @@ void EntranceShuffler::ShuffleEntrancePool(std::vector<Entrance*>& entrancePool,
} }
} }
int EntranceShuffler::ShuffleAllEntrances() {
auto ctx = Rando::Context::GetInstance();
mTotalRandomizableEntrances = 0;
mCurNumRandomizedEntrances = 0;
std::vector<EntranceInfoPair> entranceShuffleTable = { std::vector<EntranceInfoPair> entranceShuffleTable = {
// clang-format off // clang-format off
// Type Parent Region Connected Region Index // Type Parent Region Connected Region Index
@ -1167,6 +1161,12 @@ int EntranceShuffler::ShuffleAllEntrances() {
// clang-format on // clang-format on
}; };
int EntranceShuffler::ShuffleAllEntrances() {
auto ctx = Rando::Context::GetInstance();
mTotalRandomizableEntrances = 0;
mCurNumRandomizedEntrances = 0;
std::map<std::string, PriorityEntrance> priorityEntranceTable = { std::map<std::string, PriorityEntrance> priorityEntranceTable = {
{ "Bolero", { { RR_DMC_CENTRAL_LOCAL }, { EntranceType::OwlDrop, EntranceType::WarpSong } } }, { "Bolero", { { RR_DMC_CENTRAL_LOCAL }, { EntranceType::OwlDrop, EntranceType::WarpSong } } },
{ "Nocturne", { "Nocturne",
@ -1663,6 +1663,36 @@ void EntranceShuffler::ParseJson(nlohmann::json spoilerFileJson) {
} }
} catch (const std::exception& e) { throw e; } } catch (const std::exception& e) { throw e; }
} }
void EntranceShuffler::ApplyEntranceOverrides() {
std::vector<EntranceInfoPair> shuffledEntrances;
shuffledEntrances.reserve(entranceOverrides.size());
for (size_t i = 0; i < entranceOverrides.size(); i++) {
EntranceOverride entranceOverride = entranceOverrides[i];
const EntranceLinkInfo* forwardInfo;
const EntranceLinkInfo* returnInfo;
for (const auto& pair : entranceShuffleTable) {
if (pair.first.index == entranceOverride.index) {
forwardInfo = &pair.first;
}
if (pair.second.index == entranceOverride.index) {
forwardInfo = &pair.second;
}
if (pair.first.index == entranceOverride.override) {
returnInfo = &pair.first;
}
if (pair.second.index == entranceOverride.override) {
returnInfo = &pair.second;
}
}
shuffledEntrances.push_back({ *forwardInfo, *returnInfo });
}
SetAllEntrancesData(shuffledEntrances);
}
} // namespace Rando } // namespace Rando
extern "C" EntranceOverride* Randomizer_GetEntranceOverrides() { extern "C" EntranceOverride* Randomizer_GetEntranceOverrides() {

View file

@ -128,6 +128,7 @@ class EntranceShuffler {
void CreateEntranceOverrides(); void CreateEntranceOverrides();
void UnshuffleAllEntrances(); void UnshuffleAllEntrances();
void ParseJson(nlohmann::json spoilerFileJson); void ParseJson(nlohmann::json spoilerFileJson);
void ApplyEntranceOverrides();
private: private:
std::vector<Entrance*> AssumeEntrancePool(std::vector<Entrance*>& entrancePool); std::vector<Entrance*> AssumeEntrancePool(std::vector<Entrance*>& entrancePool);

View file

@ -580,6 +580,13 @@ void CheckTrackerLoadGame(int32_t fileNum) {
UpdateAllOrdering(); UpdateAllOrdering();
UpdateInventoryChecks(); UpdateInventoryChecks();
UpdateFilters(); UpdateFilters();
RegionTable_Init();
if (Rando::Context::GetInstance()->GetOption(RSK_SHUFFLE_ENTRANCES).Get()) {
Rando::Context::GetInstance()->GetEntranceShuffler()->ApplyEntranceOverrides();
}
RecalculateAvailableChecks(); RecalculateAvailableChecks();
} }
@ -898,7 +905,6 @@ void LoadFile() {
SaveManager::Instance->LoadData("areasSpoiled", areasSpoiled, (uint32_t)0); SaveManager::Instance->LoadData("areasSpoiled", areasSpoiled, (uint32_t)0);
UpdateAllOrdering(); UpdateAllOrdering();
UpdateAllAreas(); UpdateAllAreas();
RegionTable_Init();
} }
void Teardown() { void Teardown() {