From 03e3f65653bf581c6b9024180e87277aed75930b Mon Sep 17 00:00:00 2001 From: LillyJadeKatrin Date: Tue, 23 Jan 2024 22:55:21 -0500 Subject: [PATCH] Add host URL setting to achievements config The Host URL setting in the RetroAchievements config will, if set, be used as the host URL for all server requests for achievements. This allows for an easy switch to the RetroAchievements staging server for testing. --- Source/Core/Core/AchievementManager.cpp | 3 +++ Source/Core/Core/Config/AchievementSettings.cpp | 1 + Source/Core/Core/Config/AchievementSettings.h | 1 + 3 files changed, 5 insertions(+) diff --git a/Source/Core/Core/AchievementManager.cpp b/Source/Core/Core/AchievementManager.cpp index f7ccbbea81ec..0d8a18fdc372 100644 --- a/Source/Core/Core/AchievementManager.cpp +++ b/Source/Core/Core/AchievementManager.cpp @@ -38,6 +38,9 @@ void AchievementManager::Init() { if (!m_is_runtime_initialized && Config::Get(Config::RA_ENABLED)) { + std::string host_url = Config::Get(Config::RA_HOST_URL); + if (!host_url.empty()) + rc_api_set_host(host_url.c_str()); rc_runtime_init(&m_runtime); m_is_runtime_initialized = true; m_queue.Reset("AchievementManagerQueue", [](const std::function& func) { func(); }); diff --git a/Source/Core/Core/Config/AchievementSettings.cpp b/Source/Core/Core/Config/AchievementSettings.cpp index 5edaa6a54c03..52502b5c2012 100644 --- a/Source/Core/Core/Config/AchievementSettings.cpp +++ b/Source/Core/Core/Config/AchievementSettings.cpp @@ -12,6 +12,7 @@ namespace Config { // Configuration Information const Info RA_ENABLED{{System::Achievements, "Achievements", "Enabled"}, false}; +const Info RA_HOST_URL{{System::Achievements, "Achievements", "HostUrl"}, ""}; const Info RA_USERNAME{{System::Achievements, "Achievements", "Username"}, ""}; const Info RA_API_TOKEN{{System::Achievements, "Achievements", "ApiToken"}, ""}; const Info RA_ACHIEVEMENTS_ENABLED{ diff --git a/Source/Core/Core/Config/AchievementSettings.h b/Source/Core/Core/Config/AchievementSettings.h index 15277ca04313..b92cff83b26f 100644 --- a/Source/Core/Core/Config/AchievementSettings.h +++ b/Source/Core/Core/Config/AchievementSettings.h @@ -11,6 +11,7 @@ namespace Config // Configuration Information extern const Info RA_ENABLED; extern const Info RA_USERNAME; +extern const Info RA_HOST_URL; extern const Info RA_API_TOKEN; extern const Info RA_ACHIEVEMENTS_ENABLED; extern const Info RA_LEADERBOARDS_ENABLED;