diff options
| author | Garrett Cox <garrettjcox@gmail.com> | 2026-01-23 23:58:38 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-01-23 23:58:38 -0600 |
| commit | 1e57e04d44fda7a44629a8e5db5637300016a2e7 (patch) | |
| tree | 790d954bfc98f0af66385816cd83d9184171058a | |
| parent | c01bfa9591f341ff078bc8b1d3cbbeb5eefa9fef (diff) | |
Fix glitchless not handling force junk items corretly (#1497)
| -rw-r--r-- | mm/2s2h/Rando/Logic/GlitchlessLogic.cpp | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/mm/2s2h/Rando/Logic/GlitchlessLogic.cpp b/mm/2s2h/Rando/Logic/GlitchlessLogic.cpp index af266198f..c00652fd8 100644 --- a/mm/2s2h/Rando/Logic/GlitchlessLogic.cpp +++ b/mm/2s2h/Rando/Logic/GlitchlessLogic.cpp @@ -22,7 +22,7 @@ void ApplyGlitchlessLogicToSaveContext(std::vector<RandoCheckId>& checkPool, std memcpy(&copiedSaveContext, &gSaveContext, sizeof(SaveContext)); std::set<RandoRegionId> regionsInLogic = { RR_MAX }; - std::map<RandoCheckId, bool> checksInLogic; + std::set<RandoCheckId> checksInLogic; std::set<std::pair<RandoEvent, std::function<bool()>>*> eventsInLogic; // Initialize time states using shared function @@ -100,22 +100,22 @@ void ApplyGlitchlessLogicToSaveContext(std::vector<RandoCheckId>& checkPool, std // Apply any new checks for (auto& [randoCheckId, checkLogic] : randoRegion.checks) { - if (checksInLogic.find(randoCheckId) == checksInLogic.end() && checkLogic.first()) { + if (!checksInLogic.contains(randoCheckId) && checkLogic.first()) { // VALIDATION: Verify check is reachable with owned time TimeLogic::ValidateRegionTimeOwnership(regionId, randoCheckId, regionTimeStates[regionId].timeSlices, "Glitchless"); + checksInLogic.insert(randoCheckId); + + RandoItemId randoItemId = RANDO_SAVE_CHECKS[randoCheckId].randoItemId; + auto it = std::find(checkPool.begin(), checkPool.end(), randoCheckId); - bool isShuffled = it != checkPool.end(); - checksInLogic.insert({ randoCheckId, isShuffled }); - if (isShuffled) { + bool inPool = it != checkPool.end(); + if (inPool) { checkPool.erase(it); - } - - RandoItemId randoItemId; + randoItemId = RANDO_SAVE_CHECKS[randoCheckId].randoItemId = itemPool.back(); + RANDO_SAVE_CHECKS[randoCheckId].shuffled = true; - if (isShuffled) { - randoItemId = itemPool.back(); itemPool.pop_back(); if (Rando::StaticData::Items[randoItemId].randoItemType == RITYPE_JUNK || @@ -125,12 +125,8 @@ void ApplyGlitchlessLogicToSaveContext(std::vector<RandoCheckId>& checkPool, std } SPDLOG_TRACE("Check: {}:{}", Rando::StaticData::Checks[randoCheckId].name, Rando::StaticData::Items[randoItemId].spoilerName); - } else { - randoItemId = Rando::StaticData::Checks[randoCheckId].randoItemId; } - RANDO_SAVE_CHECKS[randoCheckId].randoItemId = randoItemId; - RANDO_SAVE_CHECKS[randoCheckId].shuffled = isShuffled; GiveItem(ConvertItem(randoItemId)); // Update time states for all regions when time items are obtained @@ -249,10 +245,11 @@ void ApplyGlitchlessLogicToSaveContext(std::vector<RandoCheckId>& checkPool, std } } - for (auto& [randoCheckId, isShuffled] : checksInLogic) { + for (auto& randoCheckId : checksInLogic) { copiedSaveContext.save.shipSaveInfo.rando.randoSaveChecks[randoCheckId].randoItemId = RANDO_SAVE_CHECKS[randoCheckId].randoItemId; - copiedSaveContext.save.shipSaveInfo.rando.randoSaveChecks[randoCheckId].shuffled = isShuffled; + copiedSaveContext.save.shipSaveInfo.rando.randoSaveChecks[randoCheckId].shuffled = + RANDO_SAVE_CHECKS[randoCheckId].shuffled; } memcpy(&gSaveContext, &copiedSaveContext, sizeof(SaveContext)); |
