From db0a5575900b7223f223064e1cc01b7d087fb986 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Fri, 30 Jan 2026 09:43:31 +0100 Subject: [PATCH] Make it possible to have RetroAchievements enabled in a game config. Fixes #21175 --- Core/RetroAchievements.cpp | 5 ++++- Core/System.cpp | 1 + UI/EmuScreen.cpp | 22 ++++++++++++++++++---- UI/EmuScreen.h | 1 + 4 files changed, 24 insertions(+), 5 deletions(-) diff --git a/Core/RetroAchievements.cpp b/Core/RetroAchievements.cpp index a4a9aab08b..9b3e76a41e 100644 --- a/Core/RetroAchievements.cpp +++ b/Core/RetroAchievements.cpp @@ -627,7 +627,10 @@ void Initialize() { INFO_LOG(Log::Achievements, "Achievements are disabled, not initializing."); return; } - _assert_msg_(!g_rcClient, "Achievements already initialized"); + if (g_rcClient) { + INFO_LOG(Log::Achievements, "Achievements already initialized"); + return; + } g_rcClient = rc_client_create(read_memory_callback, server_call_callback); if (!g_rcClient) { diff --git a/Core/System.cpp b/Core/System.cpp index ad7e7decd0..76794a8031 100644 --- a/Core/System.cpp +++ b/Core/System.cpp @@ -502,6 +502,7 @@ static bool CPU_Init(FileLoader *fileLoader, IdentifiedFileType type, std::strin } InstallExceptionHandler(&Memory::HandleFault); + return true; } diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index 5a724fc67d..42b3bf834a 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -209,7 +209,7 @@ bool EmuScreen::bootAllowStorage(const Path &filename) { } void EmuScreen::ProcessGameBoot(const Path &filename) { - if (!bootPending_) { + if (!bootPending_ && !readyToFinishBoot_) { // Nothing to do. return; } @@ -230,6 +230,13 @@ void EmuScreen::ProcessGameBoot(const Path &filename) { return; } + if (readyToFinishBoot_) { + // Finish booting. + bootComplete(); + readyToFinishBoot_ = false; + return; + } + std::string error_string = "(unknown error)"; const BootState state = PSP_InitUpdate(&error_string); @@ -263,10 +270,9 @@ void EmuScreen::ProcessGameBoot(const Path &filename) { coreState = CORE_RUNNING_CPU; } - bootComplete(); + Achievements::Initialize(); - // Reset views in case controls are in a different place. - RecreateViews(); + readyToFinishBoot_ = true; return; case BootState::Off: // Gotta start the boot process! Continue below. @@ -430,6 +436,9 @@ void EmuScreen::bootComplete() { g_Config.TimeTracker().Start(gameID); bootIsReset_ = false; + + // Reset views in case controls are in a different place. + RecreateViews(); } EmuScreen::~EmuScreen() { @@ -448,6 +457,11 @@ EmuScreen::~EmuScreen() { PSP_Shutdown(true); } + // If achievements are disabled in the global config, let's shut it down here. + if (!g_Config.bAchievementsEnable) { + Achievements::Shutdown(); + } + _dbg_assert_(coreState == CORE_POWERDOWN); System_PostUIMessage(UIMessage::GAME_SELECTED, ""); diff --git a/UI/EmuScreen.h b/UI/EmuScreen.h index 35e5461eae..122ffa4a8e 100644 --- a/UI/EmuScreen.h +++ b/UI/EmuScreen.h @@ -157,6 +157,7 @@ private: bool startDumping_ = false; #endif bool autoLoadFailed_ = false; // to prevent repeat reloads + bool readyToFinishBoot_ = false; }; bool MustRunBehind();