fix: Remove Duplicate Games Appearing When Creating Room

Evilperson1337 from Discord showcased a bug to where if you had a game stored within multiple folders in the game list, when you'd create a room the game would appear twice.

The fix was to add an std::set which will keep track of games Title ID's. The way it functions is simple, "Did I see this Title ID before? Yes or no?" and, as mentioned, will ensure there are no duplicate games being shown, ensuring one version of the game is present for selection.

Signed-off-by: Collecting <collecting@noreply.localhost>
This commit is contained in:
Collecting
2025-12-11 04:21:19 +00:00
parent 5644a406cd
commit cc96039134

View File

@@ -3,6 +3,7 @@
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
#include <future> #include <future>
#include <set>
#include <QColor> #include <QColor>
#include <QImage> #include <QImage>
#include <QList> #include <QList>
@@ -83,10 +84,20 @@ HostRoomWindow::~HostRoomWindow() = default;
void HostRoomWindow::UpdateGameList(QStandardItemModel* list) { void HostRoomWindow::UpdateGameList(QStandardItemModel* list) {
game_list->clear(); game_list->clear();
std::set<u64> seen_program_ids;
for (int i = 0; i < list->rowCount(); i++) { for (int i = 0; i < list->rowCount(); i++) {
auto parent = list->item(i, 0); auto parent = list->item(i, 0);
for (int j = 0; j < parent->rowCount(); j++) { for (int j = 0; j < parent->rowCount(); j++) {
game_list->appendRow(parent->child(j)->clone()); auto child_item = parent->child(j);
u64 program_id =
child_item->data(GameListItemPath::ProgramIdRole).toULongLong();
// Only add the game if we haven't seen its program ID before
if (seen_program_ids.count(program_id) == 0) {
game_list->appendRow(child_item->clone());
seen_program_ids.insert(program_id);
}
} }
} }
} }