From 22ee729055a94e7d5da1a8b3f7dbaa17d7655b25 Mon Sep 17 00:00:00 2001 From: LillyJadeKatrin Date: Sat, 15 Apr 2023 12:02:28 -0400 Subject: [PATCH] Added GenerateRichPresence to AchievementManager GenerateRichPresence calls rc_runtime_get_richpresence in rhceevos on the achievement runtime to get the current Rich Presence string, a description of the player's current in-game state based on its memory as fed into a custom-developed script downloaded via FetchGameData. This gets passed into PingRichPresence, but is separated into its own method so it can be used elsewhere locally. --- Source/Core/Core/AchievementManager.cpp | 14 ++++++++++++++ Source/Core/Core/AchievementManager.h | 1 + 2 files changed, 15 insertions(+) diff --git a/Source/Core/Core/AchievementManager.cpp b/Source/Core/Core/AchievementManager.cpp index 2d4fce9af8..ebb0302a53 100644 --- a/Source/Core/Core/AchievementManager.cpp +++ b/Source/Core/Core/AchievementManager.cpp @@ -409,6 +409,20 @@ void AchievementManager::ActivateDeactivateAchievement(AchievementId id, bool en rc_runtime_deactivate_achievement(&m_runtime, id); } +RichPresence AchievementManager::GenerateRichPresence() +{ + RichPresence rp_buffer; + Core::RunAsCPUThread([&] { + rc_runtime_get_richpresence( + &m_runtime, rp_buffer.data(), RP_SIZE, + [](unsigned address, unsigned num_bytes, void* ud) { + return static_cast(ud)->MemoryPeeker(address, num_bytes, ud); + }, + this, nullptr); + }); + return rp_buffer; +} + AchievementManager::ResponseType AchievementManager::AwardAchievement(AchievementId achievement_id) { std::string username = Config::Get(Config::RA_USERNAME); diff --git a/Source/Core/Core/AchievementManager.h b/Source/Core/Core/AchievementManager.h index d041259c1c..82e7eb723f 100644 --- a/Source/Core/Core/AchievementManager.h +++ b/Source/Core/Core/AchievementManager.h @@ -72,6 +72,7 @@ private: ResponseType FetchUnlockData(bool hardcore); void ActivateDeactivateAchievement(AchievementId id, bool enabled, bool unofficial, bool encore); + RichPresence GenerateRichPresence(); ResponseType AwardAchievement(AchievementId achievement_id); ResponseType SubmitLeaderboard(AchievementId leaderboard_id, int value);