diff --git a/deps/rcheevos/CHANGELOG.md b/deps/rcheevos/CHANGELOG.md index 302c240306..0a1a1d002a 100644 --- a/deps/rcheevos/CHANGELOG.md +++ b/deps/rcheevos/CHANGELOG.md @@ -1,3 +1,7 @@ +# v6.5.0 + +* Added a schema for errors returned by the server + # v6.4.0 * Added an enumeration with the console identifiers used in RetroAchievements diff --git a/deps/rcheevos/README.md b/deps/rcheevos/README.md index d9da7487ba..4685e7a11f 100644 --- a/deps/rcheevos/README.md +++ b/deps/rcheevos/README.md @@ -502,6 +502,7 @@ enum { * `rc_json_login_t`: The login token for the user, given their user name and password. * `rc_json_patch_t`: The information about a game, given its identifier. It includes arrays with the achievements and leaderboards for the game. * `rc_json_unlocks_t`: The list of achievements already awarded for the player, given the game identifier. Used to avoid the emulator awarding achievements more than once. +* `rc_json_error_t`: Error messages returned by the server. For each schema there are two functions, for example: diff --git a/deps/rcheevos/include/rjson.h b/deps/rcheevos/include/rjson.h index e8d5aa04ca..f13f0ef3bd 100644 --- a/deps/rcheevos/include/rjson.h +++ b/deps/rcheevos/include/rjson.h @@ -115,6 +115,15 @@ rc_json_unlocks_t; int rc_json_get_unlocks_size(const char* json); const rc_json_unlocks_t* rc_json_parse_unlocks(void* buffer, const char* json); +typedef struct { + const char* error; + char success; +} +rc_json_error_t; + +int rc_json_get_error_size(const char* json); +const rc_json_error_t* rc_json_parse_error(void* buffer, const char* json); + #ifdef __cplusplus } #endif diff --git a/deps/rcheevos/src/rjson/schema.c b/deps/rcheevos/src/rjson/schema.c index f063568f60..afd2d64f65 100644 --- a/deps/rcheevos/src/rjson/schema.c +++ b/deps/rcheevos/src/rjson/schema.c @@ -551,6 +551,48 @@ const rc_json_unlocks_t* rc_json_parse_unlocks(void* buffer, const char* json) { return (const rc_json_unlocks_t*)rc_json_deserialize(buffer, 0x9b4e2684U, (const uint8_t*)json); } +static const rc_json_field_meta_t rc_json_field_meta_error[] = { + { + /* Metadata for field const char* error;. */ + /* name_hash */ 0x0d2011cfU, + /* type_hash */ 0x00000000U, + /* offset */ RC_JSON_OFFSETOF(rc_json_error_t, error), + /* type */ RC_JSON_TYPE_STRING, + /* flags */ 0 + }, + { + /* Metadata for field char success;. */ + /* name_hash */ 0x110461deU, + /* type_hash */ 0x00000000U, + /* offset */ RC_JSON_OFFSETOF(rc_json_error_t, success), + /* type */ RC_JSON_TYPE_BOOL, + /* flags */ 0 + }, +}; + +static const rc_json_struct_meta_t rc_json_struct_meta_error = { + /* fields */ rc_json_field_meta_error, + /* name_hash */ 0x0d2011cfU, + /* size */ sizeof(rc_json_error_t), + /* alignment */ RC_JSON_ALIGNOF(rc_json_error_t), + /* num_fields */ 2 +}; + +int rc_json_get_error_size(const char* json) { + size_t size; + int res = rc_json_get_size(&size, 0x0d2011cfU, (const uint8_t*)json); + + if (res == RC_JSON_OK) { + res = (int)size; + } + + return res; +} + +const rc_json_error_t* rc_json_parse_error(void* buffer, const char* json) { + return (const rc_json_error_t*)rc_json_deserialize(buffer, 0x0d2011cfU, (const uint8_t*)json); +} + const rc_json_struct_meta_t* rc_json_resolve_struct(unsigned hash) { switch (hash) { @@ -561,6 +603,7 @@ const rc_json_struct_meta_t* rc_json_resolve_struct(unsigned hash) { case 0xadc4ac0fU: return &rc_json_struct_meta_patchdata; case 0x0dddd3d5U: return &rc_json_struct_meta_patch; case 0x9b4e2684U: return &rc_json_struct_meta_unlocks; + case 0x0d2011cfU: return &rc_json_struct_meta_error; default: return NULL; } } diff --git a/deps/rcheevos/src/rjson/schema.dej b/deps/rcheevos/src/rjson/schema.dej index a902d5e835..f11e6a55f8 100644 --- a/deps/rcheevos/src/rjson/schema.dej +++ b/deps/rcheevos/src/rjson/schema.dej @@ -73,3 +73,10 @@ struct unlocks/Unlocks { unsigned gameid/GameID; bool hardcore/HardcoreMode; }; + +//---------------------------------------------------------------------------- + +struct error/Error { + bool success/Success; + string error/Error; +};