Path: blob/master/dep/rcheevos/include/rc_api_runtime.h
4804 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#define RC_ACHIEVEMENT_CATEGORY_CORE 3138#define RC_ACHIEVEMENT_CATEGORY_UNOFFICIAL 5139140#define RC_ACHIEVEMENT_TYPE_STANDARD 0141#define RC_ACHIEVEMENT_TYPE_MISSABLE 1142#define RC_ACHIEVEMENT_TYPE_PROGRESSION 2143#define RC_ACHIEVEMENT_TYPE_WIN 3144145/**146* Response data for a fetch game data request.147*/148typedef struct rc_api_fetch_game_data_response_t {149/* The unique identifier of the game */150uint32_t id;151/* The console associated to the game */152uint32_t console_id;153/* The title of the game */154const char* title;155/* The image name for the game badge */156const char* image_name;157/* The URL for the game badge */158const char* image_url;159/* The rich presence script for the game to be passed to rc_runtime_activate_richpresence */160const char* rich_presence_script;161162/* An array of achievements for the game */163rc_api_achievement_definition_t* achievements;164/* The number of items in the achievements array */165uint32_t num_achievements;166167/* An array of leaderboards for the game */168rc_api_leaderboard_definition_t* leaderboards;169/* The number of items in the leaderboards array */170uint32_t num_leaderboards;171172/* Common server-provided response information */173rc_api_response_t response;174}175rc_api_fetch_game_data_response_t;176177RC_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);178RC_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);179/* [deprecated] use rc_api_process_fetch_game_data_server_response instead */180RC_EXPORT int RC_CCONV rc_api_process_fetch_game_data_response(rc_api_fetch_game_data_response_t* response, const char* server_response);181RC_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);182RC_EXPORT void RC_CCONV rc_api_destroy_fetch_game_data_response(rc_api_fetch_game_data_response_t* response);183184/* --- Fetch Game Sets --- */185186/**187* API parameters for a fetch game data request.188*/189typedef struct rc_api_fetch_game_sets_request_t {190/* The username of the player */191const char* username;192/* The API token from the login request */193const char* api_token;194/* The unique identifier of the game */195uint32_t game_id;196/* The generated hash of the game to be identified (ignored if game_id is not 0) */197const char* game_hash;198}199rc_api_fetch_game_sets_request_t;200201#define RC_ACHIEVEMENT_SET_TYPE_CORE 0202#define RC_ACHIEVEMENT_SET_TYPE_BONUS 1203#define RC_ACHIEVEMENT_SET_TYPE_SPECIALTY 2204#define RC_ACHIEVEMENT_SET_TYPE_EXCLUSIVE 3205206/* A game subset definition */207typedef struct rc_api_achievement_set_definition_t {208/* The unique identifier of the achievement set */209uint32_t id;210/* The legacy game_id of the achievement set (used for editor API calls) */211uint32_t game_id;212/* The title of the achievement set */213const char* title;214/* The image name for the achievement set badge */215const char* image_name;216/* The URL for the achievement set badge */217const char* image_url;218219/* An array of achievements for the achievement set */220rc_api_achievement_definition_t* achievements;221/* The number of items in the achievements array */222uint32_t num_achievements;223224/* An array of leaderboards for the achievement set */225rc_api_leaderboard_definition_t* leaderboards;226/* The number of items in the leaderboards array */227uint32_t num_leaderboards;228229/* The type of the achievement set */230uint8_t type;231}232rc_api_achievement_set_definition_t;233234/**235* Response data for a fetch game sets request.236*/237typedef struct rc_api_fetch_game_sets_response_t {238/* The unique identifier of the game */239uint32_t id;240/* The console associated to the game */241uint32_t console_id;242/* The title of the game */243const char* title;244/* The image name for the game badge */245const char* image_name;246/* The URL for the game badge */247const char* image_url;248/* The rich presence script for the game to be passed to rc_runtime_activate_richpresence */249const char* rich_presence_script;250/* The unique identifier of the game to use for session requests (startsession/ping/etc) */251uint32_t session_game_id;252253/* An array of sets for the game */254rc_api_achievement_set_definition_t* sets;255/* The number of items in the sets array */256uint32_t num_sets;257258/* Common server-provided response information */259rc_api_response_t response;260}261rc_api_fetch_game_sets_response_t;262263RC_EXPORT int RC_CCONV rc_api_init_fetch_game_sets_request(rc_api_request_t* request, const rc_api_fetch_game_sets_request_t* api_params);264RC_EXPORT int RC_CCONV rc_api_init_fetch_game_sets_request_hosted(rc_api_request_t* request, const rc_api_fetch_game_sets_request_t* api_params, const rc_api_host_t* host);265RC_EXPORT int RC_CCONV rc_api_process_fetch_game_sets_server_response(rc_api_fetch_game_sets_response_t* response, const rc_api_server_response_t* server_response);266RC_EXPORT void RC_CCONV rc_api_destroy_fetch_game_sets_response(rc_api_fetch_game_sets_response_t* response);267268/* --- Ping --- */269270/**271* API parameters for a ping request.272*/273typedef struct rc_api_ping_request_t {274/* The username of the player */275const char* username;276/* The API token from the login request */277const char* api_token;278/* The unique identifier of the game */279uint32_t game_id;280/* (optional) The current rich presence evaluation for the user */281const char* rich_presence;282/* (recommended) The hash associated to the game being played */283const char* game_hash;284/* Non-zero if hardcore is currently enabled (ignored if game_hash is null) */285uint32_t hardcore;286}287rc_api_ping_request_t;288289/**290* Response data for a ping request.291*/292typedef struct rc_api_ping_response_t {293/* Common server-provided response information */294rc_api_response_t response;295}296rc_api_ping_response_t;297298RC_EXPORT int RC_CCONV rc_api_init_ping_request(rc_api_request_t* request, const rc_api_ping_request_t* api_params);299RC_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);300/* [deprecated] use rc_api_process_ping_server_response instead */301RC_EXPORT int RC_CCONV rc_api_process_ping_response(rc_api_ping_response_t* response, const char* server_response);302RC_EXPORT int RC_CCONV rc_api_process_ping_server_response(rc_api_ping_response_t* response, const rc_api_server_response_t* server_response);303RC_EXPORT void RC_CCONV rc_api_destroy_ping_response(rc_api_ping_response_t* response);304305/* --- Award Achievement --- */306307/**308* API parameters for an award achievement request.309*/310typedef struct rc_api_award_achievement_request_t {311/* The username of the player */312const char* username;313/* The API token from the login request */314const char* api_token;315/* The unique identifier of the achievement */316uint32_t achievement_id;317/* Non-zero if the achievement was earned in hardcore */318uint32_t hardcore;319/* The hash associated to the game being played */320const char* game_hash;321/* The number of seconds since the achievement was unlocked */322uint32_t seconds_since_unlock;323}324rc_api_award_achievement_request_t;325326/**327* Response data for an award achievement request.328*/329typedef struct rc_api_award_achievement_response_t {330/* The unique identifier of the achievement that was awarded */331uint32_t awarded_achievement_id;332/* The updated player score */333uint32_t new_player_score;334/* The updated player softcore score */335uint32_t new_player_score_softcore;336/* The number of achievements the user has not yet unlocked for this game337* (in hardcore/non-hardcore per hardcore flag in request) */338uint32_t achievements_remaining;339340/* Common server-provided response information */341rc_api_response_t response;342}343rc_api_award_achievement_response_t;344345RC_EXPORT int RC_CCONV rc_api_init_award_achievement_request(rc_api_request_t* request, const rc_api_award_achievement_request_t* api_params);346RC_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);347/* [deprecated] use rc_api_process_award_achievement_server_response instead */348RC_EXPORT int RC_CCONV rc_api_process_award_achievement_response(rc_api_award_achievement_response_t* response, const char* server_response);349RC_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);350RC_EXPORT void RC_CCONV rc_api_destroy_award_achievement_response(rc_api_award_achievement_response_t* response);351352/* --- Submit Leaderboard Entry --- */353354/**355* API parameters for a submit lboard entry request.356*/357typedef struct rc_api_submit_lboard_entry_request_t {358/* The username of the player */359const char* username;360/* The API token from the login request */361const char* api_token;362/* The unique identifier of the leaderboard */363uint32_t leaderboard_id;364/* The value being submitted */365int32_t score;366/* The hash associated to the game being played */367const char* game_hash;368/* The number of seconds since the leaderboard attempt was completed */369uint32_t seconds_since_completion;370}371rc_api_submit_lboard_entry_request_t;372373/* A leaderboard entry */374typedef struct rc_api_lboard_entry_t {375/* The user associated to the entry */376const char* username;377/* The rank of the entry */378uint32_t rank;379/* The value of the entry */380int32_t score;381}382rc_api_lboard_entry_t;383384/**385* Response data for a submit lboard entry request.386*/387typedef struct rc_api_submit_lboard_entry_response_t {388/* The value that was submitted */389int32_t submitted_score;390/* The player's best submitted value */391int32_t best_score;392/* The player's new rank within the leaderboard */393uint32_t new_rank;394/* The total number of entries in the leaderboard */395uint32_t num_entries;396397/* An array of the top entries for the leaderboard */398rc_api_lboard_entry_t* top_entries;399/* The number of items in the top_entries array */400uint32_t num_top_entries;401402/* Common server-provided response information */403rc_api_response_t response;404}405rc_api_submit_lboard_entry_response_t;406407RC_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);408RC_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);409/* [deprecated] use rc_api_process_submit_lboard_entry_server_response instead */410RC_EXPORT int RC_CCONV rc_api_process_submit_lboard_entry_response(rc_api_submit_lboard_entry_response_t* response, const char* server_response);411RC_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);412RC_EXPORT void RC_CCONV rc_api_destroy_submit_lboard_entry_response(rc_api_submit_lboard_entry_response_t* response);413414RC_END_C_DECLS415416#endif /* RC_API_RUNTIME_H */417418419