CheckBeatable: move clearing ctx->playthroughBeatable into function (#5408)

This commit is contained in:
Philip Dubé 2025-05-02 03:11:55 +00:00 committed by GitHub
commit 626511ffb1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -327,13 +327,12 @@ bool IsBeatableWithout(RandomizerCheck excludedCheck, bool replaceItem,
auto ctx = Rando::Context::GetInstance(); auto ctx = Rando::Context::GetInstance();
RandomizerGet copy = ctx->GetItemLocation(excludedCheck)->GetPlacedRandomizerGet(); // Copy out item RandomizerGet copy = ctx->GetItemLocation(excludedCheck)->GetPlacedRandomizerGet(); // Copy out item
ctx->GetItemLocation(excludedCheck)->SetPlacedItem(RG_NONE); // Write in empty item ctx->GetItemLocation(excludedCheck)->SetPlacedItem(RG_NONE); // Write in empty item
ctx->playthroughBeatable = false;
logic->Reset(); logic->Reset();
CheckBeatable(ignore); bool result = CheckBeatable(ignore);
if (replaceItem) { if (replaceItem) {
ctx->GetItemLocation(excludedCheck)->SetPlacedItem(copy); // Immediately put item back ctx->GetItemLocation(excludedCheck)->SetPlacedItem(copy); // Immediately put item back
} }
return ctx->playthroughBeatable; return result;
} }
// Reset non-Logic-class logic, and optionally apply the initial inventory // Reset non-Logic-class logic, and optionally apply the initial inventory
@ -581,6 +580,7 @@ void GeneratePlaythrough() {
// return if the seed is currently beatable or not // return if the seed is currently beatable or not
bool CheckBeatable(RandomizerGet ignore /* = RG_NONE*/) { bool CheckBeatable(RandomizerGet ignore /* = RG_NONE*/) {
auto ctx = Rando::Context::GetInstance(); auto ctx = Rando::Context::GetInstance();
ctx->playthroughBeatable = false;
GetAccessibleLocationsStruct gals(0); GetAccessibleLocationsStruct gals(0);
ResetLogic(ctx, gals, true); ResetLogic(ctx, gals, true);
do { do {
@ -929,10 +929,8 @@ static void AssumedFill(const std::vector<RandomizerGet>& items, const std::vect
// If ALR is off, then we check beatability after placing the item. // If ALR is off, then we check beatability after placing the item.
// If the game is beatable, then we can stop placing items with logic. // If the game is beatable, then we can stop placing items with logic.
if (!ctx->GetOption(RSK_ALL_LOCATIONS_REACHABLE)) { if (!ctx->GetOption(RSK_ALL_LOCATIONS_REACHABLE)) {
ctx->playthroughBeatable = false;
logic->Reset(); logic->Reset();
CheckBeatable(); if (CheckBeatable()) {
if (ctx->playthroughBeatable) {
SPDLOG_DEBUG("Game beatable, now placing items randomly. " + std::to_string(itemsToPlace.size()) + SPDLOG_DEBUG("Game beatable, now placing items randomly. " + std::to_string(itemsToPlace.size()) +
" major items remaining.\n\n"); " major items remaining.\n\n");
FastFill(itemsToPlace, GetEmptyLocations(allowedLocations), true); FastFill(itemsToPlace, GetEmptyLocations(allowedLocations), true);