Merge pull request #13514 from LillyJadeKatrin/retroachievements-failed-load-bug

Call AchievementManager CloseGame on load failures
This commit is contained in:
JosJuice 2025-04-26 10:36:09 +02:00 committed by GitHub
commit 741ffc3114
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -717,8 +717,6 @@ void AchievementManager::CloseGame()
{
{
std::lock_guard lg{m_lock};
if (rc_client_get_game_info(m_client))
{
m_active_challenges.clear();
m_active_leaderboards.clear();
m_game_badge.width = 0;
@ -728,16 +726,18 @@ void AchievementManager::CloseGame()
m_locked_badges.clear();
m_leaderboard_map.clear();
m_rich_presence.fill('\0');
rc_api_destroy_fetch_game_data_response(&m_game_data);
m_game_data = {};
m_queue.Cancel();
m_image_queue.Cancel();
rc_client_unload_game(m_client);
m_system.store(nullptr, std::memory_order_release);
if (Config::Get(Config::RA_DISCORD_PRESENCE_ENABLED))
Discord::UpdateDiscordPresence();
INFO_LOG_FMT(ACHIEVEMENTS, "Game closed.");
if (rc_client_get_game_info(m_client))
{
rc_api_destroy_fetch_game_data_response(&m_game_data);
rc_client_unload_game(m_client);
}
INFO_LOG_FMT(ACHIEVEMENTS, "Game closed.");
m_game_data = {};
}
m_update_callback(UpdatedItems{.all = true});
@ -984,6 +984,7 @@ void AchievementManager::LoadGameCallback(int result, const char* error_message,
OSD::Duration::VERY_LONG, OSD::Color::RED);
OSD::AddMessage("Please update Dolphin to a newer version.", OSD::Duration::VERY_LONG,
OSD::Color::RED);
instance.CloseGame();
return;
}
if (result != RC_OK)
@ -997,6 +998,7 @@ void AchievementManager::LoadGameCallback(int result, const char* error_message,
rc_client_set_read_memory_function(instance.m_client, MemoryPeeker);
instance.m_system.store(&Core::System::GetInstance(), std::memory_order_release);
}
instance.CloseGame();
return;
}
@ -1006,6 +1008,7 @@ void AchievementManager::LoadGameCallback(int result, const char* error_message,
ERROR_LOG_FMT(ACHIEVEMENTS, "Failed to retrieve game information from client.");
OSD::AddMessage("Failed to load achievements for this title.", OSD::Duration::VERY_LONG,
OSD::Color::RED);
instance.CloseGame();
return;
}
INFO_LOG_FMT(ACHIEVEMENTS, "Loaded data for game ID {}.", game->id);