Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
stenzek
GitHub Repository: stenzek/duckstation
Path: blob/master/dep/rcheevos/include/rc_api_info.h
4246 views
1
#ifndef RC_API_INFO_H
2
#define RC_API_INFO_H
3
4
#include "rc_api_request.h"
5
6
#include <stdint.h>
7
#include <time.h>
8
9
RC_BEGIN_C_DECLS
10
11
/* --- Fetch Achievement Info --- */
12
13
/**
14
* API parameters for a fetch achievement info request.
15
*/
16
typedef struct rc_api_fetch_achievement_info_request_t {
17
/* The username of the player */
18
const char* username;
19
/* The API token from the login request */
20
const char* api_token;
21
/* The unique identifier of the achievement */
22
uint32_t achievement_id;
23
/* The 1-based index of the first entry to retrieve */
24
uint32_t first_entry;
25
/* The number of entries to retrieve */
26
uint32_t count;
27
/* Non-zero to only return unlocks earned by the user's friends */
28
uint32_t friends_only;
29
}
30
rc_api_fetch_achievement_info_request_t;
31
32
/* An achievement awarded entry */
33
typedef struct rc_api_achievement_awarded_entry_t {
34
/* The user associated to the entry */
35
const char* username;
36
/* A URL to the user's avatar image */
37
const char* avatar_url;
38
/* When the achievement was awarded */
39
time_t awarded;
40
}
41
rc_api_achievement_awarded_entry_t;
42
43
/**
44
* Response data for a fetch achievement info request.
45
*/
46
typedef struct rc_api_fetch_achievement_info_response_t {
47
/* The unique identifier of the achievement */
48
uint32_t id;
49
/* The unique identifier of the game to which the leaderboard is associated */
50
uint32_t game_id;
51
/* The number of times the achievement has been awarded */
52
uint32_t num_awarded;
53
/* The number of players that have earned at least one achievement for the game */
54
uint32_t num_players;
55
56
/* An array of recently rewarded entries */
57
rc_api_achievement_awarded_entry_t* recently_awarded;
58
/* The number of items in the recently_awarded array */
59
uint32_t num_recently_awarded;
60
61
/* Common server-provided response information */
62
rc_api_response_t response;
63
}
64
rc_api_fetch_achievement_info_response_t;
65
66
RC_EXPORT int RC_CCONV rc_api_init_fetch_achievement_info_request(rc_api_request_t* request, const rc_api_fetch_achievement_info_request_t* api_params);
67
RC_EXPORT int RC_CCONV rc_api_init_fetch_achievement_info_request_hosted(rc_api_request_t* request, const rc_api_fetch_achievement_info_request_t* api_params, const rc_api_host_t* host);
68
/* [deprecated] use rc_api_process_fetch_achievement_info_server_response instead */
69
RC_EXPORT int RC_CCONV rc_api_process_fetch_achievement_info_response(rc_api_fetch_achievement_info_response_t* response, const char* server_response);
70
RC_EXPORT int RC_CCONV rc_api_process_fetch_achievement_info_server_response(rc_api_fetch_achievement_info_response_t* response, const rc_api_server_response_t* server_response);
71
RC_EXPORT void RC_CCONV rc_api_destroy_fetch_achievement_info_response(rc_api_fetch_achievement_info_response_t* response);
72
73
/* --- Fetch Leaderboard Info --- */
74
75
/**
76
* API parameters for a fetch leaderboard info request.
77
*/
78
typedef struct rc_api_fetch_leaderboard_info_request_t {
79
/* The unique identifier of the leaderboard */
80
uint32_t leaderboard_id;
81
/* The number of entries to retrieve */
82
uint32_t count;
83
/* The 1-based index of the first entry to retrieve */
84
uint32_t first_entry;
85
/* The username of the player around whom the entries should be returned */
86
const char* username;
87
}
88
rc_api_fetch_leaderboard_info_request_t;
89
90
/* A leaderboard info entry */
91
typedef struct rc_api_lboard_info_entry_t {
92
/* The user associated to the entry */
93
const char* username;
94
/* A URL to the user's avatar image */
95
const char* avatar_url;
96
/* The rank of the entry */
97
uint32_t rank;
98
/* The index of the entry */
99
uint32_t index;
100
/* The value of the entry */
101
int32_t score;
102
/* When the entry was submitted */
103
time_t submitted;
104
}
105
rc_api_lboard_info_entry_t;
106
107
/**
108
* Response data for a fetch leaderboard info request.
109
*/
110
typedef struct rc_api_fetch_leaderboard_info_response_t {
111
/* The unique identifier of the leaderboard */
112
uint32_t id;
113
/* The format to pass to rc_format_value to format the leaderboard value */
114
int format;
115
/* If non-zero, indicates that lower scores appear first */
116
uint32_t lower_is_better;
117
/* The title of the leaderboard */
118
const char* title;
119
/* The description of the leaderboard */
120
const char* description;
121
/* The definition of the leaderboard to be passed to rc_runtime_activate_lboard */
122
const char* definition;
123
/* The unique identifier of the game to which the leaderboard is associated */
124
uint32_t game_id;
125
/* The author of the leaderboard */
126
const char* author;
127
/* When the leaderboard was first uploaded to the server */
128
time_t created;
129
/* When the leaderboard was last modified on the server */
130
time_t updated;
131
132
/* An array of requested entries */
133
rc_api_lboard_info_entry_t* entries;
134
/* The number of items in the entries array */
135
uint32_t num_entries;
136
137
/* The total number of entries on the server */
138
uint32_t total_entries;
139
140
/* Common server-provided response information */
141
rc_api_response_t response;
142
}
143
rc_api_fetch_leaderboard_info_response_t;
144
145
RC_EXPORT int RC_CCONV rc_api_init_fetch_leaderboard_info_request(rc_api_request_t* request, const rc_api_fetch_leaderboard_info_request_t* api_params);
146
RC_EXPORT int RC_CCONV rc_api_init_fetch_leaderboard_info_request_hosted(rc_api_request_t* request, const rc_api_fetch_leaderboard_info_request_t* api_params, const rc_api_host_t* host);
147
/* [deprecated] use rc_api_process_fetch_leaderboard_info_server_response instead */
148
RC_EXPORT int RC_CCONV rc_api_process_fetch_leaderboard_info_response(rc_api_fetch_leaderboard_info_response_t* response, const char* server_response);
149
RC_EXPORT int RC_CCONV rc_api_process_fetch_leaderboard_info_server_response(rc_api_fetch_leaderboard_info_response_t* response, const rc_api_server_response_t* server_response);
150
RC_EXPORT void RC_CCONV rc_api_destroy_fetch_leaderboard_info_response(rc_api_fetch_leaderboard_info_response_t* response);
151
152
/* --- Fetch Games List --- */
153
154
/**
155
* API parameters for a fetch games list request.
156
*/
157
typedef struct rc_api_fetch_games_list_request_t {
158
/* The unique identifier of the console to query */
159
uint32_t console_id;
160
}
161
rc_api_fetch_games_list_request_t;
162
163
/* A game list entry */
164
typedef struct rc_api_game_list_entry_t {
165
/* The unique identifier of the game */
166
uint32_t id;
167
/* The name of the game */
168
const char* name;
169
}
170
rc_api_game_list_entry_t;
171
172
/**
173
* Response data for a fetch games list request.
174
*/
175
typedef struct rc_api_fetch_games_list_response_t {
176
/* An array of requested entries */
177
rc_api_game_list_entry_t* entries;
178
/* The number of items in the entries array */
179
uint32_t num_entries;
180
181
/* Common server-provided response information */
182
rc_api_response_t response;
183
}
184
rc_api_fetch_games_list_response_t;
185
186
RC_EXPORT int RC_CCONV rc_api_init_fetch_games_list_request(rc_api_request_t* request, const rc_api_fetch_games_list_request_t* api_params);
187
RC_EXPORT int RC_CCONV rc_api_init_fetch_games_list_request_hosted(rc_api_request_t* request, const rc_api_fetch_games_list_request_t* api_params, const rc_api_host_t* host);
188
/* [deprecated] use rc_api_process_fetch_games_list_server_response instead */
189
RC_EXPORT int RC_CCONV rc_api_process_fetch_games_list_response(rc_api_fetch_games_list_response_t* response, const char* server_response);
190
RC_EXPORT int RC_CCONV rc_api_process_fetch_games_list_server_response(rc_api_fetch_games_list_response_t* response, const rc_api_server_response_t* server_response);
191
RC_EXPORT void RC_CCONV rc_api_destroy_fetch_games_list_response(rc_api_fetch_games_list_response_t* response);
192
193
/* --- Fetch Game Titles --- */
194
195
/**
196
* API parameters for a fetch games list request.
197
*/
198
typedef struct rc_api_fetch_game_titles_request_t {
199
/* An array of game ids to fetch titles for */
200
const uint32_t* game_ids;
201
/* The number of items in the game_ids array */
202
uint32_t num_game_ids;
203
}
204
rc_api_fetch_game_titles_request_t;
205
206
/* A game title entry */
207
typedef struct rc_api_game_title_entry_t {
208
/* The unique identifier of the game */
209
uint32_t id;
210
/* The title of the game */
211
const char* title;
212
/* The image name for the game badge */
213
const char* image_name;
214
}
215
rc_api_game_title_entry_t;
216
217
/**
218
* Response data for a fetch games title request.
219
*/
220
typedef struct rc_api_fetch_game_titles_response_t {
221
/* An array of requested entries */
222
rc_api_game_title_entry_t* entries;
223
/* The number of items in the entries array */
224
uint32_t num_entries;
225
226
/* Common server-provided response information */
227
rc_api_response_t response;
228
}
229
rc_api_fetch_game_titles_response_t;
230
231
RC_EXPORT int RC_CCONV rc_api_init_fetch_game_titles_request(rc_api_request_t* request, const rc_api_fetch_game_titles_request_t* api_params);
232
RC_EXPORT int RC_CCONV rc_api_init_fetch_game_titles_request_hosted(rc_api_request_t* request, const rc_api_fetch_game_titles_request_t* api_params, const rc_api_host_t* host);
233
RC_EXPORT int RC_CCONV rc_api_process_fetch_game_titles_server_response(rc_api_fetch_game_titles_response_t* response, const rc_api_server_response_t* server_response);
234
RC_EXPORT void RC_CCONV rc_api_destroy_fetch_game_titles_response(rc_api_fetch_game_titles_response_t* response);
235
236
/* --- Fetch Game Hashes --- */
237
238
/**
239
* API parameters for a fetch games list request.
240
*/
241
typedef struct rc_api_fetch_hash_library_request_t {
242
/**
243
* The unique identifier of the console to query.
244
* Passing RC_CONSOLE_UNKNOWN will return hashes for all consoles.
245
*/
246
uint32_t console_id;
247
} rc_api_fetch_hash_library_request_t;
248
249
/* A hash library entry */
250
typedef struct rc_api_hash_library_entry_t {
251
/* The hash for the game */
252
const char* hash;
253
/* The unique identifier of the game */
254
uint32_t game_id;
255
} rc_api_hash_library_entry_t;
256
257
/**
258
* Response data for a fetch hash library request.
259
*/
260
typedef struct rc_api_fetch_hash_library_response_t {
261
/* An array of entries, one per game */
262
rc_api_hash_library_entry_t* entries;
263
/* The number of items in the entries array */
264
uint32_t num_entries;
265
266
/* Common server-provided response information */
267
rc_api_response_t response;
268
}
269
rc_api_fetch_hash_library_response_t;
270
271
RC_EXPORT int RC_CCONV rc_api_init_fetch_hash_library_request(rc_api_request_t* request, const rc_api_fetch_hash_library_request_t* api_params);
272
RC_EXPORT int RC_CCONV rc_api_init_fetch_hash_library_request_hosted(rc_api_request_t* request, const rc_api_fetch_hash_library_request_t* api_params, const rc_api_host_t* host);
273
RC_EXPORT int RC_CCONV rc_api_process_fetch_hash_library_server_response(rc_api_fetch_hash_library_response_t* response, const rc_api_server_response_t* server_response);
274
RC_EXPORT void RC_CCONV rc_api_destroy_fetch_hash_library_response(rc_api_fetch_hash_library_response_t* response);
275
276
RC_END_C_DECLS
277
278
#endif /* RC_API_INFO_H */
279
280