mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-08-22 22:33:43 -07:00
Added Randomizer_EntranceDiscovered.
This commit is contained in:
parent
605c86e02c
commit
8738c1f936
6 changed files with 37 additions and 25 deletions
|
@ -4,6 +4,7 @@
|
|||
#include "3drando/pool_functions.hpp"
|
||||
#include "3drando/item_pool.hpp"
|
||||
#include "../debugger/performanceTimer.h"
|
||||
#include "randomizer_check_tracker.h"
|
||||
|
||||
#include <spdlog/spdlog.h>
|
||||
|
||||
|
@ -250,6 +251,8 @@ std::string EntranceNameByRegions(RandomizerRegion parentRegion, RandomizerRegio
|
|||
return RegionTable(parentRegion)->regionName + " -> " + RegionTable(connectedRegion)->regionName;
|
||||
}
|
||||
|
||||
std::unordered_map<int16_t, Entrance*> entranceMap;
|
||||
|
||||
void SetAllEntrancesData(std::vector<EntranceInfoPair>& entranceShuffleTable) {
|
||||
auto ctx = Rando::Context::GetInstance();
|
||||
for (auto& entrancePair : entranceShuffleTable) {
|
||||
|
@ -262,6 +265,7 @@ void SetAllEntrancesData(std::vector<EntranceInfoPair>& entranceShuffleTable) {
|
|||
forwardEntrance->SetIndex(forwardEntry.index);
|
||||
forwardEntrance->SetType(forwardEntry.type);
|
||||
forwardEntrance->SetAsPrimary();
|
||||
entranceMap[forwardEntry.index] = forwardEntrance;
|
||||
|
||||
// When decouple entrances is on, mark the forward entrance
|
||||
if (ctx->GetOption(RSK_DECOUPLED_ENTRANCES)) {
|
||||
|
@ -273,6 +277,7 @@ void SetAllEntrancesData(std::vector<EntranceInfoPair>& entranceShuffleTable) {
|
|||
returnEntrance->SetIndex(returnEntry.index);
|
||||
returnEntrance->SetType(returnEntry.type);
|
||||
forwardEntrance->BindTwoWay(returnEntrance);
|
||||
entranceMap[returnEntry.index] = returnEntrance;
|
||||
|
||||
// Mark reverse entrance as decoupled
|
||||
if (ctx->GetOption(RSK_DECOUPLED_ENTRANCES)) {
|
||||
|
@ -1667,21 +1672,11 @@ void EntranceShuffler::ParseJson(nlohmann::json spoilerFileJson) {
|
|||
void EntranceShuffler::ApplyEntranceOverrides() {
|
||||
SetAllEntrancesData(entranceShuffleTable);
|
||||
|
||||
std::unordered_map<int16_t, Entrance*> entrances;
|
||||
for (uint32_t rr = RR_NONE; rr < RR_MAX; rr++) {
|
||||
for (auto& exit : areaTable[rr].exits) {
|
||||
int16_t index = exit.GetIndex();
|
||||
if (index != -1) {
|
||||
entrances[index] = &exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < entranceOverrides.size(); i++) {
|
||||
EntranceOverride entranceOverride = entranceOverrides[i];
|
||||
|
||||
Entrance* entrance = entrances[entranceOverride.index];
|
||||
Entrance* overrideEntrance = entrances[entranceOverride.override];
|
||||
Entrance* entrance = entranceMap[entranceOverride.index];
|
||||
Entrance* overrideEntrance = entranceMap[entranceOverride.override];
|
||||
|
||||
entrance->Disconnect();
|
||||
entrance->Connect(overrideEntrance->GetOriginalConnectedRegionKey());
|
||||
|
@ -1689,6 +1684,23 @@ void EntranceShuffler::ApplyEntranceOverrides() {
|
|||
}
|
||||
} // namespace Rando
|
||||
|
||||
extern "C" EntranceOverride* Randomizer_GetEntranceOverrides() {
|
||||
extern "C" {
|
||||
EntranceOverride* Randomizer_GetEntranceOverrides() {
|
||||
return Rando::Context::GetInstance()->GetEntranceShuffler()->entranceOverrides.data();
|
||||
}
|
||||
|
||||
void Randomizer_DiscoverRegion(Region* region) {
|
||||
region->IsDiscovered = true;
|
||||
|
||||
// RANDOTODO: Discover other regions that will be known based on rando settings
|
||||
}
|
||||
|
||||
void Randomizer_EntranceDiscovered(s16 index) {
|
||||
Rando::Entrance* entrance = Rando::entranceMap[index];
|
||||
Region* region = entrance->GetConnectedRegion();
|
||||
|
||||
Randomizer_DiscoverRegion(region);
|
||||
|
||||
CheckTracker::RecalculateAvailableChecks();
|
||||
}
|
||||
}
|
|
@ -153,6 +153,7 @@ class EntranceShuffler {
|
|||
extern "C" {
|
||||
#endif
|
||||
EntranceOverride* Randomizer_GetEntranceOverrides();
|
||||
void Randomizer_EntranceDiscovered(s16 index);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -138,6 +138,8 @@ class Region {
|
|||
bool addedToPool = false;
|
||||
;
|
||||
|
||||
bool IsDiscovered = false;
|
||||
|
||||
void ApplyTimePass();
|
||||
|
||||
bool UpdateEvents();
|
||||
|
|
|
@ -1967,11 +1967,13 @@ void RecalculateAvailableChecks() {
|
|||
ResetPerformanceTimer(PT_RECALCULATE_AVAILABLE_CHECKS);
|
||||
StartPerformanceTimer(PT_RECALCULATE_AVAILABLE_CHECKS);
|
||||
|
||||
const auto& ctx = Rando::Context::GetInstance();
|
||||
|
||||
std::vector<RandomizerCheck> targetLocations;
|
||||
targetLocations.reserve(RR_MAX);
|
||||
for (auto& location : Rando::StaticData::GetLocationTable()) {
|
||||
RandomizerCheck rc = location.GetRandomizerCheck();
|
||||
Rando::ItemLocation* itemLocation = OTRGlobals::Instance->gRandoContext->GetItemLocation(rc);
|
||||
Rando::ItemLocation* itemLocation = ctx->GetItemLocation(rc);
|
||||
itemLocation->SetAvailable(false);
|
||||
if (!itemLocation->HasObtained()) {
|
||||
targetLocations.emplace_back(rc);
|
||||
|
@ -1981,17 +1983,10 @@ void RecalculateAvailableChecks() {
|
|||
std::vector<RandomizerCheck> availableChecks = ReachabilitySearch(targetLocations, RG_NONE, true);
|
||||
for (auto& rc : availableChecks) {
|
||||
const auto& location = Rando::StaticData::GetLocation(rc);
|
||||
const auto& itemLocation = OTRGlobals::Instance->gRandoContext->GetItemLocation(rc);
|
||||
const auto& itemLocation = ctx->GetItemLocation(rc);
|
||||
const auto& region = areaTable[itemLocation->GetParentRegionKey()];
|
||||
|
||||
bool regionDiscovered = false;
|
||||
const auto& entrances = areaTable[itemLocation->GetParentRegionKey()].entrances;
|
||||
for (const auto& entrance : entrances) {
|
||||
if (IsEntranceDiscovered(entrance->GetIndex())) {
|
||||
regionDiscovered = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!regionDiscovered) {
|
||||
if (ctx->GetOption(RSK_SHUFFLE_ENTRANCES).Get() && !region.IsDiscovered) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -2008,7 +2003,7 @@ void RecalculateAvailableChecks() {
|
|||
for (auto& [rcArea, vec] : checksByArea) {
|
||||
areaChecksAvailable[rcArea] = 0;
|
||||
for (auto& rc : vec) {
|
||||
Rando::ItemLocation* itemLocation = OTRGlobals::Instance->gRandoContext->GetItemLocation(rc);
|
||||
Rando::ItemLocation* itemLocation = ctx->GetItemLocation(rc);
|
||||
if (itemLocation->IsAvailable() && IsVisibleInCheckTracker(rc) && !IsCheckHidden(rc)) {
|
||||
areaChecksAvailable[rcArea]++;
|
||||
}
|
||||
|
|
|
@ -809,6 +809,7 @@ void Entrance_SetEntranceDiscovered(u16 entranceIndex, u8 isReversedEntrance) {
|
|||
if (idx < SAVEFILE_ENTRANCES_DISCOVERED_IDX_COUNT) {
|
||||
u32 entranceBit = 1 << (entranceIndex - (idx * bitsPerIndex));
|
||||
gSaveContext.ship.stats.entrancesDiscovered[idx] |= entranceBit;
|
||||
Randomizer_EntranceDiscovered(entranceIndex);
|
||||
|
||||
// Set reverse entrance when not decoupled
|
||||
if (!Randomizer_GetSettingValue(RSK_DECOUPLED_ENTRANCES) && !isReversedEntrance) {
|
||||
|
|
|
@ -90,6 +90,7 @@ void InitEntranceTrackingData();
|
|||
s16 GetLastEntranceOverride();
|
||||
s16 GetCurrentGrottoId();
|
||||
const EntranceData* GetEntranceData(s16);
|
||||
void EntranceDiscovered(s16 index);
|
||||
bool IsEntranceDiscovered(s16 index);
|
||||
|
||||
class EntranceTrackerSettingsWindow : public Ship::GuiWindow {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue