New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RetroAchievements Memory, Events, and Awarding #11763
Merged
AdmiralCurtiss
merged 9 commits into
dolphin-emu:master
from
LillyJadeKatrin:retroachievements-memory-events
May 21, 2023
Merged
RetroAchievements Memory, Events, and Awarding #11763
AdmiralCurtiss
merged 9 commits into
dolphin-emu:master
from
LillyJadeKatrin:retroachievements-memory-events
May 21, 2023
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lioncash
reviewed
Apr 16, 2023
26da2e8
to
b5ec51e
Compare
lioncash
reviewed
Apr 19, 2023
lioncash
reviewed
Apr 19, 2023
b5ec51e
to
5d24e06
Compare
Pokechu22
reviewed
Apr 20, 2023
0b3dd96
to
63c6361
Compare
lioncash
reviewed
Apr 20, 2023
Minty-Meeo
reviewed
Apr 21, 2023
4dbb66e
to
a7fbcaf
Compare
lioncash
reviewed
Apr 24, 2023
a7fbcaf
to
5788a9a
Compare
49d9b11
to
5135d60
Compare
lioncash
reviewed
Apr 29, 2023
lioncash
reviewed
Apr 29, 2023
0a3926c
to
a7092c6
Compare
736f9bb
to
42e1485
Compare
lioncash
reviewed
May 11, 2023
42e1485
to
0d18fa0
Compare
AwardAchievement performs the API call to notify the site that an achievement has been unlocked. As one of the parameters is the game hash (something I overlooked previously; I thought it was the game ID) this change also moves the game hash into a member field.
SubmitLeaderboard submits the player's score/time to a leaderboard on the website via an API call.
0d18fa0
to
264e09b
Compare
PingRichPresence makes a "ping" API request to the RetroAchievements website with the provided RichPresence string parameter. While there has been talk about tying ping in with session, in its current state the primary purpose of ping is to send the player's Rich Presence to the website.
HandleAchievementTriggeredEvent is an asynchronous method that processes an event and places a synchronous AwardAchievement call on the work queue. In the process, it also updates the unlock map and makes the ActivateDeactivateAchievement call to determine and adjust the achievement's current active state.
HandleLeaderboardTriggeredEvent processes a leaderboard event and asynchronizes via the work queue a synchronous call to SubmitLeaderboard.
AchievementEventHandler simply checks which kind of event is triggered and calls the appropriate function. Its primary purpose is as a function to be pointed to.
MemoryPeeker is a function passed by pointer into rcheevos DoFrame functionality that forms the lynchpin of the rcheevos runtime - it provides the interface by which rcheevos accesses memory and determines if the fields provided by achievement, leaderboard, and rich presence definitions are meeting the criteria needed.
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.
DoFrame is a function called every frame by the emulator so that rcheevos can be properly updated and processed. It requires a memory peeker and an event handler to be passed in; the memory peeker is called repeatedly each frame to measure what's in memory and compare to achievement definitions, and any events thrown by that comparison are sent to the event handler. Also, DoFrame checks for the current system time to determine when to ping rich presence. Rich Presence on the RetroAchievements website updates every two minutes, so if two minutes have elapsed since the previous ping, another ping is sent.
264e09b
to
c9c2e17
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
This is a portion of an integration with the RetroAchievements tools and libraries for connecting to the website, downloading data, unlocking achievements and submitting to leaderboards for games running in Dolphin. In this PR, the AchievementsManager created in a previous PR is further implemented to peek into game memory, process that within the rcheevos library, and handle achievement events that occur, resulting in the API calls to award achievements, submit scores/times to leaderboards, and generate and post Rich Presence for the currently played game.