Skip to content

Commit

Permalink
use explicitly sized fields for addresses/values/ids (#282)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamiras authored Oct 16, 2023
1 parent 0a1d19d commit 94a2ba5
Show file tree
Hide file tree
Showing 30 changed files with 533 additions and 523 deletions.
40 changes: 21 additions & 19 deletions include/rc_api_editor.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

#include "rc_api_request.h"

#include <stdint.h>

#ifdef __cplusplus
extern "C" {
#endif
Expand All @@ -21,7 +23,7 @@ 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 */
Expand All @@ -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;
Expand All @@ -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;
}
Expand Down Expand Up @@ -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 */
Expand All @@ -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;

Expand All @@ -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;
Expand All @@ -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 */
Expand All @@ -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;

Expand All @@ -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;
Expand All @@ -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;

Expand All @@ -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;
Expand All @@ -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 */
Expand All @@ -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;
Expand Down
45 changes: 23 additions & 22 deletions include/rc_api_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include "rc_api_request.h"

#include <stdint.h>
#include <time.h>

#ifdef __cplusplus
Expand All @@ -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;

Expand All @@ -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;
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -104,19 +105,19 @@ 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 */
const char* description;
/* 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 */
Expand All @@ -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;
Expand All @@ -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;
}
Expand All @@ -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;
Expand Down
Loading

0 comments on commit 94a2ba5

Please sign in to comment.