about summary refs log tree commit diff
path: root/src/engine/e_if_client.h
blob: 4f6393ce8b9923713b5cf8aa95d0f31213cba65b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
/* copyright (c) 2007 magnus auvinen, see licence.txt for more info */
#ifndef ENGINE_IF_CLIENT_H
#define ENGINE_IF_CLIENT_H

/*
	Section: Constants
*/

enum
{
	/* Constants: Client States
		CLIENTSTATE_OFFLINE - The client is offline.
		CLIENTSTATE_CONNECTING - The client is trying to connect to a server.
		CLIENTSTATE_LOADING - The client has connected to a server and is loading resources.
		CLIENTSTATE_ONLINE - The client is connected to a server and running the game.
		CLIENTSTATE_QUITING - The client is quiting.
	*/
	CLIENTSTATE_OFFLINE=0,
	CLIENTSTATE_CONNECTING,
	CLIENTSTATE_LOADING,
	CLIENTSTATE_ONLINE,
	CLIENTSTATE_QUITING,


	/* Constants: Image Formats
		IMG_AUTO - Lets the engine choose the format.
		IMG_RGB - 8-Bit uncompressed RGB
		IMG_RGBA - 8-Bit uncompressed RGBA
		IMG_ALPHA - 8-Bit uncompressed alpha
	*/
	IMG_AUTO=-1,
	IMG_RGB=0,
	IMG_RGBA=1,
	IMG_ALPHA=2,
	
	/* Constants: Server Browser Sorting
		BROWSESORT_NAME - Sort by name.
		BROWSESORT_PING - Sort by ping.
		BROWSESORT_MAP - Sort by map
		BROWSESORT_GAMETYPE - Sort by game type. DM, TDM etc.
		BROWSESORT_PROGRESSION - Sort by progression.
		BROWSESORT_NUMPLAYERS - Sort after how many players there are on the server.
	*/
	BROWSESORT_NAME = 0,
	BROWSESORT_PING,
	BROWSESORT_MAP,
	BROWSESORT_GAMETYPE,
	BROWSESORT_PROGRESSION,
	BROWSESORT_NUMPLAYERS
};

/*
	Section: Structures
*/

/*
	Structure: SERVER_INFO
*/
typedef struct
{
	int sorted_index;
	int server_index;
	
	int progression;
	int game_type;
	int max_players;
	int num_players;
	int flags;
	int latency; /* in ms */
	char name[64];
	char map[32];
	char version[32];
	char address[24];
	char player_names[16][48];
	int player_scores[16];
} SERVER_INFO;

/*
	Section: Functions
*/

/**********************************************************************************
	Group: Time
**********************************************************************************/
/*
	Function: client_tick
		Returns the tick of the current snapshot.
*/
int client_tick();


/*
	Function: client_intratick
		Returns the current intratick.
	
	Remarks:
		The intratick is how far gone the time is from the previous snapshot to the current.
		0.0 means that it on the previous snapshot. 0.5 means that it's halfway to the current,
		and 1.0 means that it is on the current snapshot. It can go beyond 1.0 which means that
		the client has started to extrapolate due to lack of data from the server.

	See Also:
		<client_tick>
*/
float client_intratick();

/*
	Function: client_predtick
		Returns the current predicted tick.
*/
int client_predtick();

/*
	Function: client_predintratick
		Returns the current preticted intra tick.
	
	Remarks:
		This is the same as <client_intratick> but for the current predicted tick and
		previous predicted tick.

	See Also:
		<client_intratick>
*/
float client_predintratick();

/*
	Function: client_ticktime
		TODO
	
	Arguments:
		arg1 - desc
	
	Returns:

	See Also:
		<other_func>
*/
float client_ticktime();

/*
	Function: client_tickspeed
		Returns how many ticks per second the client is doing.
	
	Remarks:
		This will be the same as the server tick speed.
*/
int client_tickspeed();

/*
	Function: client_frametime
		Returns how long time the last frame took to process.
*/
float client_frametime();

/*
	Function: client_localtime
		Returns the clients local time.
	
	Remarks:
		The local time is set to 0 when the client starts and when
		it connects to a server. Can be used for client side effects.
*/
float client_localtime();

/**********************************************************************************
	Group: Server Browser
**********************************************************************************/

/*
	Function: client_serverbrowse_refresh
		Issues a refresh of the server browser.
	
	Arguments:
		lan - Tells the function if it should do a LAN listing or an Internet listing.
	
	Remarks:
		This will cause a broadcast on the local network if the lan argument is set.
		Otherwise it call ask all the master servers for their servers lists.
*/
void client_serverbrowse_refresh(int lan);

/*
	Function: client_serverbrowse_sorted_get
		Returns server info from the sorted list.
	
	Arguments:
		index - Zero based index into the sorted list.
	
	See Also:
		<client_serverbrowse_sorted_num>
*/
SERVER_INFO *client_serverbrowse_sorted_get(int index);

/*
	Function: client_serverbrowse_sorted_num
		Returns how many servers there are in the sorted list.
	
	See Also:
		<client_serverbrowse_sorted_get>
*/
int client_serverbrowse_sorted_num();

/*
	Function: client_serverbrowse_get
		TODO
	
	Arguments:
		arg1 - desc
	
	Returns:

	See Also:
		<other_func>
*/
SERVER_INFO *client_serverbrowse_get(int index);

/*
	Function: client_serverbrowse_num
		TODO
	
	Arguments:
		arg1 - desc
	
	Returns:

	See Also:
		<other_func>
*/
int client_serverbrowse_num();

/*
	Function: client_serverbrowse_num_requests
		TODO
	
	Arguments:
		arg1 - desc
	
	Returns:

	See Also:
		<other_func>
*/
int client_serverbrowse_num_requests();

/*
	Function: client_serverbrowse_update
		TODO
	
	Arguments:
		arg1 - desc
	
	Returns:

	See Also:
		<other_func>
*/
void client_serverbrowse_update();

/*
	Function: client_serverbrowse_lan
		TODO
	
	Arguments:
		arg1 - desc
	
	Returns:

	See Also:
		<other_func>
*/
int client_serverbrowse_lan();

/**********************************************************************************
	Group: Actions
**********************************************************************************/


/*
	Function: client_connect
		Connects to a server at the specified address.
	
	Arguments:
		address - Address of the server to connect to.
	
	See Also:
		<client_disconnect>
*/
void client_connect(const char *address);

/*
	Function: client_disconnect
		Disconnects from the current server.
	
	Remarks:
		Does nothing if not connected to a server.

	See Also:
		<client_connect, client_quit>
*/
void client_disconnect();

/*
	Function: client_quit
		Tells to client to shutdown.

	See Also:
		<client_disconnect>
*/
void client_quit();

void client_entergame();

/*
	Function: client_rcon
		Sends a command to the server to execute on it's console.
	
	Arguments:
		cmd - The command to send.
	
	Remarks:
		The client must have the correct rcon password to connect.
*/
void client_rcon(const char *cmd);

/**********************************************************************************
	Group: Other
**********************************************************************************/
/*
	Function: client_get_input
		TODO
	
	Arguments:
		arg1 - desc
	
	Returns:

	See Also:
		<other_func>
*/
int *client_get_input(int tick);

/*
	Function: client_direct_input
		TODO
	
	Arguments:
		arg1 - desc
	
	Returns:

	See Also:
		<other_func>
*/
void client_direct_input(int *input, int size);

/*
	Function: client_error_string
		TODO
	
	Arguments:
		arg1 - desc
	
	Returns:

	See Also:
		<other_func>
*/
const char *client_error_string();

/*
	Function: client_connection_problems
		Returns 1 if the client is connection problems.
	
	Remarks:
		Connections problems usually means that the client havn't recvived any data
		from the server in a while.
*/
int client_connection_problems();

/*
	Function: client_state
		Returns the state of the client.
		
	See Also:
		<Client States>
*/
int client_state();

#endif