Skip to content

Commit

Permalink
update rcheevos
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamiras committed Oct 28, 2023
1 parent 9e1d8f9 commit 455b934
Show file tree
Hide file tree
Showing 37 changed files with 892 additions and 650 deletions.
12 changes: 6 additions & 6 deletions cheevos/cheevos.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ static void rcheevos_handle_log_message(const char* message)
CHEEVOS_LOG(RCHEEVOS_TAG "%s\n", message);
}

static void rcheevos_get_core_memory_info(unsigned id,
static void rcheevos_get_core_memory_info(uint32_t id,
rc_libretro_core_memory_info_t* info)
{
retro_ctx_memory_info_t ctx_info;
Expand Down Expand Up @@ -220,10 +220,10 @@ uint8_t* rcheevos_patch_address(unsigned address)
return rc_libretro_memory_find(&rcheevos_locals.memory, address);
}

static unsigned rcheevos_peek(unsigned address,
unsigned num_bytes, void* ud)
static uint32_t rcheevos_peek(uint32_t address,
uint32_t num_bytes, void* ud)
{
unsigned avail;
uint32_t avail;
uint8_t* data = rc_libretro_memory_find_avail(
&rcheevos_locals.memory, address, &avail);

Expand Down Expand Up @@ -1321,7 +1321,7 @@ static void rcheevos_runtime_event_handler(
}
}

static int rcheevos_runtime_address_validator(unsigned address)
static int rcheevos_runtime_address_validator(uint32_t address)
{
return rc_libretro_memory_find(
&rcheevos_locals.memory, address) != NULL;
Expand Down Expand Up @@ -2066,7 +2066,7 @@ static void rcheevos_identify_game_callback(void* userdata)
rcheevos_fetch_game_data();
}

static int rcheevos_get_image_path(unsigned index, char* buffer, size_t buffer_size)
static int rcheevos_get_image_path(uint32_t index, char* buffer, size_t buffer_size)
{
rarch_system_info_t *sys_info = &runloop_state_get_ptr()->system;
if (!sys_info->disk_control.cb.get_image_path)
Expand Down
2 changes: 1 addition & 1 deletion cheevos/cheevos_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -1756,7 +1756,7 @@ static void rcheevos_async_award_achievement_callback(
{
if ((int)api_response.awarded_achievement_id != request->id)
snprintf(buffer, buffer_size, "Achievement %u awarded instead",
api_response.awarded_achievement_id);
(unsigned)api_response.awarded_achievement_id);
else if (api_response.response.error_message)
{
/* previously unlocked achievements are returned as a "successful" error */
Expand Down
45 changes: 23 additions & 22 deletions deps/rcheevos/include/rc_api_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include "rc_api_request.h"

#include <stdint.h>
#include <time.h>

#ifdef __cplusplus
Expand All @@ -20,13 +21,13 @@ typedef struct rc_api_fetch_achievement_info_request_t {
/* The API token from the login request */
const char* api_token;
/* The unique identifier of the achievement */
unsigned achievement_id;
uint32_t achievement_id;
/* The 1-based index of the first entry to retrieve */
unsigned first_entry;
uint32_t first_entry;
/* The number of entries to retrieve */
unsigned count;
uint32_t count;
/* Non-zero to only return unlocks earned by the user's friends */
unsigned friends_only;
uint32_t friends_only;
}
rc_api_fetch_achievement_info_request_t;

Expand All @@ -44,18 +45,18 @@ rc_api_achievement_awarded_entry_t;
*/
typedef struct rc_api_fetch_achievement_info_response_t {
/* The unique identifier of the achievement */
unsigned id;
uint32_t id;
/* The unique identifier of the game to which the leaderboard is associated */
unsigned game_id;
uint32_t game_id;
/* The number of times the achievement has been awarded */
unsigned num_awarded;
uint32_t num_awarded;
/* The number of players that have earned at least one achievement for the game */
unsigned num_players;
uint32_t num_players;

/* An array of recently rewarded entries */
rc_api_achievement_awarded_entry_t* recently_awarded;
/* The number of items in the recently_awarded array */
unsigned num_recently_awarded;
uint32_t num_recently_awarded;

/* Common server-provided response information */
rc_api_response_t response;
Expand All @@ -74,11 +75,11 @@ void rc_api_destroy_fetch_achievement_info_response(rc_api_fetch_achievement_inf
*/
typedef struct rc_api_fetch_leaderboard_info_request_t {
/* The unique identifier of the leaderboard */
unsigned leaderboard_id;
uint32_t leaderboard_id;
/* The number of entries to retrieve */
unsigned count;
uint32_t count;
/* The 1-based index of the first entry to retrieve */
unsigned first_entry;
uint32_t first_entry;
/* The username of the player around whom the entries should be returned */
const char* username;
}
Expand All @@ -89,11 +90,11 @@ typedef struct rc_api_lboard_info_entry_t {
/* The user associated to the entry */
const char* username;
/* The rank of the entry */
unsigned rank;
uint32_t rank;
/* The index of the entry */
unsigned index;
uint32_t index;
/* The value of the entry */
int score;
int32_t score;
/* When the entry was submitted */
time_t submitted;
}
Expand All @@ -104,19 +105,19 @@ rc_api_lboard_info_entry_t;
*/
typedef struct rc_api_fetch_leaderboard_info_response_t {
/* The unique identifier of the leaderboard */
unsigned id;
uint32_t id;
/* The format to pass to rc_format_value to format the leaderboard value */
int format;
/* If non-zero, indicates that lower scores appear first */
int lower_is_better;
uint32_t lower_is_better;
/* The title of the leaderboard */
const char* title;
/* The description of the leaderboard */
const char* description;
/* The definition of the leaderboard to be passed to rc_runtime_activate_lboard */
const char* definition;
/* The unique identifier of the game to which the leaderboard is associated */
unsigned game_id;
uint32_t game_id;
/* The author of the leaderboard */
const char* author;
/* When the leaderboard was first uploaded to the server */
Expand All @@ -127,7 +128,7 @@ typedef struct rc_api_fetch_leaderboard_info_response_t {
/* An array of requested entries */
rc_api_lboard_info_entry_t* entries;
/* The number of items in the entries array */
unsigned num_entries;
uint32_t num_entries;

/* Common server-provided response information */
rc_api_response_t response;
Expand All @@ -146,14 +147,14 @@ void rc_api_destroy_fetch_leaderboard_info_response(rc_api_fetch_leaderboard_inf
*/
typedef struct rc_api_fetch_games_list_request_t {
/* The unique identifier of the console to query */
unsigned console_id;
uint32_t console_id;
}
rc_api_fetch_games_list_request_t;

/* A game list entry */
typedef struct rc_api_game_list_entry_t {
/* The unique identifier of the game */
unsigned id;
uint32_t id;
/* The name of the game */
const char* name;
}
Expand All @@ -166,7 +167,7 @@ typedef struct rc_api_fetch_games_list_response_t {
/* An array of requested entries */
rc_api_game_list_entry_t* entries;
/* The number of items in the entries array */
unsigned num_entries;
uint32_t num_entries;

/* Common server-provided response information */
rc_api_response_t response;
Expand Down
5 changes: 5 additions & 0 deletions deps/rcheevos/include/rc_api_request.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ typedef struct rc_api_server_response_t {
int http_status_code;
} rc_api_server_response_t;

enum {
RC_API_SERVER_RESPONSE_CLIENT_ERROR = -1,
RC_API_SERVER_RESPONSE_RETRYABLE_CLIENT_ERROR = -2
};

#ifdef __cplusplus
}
#endif
Expand Down
59 changes: 30 additions & 29 deletions deps/rcheevos/include/rc_api_runtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include "rc_api_request.h"

#include <stdint.h>
#include <time.h>

#ifdef __cplusplus
Expand All @@ -19,7 +20,7 @@ typedef struct rc_api_fetch_image_request_t {
/* The name of the image to fetch */
const char* image_name;
/* The type of image to fetch */
int image_type;
uint32_t image_type;
}
rc_api_fetch_image_request_t;

Expand Down Expand Up @@ -50,7 +51,7 @@ rc_api_resolve_hash_request_t;
*/
typedef struct rc_api_resolve_hash_response_t {
/* The unique identifier of the game, 0 if no match was found */
unsigned game_id;
uint32_t game_id;

/* Common server-provided response information */
rc_api_response_t response;
Expand All @@ -73,14 +74,14 @@ typedef struct rc_api_fetch_game_data_request_t {
/* The API token from the login request */
const char* api_token;
/* The unique identifier of the game */
unsigned game_id;
uint32_t game_id;
}
rc_api_fetch_game_data_request_t;

/* A leaderboard definition */
typedef struct rc_api_leaderboard_definition_t {
/* The unique identifier of the leaderboard */
unsigned id;
uint32_t id;
/* The format to pass to rc_format_value to format the leaderboard value */
int format;
/* The title of the leaderboard */
Expand All @@ -90,20 +91,20 @@ typedef struct rc_api_leaderboard_definition_t {
/* The definition of the leaderboard to be passed to rc_runtime_activate_lboard */
const char* definition;
/* Non-zero if lower values are better for this leaderboard */
int lower_is_better;
uint8_t lower_is_better;
/* Non-zero if the leaderboard should not be displayed in a list of leaderboards */
int hidden;
uint8_t hidden;
}
rc_api_leaderboard_definition_t;

/* An achievement definition */
typedef struct rc_api_achievement_definition_t {
/* The unique identifier of the achievement */
unsigned id;
uint32_t id;
/* The number of points the achievement is worth */
unsigned points;
uint32_t points;
/* The achievement category (core, unofficial) */
unsigned category;
uint32_t category;
/* The title of the achievement */
const char* title;
/* The dscription of the achievement */
Expand All @@ -129,9 +130,9 @@ rc_api_achievement_definition_t;
*/
typedef struct rc_api_fetch_game_data_response_t {
/* The unique identifier of the game */
unsigned id;
uint32_t id;
/* The console associated to the game */
unsigned console_id;
uint32_t console_id;
/* The title of the game */
const char* title;
/* The image name for the game badge */
Expand All @@ -142,12 +143,12 @@ typedef struct rc_api_fetch_game_data_response_t {
/* An array of achievements for the game */
rc_api_achievement_definition_t* achievements;
/* The number of items in the achievements array */
unsigned num_achievements;
uint32_t num_achievements;

/* An array of leaderboards for the game */
rc_api_leaderboard_definition_t* leaderboards;
/* The number of items in the leaderboards array */
unsigned num_leaderboards;
uint32_t num_leaderboards;

/* Common server-provided response information */
rc_api_response_t response;
Expand All @@ -170,7 +171,7 @@ typedef struct rc_api_ping_request_t {
/* The API token from the login request */
const char* api_token;
/* The unique identifier of the game */
unsigned game_id;
uint32_t game_id;
/* (optional) The current rich presence evaluation for the user */
const char* rich_presence;
}
Expand Down Expand Up @@ -201,9 +202,9 @@ typedef struct rc_api_award_achievement_request_t {
/* The API token from the login request */
const char* api_token;
/* The unique identifier of the achievement */
unsigned achievement_id;
uint32_t achievement_id;
/* Non-zero if the achievement was earned in hardcore */
int hardcore;
uint32_t hardcore;
/* The hash associated to the game being played */
const char* game_hash;
}
Expand All @@ -214,14 +215,14 @@ rc_api_award_achievement_request_t;
*/
typedef struct rc_api_award_achievement_response_t {
/* The unique identifier of the achievement that was awarded */
unsigned awarded_achievement_id;
uint32_t awarded_achievement_id;
/* The updated player score */
unsigned new_player_score;
uint32_t new_player_score;
/* The updated player softcore score */
unsigned new_player_score_softcore;
uint32_t new_player_score_softcore;
/* The number of achievements the user has not yet unlocked for this game
* (in hardcore/non-hardcore per hardcore flag in request) */
unsigned achievements_remaining;
uint32_t achievements_remaining;

/* Common server-provided response information */
rc_api_response_t response;
Expand All @@ -244,9 +245,9 @@ typedef struct rc_api_submit_lboard_entry_request_t {
/* The API token from the login request */
const char* api_token;
/* The unique identifier of the leaderboard */
unsigned leaderboard_id;
uint32_t leaderboard_id;
/* The value being submitted */
int score;
int32_t score;
/* The hash associated to the game being played */
const char* game_hash;
}
Expand All @@ -257,9 +258,9 @@ typedef struct rc_api_lboard_entry_t {
/* The user associated to the entry */
const char* username;
/* The rank of the entry */
unsigned rank;
uint32_t rank;
/* The value of the entry */
int score;
int32_t score;
}
rc_api_lboard_entry_t;

Expand All @@ -268,18 +269,18 @@ rc_api_lboard_entry_t;
*/
typedef struct rc_api_submit_lboard_entry_response_t {
/* The value that was submitted */
int submitted_score;
int32_t submitted_score;
/* The player's best submitted value */
int best_score;
int32_t best_score;
/* The player's new rank within the leaderboard */
unsigned new_rank;
uint32_t new_rank;
/* The total number of entries in the leaderboard */
unsigned num_entries;
uint32_t num_entries;

/* An array of the top entries for the leaderboard */
rc_api_lboard_entry_t* top_entries;
/* The number of items in the top_entries array */
unsigned num_top_entries;
uint32_t num_top_entries;

/* Common server-provided response information */
rc_api_response_t response;
Expand Down
Loading

0 comments on commit 455b934

Please sign in to comment.