From 456cfb0f5a109cbb57dd4406f2ffbe416745c236 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 27 Jul 2026 17:53:55 +0200 Subject: [PATCH] RAIntegration crashfix --- Core/RetroAchievements.cpp | 17 +++++++++++++++-- Core/RetroAchievements.h | 1 + Windows/main.cpp | 1 + 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/Core/RetroAchievements.cpp b/Core/RetroAchievements.cpp index 4366d87359..84951deb9c 100644 --- a/Core/RetroAchievements.cpp +++ b/Core/RetroAchievements.cpp @@ -674,6 +674,16 @@ void Initialize() { rc_client_set_encore_mode_enabled(g_rcClient, g_Config.bAchievementsEncoreMode ? 1 : 0); rc_client_set_unofficial_enabled(g_rcClient, g_Config.bAchievementsUnofficial ? 1 : 0); +#ifdef RC_CLIENT_SUPPORTS_RAINTEGRATION + if (!g_Config.bAchievementsEnableRAIntegration) { + TryLoginByToken(true); + } +#else + TryLoginByToken(true); +#endif +} + +void InitializeRAIntegration(void *windowHandle) { #ifdef RC_CLIENT_SUPPORTS_RAINTEGRATION if (g_Config.bAchievementsEnableRAIntegration) { wchar_t szFilePath[MAX_PATH]; @@ -684,12 +694,15 @@ void Initialize() { break; } } - HWND hWnd = (HWND)System_GetPropertyInt(SYSPROP_MAIN_WINDOW_HANDLE); + HWND hWnd = (HWND)windowHandle; + if (!hWnd) { + ERROR_LOG(Log::Achievements, "RAIntegration is enabled, but no main window handle was found."); + return; + } rc_client_begin_load_raintegration(g_rcClient, szFilePath, hWnd, "PPSSPP", PPSSPP_GIT_VERSION, &load_integration_callback, hWnd); return; } #endif - TryLoginByToken(true); } bool HasToken() { diff --git a/Core/RetroAchievements.h b/Core/RetroAchievements.h index 158c5a322e..aa70fcecba 100644 --- a/Core/RetroAchievements.h +++ b/Core/RetroAchievements.h @@ -71,6 +71,7 @@ bool RAIntegrationDirty(); rc_client_t *GetClient(); void Initialize(); +void InitializeRAIntegration(void *windowHandle); // This must be call after the main window exists. void UpdateSettings(); bool LoginProblems(std::string *errorString); diff --git a/Windows/main.cpp b/Windows/main.cpp index a2940f7973..f59273cbe7 100644 --- a/Windows/main.cpp +++ b/Windows/main.cpp @@ -1205,6 +1205,7 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin MainWindow::Show(_hInstance); HWND hwndMain = MainWindow::GetHWND(); + Achievements::InitializeRAIntegration(hwndMain); //initialize custom controls CtrlDisAsmView::init();