mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-08-22 14:23:44 -07:00
Added initial Available Checks - Recalculate DebugConsole command.
This commit is contained in:
parent
b8796926a9
commit
de8cb5bf08
5 changed files with 37 additions and 5 deletions
|
@ -1474,6 +1474,28 @@ static bool AvailabeChecksProcessUndiscoveredExitsHandler(std::shared_ptr<Ship::
|
|||
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) {
|
||||
// Console
|
||||
CMD_REGISTER("file_select", { FileSelectHandler, "Returns to the file select." });
|
||||
|
@ -1736,5 +1758,11 @@ void DebugConsole_Init(void) {
|
|||
"Available Checks - Process Undiscovered Exits",
|
||||
{ { "enable", Ship::ArgumentType::NUMBER, true } } });
|
||||
|
||||
CMD_REGISTER("acr", { AvailabeChecksRecalculateHandler,
|
||||
"Available Checks - Recalculate",
|
||||
{
|
||||
{ "starting_region", Ship::ArgumentType::NUMBER, true },
|
||||
} });
|
||||
|
||||
Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame();
|
||||
}
|
||||
|
|
|
@ -530,9 +530,13 @@ void ProcessRegion(Region* region, GetAccessibleLocationsStruct& gals, Randomize
|
|||
// Return any of the targetLocations that are accessible in logic
|
||||
std::vector<RandomizerCheck> ReachabilitySearch(const std::vector<RandomizerCheck>& targetLocations,
|
||||
RandomizerGet ignore /* = RG_NONE*/,
|
||||
bool calculatingAvailableChecks /* = false */) {
|
||||
bool calculatingAvailableChecks /* = false */,
|
||||
RandomizerRegion startingRegion /* = RR_ROOT */) {
|
||||
auto ctx = Rando::Context::GetInstance();
|
||||
GetAccessibleLocationsStruct gals(0);
|
||||
if (startingRegion != RR_ROOT) {
|
||||
gals.regionPool.insert(gals.regionPool.begin(), startingRegion);
|
||||
}
|
||||
ResetLogic(ctx, gals, !calculatingAvailableChecks);
|
||||
if (calculatingAvailableChecks) {
|
||||
logic->Reset(false);
|
||||
|
|
|
@ -62,7 +62,7 @@ std::vector<RandomizerCheck> GetEmptyLocations(std::vector<RandomizerCheck> allo
|
|||
void ProcessRegion(Region* region, GetAccessibleLocationsStruct& gals, RandomizerGet ignore = RG_NONE,
|
||||
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();
|
||||
|
||||
|
|
|
@ -1984,7 +1984,7 @@ void ImGuiDrawTwoColorPickerSection(const char* text, const char* cvarMainName,
|
|||
UIWidgets::PopStyleCombobox();
|
||||
}
|
||||
|
||||
void RecalculateAvailableChecks() {
|
||||
void RecalculateAvailableChecks(RandomizerRegion startingRegion /* = RR_ROOT */) {
|
||||
if (!enableAvailableChecks) {
|
||||
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) {
|
||||
const auto& location = Rando::StaticData::GetLocation(rc);
|
||||
const auto& itemLocation = ctx->GetItemLocation(rc);
|
||||
|
|
|
@ -61,5 +61,5 @@ void UpdateAllOrdering();
|
|||
void UpdateAllAreas();
|
||||
void RecalculateAllAreaTotals();
|
||||
void SpoilAreaFromCheck(RandomizerCheck rc);
|
||||
void RecalculateAvailableChecks();
|
||||
void RecalculateAvailableChecks(RandomizerRegion startingRegion = RR_ROOT);
|
||||
} // namespace CheckTracker
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue