diff --git a/Source/Core/Core/HW/EXI/EXI_DeviceSlippi.cpp b/Source/Core/Core/HW/EXI/EXI_DeviceSlippi.cpp index 6583f9d9a4..9e4cb06cc5 100644 --- a/Source/Core/Core/HW/EXI/EXI_DeviceSlippi.cpp +++ b/Source/Core/Core/HW/EXI/EXI_DeviceSlippi.cpp @@ -1868,31 +1868,16 @@ u16 CEXISlippi::getRandomStage() 0x20, // Final Destination }; - std::vector stagesToConsider; - - // stagesToConsider = stages; - // Add all stages to consider to the vector - for (auto it = stages.begin(); it != stages.end(); ++it) - { - auto stageId = *it; - if (lastSelectedStage != nullptr && stageId == *lastSelectedStage) - continue; - - stagesToConsider.push_back(stageId); - } - - // Shuffle the stages to consider. This isn't really necessary considering we - // use a random number to select an index but idk the generator was giving a lot - // of the same stage (same index) many times in a row or so it seemed to I figured - // this can't hurt - std::shuffle(stagesToConsider.begin(), stagesToConsider.end(), generator); + // Reset stage pool if it's empty + if (stagePool.empty()) + stagePool.insert(stagePool.end(), stages.begin(), stages.end()); // Get random stage - int randIndex = generator() % stagesToConsider.size(); - selectedStage = stagesToConsider[randIndex]; + int randIndex = generator() % stagePool.size(); + selectedStage = stagePool[randIndex]; - // Set last selected stage - lastSelectedStage = &selectedStage; + // Remove last selection from stage pool + stagePool.erase(stagePool.begin() + randIndex); return selectedStage; } @@ -2074,6 +2059,9 @@ void CEXISlippi::handleConnectionCleanup() // Clear character selections localSelections.Reset(); + // Reset random stage pool + stagePool.clear(); + ERROR_LOG(SLIPPI_ONLINE, "Connection cleanup completed..."); } diff --git a/Source/Core/Core/HW/EXI/EXI_DeviceSlippi.h b/Source/Core/Core/HW/EXI/EXI_DeviceSlippi.h index 2daf21cfe9..7f51249747 100644 --- a/Source/Core/Core/HW/EXI/EXI_DeviceSlippi.h +++ b/Source/Core/Core/HW/EXI/EXI_DeviceSlippi.h @@ -197,7 +197,7 @@ namespace ExpansionInterface std::unique_ptr m_current_game = nullptr; SlippiMatchmaking::MatchSearchSettings lastSearch; - u16* lastSelectedStage = nullptr; + std::vector stagePool; u32 frameSeqIdx = 0;