From 8e43138722aea52ab5a3b8737d9dde5e28275bb2 Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Mon, 12 Sep 2022 19:48:11 +0200 Subject: [PATCH] Made GameSelectorComponent not return the same game repeatedly in a row. --- es-core/src/components/GameSelectorComponent.h | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/es-core/src/components/GameSelectorComponent.h b/es-core/src/components/GameSelectorComponent.h index e6b42e741..c08eb8747 100644 --- a/es-core/src/components/GameSelectorComponent.h +++ b/es-core/src/components/GameSelectorComponent.h @@ -49,6 +49,12 @@ public: { if (!mNeedsRefresh) return; + + FileData* lastGame {nullptr}; + + if (mGameCount == 1 && !mGames.empty()) + lastGame = mGames.front(); + mGames.clear(); mNeedsRefresh = false; @@ -59,7 +65,14 @@ public: for (int i = 0; i < mGameCount; ++i) { if (mSystem->getRootFolder()->getGameCount().first == 0) break; - FileData* randomGame {mSystem->getRandomGame(nullptr, true)}; + FileData* randomGame {nullptr}; + + if (mGameCount > 1 || lastGame == nullptr || + mSystem->getRootFolder()->getGameCount().first == 1) + randomGame = mSystem->getRandomGame(nullptr, true); + else + randomGame = mSystem->getRandomGame(lastGame, true); + if (randomGame != nullptr) mGames.emplace_back(randomGame); }