Recalculate Available Checks from Current Region (#6165)
This commit is contained in:
@@ -1736,6 +1736,11 @@ void EntranceShuffler::ApplyEntranceOverrides() {
|
|||||||
entrance->SetAsShuffled();
|
entrance->SetAsShuffled();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const Entrance* EntranceShuffler::GetEntranceByIndex(int16_t index) {
|
||||||
|
auto iter = entranceMap.find(index);
|
||||||
|
return iter != entranceMap.end() ? iter->second : nullptr;
|
||||||
|
}
|
||||||
} // namespace Rando
|
} // namespace Rando
|
||||||
|
|
||||||
extern "C" EntranceOverride* Randomizer_GetEntranceOverrides() {
|
extern "C" EntranceOverride* Randomizer_GetEntranceOverrides() {
|
||||||
|
|||||||
@@ -133,6 +133,8 @@ class EntranceShuffler {
|
|||||||
void ParseJson(nlohmann::json spoilerFileJson);
|
void ParseJson(nlohmann::json spoilerFileJson);
|
||||||
void ApplyEntranceOverrides();
|
void ApplyEntranceOverrides();
|
||||||
|
|
||||||
|
static const Entrance* GetEntranceByIndex(int16_t index);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<Entrance*> AssumeEntrancePool(std::vector<Entrance*>& entrancePool);
|
std::vector<Entrance*> AssumeEntrancePool(std::vector<Entrance*>& entrancePool);
|
||||||
bool ShuffleOneWayPriorityEntrances(std::map<std::string, PriorityEntrance>& oneWayPriorities,
|
bool ShuffleOneWayPriorityEntrances(std::map<std::string, PriorityEntrance>& oneWayPriorities,
|
||||||
|
|||||||
@@ -270,6 +270,8 @@ std::vector<uint32_t> buttons = { BTN_A, BTN_B, BTN_CUP, BTN_CDOWN, BTN_CLEFT,
|
|||||||
BTN_Z, BTN_R, BTN_START, BTN_DUP, BTN_DDOWN, BTN_DLEFT, BTN_DRIGHT };
|
BTN_Z, BTN_R, BTN_START, BTN_DUP, BTN_DDOWN, BTN_DLEFT, BTN_DRIGHT };
|
||||||
static ImGuiTextFilter checkSearch;
|
static ImGuiTextFilter checkSearch;
|
||||||
static bool recalculateAvailable = false;
|
static bool recalculateAvailable = false;
|
||||||
|
static RandomizerRegion availableChecksStartingRegion = RR_ROOT;
|
||||||
|
static int16_t previousEntrance = 0;
|
||||||
std::array<bool, RCAREA_INVALID> filterAreasHidden = { 0 };
|
std::array<bool, RCAREA_INVALID> filterAreasHidden = { 0 };
|
||||||
std::array<bool, RC_MAX> filterChecksHidden = { 0 };
|
std::array<bool, RC_MAX> filterChecksHidden = { 0 };
|
||||||
|
|
||||||
@@ -610,9 +612,7 @@ void CheckTrackerLoadGame(int32_t fileNum) {
|
|||||||
|
|
||||||
RegionTable_Init();
|
RegionTable_Init();
|
||||||
|
|
||||||
if (Rando::Context::GetInstance()->GetOption(RSK_SHUFFLE_ENTRANCES).Get()) {
|
Rando::Context::GetInstance()->GetEntranceShuffler()->ApplyEntranceOverrides();
|
||||||
Rando::Context::GetInstance()->GetEntranceShuffler()->ApplyEntranceOverrides();
|
|
||||||
}
|
|
||||||
|
|
||||||
recalculateAvailable = true;
|
recalculateAvailable = true;
|
||||||
}
|
}
|
||||||
@@ -954,6 +954,8 @@ void SetAreaSpoiled(RandomizerCheckArea rcArea) {
|
|||||||
SaveManager::Instance->SaveSection(gSaveContext.fileNum, sectionId, true);
|
SaveManager::Instance->SaveSection(gSaveContext.fileNum, sectionId, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InternalRecalculateAvailableChecks(RandomizerRegion startingRegion);
|
||||||
|
|
||||||
void CheckTrackerWindow::DrawElement() {
|
void CheckTrackerWindow::DrawElement() {
|
||||||
Color_Background = CVarGetColor(CVAR_TRACKER_CHECK("BgColor.Value"), Color_Bg_Default);
|
Color_Background = CVarGetColor(CVAR_TRACKER_CHECK("BgColor.Value"), Color_Bg_Default);
|
||||||
Color_Area_Incomplete_Main = CVarGetColor(CVAR_TRACKER_CHECK("AreaIncomplete.MainColor.Value"), Color_Main_Default);
|
Color_Area_Incomplete_Main = CVarGetColor(CVAR_TRACKER_CHECK("AreaIncomplete.MainColor.Value"), Color_Main_Default);
|
||||||
@@ -1027,9 +1029,15 @@ void CheckTrackerWindow::DrawElement() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (gPlayState->nextEntranceIndex != previousEntrance) {
|
||||||
|
previousEntrance = gPlayState->nextEntranceIndex;
|
||||||
|
recalculateAvailable = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (recalculateAvailable) {
|
if (recalculateAvailable) {
|
||||||
recalculateAvailable = false;
|
recalculateAvailable = false;
|
||||||
RecalculateAvailableChecks();
|
InternalRecalculateAvailableChecks(availableChecksStartingRegion);
|
||||||
|
availableChecksStartingRegion = RR_ROOT;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Quick Options
|
// Quick Options
|
||||||
@@ -2052,7 +2060,7 @@ void ImGuiDrawTwoColorPickerSection(const char* text, const char* cvarMainName,
|
|||||||
UIWidgets::PopStyleCombobox();
|
UIWidgets::PopStyleCombobox();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RecalculateAvailableChecks(RandomizerRegion startingRegion /* = RR_ROOT */) {
|
void InternalRecalculateAvailableChecks(RandomizerRegion startingRegion) {
|
||||||
if (!enableAvailableChecks || !GameInteractor::IsSaveLoaded()) {
|
if (!enableAvailableChecks || !GameInteractor::IsSaveLoaded()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -2063,6 +2071,20 @@ void RecalculateAvailableChecks(RandomizerRegion startingRegion /* = RR_ROOT */)
|
|||||||
const auto& ctx = Rando::Context::GetInstance();
|
const auto& ctx = Rando::Context::GetInstance();
|
||||||
logic = ctx->GetLogic();
|
logic = ctx->GetLogic();
|
||||||
|
|
||||||
|
int16_t entranceIndex = gPlayState->nextEntranceIndex;
|
||||||
|
if (startingRegion == RR_ROOT && entranceIndex >= 0 && entranceIndex < ENTR_MAX) {
|
||||||
|
// Try to find a mapped entrance
|
||||||
|
// e.g. ENTR_DEKU_TREE_0_1 (index 1) is not mapped, but ENTR_DEKU_TREE_ENTRANCE (index 0) is mapped
|
||||||
|
const int8_t scene = gEntranceTable[entranceIndex].scene;
|
||||||
|
for (; entranceIndex >= 0 && gEntranceTable[entranceIndex].scene == scene; entranceIndex--) {
|
||||||
|
const auto entrance = Rando::EntranceShuffler::GetEntranceByIndex(entranceIndex);
|
||||||
|
if (entrance != nullptr) {
|
||||||
|
startingRegion = entrance->GetOriginalConnectedRegionKey();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<RandomizerCheck> targetLocations;
|
std::vector<RandomizerCheck> targetLocations;
|
||||||
targetLocations.reserve(RC_MAX);
|
targetLocations.reserve(RC_MAX);
|
||||||
for (auto& location : Rando::StaticData::GetLocationTable()) {
|
for (auto& location : Rando::StaticData::GetLocationTable()) {
|
||||||
@@ -2097,6 +2119,11 @@ void RecalculateAvailableChecks(RandomizerRegion startingRegion /* = RR_ROOT */)
|
|||||||
GetPerformanceTimer(PT_RECALCULATE_AVAILABLE_CHECKS).count());
|
GetPerformanceTimer(PT_RECALCULATE_AVAILABLE_CHECKS).count());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RecalculateAvailableChecks(RandomizerRegion startingRegion /* = RR_ROOT */) {
|
||||||
|
recalculateAvailable = true;
|
||||||
|
availableChecksStartingRegion = startingRegion;
|
||||||
|
}
|
||||||
|
|
||||||
void CheckTracker_LoadFromPreset(nlohmann::json info) {
|
void CheckTracker_LoadFromPreset(nlohmann::json info) {
|
||||||
presetLoaded = true;
|
presetLoaded = true;
|
||||||
presetPos = { info["pos"]["x"], info["pos"]["y"] };
|
presetPos = { info["pos"]["x"], info["pos"]["y"] };
|
||||||
|
|||||||
@@ -820,7 +820,6 @@ void Entrance_SetEntranceDiscovered(u16 entranceIndex, u8 isReversedEntrance) {
|
|||||||
if (idx < SAVEFILE_ENTRANCES_DISCOVERED_IDX_COUNT) {
|
if (idx < SAVEFILE_ENTRANCES_DISCOVERED_IDX_COUNT) {
|
||||||
u32 entranceBit = 1 << (entranceIndex - (idx * bitsPerIndex));
|
u32 entranceBit = 1 << (entranceIndex - (idx * bitsPerIndex));
|
||||||
gSaveContext.ship.stats.entrancesDiscovered[idx] |= entranceBit;
|
gSaveContext.ship.stats.entrancesDiscovered[idx] |= entranceBit;
|
||||||
CheckTracker_RecalculateAvailableChecks();
|
|
||||||
|
|
||||||
// Set reverse entrance when not decoupled
|
// Set reverse entrance when not decoupled
|
||||||
if (!Randomizer_GetSettingValue(RSK_DECOUPLED_ENTRANCES) && !isReversedEntrance) {
|
if (!Randomizer_GetSettingValue(RSK_DECOUPLED_ENTRANCES) && !isReversedEntrance) {
|
||||||
|
|||||||
@@ -690,6 +690,9 @@ void Play_Init(GameState* thisx) {
|
|||||||
GET_PLAYER(play)->actor.world.pos.y + Player_GetHeight(GET_PLAYER(play)) + 5.0f,
|
GET_PLAYER(play)->actor.world.pos.y + Player_GetHeight(GET_PLAYER(play)) + 5.0f,
|
||||||
GET_PLAYER(play)->actor.world.pos.z, 0, 0, 0, 1, true);
|
GET_PLAYER(play)->actor.world.pos.z, 0, 0, 0, 1, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// nextEntranceIndex was not initialized, so the previous value was carried over during soft resets.
|
||||||
|
gPlayState->nextEntranceIndex = gSaveContext.entranceIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Play_Update(PlayState* play) {
|
void Play_Update(PlayState* play) {
|
||||||
|
|||||||
Reference in New Issue
Block a user