From 2067b660f66105ae70dd7f4f37e9154b9d46601b Mon Sep 17 00:00:00 2001 From: Stenzek Date: Fri, 22 Sep 2023 23:04:09 +1000 Subject: [PATCH] dep/rcheevos: Bump to a34895b --- dep/rcheevos/include/rc_client.h | 11 ++++++----- dep/rcheevos/src/rapi/rc_api_common.c | 1 + dep/rcheevos/src/rcheevos/consoleinfo.c | 8 +++++--- dep/rcheevos/src/rcheevos/rc_client.c | 22 +++++++++++++++++++--- 4 files changed, 31 insertions(+), 11 deletions(-) diff --git a/dep/rcheevos/include/rc_client.h b/dep/rcheevos/include/rc_client.h index 9e45653cf..fdfc682d4 100644 --- a/dep/rcheevos/include/rc_client.h +++ b/dep/rcheevos/include/rc_client.h @@ -514,10 +514,11 @@ typedef struct rc_client_leaderboard_scoreboard_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 */ char score[RC_CLIENT_LEADERBOARD_DISPLAY_SIZE]; } rc_client_leaderboard_scoreboard_entry_t; + typedef struct rc_client_leaderboard_scoreboard_t { /* The ID of the leaderboard which was submitted */ uint32_t leaderboard_id; @@ -526,14 +527,14 @@ typedef struct rc_client_leaderboard_scoreboard_t { /* The player's best submitted value */ char best_score[RC_CLIENT_LEADERBOARD_DISPLAY_SIZE]; /* 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_client_leaderboard_scoreboard_entry_t* top_entries; /* The number of items in the top_entries array */ - unsigned num_top_entries; + uint32_t num_top_entries; } rc_client_leaderboard_scoreboard_t; /*****************************************************************************\ @@ -569,7 +570,7 @@ enum { RC_CLIENT_EVENT_LEADERBOARD_TRACKER_SHOW = 10, /* [leaderboard_tracker] should be shown */ RC_CLIENT_EVENT_LEADERBOARD_TRACKER_HIDE = 11, /* [leaderboard_tracker] should be hidden */ RC_CLIENT_EVENT_LEADERBOARD_TRACKER_UPDATE = 12, /* [leaderboard_tracker] updated */ - RC_CLIENT_EVENT_LEADERBOARD_SCOREBOARD = 13, /* [leaderboard_scoreboard] possibly-new ranking received */ + RC_CLIENT_EVENT_LEADERBOARD_SCOREBOARD = 13, /* [leaderboard_scoreboard] possibly-new ranking received for [leaderboard] */ RC_CLIENT_EVENT_RESET = 14, /* emulated system should be reset (as the result of enabling hardcore) */ RC_CLIENT_EVENT_GAME_COMPLETED = 15, /* all achievements for the game have been earned */ RC_CLIENT_EVENT_SERVER_ERROR = 16, /* an API response returned a [server_error] and will not be retried */ diff --git a/dep/rcheevos/src/rapi/rc_api_common.c b/dep/rcheevos/src/rapi/rc_api_common.c index 1abcebe40..46cec97cb 100644 --- a/dep/rcheevos/src/rapi/rc_api_common.c +++ b/dep/rcheevos/src/rapi/rc_api_common.c @@ -389,6 +389,7 @@ int rc_json_get_required_unum_array(unsigned** entries, unsigned* num_entries, r rc_json_field_t value; unsigned* entry; + memset(&array, 0, sizeof(array)); if (!rc_json_get_required_array(num_entries, &array, response, field, field_name)) return RC_MISSING_VALUE; diff --git a/dep/rcheevos/src/rcheevos/consoleinfo.c b/dep/rcheevos/src/rcheevos/consoleinfo.c index 0ef0089e8..3a5db9f82 100644 --- a/dep/rcheevos/src/rcheevos/consoleinfo.c +++ b/dep/rcheevos/src/rcheevos/consoleinfo.c @@ -444,11 +444,13 @@ static const rc_memory_regions_t rc_memory_regions_gameboy = { _rc_memory_region static const rc_memory_regions_t rc_memory_regions_gameboy_color = { _rc_memory_regions_gameboy, 17 }; /* ===== GameBoy Advance ===== */ +/* http://problemkaputt.de/gbatek-gba-memory-map.htm */ static const rc_memory_region_t _rc_memory_regions_gameboy_advance[] = { - { 0x000000U, 0x007FFFU, 0x03000000U, RC_MEMORY_TYPE_SAVE_RAM, "Cartridge RAM" }, - { 0x008000U, 0x047FFFU, 0x02000000U, RC_MEMORY_TYPE_SYSTEM_RAM, "System RAM" } + { 0x000000U, 0x007FFFU, 0x03000000U, RC_MEMORY_TYPE_SYSTEM_RAM, "System RAM" }, /* 32KB Internal Work RAM */ + { 0x008000U, 0x047FFFU, 0x02000000U, RC_MEMORY_TYPE_SYSTEM_RAM, "System RAM" }, /* 256KB External Work RAM */ + { 0x048000U, 0x057FFFU, 0x0E000000U, RC_MEMORY_TYPE_SAVE_RAM, "Save RAM" } /* 64KB Game Pak SRAM */ }; -static const rc_memory_regions_t rc_memory_regions_gameboy_advance = { _rc_memory_regions_gameboy_advance, 2 }; +static const rc_memory_regions_t rc_memory_regions_gameboy_advance = { _rc_memory_regions_gameboy_advance, 3 }; /* ===== GameCube ===== */ /* https://wiibrew.org/wiki/Memory_map */ diff --git a/dep/rcheevos/src/rcheevos/rc_client.c b/dep/rcheevos/src/rcheevos/rc_client.c index bc7189f50..8f6655f34 100644 --- a/dep/rcheevos/src/rcheevos/rc_client.c +++ b/dep/rcheevos/src/rcheevos/rc_client.c @@ -1942,7 +1942,7 @@ static rc_client_async_handle_t* rc_client_load_game(rc_client_load_state_t* loa rc_client_begin_fetch_game_data(load_state); } - return &load_state->async_handle; + return (client->state.load == load_state) ? &load_state->async_handle : NULL; } rc_hash_iterator_t* rc_client_get_load_state_hash_iterator(rc_client_t* client) @@ -2526,7 +2526,21 @@ static int rc_client_compare_achievement_unlock_times(const void* a, const void* { const rc_client_achievement_t* unlock_a = *(const rc_client_achievement_t**)a; const rc_client_achievement_t* unlock_b = *(const rc_client_achievement_t**)b; - return (int)(unlock_b->unlock_time - unlock_a->unlock_time); + if (unlock_b->unlock_time == unlock_a->unlock_time) + return 0; + return (unlock_b->unlock_time < unlock_a->unlock_time) ? -1 : 1; +} + +static int rc_client_compare_achievement_progress(const void* a, const void* b) +{ + const rc_client_achievement_t* unlock_a = *(const rc_client_achievement_t**)a; + const rc_client_achievement_t* unlock_b = *(const rc_client_achievement_t**)b; + if (unlock_b->measured_percent == unlock_a->measured_percent) { + if (unlock_a->id == unlock_b->id) + return 0; + return (unlock_a->id < unlock_b->id) ? -1 : 1; + } + return (unlock_b->measured_percent < unlock_a->measured_percent) ? -1 : 1; } static uint8_t rc_client_map_bucket(uint8_t bucket, int grouping) @@ -2678,6 +2692,8 @@ rc_client_achievement_list_t* rc_client_create_achievement_list(rc_client_t* cli if (bucket_type == RC_CLIENT_ACHIEVEMENT_BUCKET_RECENTLY_UNLOCKED) qsort(bucket_ptr->achievements, bucket_ptr->num_achievements, sizeof(rc_client_achievement_t*), rc_client_compare_achievement_unlock_times); + else if (bucket_type == RC_CLIENT_ACHIEVEMENT_BUCKET_ALMOST_THERE) + qsort(bucket_ptr->achievements, bucket_ptr->num_achievements, sizeof(rc_client_achievement_t*), rc_client_compare_achievement_progress); ++bucket_ptr; } @@ -3845,7 +3861,7 @@ int rc_client_has_rich_presence(rc_client_t* client) if (!client || !client->game) return 0; - if (!client->game->runtime.richpresence || !client->game->runtime.richpresence) + if (!client->game->runtime.richpresence || !client->game->runtime.richpresence->richpresence) return 0; return 1;