diff --git a/es-core/src/components/GameSelectorComponent.h b/es-core/src/components/GameSelectorComponent.h index b810be411..b123e2a2d 100644 --- a/es-core/src/components/GameSelectorComponent.h +++ b/es-core/src/components/GameSelectorComponent.h @@ -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); }