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
|
/* copyright (c) 2007 magnus auvinen, see licence.txt for more info */
#ifndef ENGINE_IF_OTHER_H
#define ENGINE_IF_OTHER_H
/*
Title: Engine Interface
*/
#include <base/system.h>
#include "e_keys.h"
enum
{
SERVER_TICK_SPEED=50,
MAX_CLIENTS=16,
SNAP_CURRENT=0,
SNAP_PREV=1,
MASK_NONE=0,
MASK_SET,
MASK_ZERO,
SNDFLAG_LOOP=1,
SNDFLAG_POS=2,
SNDFLAG_ALL=3,
MAX_NAME_LENGTH=32
};
enum
{
SRVFLAG_PASSWORD = 0x1,
SRVFLAG_TUNED = 0x2,
SRVFLAG_MOD = 0x4
};
/*
Structure: SNAP_ITEM
*/
typedef struct
{
int type;
int id;
int datasize;
} SNAP_ITEM;
/*
Structure: CLIENT_INFO
*/
typedef struct
{
const char *name;
int latency;
} CLIENT_INFO;
typedef struct PERFORMACE_INFO_t
{
const char *name;
struct PERFORMACE_INFO_t *parent;
struct PERFORMACE_INFO_t *first_child;
struct PERFORMACE_INFO_t *next_child;
int tick;
int64 start;
int64 total;
int64 biggest;
int64 last_delta;
} PERFORMACE_INFO;
void perf_init();
void perf_next();
void perf_start(PERFORMACE_INFO *info);
void perf_end();
void perf_dump();
int gfx_init();
void gfx_shutdown();
void gfx_swap();
int gfx_window_active();
int gfx_window_open();
void gfx_set_vsync(int val);
void gfx_mask_op(int mask, int write);
void gfx_clear_mask(int fill);
int snd_init();
int snd_shutdown();
int snd_update();
int map_load(const char *mapname);
void map_unload();
void map_set(void *m);
/*
#include "e_if_client.h"
#include "e_if_server.h"
#include "e_if_snd.h"
#include "e_if_gfx.h"
#include "e_if_inp.h"
#include "e_if_msg.h"
#include "e_if_mod.h"*/
/*
Section: Map
*/
/*
Function: map_is_loaded
Checks if a map is loaded.
Returns:
Returns 1 if the button is pressed, otherwise 0.
*/
int map_is_loaded();
/*
Function: map_num_items
Checks the number of items in the loaded map.
Returns:
Returns the number of items. 0 if no map is loaded.
*/
int map_num_items();
/*
Function: map_find_item
Searches the map for an item.
Arguments:
type - Item type.
id - Item ID.
Returns:
Returns a pointer to the item if it exists, otherwise it returns NULL.
*/
void *map_find_item(int type, int id);
/*
Function: map_get_item
Gets an item from the loaded map from index.
Arguments:
index - Item index.
type - Pointer that recives the item type (can be NULL).
id - Pointer that recives the item id (can be NULL).
Returns:
Returns a pointer to the item if it exists, otherwise it returns NULL.
*/
void *map_get_item(int index, int *type, int *id);
/*
Function: map_get_type
Gets the index range of an item type.
Arguments:
type - Item type to search for.
start - Pointer that recives the starting index.
num - Pointer that recives the number of items.
Returns:
If the item type is not in the map, start and num will be set to 0.
*/
void map_get_type(int type, int *start, int *num);
/*
Function: map_get_data
Fetches a pointer to a raw data chunk in the map.
Arguments:
index - Index to the data to fetch.
Returns:
A pointer to the raw data, otherwise 0.
*/
void *map_get_data(int index);
/*
Function: map_get_data_swapped
TODO
Arguments:
arg1 - desc
Returns:
See Also:
<other_func>
*/
void *map_get_data_swapped(int index);
/*
Section: Network (Server)
*/
/*
Function: snap_new_item
Creates a new item that should be sent.
Arguments:
type - Type of the item.
id - ID of the item.
size - Size of the item.
Returns:
A pointer to the item data, otherwise 0.
Remarks:
The item data should only consist pf 4 byte integers as
they are subject to byte swapping. This means that the size
argument should be dividable by 4.
*/
void *snap_new_item(int type, int id, int size);
/*
Section:Section: Network (Client)
*/
/*
Function: snap_num_items
Check the number of items in a snapshot.
Arguments:
snapid - Snapshot ID to the data to fetch.
* SNAP_PREV for previous snapshot.
* SNAP_CUR for current snapshot.
Returns:
The number of items in the snapshot.
*/
int snap_num_items(int snapid);
/*
Function: snap_get_item
Gets an item from a snapshot.
Arguments:
snapid - Snapshot ID to the data to fetch.
* SNAP_PREV for previous snapshot.
* SNAP_CUR for current snapshot.
index - Index of the item.
item - Pointer that recives the item info.
Returns:
Returns a pointer to the item if it exists, otherwise NULL.
*/
void *snap_get_item(int snapid, int index, SNAP_ITEM *item);
/*
Function: snap_find_item
Searches a snapshot for an item.
Arguments:
snapid - Snapshot ID to the data to fetch.
* SNAP_PREV for previous snapshot.
* SNAP_CUR for current snapshot.
type - Type of the item.
id - ID of the item.
Returns:
Returns a pointer to the item if it exists, otherwise NULL.
*/
void *snap_find_item(int snapid, int type, int id);
/*
Function: snap_invalidate_item
Marks an item as invalid byt setting type and id to 0xffffffff.
Arguments:
snapid - Snapshot ID to the data to fetch.
* SNAP_PREV for previous snapshot.
* SNAP_CUR for current snapshot.
index - Index of the item.
*/
void snap_invalidate_item(int snapid, int index);
/*
Function: snap_input
Sets the input data to send to the server.
Arguments:
data - Pointer to the data.
size - Size of the data.
Remarks:
The data should only consist of 4 bytes integer as they are
subject to byte swapping.
*/
void snap_input(void *data, int size);
/*
Function: snap_set_staticsize
Tells the engine how big a specific item always will be. This
helps the engine to compress snapshots better.
Arguments:
type - Item type
size - Size of the data.
Remarks:
Size must be in a multiple of 4.
*/
void snap_set_staticsize(int type, int size);
/* message packing */
enum
{
MSGFLAG_VITAL=1,
MSGFLAG_FLUSH=2,
MSGFLAG_NORECORD=4,
MSGFLAG_RECORD=8,
MSGFLAG_NOSEND=16
};
/* message sending */
/*
Function: server_send_msg
TODO
Arguments:
arg1 - desc
Returns:
See Also:
<other_func>
*/
int server_send_msg(int client_id); /* client_id == -1 == broadcast */
/*
Function: client_send_msg
TODO
Arguments:
arg1 - desc
Returns:
See Also:
<other_func>
*/
int client_send_msg();
/* undocumented graphics stuff */
/* server snap id */
/*
Function: snap_new_id
TODO
Arguments:
arg1 - desc
Returns:
See Also:
<other_func>
*/
int snap_new_id();
/*
Function: snap_free_id
TODO
Arguments:
arg1 - desc
Returns:
See Also:
<other_func>
*/
void snap_free_id(int id);
/* other */
/*
Function: map_unload_data
TODO
Arguments:
arg1 - desc
Returns:
See Also:
<other_func>
*/
void map_unload_data(int index);
#endif
|