mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-08-26 20:25:58 +00:00
make dolphin random cycle through all stages (#31)
Co-authored-by: Jas Laferriere <Fizzi36@gmail.com>
This commit is contained in:
parent
98285614b2
commit
fc7b9e4e8f
2 changed files with 11 additions and 23 deletions
|
@ -1868,31 +1868,16 @@ u16 CEXISlippi::getRandomStage()
|
||||||
0x20, // Final Destination
|
0x20, // Final Destination
|
||||||
};
|
};
|
||||||
|
|
||||||
std::vector<u16> stagesToConsider;
|
// Reset stage pool if it's empty
|
||||||
|
if (stagePool.empty())
|
||||||
// stagesToConsider = stages;
|
stagePool.insert(stagePool.end(), stages.begin(), stages.end());
|
||||||
// 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);
|
|
||||||
|
|
||||||
// Get random stage
|
// Get random stage
|
||||||
int randIndex = generator() % stagesToConsider.size();
|
int randIndex = generator() % stagePool.size();
|
||||||
selectedStage = stagesToConsider[randIndex];
|
selectedStage = stagePool[randIndex];
|
||||||
|
|
||||||
// Set last selected stage
|
// Remove last selection from stage pool
|
||||||
lastSelectedStage = &selectedStage;
|
stagePool.erase(stagePool.begin() + randIndex);
|
||||||
|
|
||||||
return selectedStage;
|
return selectedStage;
|
||||||
}
|
}
|
||||||
|
@ -2074,6 +2059,9 @@ void CEXISlippi::handleConnectionCleanup()
|
||||||
// Clear character selections
|
// Clear character selections
|
||||||
localSelections.Reset();
|
localSelections.Reset();
|
||||||
|
|
||||||
|
// Reset random stage pool
|
||||||
|
stagePool.clear();
|
||||||
|
|
||||||
ERROR_LOG(SLIPPI_ONLINE, "Connection cleanup completed...");
|
ERROR_LOG(SLIPPI_ONLINE, "Connection cleanup completed...");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -197,7 +197,7 @@ namespace ExpansionInterface
|
||||||
std::unique_ptr<Slippi::SlippiGame> m_current_game = nullptr;
|
std::unique_ptr<Slippi::SlippiGame> m_current_game = nullptr;
|
||||||
SlippiMatchmaking::MatchSearchSettings lastSearch;
|
SlippiMatchmaking::MatchSearchSettings lastSearch;
|
||||||
|
|
||||||
u16* lastSelectedStage = nullptr;
|
std::vector<u16> stagePool;
|
||||||
|
|
||||||
u32 frameSeqIdx = 0;
|
u32 frameSeqIdx = 0;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue