63#define GJ_TROPHY_RESPONSE_TABLE(X_MACRO) \
64 X_MACRO(id, string, char*) \
65 X_MACRO(title, string, char*) \
66 X_MACRO(difficulty, trophy_difficulty, enum gj_trophy_difficulty) \
67 X_MACRO(description, string, char*) \
68 X_MACRO(image_url, string, char*) \
69 X_MACRO(achieved, string, char*)
72#define GJ_TIME_RESPONSE_TABLE(X_MACRO) \
73 X_MACRO(timestamp, string, char*) \
74 X_MACRO(timezone, string, char*) \
75 X_MACRO(day, string, char*) \
76 X_MACRO(hour, string, char*) \
77 X_MACRO(minute, string, char*) \
78 X_MACRO(second, string, char*)
81#define GJ_SCORE_RESPONSE_TABLE(X_MACRO) \
82 X_MACRO(score, string, char*) \
83 X_MACRO(sort, string, char*) \
84 X_MACRO(extra_data, string, char*) \
85 X_MACRO(user, string, char*) \
86 X_MACRO(user_id, string, char*) \
87 X_MACRO(guest, string, char*) \
88 X_MACRO(stored, string, char*) \
89 X_MACRO(stored_timestamp, string, char*)
92#define GJ_SCORE_TABLE_RESPONSE_TABLE(X_MACRO) \
93 X_MACRO(id, string, char*) \
94 X_MACRO(name, string, char*) \
95 X_MACRO(description, string, char*) \
96 X_MACRO(primary, bool_num, bool)
99#define GJ_SCORE_GETRANK_RESPONSE_TABLE(X_MACRO) \
100 X_MACRO(message, string, char*) \
101 X_MACRO(rank, string, char*)
104#define GJ_USER_RESPONSE_TABLE(X_MACRO) \
105 X_MACRO(id, string, char*) \
106 X_MACRO(type, string, char*) \
107 X_MACRO(username, string, char*) \
108 X_MACRO(avatar_url, string, char*) \
109 X_MACRO(signed_up, string, char*) \
110 X_MACRO(signed_up_timestamp, string, char*) \
111 X_MACRO(last_logged_in, string, char*) \
112 X_MACRO(last_logged_in_timestamp, string, char*) \
113 X_MACRO(status, string, char*) \
114 X_MACRO(developer_name, string, char*) \
115 X_MACRO(developer_website, string, char*) \
116 X_MACRO(developer_description, string, char*)
119#define X_AS_STRUCT(field, decoder, type) \
171bool gj_init(
const char *endpoint,
const char *game_id,
const char *private_key,
172 const char *username,
const char *user_token,
char *reply_buf,
173 uint16_t buf_len, uint16_t tout_frames);
266 const char *guest,
const char *better_than,
267 const char *worse_than,
bool only_user);
330bool gj_scores_add(
const char *score,
const char *sort,
const char *table_id,
331 const char *guest,
const char *extra_data);
399 const char *value,
bool user_store);
534char *
gj_request(
const char **path, uint8_t num_paths,
const char **key,
535 const char **value, uint8_t num_kv_pairs, uint32_t *out_len);
char * gj_friend_get_next(char *pos, char **user_id)
Decode the friend raw data for the next entry.
bool gj_time(struct gj_time *time)
Get the date and time from server.
char * gj_data_store_key_next(char *pos, char **key)
Decode the key data from a gj_data_store_keys_fetch() call.
char * gj_friends_fetch(void)
Get friends list.
bool gj_scores_add(const char *score, const char *sort, const char *table_id, const char *guest, const char *extra_data)
Add a score to a scoreboard.
const char * gj_trophy_difficulty_str(enum gj_trophy_difficulty difficulty)
Get the string corresponding to a trophy difficulty.
bool gj_sessions_ping(bool active)
Ping a session, and allow setting it as active or idle.
bool gj_sessions_check(const char *username, const char *user_token)
Checks if a user session is active in the game.
char * data_store_fetch(const char *key, bool user_store)
Retrieve data from the data store.
enum gj_error gj_get_error(void)
Return the last error code.
bool gj_users_auth(void)
Check user credentials.
#define GJ_SCORE_RESPONSE_TABLE(X_MACRO)
Reply field to a scores fetch request.
bool gj_data_store_remove(const char *key, bool user_store)
Remove data from the data store.
char * gj_users_fetch(const char *username, const char *user_id)
Get user data.
#define GJ_USER_RESPONSE_TABLE(X_MACRO)
Reply fields to a users fetch request.
char * gj_data_store_keys_fetch(const char *pattern, bool user_store)
Fetch data store keys.
gj_data_store_update_operation
Operations supported by gj_data_store_update() function.
#define GJ_SCORE_TABLE_RESPONSE_TABLE(X_MACRO)
Reply fields to a scores tables request.
#define GJ_TIME_RESPONSE_TABLE(X_MACRO)
Reply fields to a time fetch request.
#define GJ_TROPHY_RESPONSE_TABLE(X_MACRO)
Reply fields to a trophy fetch request.
char * gj_trophy_get_next(char *pos, struct gj_trophy *trophy)
Decode the trophy raw data for the next entry.
char * gj_data_store_update(const char *key, enum gj_data_store_update_operation operation, const char *value, bool user_store)
Update data in the data store.
gj_error
Module error codes.
#define X_AS_STRUCT(field, decoder, type)
Expands a response table as a structure with its fields.
char * gj_request(const char **path, uint8_t num_paths, const char **key, const char **value, uint8_t num_kv_pairs, uint32_t *out_len)
Generic GameJolt Game API request.
char * gj_scores_tables_fetch(void)
Fetch score tables.
bool gj_trophy_remove_achieved(const char *trophy_id)
Mark a trophy as not achieved.
char * gj_trophies_fetch(bool achieved, const char *trophy_id)
Fetch player trophies.
char * gj_scores_get_rank(const char *sort, const char *table_id)
Get ranking corresponding to a sort parameter.
char * gj_score_table_get_next(char *pos, struct gj_score_table *score_table)
Decode the score tables raw data for the next entry.
char * gj_scores_fetch(const char *limit, const char *table_id, const char *guest, const char *better_than, const char *worse_than, bool only_user)
Fetch scores data.
bool gj_sessions_open(void)
Open a game session for the player.
gj_trophy_difficulty
Difficulty to achieve the trophy.
bool gj_trophy_add_achieved(const char *trophy_id)
Mark a trophy as achieved.
char * gj_score_get_next(char *pos, struct gj_score *score)
Decode the score raw data for the next entry.
bool gj_sessions_close(void)
Close a previously opened session.
char * gj_user_get_next(char *pos, struct gj_user *user)
Decode the user raw data for the next entry.
bool gj_data_store_set(const char *key, const char *data, bool user_store)
Sets a key/value pair in the data store.
bool gj_init(const char *endpoint, const char *game_id, const char *private_key, const char *username, const char *user_token, char *reply_buf, uint16_t buf_len, uint16_t tout_frames)
Initialize the GameJolt API.
@ GJ_OP_APPEND
Appends value to the data store.
@ GJ_OP_ADD
Adds the value to item.
@ GJ_OP_DIVIDE
Divides the item by value.
@ GJ_OP_MAX
Maximum enum value, do not use for operation.
@ GJ_OP_SUBTRACT
Subtracs the value from item.
@ GJ_OP_MULTIPLY
Multiplies value by item.
@ GJ_OP_PREPEND
Prepends value to the data store.
@ GJ_ERR_RESPONSE
Response has no success:"true" head.
@ GJ_ERR_REQUEST
Request failed (network or server down?)
@ GJ_ERR_PARAM
Missing or invalid parameter.
@ GJ_ERR_RECEPTION
Failed to receive response data.
@ GJ_ERR_PARSE
Error while parsing response data.
@ GJ_TROPHY_TYPE_SILVER
Silver trophy (medium)
@ GJ_TROPHY_TYPE_PLATINUM
Platinum trophy (hardest)
@ GJ_TROPHY_TYPE_GOLD
Gold trophy (hard)
@ GJ_TROPHY_TYPE_UNKNOWN
Unknown, just for errors.
@ GJ_TROPHY_TYPE_BRONZE
Bronze trophy (easiest)
Holds data of a single score table.
Holds data of a single score.
Holds the date/time from server.
Holds the data of a single trophy.
bool secret
If true, trophy is secret.