mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-26 08:05:38 +00:00
Improved the random game selection functionality in GameSelectorComponent.
This commit is contained in:
parent
f195ba72a2
commit
da3fb9a825
|
@ -63,9 +63,12 @@ public:
|
|||
Settings::getInstance()->getBool("ForceKid"))};
|
||||
|
||||
if (mGameSelection == GameSelection::RANDOM) {
|
||||
for (int i = 0; i < mGameCount; ++i) {
|
||||
int tries {8};
|
||||
for (int i {0}; i < mGameCount; ++i) {
|
||||
if (mSystem->getRootFolder()->getGameCount().first == 0)
|
||||
break;
|
||||
if (mSystem->getRootFolder()->getGameCount().first == mGames.size())
|
||||
break;
|
||||
FileData* randomGame {nullptr};
|
||||
|
||||
if (mGameCount > 1 || lastGame == nullptr ||
|
||||
|
@ -74,6 +77,14 @@ public:
|
|||
else
|
||||
randomGame = mSystem->getRandomGame(lastGame, true);
|
||||
|
||||
if (std::find(mGames.begin(), mGames.end(), randomGame) != mGames.end()) {
|
||||
if (tries > 0) {
|
||||
--i;
|
||||
--tries;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (randomGame != nullptr)
|
||||
mGames.emplace_back(randomGame);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue