From e7504d0b12fbb773ed5b86b1e3e389414a085d95 Mon Sep 17 00:00:00 2001 From: LillyJadeKatrin Date: Wed, 17 Jul 2024 22:51:24 -0400 Subject: [PATCH 1/3] Remove Leaderboard Fetch when Getting Info The cause of the leaderboard spam was primarily this call where if there was an attempt to get leaderboard info and there wasn't already, there would be a fetch request. This is bad for many reasons: some games have hundreds of boards that will be fetched at startup, if there's simply no data to populate that board, this will just continue to fetch every time the dialog needs to update. To mitigate this, I simply don't load leaderboard information until there are events for that leaderboard - less information for the player, sadly, but heavily cuts down on the number of leaderboard fetches. --- Source/Core/Core/AchievementManager.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/Source/Core/Core/AchievementManager.cpp b/Source/Core/Core/AchievementManager.cpp index 7788876139..7dab23d5f6 100644 --- a/Source/Core/Core/AchievementManager.cpp +++ b/Source/Core/Core/AchievementManager.cpp @@ -479,8 +479,6 @@ AchievementManager::GetLeaderboardInfo(AchievementManager::AchievementId leaderb if (const auto leaderboard_iter = m_leaderboard_map.find(leaderboard_id); leaderboard_iter != m_leaderboard_map.end()) { - if (leaderboard_iter->second.entries.size() == 0) - FetchBoardInfo(leaderboard_id); return &leaderboard_iter->second; } From 5ccd157c944a24de13975661a62e6d46a3a5bb44 Mon Sep 17 00:00:00 2001 From: LillyJadeKatrin Date: Wed, 17 Jul 2024 22:51:43 -0400 Subject: [PATCH 2/3] Re-enable Leaderboards Tab --- .../Achievements/AchievementsWindow.cpp | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Source/Core/DolphinQt/Achievements/AchievementsWindow.cpp b/Source/Core/DolphinQt/Achievements/AchievementsWindow.cpp index 2e0a6cb40c..8605c10725 100644 --- a/Source/Core/DolphinQt/Achievements/AchievementsWindow.cpp +++ b/Source/Core/DolphinQt/Achievements/AchievementsWindow.cpp @@ -55,12 +55,12 @@ void AchievementsWindow::CreateMainLayout() m_tab_widget = new QTabWidget(); m_settings_widget = new AchievementSettingsWidget(m_tab_widget); m_progress_widget = new AchievementProgressWidget(m_tab_widget); - // m_leaderboard_widget = new AchievementLeaderboardWidget(m_tab_widget); + m_leaderboard_widget = new AchievementLeaderboardWidget(m_tab_widget); m_tab_widget->addTab(GetWrappedWidget(m_settings_widget, this, 125, 100), tr("Settings")); m_tab_widget->addTab(GetWrappedWidget(m_progress_widget, this, 125, 100), tr("Progress")); m_tab_widget->setTabVisible(1, is_game_loaded); - // m_tab_widget->addTab(GetWrappedWidget(m_leaderboard_widget, this, 125, 100), - // tr("Leaderboards")); m_tab_widget->setTabVisible(2, is_game_loaded); + m_tab_widget->addTab(GetWrappedWidget(m_leaderboard_widget, this, 125, 100), tr("Leaderboards")); + m_tab_widget->setTabVisible(2, is_game_loaded); m_button_box = new QDialogButtonBox(QDialogButtonBox::Close); @@ -84,9 +84,9 @@ void AchievementsWindow::UpdateData(AchievementManager::UpdatedItems updated_ite { m_header_widget->UpdateData(); m_progress_widget->UpdateData(true); - // m_leaderboard_widget->UpdateData(true); + m_leaderboard_widget->UpdateData(true); static_cast(m_tab_widget->widget(1))->verticalScrollBar()->setValue(0); - // static_cast(m_tab_widget->widget(2))->verticalScrollBar()->setValue(0); + static_cast(m_tab_widget->widget(2))->verticalScrollBar()->setValue(0); } else { @@ -99,10 +99,10 @@ void AchievementsWindow::UpdateData(AchievementManager::UpdatedItems updated_ite m_progress_widget->UpdateData(false); else if (updated_items.achievements.size() > 0) m_progress_widget->UpdateData(updated_items.achievements); - // if (updated_items.all_leaderboards) - // m_leaderboard_widget->UpdateData(false); - // else if (updated_items.leaderboards.size() > 0) - // m_leaderboard_widget->UpdateData(updated_items.leaderboards); + if (updated_items.all_leaderboards) + m_leaderboard_widget->UpdateData(false); + else if (updated_items.leaderboards.size() > 0) + m_leaderboard_widget->UpdateData(updated_items.leaderboards); } { @@ -111,7 +111,7 @@ void AchievementsWindow::UpdateData(AchievementManager::UpdatedItems updated_ite const bool is_game_loaded = instance.IsGameLoaded(); m_header_widget->setVisible(instance.HasAPIToken()); m_tab_widget->setTabVisible(1, is_game_loaded); - // m_tab_widget->setTabVisible(2, is_game_loaded); + m_tab_widget->setTabVisible(2, is_game_loaded); } update(); } From 8bb2f98c6a9c4bbf265fb91737d0994dfe1f83dc Mon Sep 17 00:00:00 2001 From: LillyJadeKatrin Date: Wed, 17 Jul 2024 22:53:15 -0400 Subject: [PATCH 3/3] Properly Populate Player Index The player_index field in question is ultimately what gets used to determine which ranks get displayed in the leaderboards chart, and because this was missing the chart was simply displaying the top four results no matter what. --- Source/Core/Core/AchievementManager.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Source/Core/Core/AchievementManager.cpp b/Source/Core/Core/AchievementManager.cpp index 7dab23d5f6..b669a445b1 100644 --- a/Source/Core/Core/AchievementManager.cpp +++ b/Source/Core/Core/AchievementManager.cpp @@ -804,6 +804,8 @@ void AchievementManager::LeaderboardEntriesCallback(int result, const char* erro map_entry.username.assign(response_entry.user); memcpy(map_entry.score.data(), response_entry.display, FORMAT_SIZE); map_entry.rank = response_entry.rank; + if (ix == list->user_index) + leaderboard.player_index = response_entry.rank; } AchievementManager::GetInstance().m_update_callback({.leaderboards = {*leaderboard_id}}); }