Updated rcheevos to 6.5.0

This commit is contained in:
Andre Leiradella 2018-08-28 22:20:38 +01:00
parent 4b2bc29775
commit 3f72e1fd96
5 changed files with 64 additions and 0 deletions

View File

@ -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

View File

@ -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:

View File

@ -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

View File

@ -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;
}
}

View File

@ -73,3 +73,10 @@ struct unlocks/Unlocks {
unsigned gameid/GameID;
bool hardcore/HardcoreMode;
};
//----------------------------------------------------------------------------
struct error/Error {
bool success/Success;
string error/Error;
};