Path: blob/master/dep/rcheevos/include/rc_api_runtime.h
4246 views
#ifndef RC_API_RUNTIME_H1#define RC_API_RUNTIME_H23#include "rc_api_request.h"45#include <stdint.h>6#include <time.h>78RC_BEGIN_C_DECLS910/* --- Fetch Image --- */1112/**13* API parameters for a fetch image request.14* NOTE: fetch image server response is the raw image data. There is no rc_api_process_fetch_image_response function.15*/16typedef struct rc_api_fetch_image_request_t {17/* The name of the image to fetch */18const char* image_name;19/* The type of image to fetch */20uint32_t image_type;21}22rc_api_fetch_image_request_t;2324#define RC_IMAGE_TYPE_GAME 125#define RC_IMAGE_TYPE_ACHIEVEMENT 226#define RC_IMAGE_TYPE_ACHIEVEMENT_LOCKED 327#define RC_IMAGE_TYPE_USER 42829RC_EXPORT int RC_CCONV rc_api_init_fetch_image_request(rc_api_request_t* request, const rc_api_fetch_image_request_t* api_params);30RC_EXPORT int RC_CCONV rc_api_init_fetch_image_request_hosted(rc_api_request_t* request, const rc_api_fetch_image_request_t* api_params, const rc_api_host_t* host);3132/* --- Resolve Hash --- */3334/**35* API parameters for a resolve hash request.36*/37typedef struct rc_api_resolve_hash_request_t {38/* Unused - hash lookup does not require credentials */39const char* username;40/* Unused - hash lookup does not require credentials */41const char* api_token;42/* The generated hash of the game to be identified */43const char* game_hash;44}45rc_api_resolve_hash_request_t;4647/**48* Response data for a resolve hash request.49*/50typedef struct rc_api_resolve_hash_response_t {51/* The unique identifier of the game, 0 if no match was found */52uint32_t game_id;5354/* Common server-provided response information */55rc_api_response_t response;56}57rc_api_resolve_hash_response_t;5859RC_EXPORT int RC_CCONV rc_api_init_resolve_hash_request(rc_api_request_t* request, const rc_api_resolve_hash_request_t* api_params);60RC_EXPORT int RC_CCONV rc_api_init_resolve_hash_request_hosted(rc_api_request_t* request, const rc_api_resolve_hash_request_t* api_params, const rc_api_host_t* host);61/* [deprecated] use rc_api_process_resolve_hash_server_response instead */62RC_EXPORT int RC_CCONV rc_api_process_resolve_hash_response(rc_api_resolve_hash_response_t* response, const char* server_response);63RC_EXPORT int RC_CCONV rc_api_process_resolve_hash_server_response(rc_api_resolve_hash_response_t* response, const rc_api_server_response_t* server_response);64RC_EXPORT void RC_CCONV rc_api_destroy_resolve_hash_response(rc_api_resolve_hash_response_t* response);6566/* --- Fetch Game Data --- */6768/**69* API parameters for a fetch game data request.70*/71typedef struct rc_api_fetch_game_data_request_t {72/* The username of the player */73const char* username;74/* The API token from the login request */75const char* api_token;76/* The unique identifier of the game */77uint32_t game_id;78/* The generated hash of the game to be identified (ignored if game_id is not 0) */79const char* game_hash;80}81rc_api_fetch_game_data_request_t;8283/* A leaderboard definition */84typedef struct rc_api_leaderboard_definition_t {85/* The unique identifier of the leaderboard */86uint32_t id;87/* The format to pass to rc_format_value to format the leaderboard value */88int format;89/* The title of the leaderboard */90const char* title;91/* The description of the leaderboard */92const char* description;93/* The definition of the leaderboard to be passed to rc_runtime_activate_lboard */94const char* definition;95/* Non-zero if lower values are better for this leaderboard */96uint8_t lower_is_better;97/* Non-zero if the leaderboard should not be displayed in a list of leaderboards */98uint8_t hidden;99}100rc_api_leaderboard_definition_t;101102/* An achievement definition */103typedef struct rc_api_achievement_definition_t {104/* The unique identifier of the achievement */105uint32_t id;106/* The number of points the achievement is worth */107uint32_t points;108/* The achievement category (core, unofficial) */109uint32_t category;110/* The title of the achievement */111const char* title;112/* The description of the achievement */113const char* description;114/* The definition of the achievement to be passed to rc_runtime_activate_achievement */115const char* definition;116/* The author of the achievment */117const char* author;118/* The image name for the achievement badge */119const char* badge_name;120/* When the achievement was first uploaded to the server */121time_t created;122/* When the achievement was last modified on the server */123time_t updated;124/* The achievement type (win/progression/missable) */125uint32_t type;126/* The approximate rarity of the achievement (X% of users have earned the achievement) */127float rarity;128/* The approximate rarity of the achievement in hardcore (X% of users have earned the achievement in hardcore) */129float rarity_hardcore;130/* The URL for the achievement badge */131const char* badge_url;132/* The URL for the locked achievement badge */133const char* badge_locked_url;134}135rc_api_achievement_definition_t;136137/* A game subset definition */138typedef struct rc_api_subset_definition_t {139/* The unique identifier of the subset */140uint32_t id;141/* The title of the subset */142const char* title;143/* The image name for the subset badge */144const char* image_name;145/* The URL for the subset badge */146const char* image_url;147148/* An array of achievements for the game */149rc_api_achievement_definition_t* achievements;150/* The number of items in the achievements array */151uint32_t num_achievements;152153/* An array of leaderboards for the game */154rc_api_leaderboard_definition_t* leaderboards;155/* The number of items in the leaderboards array */156uint32_t num_leaderboards;157}158rc_api_subset_definition_t;159160#define RC_ACHIEVEMENT_CATEGORY_CORE 3161#define RC_ACHIEVEMENT_CATEGORY_UNOFFICIAL 5162163#define RC_ACHIEVEMENT_TYPE_STANDARD 0164#define RC_ACHIEVEMENT_TYPE_MISSABLE 1165#define RC_ACHIEVEMENT_TYPE_PROGRESSION 2166#define RC_ACHIEVEMENT_TYPE_WIN 3167168/**169* Response data for a fetch game data request.170*/171typedef struct rc_api_fetch_game_data_response_t {172/* The unique identifier of the game */173uint32_t id;174/* The console associated to the game */175uint32_t console_id;176/* The title of the game */177const char* title;178/* The image name for the game badge */179const char* image_name;180/* The URL for the game badge */181const char* image_url;182/* The rich presence script for the game to be passed to rc_runtime_activate_richpresence */183const char* rich_presence_script;184185/* An array of achievements for the game */186rc_api_achievement_definition_t* achievements;187/* The number of items in the achievements array */188uint32_t num_achievements;189190/* An array of leaderboards for the game */191rc_api_leaderboard_definition_t* leaderboards;192/* The number of items in the leaderboards array */193uint32_t num_leaderboards;194195/* An array of subsets for the game */196rc_api_subset_definition_t* subsets;197/* The number of items in the subsets array */198uint32_t num_subsets;199200/* Common server-provided response information */201rc_api_response_t response;202}203rc_api_fetch_game_data_response_t;204205RC_EXPORT int RC_CCONV rc_api_init_fetch_game_data_request(rc_api_request_t* request, const rc_api_fetch_game_data_request_t* api_params);206RC_EXPORT int RC_CCONV rc_api_init_fetch_game_data_request_hosted(rc_api_request_t* request, const rc_api_fetch_game_data_request_t* api_params, const rc_api_host_t* host);207/* [deprecated] use rc_api_process_fetch_game_data_server_response instead */208RC_EXPORT int RC_CCONV rc_api_process_fetch_game_data_response(rc_api_fetch_game_data_response_t* response, const char* server_response);209RC_EXPORT int RC_CCONV rc_api_process_fetch_game_data_server_response(rc_api_fetch_game_data_response_t* response, const rc_api_server_response_t* server_response);210RC_EXPORT void RC_CCONV rc_api_destroy_fetch_game_data_response(rc_api_fetch_game_data_response_t* response);211212/* --- Ping --- */213214/**215* API parameters for a ping request.216*/217typedef struct rc_api_ping_request_t {218/* The username of the player */219const char* username;220/* The API token from the login request */221const char* api_token;222/* The unique identifier of the game */223uint32_t game_id;224/* (optional) The current rich presence evaluation for the user */225const char* rich_presence;226/* (recommended) The hash associated to the game being played */227const char* game_hash;228/* Non-zero if hardcore is currently enabled (ignored if game_hash is null) */229uint32_t hardcore;230}231rc_api_ping_request_t;232233/**234* Response data for a ping request.235*/236typedef struct rc_api_ping_response_t {237/* Common server-provided response information */238rc_api_response_t response;239}240rc_api_ping_response_t;241242RC_EXPORT int RC_CCONV rc_api_init_ping_request(rc_api_request_t* request, const rc_api_ping_request_t* api_params);243RC_EXPORT int RC_CCONV rc_api_init_ping_request_hosted(rc_api_request_t* request, const rc_api_ping_request_t* api_params, const rc_api_host_t* host);244/* [deprecated] use rc_api_process_ping_server_response instead */245RC_EXPORT int RC_CCONV rc_api_process_ping_response(rc_api_ping_response_t* response, const char* server_response);246RC_EXPORT int RC_CCONV rc_api_process_ping_server_response(rc_api_ping_response_t* response, const rc_api_server_response_t* server_response);247RC_EXPORT void RC_CCONV rc_api_destroy_ping_response(rc_api_ping_response_t* response);248249/* --- Award Achievement --- */250251/**252* API parameters for an award achievement request.253*/254typedef struct rc_api_award_achievement_request_t {255/* The username of the player */256const char* username;257/* The API token from the login request */258const char* api_token;259/* The unique identifier of the achievement */260uint32_t achievement_id;261/* Non-zero if the achievement was earned in hardcore */262uint32_t hardcore;263/* The hash associated to the game being played */264const char* game_hash;265/* The number of seconds since the achievement was unlocked */266uint32_t seconds_since_unlock;267}268rc_api_award_achievement_request_t;269270/**271* Response data for an award achievement request.272*/273typedef struct rc_api_award_achievement_response_t {274/* The unique identifier of the achievement that was awarded */275uint32_t awarded_achievement_id;276/* The updated player score */277uint32_t new_player_score;278/* The updated player softcore score */279uint32_t new_player_score_softcore;280/* The number of achievements the user has not yet unlocked for this game281* (in hardcore/non-hardcore per hardcore flag in request) */282uint32_t achievements_remaining;283284/* Common server-provided response information */285rc_api_response_t response;286}287rc_api_award_achievement_response_t;288289RC_EXPORT int RC_CCONV rc_api_init_award_achievement_request(rc_api_request_t* request, const rc_api_award_achievement_request_t* api_params);290RC_EXPORT int RC_CCONV rc_api_init_award_achievement_request_hosted(rc_api_request_t* request, const rc_api_award_achievement_request_t* api_params, const rc_api_host_t* host);291/* [deprecated] use rc_api_process_award_achievement_server_response instead */292RC_EXPORT int RC_CCONV rc_api_process_award_achievement_response(rc_api_award_achievement_response_t* response, const char* server_response);293RC_EXPORT int RC_CCONV rc_api_process_award_achievement_server_response(rc_api_award_achievement_response_t* response, const rc_api_server_response_t* server_response);294RC_EXPORT void RC_CCONV rc_api_destroy_award_achievement_response(rc_api_award_achievement_response_t* response);295296/* --- Submit Leaderboard Entry --- */297298/**299* API parameters for a submit lboard entry request.300*/301typedef struct rc_api_submit_lboard_entry_request_t {302/* The username of the player */303const char* username;304/* The API token from the login request */305const char* api_token;306/* The unique identifier of the leaderboard */307uint32_t leaderboard_id;308/* The value being submitted */309int32_t score;310/* The hash associated to the game being played */311const char* game_hash;312/* The number of seconds since the leaderboard attempt was completed */313uint32_t seconds_since_completion;314}315rc_api_submit_lboard_entry_request_t;316317/* A leaderboard entry */318typedef struct rc_api_lboard_entry_t {319/* The user associated to the entry */320const char* username;321/* The rank of the entry */322uint32_t rank;323/* The value of the entry */324int32_t score;325}326rc_api_lboard_entry_t;327328/**329* Response data for a submit lboard entry request.330*/331typedef struct rc_api_submit_lboard_entry_response_t {332/* The value that was submitted */333int32_t submitted_score;334/* The player's best submitted value */335int32_t best_score;336/* The player's new rank within the leaderboard */337uint32_t new_rank;338/* The total number of entries in the leaderboard */339uint32_t num_entries;340341/* An array of the top entries for the leaderboard */342rc_api_lboard_entry_t* top_entries;343/* The number of items in the top_entries array */344uint32_t num_top_entries;345346/* Common server-provided response information */347rc_api_response_t response;348}349rc_api_submit_lboard_entry_response_t;350351RC_EXPORT int RC_CCONV rc_api_init_submit_lboard_entry_request(rc_api_request_t* request, const rc_api_submit_lboard_entry_request_t* api_params);352RC_EXPORT int RC_CCONV rc_api_init_submit_lboard_entry_request_hosted(rc_api_request_t* request, const rc_api_submit_lboard_entry_request_t* api_params, const rc_api_host_t* host);353/* [deprecated] use rc_api_process_submit_lboard_entry_server_response instead */354RC_EXPORT int RC_CCONV rc_api_process_submit_lboard_entry_response(rc_api_submit_lboard_entry_response_t* response, const char* server_response);355RC_EXPORT int RC_CCONV rc_api_process_submit_lboard_entry_server_response(rc_api_submit_lboard_entry_response_t* response, const rc_api_server_response_t* server_response);356RC_EXPORT void RC_CCONV rc_api_destroy_submit_lboard_entry_response(rc_api_submit_lboard_entry_response_t* response);357358RC_END_C_DECLS359360#endif /* RC_API_RUNTIME_H */361362363