Skip to content
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

Add rc_client_t #242

Merged
merged 86 commits into from
Jul 8, 2023
Merged

Add rc_client_t #242

merged 86 commits into from
Jul 8, 2023

Conversation

Jamiras
Copy link
Member

@Jamiras Jamiras commented Jun 11, 2023

Moves a large portion of the code from RetroArch into rcheevos for use by other standalone emulators:

  • Hides server API calls from the emulator. HTTP requests will be generated internally and dispatched to a registered function to actually call the server.
  • Stores information about the logged in user to automatically pass to other API calls.
  • Identifies and loads game data from the server.
  • Stores the retrieved achievement and leaderboard information for building menus.
  • Starts the game session and retrieves user progress within a set.
  • Manages the progress and unlock state of achievements.
  • Ensures the correct achievements and leaderboards are active based on hardcore enablement and the player's progress.
  • Supports generically enabling unofficial achievements, encore mode (achievements previously earned by player are reactivated each time the game is loaded), and spectator mode (no unlocks are sent to the server).
  • Sends unlock requests to the server with automatic retries.
  • Sends leaderboard submissions to the server with automatic retries.
  • Periodically sends rich presence updates to the server.
  • Builds list of achievements categorized by locked/unlocked/unsupported state, with optional categorization for active challenges, almost there, and recently unlocked achievements.
  • Provides hooks for reading memory from the emulator, making server requests, writing to logs, and updating UI.
  • The rc_client_t instance is passed to all callbacks. A single pointer to emulator-provided data can be attached to the rc_client_t instance.

The emulator is still responsible for providing an HTTP library and dispatching server requests. Additionally, it is responsible for downloading the game/achievement/user images, showing all supported UI, and hardcore restriction enforcements.

This code does not do any image management. Functions are provided for generating the URL of the images to be downloaded, and events are dispatched when UI should be updated.

General implementation details are provided in the wiki. Pages will be added to sidebar once this is merged.

A mutex is provided for thread-safety within the rc_client_t. It is implemented in the same manner as supported by RetroArch, which should provide pretty thorough support across platforms. For systems without pthread support, it can be compiled out by defining RC_NO_THREADS.

These changes should simplify rolling out new UI features (like the recently added leaderboard collapsing, and the much-desired subset and core at the same time). The encapsulated APIs also allow for expansion of the APIs without explicitly requiring changes in the emulator code.

@Jamiras Jamiras merged commit 223df07 into RetroAchievements:develop Jul 8, 2023
@Jamiras Jamiras deleted the rc_client branch July 8, 2023 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant