dep/rcheevos: Update to 8a717b1

This commit is contained in:
Stenzek
2023-11-06 19:41:10 +10:00
parent a4127aa2ea
commit f62a3ffbfa
50 changed files with 1584 additions and 1310 deletions

View File

@ -3,6 +3,8 @@
#include "rc_api_request.h"
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
@ -14,14 +16,14 @@ extern "C" {
*/
typedef struct rc_api_fetch_code_notes_request_t {
/* The unique identifier of the game */
unsigned game_id;
uint32_t game_id;
}
rc_api_fetch_code_notes_request_t;
/* A code note definiton */
typedef struct rc_api_code_note_t {
/* The address the note is associated to */
unsigned address;
uint32_t address;
/* The name of the use who last updated the note */
const char* author;
/* The contents of the note */
@ -35,7 +37,7 @@ typedef struct rc_api_fetch_code_notes_response_t {
/* An array of code notes for the game */
rc_api_code_note_t* notes;
/* The number of items in the notes array */
unsigned num_notes;
uint32_t num_notes;
/* Common server-provided response information */
rc_api_response_t response;
@ -58,9 +60,9 @@ typedef struct rc_api_update_code_note_request_t {
/* The API token from the login request */
const char* api_token;
/* The unique identifier of the game */
unsigned game_id;
uint32_t game_id;
/* The address the note is associated to */
unsigned address;
uint32_t address;
/* The contents of the note (NULL or empty to delete a note) */
const char* note;
}
@ -91,9 +93,9 @@ typedef struct rc_api_update_achievement_request_t {
/* The API token from the login request */
const char* api_token;
/* The unique identifier of the achievement (0 to create a new achievement) */
unsigned achievement_id;
uint32_t achievement_id;
/* The unique identifier of the game */
unsigned game_id;
uint32_t game_id;
/* The name of the achievement */
const char* title;
/* The description of the achievement */
@ -103,9 +105,9 @@ typedef struct rc_api_update_achievement_request_t {
/* The serialized trigger for the achievement */
const char* trigger;
/* The number of points the achievement is worth */
unsigned points;
uint32_t points;
/* The category of the achievement */
unsigned category;
uint32_t category;
}
rc_api_update_achievement_request_t;
@ -114,7 +116,7 @@ rc_api_update_achievement_request_t;
*/
typedef struct rc_api_update_achievement_response_t {
/* The unique identifier of the achievement */
unsigned achievement_id;
uint32_t achievement_id;
/* Common server-provided response information */
rc_api_response_t response;
@ -137,9 +139,9 @@ typedef struct rc_api_update_leaderboard_request_t {
/* The API token from the login request */
const char* api_token;
/* The unique identifier of the leaderboard (0 to create a new leaderboard) */
unsigned leaderboard_id;
uint32_t leaderboard_id;
/* The unique identifier of the game */
unsigned game_id;
uint32_t game_id;
/* The name of the leaderboard */
const char* title;
/* The description of the leaderboard */
@ -155,7 +157,7 @@ typedef struct rc_api_update_leaderboard_request_t {
/* The format of leaderboard values */
const char* format;
/* Whether or not lower scores are better for the leaderboard */
int lower_is_better;
uint32_t lower_is_better;
}
rc_api_update_leaderboard_request_t;
@ -164,7 +166,7 @@ rc_api_update_leaderboard_request_t;
*/
typedef struct rc_api_update_leaderboard_response_t {
/* The unique identifier of the leaderboard */
unsigned leaderboard_id;
uint32_t leaderboard_id;
/* Common server-provided response information */
rc_api_response_t response;
@ -183,7 +185,7 @@ void rc_api_destroy_update_leaderboard_response(rc_api_update_leaderboard_respon
*/
typedef struct rc_api_fetch_badge_range_request_t {
/* Unused */
unsigned unused;
uint32_t unused;
}
rc_api_fetch_badge_range_request_t;
@ -192,9 +194,9 @@ rc_api_fetch_badge_range_request_t;
*/
typedef struct rc_api_fetch_badge_range_response_t {
/* The numeric identifier of the first valid badge ID */
unsigned first_badge_id;
uint32_t first_badge_id;
/* The numeric identifier of the first unassigned badge ID */
unsigned next_badge_id;
uint32_t next_badge_id;
/* Common server-provided response information */
rc_api_response_t response;
@ -217,9 +219,9 @@ typedef struct rc_api_add_game_hash_request_t {
/* The API token from the login request */
const char* api_token;
/* The unique identifier of the game (0 to create a new game entry) */
unsigned game_id;
uint32_t game_id;
/* The unique identifier of the console for the game */
unsigned console_id;
uint32_t console_id;
/* The title of the game */
const char* title;
/* The hash being added */
@ -234,7 +236,7 @@ rc_api_add_game_hash_request_t;
*/
typedef struct rc_api_add_game_hash_response_t {
/* The unique identifier of the game */
unsigned game_id;
uint32_t game_id;
/* Common server-provided response information */
rc_api_response_t response;

View File

@ -3,6 +3,7 @@
#include "rc_api_request.h"
#include <stdint.h>
#include <time.h>
#ifdef __cplusplus
@ -20,13 +21,13 @@ typedef struct rc_api_fetch_achievement_info_request_t {
/* The API token from the login request */
const char* api_token;
/* The unique identifier of the achievement */
unsigned achievement_id;
uint32_t achievement_id;
/* The 1-based index of the first entry to retrieve */
unsigned first_entry;
uint32_t first_entry;
/* The number of entries to retrieve */
unsigned count;
uint32_t count;
/* Non-zero to only return unlocks earned by the user's friends */
unsigned friends_only;
uint32_t friends_only;
}
rc_api_fetch_achievement_info_request_t;
@ -44,18 +45,18 @@ rc_api_achievement_awarded_entry_t;
*/
typedef struct rc_api_fetch_achievement_info_response_t {
/* The unique identifier of the achievement */
unsigned id;
uint32_t id;
/* The unique identifier of the game to which the leaderboard is associated */
unsigned game_id;
uint32_t game_id;
/* The number of times the achievement has been awarded */
unsigned num_awarded;
uint32_t num_awarded;
/* The number of players that have earned at least one achievement for the game */
unsigned num_players;
uint32_t num_players;
/* An array of recently rewarded entries */
rc_api_achievement_awarded_entry_t* recently_awarded;
/* The number of items in the recently_awarded array */
unsigned num_recently_awarded;
uint32_t num_recently_awarded;
/* Common server-provided response information */
rc_api_response_t response;
@ -74,11 +75,11 @@ void rc_api_destroy_fetch_achievement_info_response(rc_api_fetch_achievement_inf
*/
typedef struct rc_api_fetch_leaderboard_info_request_t {
/* The unique identifier of the leaderboard */
unsigned leaderboard_id;
uint32_t leaderboard_id;
/* The number of entries to retrieve */
unsigned count;
uint32_t count;
/* The 1-based index of the first entry to retrieve */
unsigned first_entry;
uint32_t first_entry;
/* The username of the player around whom the entries should be returned */
const char* username;
}
@ -89,11 +90,11 @@ typedef struct rc_api_lboard_info_entry_t {
/* The user associated to the entry */
const char* username;
/* The rank of the entry */
unsigned rank;
uint32_t rank;
/* The index of the entry */
unsigned index;
uint32_t index;
/* The value of the entry */
int score;
int32_t score;
/* When the entry was submitted */
time_t submitted;
}
@ -104,11 +105,11 @@ rc_api_lboard_info_entry_t;
*/
typedef struct rc_api_fetch_leaderboard_info_response_t {
/* The unique identifier of the leaderboard */
unsigned id;
uint32_t id;
/* The format to pass to rc_format_value to format the leaderboard value */
int format;
/* If non-zero, indicates that lower scores appear first */
int lower_is_better;
uint32_t lower_is_better;
/* The title of the leaderboard */
const char* title;
/* The description of the leaderboard */
@ -116,7 +117,7 @@ typedef struct rc_api_fetch_leaderboard_info_response_t {
/* The definition of the leaderboard to be passed to rc_runtime_activate_lboard */
const char* definition;
/* The unique identifier of the game to which the leaderboard is associated */
unsigned game_id;
uint32_t game_id;
/* The author of the leaderboard */
const char* author;
/* When the leaderboard was first uploaded to the server */
@ -127,7 +128,7 @@ typedef struct rc_api_fetch_leaderboard_info_response_t {
/* An array of requested entries */
rc_api_lboard_info_entry_t* entries;
/* The number of items in the entries array */
unsigned num_entries;
uint32_t num_entries;
/* Common server-provided response information */
rc_api_response_t response;
@ -146,14 +147,14 @@ void rc_api_destroy_fetch_leaderboard_info_response(rc_api_fetch_leaderboard_inf
*/
typedef struct rc_api_fetch_games_list_request_t {
/* The unique identifier of the console to query */
unsigned console_id;
uint32_t console_id;
}
rc_api_fetch_games_list_request_t;
/* A game list entry */
typedef struct rc_api_game_list_entry_t {
/* The unique identifier of the game */
unsigned id;
uint32_t id;
/* The name of the game */
const char* name;
}
@ -166,7 +167,7 @@ typedef struct rc_api_fetch_games_list_response_t {
/* An array of requested entries */
rc_api_game_list_entry_t* entries;
/* The number of items in the entries array */
unsigned num_entries;
uint32_t num_entries;
/* Common server-provided response information */
rc_api_response_t response;

View File

@ -2,6 +2,7 @@
#define RC_API_REQUEST_H
#include "rc_error.h"
#include "../src/rc_util.h"
#include <stddef.h>
@ -9,32 +10,6 @@
extern "C" {
#endif
/**
* A block of memory for variable length data (like strings and arrays).
*/
typedef struct rc_api_buffer_chunk_t {
/* The current location where data is being written */
char* write;
/* The first byte past the end of data where writing cannot occur */
char* end;
/* The first byte of the data */
char* start;
/* The next block in the allocated memory chain */
struct rc_api_buffer_chunk_t* next;
}
rc_api_buffer_chunk_t;
/**
* A preallocated block of memory for variable length data (like strings and arrays).
*/
typedef struct rc_api_buffer_t {
/* The chunk data (will point at the local data member) */
struct rc_api_buffer_chunk_t chunk;
/* Small chunk of memory pre-allocated for the chunk */
char data[256];
}
rc_api_buffer_t;
/**
* A constructed request to send to the retroachievements server.
*/
@ -47,7 +22,7 @@ typedef struct rc_api_request_t {
const char* content_type;
/* Storage for the url and post_data */
rc_api_buffer_t buffer;
rc_buffer_t buffer;
}
rc_api_request_t;
@ -59,9 +34,11 @@ typedef struct rc_api_response_t {
int succeeded;
/* Server-provided message associated to the failure */
const char* error_message;
/* Server-provided error code associated to the failure */
const char* error_code;
/* Storage for the response data */
rc_api_buffer_t buffer;
rc_buffer_t buffer;
}
rc_api_response_t;
@ -79,6 +56,11 @@ typedef struct rc_api_server_response_t {
int http_status_code;
} rc_api_server_response_t;
enum {
RC_API_SERVER_RESPONSE_CLIENT_ERROR = -1,
RC_API_SERVER_RESPONSE_RETRYABLE_CLIENT_ERROR = -2
};
#ifdef __cplusplus
}
#endif

View File

@ -3,6 +3,7 @@
#include "rc_api_request.h"
#include <stdint.h>
#include <time.h>
#ifdef __cplusplus
@ -19,7 +20,7 @@ typedef struct rc_api_fetch_image_request_t {
/* The name of the image to fetch */
const char* image_name;
/* The type of image to fetch */
int image_type;
uint32_t image_type;
}
rc_api_fetch_image_request_t;
@ -50,7 +51,7 @@ rc_api_resolve_hash_request_t;
*/
typedef struct rc_api_resolve_hash_response_t {
/* The unique identifier of the game, 0 if no match was found */
unsigned game_id;
uint32_t game_id;
/* Common server-provided response information */
rc_api_response_t response;
@ -73,14 +74,14 @@ typedef struct rc_api_fetch_game_data_request_t {
/* The API token from the login request */
const char* api_token;
/* The unique identifier of the game */
unsigned game_id;
uint32_t game_id;
}
rc_api_fetch_game_data_request_t;
/* A leaderboard definition */
typedef struct rc_api_leaderboard_definition_t {
/* The unique identifier of the leaderboard */
unsigned id;
uint32_t id;
/* The format to pass to rc_format_value to format the leaderboard value */
int format;
/* The title of the leaderboard */
@ -90,20 +91,20 @@ typedef struct rc_api_leaderboard_definition_t {
/* The definition of the leaderboard to be passed to rc_runtime_activate_lboard */
const char* definition;
/* Non-zero if lower values are better for this leaderboard */
int lower_is_better;
uint8_t lower_is_better;
/* Non-zero if the leaderboard should not be displayed in a list of leaderboards */
int hidden;
uint8_t hidden;
}
rc_api_leaderboard_definition_t;
/* An achievement definition */
typedef struct rc_api_achievement_definition_t {
/* The unique identifier of the achievement */
unsigned id;
uint32_t id;
/* The number of points the achievement is worth */
unsigned points;
uint32_t points;
/* The achievement category (core, unofficial) */
unsigned category;
uint32_t category;
/* The title of the achievement */
const char* title;
/* The dscription of the achievement */
@ -129,9 +130,9 @@ rc_api_achievement_definition_t;
*/
typedef struct rc_api_fetch_game_data_response_t {
/* The unique identifier of the game */
unsigned id;
uint32_t id;
/* The console associated to the game */
unsigned console_id;
uint32_t console_id;
/* The title of the game */
const char* title;
/* The image name for the game badge */
@ -142,12 +143,12 @@ typedef struct rc_api_fetch_game_data_response_t {
/* An array of achievements for the game */
rc_api_achievement_definition_t* achievements;
/* The number of items in the achievements array */
unsigned num_achievements;
uint32_t num_achievements;
/* An array of leaderboards for the game */
rc_api_leaderboard_definition_t* leaderboards;
/* The number of items in the leaderboards array */
unsigned num_leaderboards;
uint32_t num_leaderboards;
/* Common server-provided response information */
rc_api_response_t response;
@ -170,7 +171,7 @@ typedef struct rc_api_ping_request_t {
/* The API token from the login request */
const char* api_token;
/* The unique identifier of the game */
unsigned game_id;
uint32_t game_id;
/* (optional) The current rich presence evaluation for the user */
const char* rich_presence;
}
@ -201,9 +202,9 @@ typedef struct rc_api_award_achievement_request_t {
/* The API token from the login request */
const char* api_token;
/* The unique identifier of the achievement */
unsigned achievement_id;
uint32_t achievement_id;
/* Non-zero if the achievement was earned in hardcore */
int hardcore;
uint32_t hardcore;
/* The hash associated to the game being played */
const char* game_hash;
}
@ -214,14 +215,14 @@ rc_api_award_achievement_request_t;
*/
typedef struct rc_api_award_achievement_response_t {
/* The unique identifier of the achievement that was awarded */
unsigned awarded_achievement_id;
uint32_t awarded_achievement_id;
/* The updated player score */
unsigned new_player_score;
uint32_t new_player_score;
/* The updated player softcore score */
unsigned new_player_score_softcore;
uint32_t new_player_score_softcore;
/* The number of achievements the user has not yet unlocked for this game
* (in hardcore/non-hardcore per hardcore flag in request) */
unsigned achievements_remaining;
uint32_t achievements_remaining;
/* Common server-provided response information */
rc_api_response_t response;
@ -244,9 +245,9 @@ typedef struct rc_api_submit_lboard_entry_request_t {
/* The API token from the login request */
const char* api_token;
/* The unique identifier of the leaderboard */
unsigned leaderboard_id;
uint32_t leaderboard_id;
/* The value being submitted */
int score;
int32_t score;
/* The hash associated to the game being played */
const char* game_hash;
}
@ -257,9 +258,9 @@ typedef struct rc_api_lboard_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 */
int score;
int32_t score;
}
rc_api_lboard_entry_t;
@ -268,18 +269,18 @@ rc_api_lboard_entry_t;
*/
typedef struct rc_api_submit_lboard_entry_response_t {
/* The value that was submitted */
int submitted_score;
int32_t submitted_score;
/* The player's best submitted value */
int best_score;
int32_t best_score;
/* 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_api_lboard_entry_t* top_entries;
/* The number of items in the top_entries array */
unsigned num_top_entries;
uint32_t num_top_entries;
/* Common server-provided response information */
rc_api_response_t response;

View File

@ -3,6 +3,7 @@
#include "rc_api_request.h"
#include <stdint.h>
#include <time.h>
#ifdef __cplusplus
@ -34,11 +35,11 @@ typedef struct rc_api_login_response_t {
/* The API token to use for all future requests */
const char* api_token;
/* The current score of the player */
unsigned score;
uint32_t score;
/* The current softcore score of the player */
unsigned score_softcore;
uint32_t score_softcore;
/* The number of unread messages waiting for the player on the web site */
unsigned num_unread_messages;
uint32_t num_unread_messages;
/* The preferred name to display for the player */
const char* display_name;
@ -63,7 +64,7 @@ typedef struct rc_api_start_session_request_t {
/* The API token from the login request */
const char* api_token;
/* The unique identifier of the game */
unsigned game_id;
uint32_t game_id;
}
rc_api_start_session_request_t;
@ -72,7 +73,7 @@ rc_api_start_session_request_t;
*/
typedef struct rc_api_unlock_entry_t {
/* The unique identifier of the unlocked achievement */
unsigned achievement_id;
uint32_t achievement_id;
/* When the achievement was unlocked */
time_t when;
}
@ -88,9 +89,9 @@ typedef struct rc_api_start_session_response_t {
rc_api_unlock_entry_t* unlocks;
/* The number of items in the hardcore_unlocks array */
unsigned num_hardcore_unlocks;
uint32_t num_hardcore_unlocks;
/* The number of items in the unlocks array */
unsigned num_unlocks;
uint32_t num_unlocks;
/* The server timestamp when the response was generated */
time_t server_now;
@ -116,9 +117,9 @@ typedef struct rc_api_fetch_user_unlocks_request_t {
/* The API token from the login request */
const char* api_token;
/* The unique identifier of the game */
unsigned game_id;
uint32_t game_id;
/* Non-zero to fetch hardcore unlocks, 0 to fetch non-hardcore unlocks */
int hardcore;
uint32_t hardcore;
}
rc_api_fetch_user_unlocks_request_t;
@ -127,9 +128,9 @@ rc_api_fetch_user_unlocks_request_t;
*/
typedef struct rc_api_fetch_user_unlocks_response_t {
/* An array of achievement IDs previously unlocked by the user */
unsigned* achievement_ids;
uint32_t* achievement_ids;
/* The number of items in the achievement_ids array */
unsigned num_achievement_ids;
uint32_t num_achievement_ids;
/* Common server-provided response information */
rc_api_response_t response;

View File

@ -146,8 +146,7 @@ void rc_client_abort_async(rc_client_t* client, rc_client_async_handle_t* async_
* Sets the logging level and provides a callback to be called to do the logging.
*/
void rc_client_enable_logging(rc_client_t* client, int level, rc_client_message_callback_t callback);
enum
{
enum {
RC_CLIENT_LOG_LEVEL_NONE = 0,
RC_CLIENT_LOG_LEVEL_ERROR = 1,
RC_CLIENT_LOG_LEVEL_WARN = 2,
@ -582,6 +581,8 @@ typedef struct rc_client_server_error_t
{
const char* error_message;
const char* api;
int result;
uint32_t related_id;
} rc_client_server_error_t;
typedef struct rc_client_event_t

View File

@ -5,6 +5,8 @@
extern "C" {
#endif
#include <stdint.h>
/*****************************************************************************\
| Console identifiers |
\*****************************************************************************/
@ -113,21 +115,21 @@ enum {
};
typedef struct rc_memory_region_t {
unsigned start_address; /* first address of block as queried by RetroAchievements */
unsigned end_address; /* last address of block as queried by RetroAchievements */
unsigned real_address; /* real address for first address of block */
char type; /* RC_MEMORY_TYPE_ for block */
uint32_t start_address; /* first address of block as queried by RetroAchievements */
uint32_t end_address; /* last address of block as queried by RetroAchievements */
uint32_t real_address; /* real address for first address of block */
uint8_t type; /* RC_MEMORY_TYPE_ for block */
const char* description; /* short description of block */
}
rc_memory_region_t;
typedef struct rc_memory_regions_t {
const rc_memory_region_t* region;
unsigned num_regions;
uint32_t num_regions;
}
rc_memory_regions_t;
const rc_memory_regions_t* rc_console_memory_regions(int console_id);
const rc_memory_regions_t* rc_console_memory_regions(uint32_t console_id);
#ifdef __cplusplus

View File

@ -42,7 +42,10 @@ enum {
RC_NO_GAME_LOADED = -29,
RC_HARDCORE_DISABLED = -30,
RC_ABORTED = -31,
RC_NO_RESPONSE = -32
RC_NO_RESPONSE = -32,
RC_ACCESS_DENIED = -33,
RC_INVALID_CREDENTIALS = -34,
RC_EXPIRED_TOKEN = -35
};
const char* rc_error_str(int ret);

View File

@ -8,6 +8,7 @@ extern "C" {
#include "rc_error.h"
#include <stddef.h>
#include <stdint.h>
/*****************************************************************************\
| Forward Declarations (defined in rc_runtime_types.h) |
@ -34,32 +35,32 @@ typedef struct rc_value_t rc_value_t;
* num_bytes is greater than 1, the value is read in little-endian from
* memory.
*/
typedef unsigned (*rc_runtime_peek_t)(unsigned address, unsigned num_bytes, void* ud);
typedef uint32_t(*rc_runtime_peek_t)(uint32_t address, uint32_t num_bytes, void* ud);
/*****************************************************************************\
| Runtime |
\*****************************************************************************/
typedef struct rc_runtime_trigger_t {
unsigned id;
uint32_t id;
rc_trigger_t* trigger;
void* buffer;
rc_memref_t* invalid_memref;
unsigned char md5[16];
int serialized_size;
char owns_memrefs;
uint8_t md5[16];
int32_t serialized_size;
uint8_t owns_memrefs;
}
rc_runtime_trigger_t;
typedef struct rc_runtime_lboard_t {
unsigned id;
int value;
uint32_t id;
int32_t value;
rc_lboard_t* lboard;
void* buffer;
rc_memref_t* invalid_memref;
unsigned char md5[16];
int serialized_size;
char owns_memrefs;
uint8_t md5[16];
uint32_t serialized_size;
uint8_t owns_memrefs;
}
rc_runtime_lboard_t;
@ -67,19 +68,19 @@ typedef struct rc_runtime_richpresence_t {
rc_richpresence_t* richpresence;
void* buffer;
struct rc_runtime_richpresence_t* previous;
unsigned char md5[16];
char owns_memrefs;
uint8_t md5[16];
uint8_t owns_memrefs;
}
rc_runtime_richpresence_t;
typedef struct rc_runtime_t {
rc_runtime_trigger_t* triggers;
unsigned trigger_count;
unsigned trigger_capacity;
uint32_t trigger_count;
uint32_t trigger_capacity;
rc_runtime_lboard_t* lboards;
unsigned lboard_count;
unsigned lboard_capacity;
uint32_t lboard_count;
uint32_t lboard_capacity;
rc_runtime_richpresence_t* richpresence;
@ -89,7 +90,7 @@ typedef struct rc_runtime_t {
rc_value_t* variables;
rc_value_t** next_variable;
char owns_self;
uint8_t owns_self;
}
rc_runtime_t;
@ -97,20 +98,20 @@ rc_runtime_t* rc_runtime_alloc(void);
void rc_runtime_init(rc_runtime_t* runtime);
void rc_runtime_destroy(rc_runtime_t* runtime);
int rc_runtime_activate_achievement(rc_runtime_t* runtime, unsigned id, const char* memaddr, lua_State* L, int funcs_idx);
void rc_runtime_deactivate_achievement(rc_runtime_t* runtime, unsigned id);
rc_trigger_t* rc_runtime_get_achievement(const rc_runtime_t* runtime, unsigned id);
int rc_runtime_get_achievement_measured(const rc_runtime_t* runtime, unsigned id, unsigned* measured_value, unsigned* measured_target);
int rc_runtime_format_achievement_measured(const rc_runtime_t* runtime, unsigned id, char *buffer, size_t buffer_size);
int rc_runtime_activate_achievement(rc_runtime_t* runtime, uint32_t id, const char* memaddr, lua_State* L, int funcs_idx);
void rc_runtime_deactivate_achievement(rc_runtime_t* runtime, uint32_t id);
rc_trigger_t* rc_runtime_get_achievement(const rc_runtime_t* runtime, uint32_t id);
int rc_runtime_get_achievement_measured(const rc_runtime_t* runtime, uint32_t id, unsigned* measured_value, unsigned* measured_target);
int rc_runtime_format_achievement_measured(const rc_runtime_t* runtime, uint32_t id, char *buffer, size_t buffer_size);
int rc_runtime_activate_lboard(rc_runtime_t* runtime, unsigned id, const char* memaddr, lua_State* L, int funcs_idx);
void rc_runtime_deactivate_lboard(rc_runtime_t* runtime, unsigned id);
rc_lboard_t* rc_runtime_get_lboard(const rc_runtime_t* runtime, unsigned id);
int rc_runtime_format_lboard_value(char* buffer, int size, int value, int format);
int rc_runtime_activate_lboard(rc_runtime_t* runtime, uint32_t id, const char* memaddr, lua_State* L, int funcs_idx);
void rc_runtime_deactivate_lboard(rc_runtime_t* runtime, uint32_t id);
rc_lboard_t* rc_runtime_get_lboard(const rc_runtime_t* runtime, uint32_t id);
int rc_runtime_format_lboard_value(char* buffer, int size, int32_t value, int format);
int rc_runtime_activate_richpresence(rc_runtime_t* runtime, const char* script, lua_State* L, int funcs_idx);
int rc_runtime_get_richpresence(const rc_runtime_t* runtime, char* buffer, unsigned buffersize, rc_runtime_peek_t peek, void* peek_ud, lua_State* L);
int rc_runtime_get_richpresence(const rc_runtime_t* runtime, char* buffer, size_t buffersize, rc_runtime_peek_t peek, void* peek_ud, lua_State* L);
enum {
RC_RUNTIME_EVENT_ACHIEVEMENT_ACTIVATED, /* from WAITING, PAUSED, or PRIMED to ACTIVE */
@ -129,9 +130,9 @@ enum {
};
typedef struct rc_runtime_event_t {
unsigned id;
int value;
char type;
uint32_t id;
int32_t value;
uint8_t type;
}
rc_runtime_event_t;
@ -140,13 +141,13 @@ typedef void (*rc_runtime_event_handler_t)(const rc_runtime_event_t* runtime_eve
void rc_runtime_do_frame(rc_runtime_t* runtime, rc_runtime_event_handler_t event_handler, rc_runtime_peek_t peek, void* ud, lua_State* L);
void rc_runtime_reset(rc_runtime_t* runtime);
typedef int (*rc_runtime_validate_address_t)(unsigned address);
typedef int (*rc_runtime_validate_address_t)(uint32_t address);
void rc_runtime_validate_addresses(rc_runtime_t* runtime, rc_runtime_event_handler_t event_handler, rc_runtime_validate_address_t validate_handler);
void rc_runtime_invalidate_address(rc_runtime_t* runtime, unsigned address);
void rc_runtime_invalidate_address(rc_runtime_t* runtime, uint32_t address);
int rc_runtime_progress_size(const rc_runtime_t* runtime, lua_State* L);
int rc_runtime_serialize_progress(void* buffer, const rc_runtime_t* runtime, lua_State* L);
int rc_runtime_deserialize_progress(rc_runtime_t* runtime, const unsigned char* serialized, lua_State* L);
int rc_runtime_deserialize_progress(rc_runtime_t* runtime, const uint8_t* serialized, lua_State* L);
#ifdef __cplusplus
}

View File

@ -7,6 +7,9 @@ extern "C" {
#include "rc_error.h"
#include <stddef.h>
#include <stdint.h>
#ifndef RC_RUNTIME_H /* prevents pedantic redefiniton error */
typedef struct lua_State lua_State;
@ -28,7 +31,7 @@ typedef struct rc_value_t rc_value_t;
* num_bytes is greater than 1, the value is read in little-endian from
* memory.
*/
typedef unsigned (*rc_peek_t)(unsigned address, unsigned num_bytes, void* ud);
typedef uint32_t(*rc_peek_t)(uint32_t address, uint32_t num_bytes, void* ud);
/*****************************************************************************\
| Memory References |
@ -63,19 +66,19 @@ enum {
typedef struct rc_memref_value_t {
/* The current value of this memory reference. */
unsigned value;
uint32_t value;
/* The last differing value of this memory reference. */
unsigned prior;
uint32_t prior;
/* The size of the value. */
char size;
uint8_t size;
/* True if the value changed this frame. */
char changed;
uint8_t changed;
/* The value type of the value (for variables) */
char type;
uint8_t type;
/* True if the reference will be used in indirection.
* NOTE: This is actually a property of the rc_memref_t, but we put it here to save space */
char is_indirect;
uint8_t is_indirect;
}
rc_memref_value_t;
@ -84,7 +87,7 @@ struct rc_memref_t {
rc_memref_value_t value;
/* The memory address of this variable. */
unsigned address;
uint32_t address;
/* The next memory reference in the chain. */
rc_memref_t* next;
@ -112,7 +115,7 @@ typedef struct rc_operand_t {
rc_memref_t* memref;
/* An integer value. */
unsigned num;
uint32_t num;
/* A floating point value. */
double dbl;
@ -122,10 +125,10 @@ typedef struct rc_operand_t {
} value;
/* specifies which member of the value union is being used */
char type;
uint8_t type;
/* the actual RC_MEMSIZE of the operand - memref.size may differ */
char size;
uint8_t size;
}
rc_operand_t;
@ -183,27 +186,27 @@ struct rc_condition_t {
rc_operand_t operand2;
/* Required hits to fire this condition. */
unsigned required_hits;
uint32_t required_hits;
/* Number of hits so far. */
unsigned current_hits;
uint32_t current_hits;
/* The next condition in the chain. */
rc_condition_t* next;
/* The type of the condition. */
char type;
/* The type of the condition. (RC_CONDITION_*) */
uint8_t type;
/* The comparison operator to use. */
char oper; /* operator is a reserved word in C++. */
/* The comparison operator to use. (RC_OPERATOR_*) */
uint8_t oper; /* operator is a reserved word in C++. */
/* Set if the condition needs to processed as part of the "check if paused" pass. */
char pause;
/* Set if the condition needs to processed as part of the "check if paused" pass. (bool) */
uint8_t pause;
/* Whether or not the condition evaluated true on the last check */
char is_true;
/* Whether or not the condition evaluated true on the last check. (bool) */
uint8_t is_true;
/* Unique identifier of optimized comparator to use */
char optimized_comparator;
/* Unique identifier of optimized comparator to use. (RC_PROCESSING_COMPARE_*) */
uint8_t optimized_comparator;
};
/*****************************************************************************\
@ -220,13 +223,13 @@ struct rc_condset_t {
rc_condition_t* conditions;
/* True if any condition in the set is a pause condition. */
char has_pause;
uint8_t has_pause;
/* True if the set is currently paused. */
char is_paused;
uint8_t is_paused;
/* True if the set has indirect memory references. */
char has_indirect_memrefs;
uint8_t has_indirect_memrefs;
};
/*****************************************************************************\
@ -255,22 +258,22 @@ struct rc_trigger_t {
rc_memref_t* memrefs;
/* The current state of the MEASURED condition. */
unsigned measured_value;
uint32_t measured_value;
/* The target state of the MEASURED condition */
unsigned measured_target;
uint32_t measured_target;
/* The current state of the trigger */
char state;
uint8_t state;
/* True if at least one condition has a non-zero hit count */
char has_hits;
uint8_t has_hits;
/* True if at least one condition has a non-zero required hit count */
char has_required_hits;
uint8_t has_required_hits;
/* True if the measured value should be displayed as a percentage */
char measured_as_percent;
uint8_t measured_as_percent;
};
int rc_trigger_size(const char* memaddr);
@ -302,7 +305,7 @@ struct rc_value_t {
int rc_value_size(const char* memaddr);
rc_value_t* rc_parse_value(void* buffer, const char* memaddr, lua_State* L, int funcs_ndx);
int rc_evaluate_value(rc_value_t* value, rc_peek_t peek, void* ud, lua_State* L);
int32_t rc_evaluate_value(rc_value_t* value, rc_peek_t peek, void* ud, lua_State* L);
/*****************************************************************************\
| Leaderboards |
@ -327,12 +330,12 @@ struct rc_lboard_t {
rc_value_t* progress;
rc_memref_t* memrefs;
char state;
uint8_t state;
};
int rc_lboard_size(const char* memaddr);
rc_lboard_t* rc_parse_lboard(void* buffer, const char* memaddr, lua_State* L, int funcs_ndx);
int rc_evaluate_lboard(rc_lboard_t* lboard, int* value, rc_peek_t peek, void* peek_ud, lua_State* L);
int rc_evaluate_lboard(rc_lboard_t* lboard, int32_t* value, rc_peek_t peek, void* peek_ud, lua_State* L);
void rc_reset_lboard(rc_lboard_t* lboard);
/*****************************************************************************\
@ -357,7 +360,7 @@ enum {
};
int rc_parse_format(const char* format_str);
int rc_format_value(char* buffer, int size, int value, int format);
int rc_format_value(char* buffer, int size, int32_t value, int format);
/*****************************************************************************\
| Rich Presence |
@ -366,8 +369,8 @@ int rc_format_value(char* buffer, int size, int value, int format);
typedef struct rc_richpresence_lookup_item_t rc_richpresence_lookup_item_t;
struct rc_richpresence_lookup_item_t {
unsigned first;
unsigned last;
uint32_t first;
uint32_t last;
rc_richpresence_lookup_item_t* left;
rc_richpresence_lookup_item_t* right;
const char* label;
@ -380,7 +383,7 @@ struct rc_richpresence_lookup_t {
rc_richpresence_lookup_t* next;
const char* name;
const char* default_label;
unsigned short format;
uint8_t format;
};
typedef struct rc_richpresence_display_part_t rc_richpresence_display_part_t;
@ -390,7 +393,7 @@ struct rc_richpresence_display_part_t {
const char* text;
rc_richpresence_lookup_t* lookup;
rc_memref_value_t *value;
unsigned short display_type;
uint8_t display_type;
};
typedef struct rc_richpresence_display_t rc_richpresence_display_t;
@ -411,9 +414,9 @@ struct rc_richpresence_t {
int rc_richpresence_size(const char* script);
int rc_richpresence_size_lines(const char* script, int* lines_read);
rc_richpresence_t* rc_parse_richpresence(void* buffer, const char* script, lua_State* L, int funcs_ndx);
int rc_evaluate_richpresence(rc_richpresence_t* richpresence, char* buffer, unsigned buffersize, rc_peek_t peek, void* peek_ud, lua_State* L);
int rc_evaluate_richpresence(rc_richpresence_t* richpresence, char* buffer, size_t buffersize, rc_peek_t peek, void* peek_ud, lua_State* L);
void rc_update_richpresence(rc_richpresence_t* richpresence, rc_peek_t peek, void* peek_ud, lua_State* L);
int rc_get_richpresence_display_string(rc_richpresence_t* richpresence, char* buffer, unsigned buffersize, rc_peek_t peek, void* peek_ud, lua_State* L);
int rc_get_richpresence_display_string(rc_richpresence_t* richpresence, char* buffer, size_t buffersize, rc_peek_t peek, void* peek_ud, lua_State* L);
void rc_reset_richpresence(rc_richpresence_t* self);
#ifdef __cplusplus