Added initial Available Checks - Recalculate DebugConsole command.

This commit is contained in:
Anthony Stewart 2025-05-13 21:21:32 -05:00
commit de8cb5bf08
5 changed files with 37 additions and 5 deletions

View file

@ -1474,6 +1474,28 @@ static bool AvailabeChecksProcessUndiscoveredExitsHandler(std::shared_ptr<Ship::
return 0; return 0;
} }
static bool AvailabeChecksRecalculateHandler(std::shared_ptr<Ship::Console> Console,
const std::vector<std::string>& args, std::string* output) {
RandomizerRegion startingRegion = RR_ROOT;
if (args.size() > 1) {
try {
startingRegion = static_cast<RandomizerRegion>(std::stoi(args[1]));
} catch (std::invalid_argument const& ex) {
ERROR_MESSAGE("[SOH] Region should be a number");
return 1;
}
if (startingRegion <= RR_NONE || startingRegion >= RR_MAX) {
ERROR_MESSAGE("[SOH] Region should be between 1 and %d", RR_MAX - 1);
return 1;
}
}
CheckTracker::RecalculateAvailableChecks(startingRegion);
return 0;
}
void DebugConsole_Init(void) { void DebugConsole_Init(void) {
// Console // Console
CMD_REGISTER("file_select", { FileSelectHandler, "Returns to the file select." }); CMD_REGISTER("file_select", { FileSelectHandler, "Returns to the file select." });
@ -1736,5 +1758,11 @@ void DebugConsole_Init(void) {
"Available Checks - Process Undiscovered Exits", "Available Checks - Process Undiscovered Exits",
{ { "enable", Ship::ArgumentType::NUMBER, true } } }); { { "enable", Ship::ArgumentType::NUMBER, true } } });
CMD_REGISTER("acr", { AvailabeChecksRecalculateHandler,
"Available Checks - Recalculate",
{
{ "starting_region", Ship::ArgumentType::NUMBER, true },
} });
Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame();
} }

View file

@ -530,9 +530,13 @@ void ProcessRegion(Region* region, GetAccessibleLocationsStruct& gals, Randomize
// Return any of the targetLocations that are accessible in logic // Return any of the targetLocations that are accessible in logic
std::vector<RandomizerCheck> ReachabilitySearch(const std::vector<RandomizerCheck>& targetLocations, std::vector<RandomizerCheck> ReachabilitySearch(const std::vector<RandomizerCheck>& targetLocations,
RandomizerGet ignore /* = RG_NONE*/, RandomizerGet ignore /* = RG_NONE*/,
bool calculatingAvailableChecks /* = false */) { bool calculatingAvailableChecks /* = false */,
RandomizerRegion startingRegion /* = RR_ROOT */) {
auto ctx = Rando::Context::GetInstance(); auto ctx = Rando::Context::GetInstance();
GetAccessibleLocationsStruct gals(0); GetAccessibleLocationsStruct gals(0);
if (startingRegion != RR_ROOT) {
gals.regionPool.insert(gals.regionPool.begin(), startingRegion);
}
ResetLogic(ctx, gals, !calculatingAvailableChecks); ResetLogic(ctx, gals, !calculatingAvailableChecks);
if (calculatingAvailableChecks) { if (calculatingAvailableChecks) {
logic->Reset(false); logic->Reset(false);

View file

@ -62,7 +62,7 @@ std::vector<RandomizerCheck> GetEmptyLocations(std::vector<RandomizerCheck> allo
void ProcessRegion(Region* region, GetAccessibleLocationsStruct& gals, RandomizerGet ignore = RG_NONE, void ProcessRegion(Region* region, GetAccessibleLocationsStruct& gals, RandomizerGet ignore = RG_NONE,
bool stopOnBeatable = false, bool addToPlaythrough = false); bool stopOnBeatable = false, bool addToPlaythrough = false);
std::vector<RandomizerCheck> ReachabilitySearch(const std::vector<RandomizerCheck>& allowedLocations, RandomizerGet ignore=RG_NONE, bool calculatingAvailableChecks=false); std::vector<RandomizerCheck> ReachabilitySearch(const std::vector<RandomizerCheck>& allowedLocations, RandomizerGet ignore=RG_NONE, bool calculatingAvailableChecks=false, RandomizerRegion startingRegion=RR_ROOT);
void GeneratePlaythrough(); void GeneratePlaythrough();

View file

@ -1984,7 +1984,7 @@ void ImGuiDrawTwoColorPickerSection(const char* text, const char* cvarMainName,
UIWidgets::PopStyleCombobox(); UIWidgets::PopStyleCombobox();
} }
void RecalculateAvailableChecks() { void RecalculateAvailableChecks(RandomizerRegion startingRegion /* = RR_ROOT */) {
if (!enableAvailableChecks) { if (!enableAvailableChecks) {
return; return;
} }
@ -2005,7 +2005,7 @@ void RecalculateAvailableChecks() {
} }
} }
std::vector<RandomizerCheck> availableChecks = ReachabilitySearch(targetLocations, RG_NONE, true); std::vector<RandomizerCheck> availableChecks = ReachabilitySearch(targetLocations, RG_NONE, true, startingRegion);
for (auto& rc : availableChecks) { for (auto& rc : availableChecks) {
const auto& location = Rando::StaticData::GetLocation(rc); const auto& location = Rando::StaticData::GetLocation(rc);
const auto& itemLocation = ctx->GetItemLocation(rc); const auto& itemLocation = ctx->GetItemLocation(rc);

View file

@ -61,5 +61,5 @@ void UpdateAllOrdering();
void UpdateAllAreas(); void UpdateAllAreas();
void RecalculateAllAreaTotals(); void RecalculateAllAreaTotals();
void SpoilAreaFromCheck(RandomizerCheck rc); void SpoilAreaFromCheck(RandomizerCheck rc);
void RecalculateAvailableChecks(); void RecalculateAvailableChecks(RandomizerRegion startingRegion = RR_ROOT);
} // namespace CheckTracker } // namespace CheckTracker