demo-reader 0.0.2 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/ext/dm68/common.h ADDED
@@ -0,0 +1,568 @@
1
+ // Copyright (C) 1999-2000 Id Software, Inc.
2
+ //
3
+ // q_shared.c -- stateless support routines that are included in each code dll
4
+
5
+ #include <stdio.h>
6
+ #include <stdlib.h>
7
+ #include <math.h>
8
+ #include <ctype.h>
9
+ #include <stdarg.h>
10
+ #include <string.h>
11
+
12
+ #define ID_INLINE
13
+
14
+ #ifdef WIN32
15
+ # pragma warning(disable:4018)
16
+ #endif
17
+
18
+ #ifdef WIN32
19
+ # undef ID_INLINE
20
+ # define ID_INLINE __inline
21
+ #endif
22
+
23
+ #define LittleLong
24
+
25
+ typedef enum {qfalse, qtrue} qboolean;
26
+ typedef unsigned char byte;
27
+ typedef float vec3_t[3];
28
+
29
+ #ifndef NULL
30
+ #define NULL ((void *)0)
31
+ #endif
32
+
33
+ #define MAXPRINTMSG 16284
34
+
35
+ // the game guarantees that no string from the network will ever
36
+ // exceed MAX_STRING_CHARS
37
+ #define MAX_STRING_CHARS 1024 // max length of a string passed to Cmd_TokenizeString
38
+ #define MAX_STRING_TOKENS 1024 // max tokens resulting from Cmd_TokenizeString
39
+ #define MAX_TOKEN_CHARS 1024 // max length of an individual token
40
+
41
+ #define MAX_INFO_STRING 1024
42
+ #define MAX_INFO_KEY 1024
43
+ #define MAX_INFO_VALUE 1024
44
+
45
+ #define BIG_INFO_STRING 8192 // used for system info key only
46
+ #define BIG_INFO_KEY 8192
47
+ #define BIG_INFO_VALUE 8192
48
+
49
+
50
+ #define MAX_QPATH 64 // max length of a quake game pathname
51
+ #ifdef PATH_MAX
52
+ #define MAX_OSPATH PATH_MAX
53
+ #else
54
+ #define MAX_OSPATH 256 // max length of a filesystem pathname
55
+ #endif
56
+
57
+ #define MAX_MAP_AREA_BYTES 32 // bit vector of area visibility
58
+
59
+
60
+ #ifdef ERR_FATAL
61
+ #undef ERR_FATAL // this is be defined in malloc.h
62
+ #endif
63
+
64
+ // parameters to the main Error routine
65
+ typedef enum {
66
+ ERR_FATAL, // exit the entire game with a popup window
67
+ ERR_DROP, // print to console and disconnect from game
68
+ ERR_SERVERDISCONNECT, // don't kill server
69
+ ERR_DISCONNECT, // client disconnected from the server
70
+ ERR_NEED_CD // pop up the need-cd dialog
71
+ } errorParm_t;
72
+
73
+ void Com_Error( errorParm_t level, const char *error, ... );
74
+ void Com_Printf( const char *text, ... );
75
+
76
+ void Com_sprintf (char *dest, int size, const char *fmt, ...);
77
+ char *va(char *format, ...);
78
+
79
+ // buffer size safe library replacements
80
+ void Q_strncpyz( char *dest, const char *src, int destsize );
81
+ void Q_strcat( char *dest, int size, const char *src );
82
+
83
+ int Q_stricmpn (const char *s1, const char *s2, int n);
84
+ int Q_strncmp (const char *s1, const char *s2, int n);
85
+ int Q_stricmp (const char *s1, const char *s2);
86
+ void Q_strcat( char *dest, int size, const char *src );
87
+
88
+ //
89
+ // key / value info strings
90
+ //
91
+ char *Info_ValueForKey( const char *s, const char *key );
92
+ void Info_RemoveKey( char *s, const char *key );
93
+ void Info_RemoveKey_big( char *s, const char *key );
94
+ void Info_SetValueForKey( char *s, const char *key, const char *value );
95
+ void Info_SetValueForKey_Big( char *s, const char *key, const char *value );
96
+ qboolean Info_Validate( const char *s );
97
+ void Info_NextPair( const char **s, char *key, char *value );
98
+
99
+
100
+ /*
101
+ ========================================================================
102
+
103
+ ELEMENTS COMMUNICATED ACROSS THE NET
104
+
105
+ ========================================================================
106
+ */
107
+
108
+ #define ANGLE2SHORT(x) ((int)((x)*65536/360) & 65535)
109
+ #define SHORT2ANGLE(x) ((x)*(360.0/65536))
110
+
111
+ #define SNAPFLAG_RATE_DELAYED 1
112
+ #define SNAPFLAG_NOT_ACTIVE 2 // snapshot used during connection and for zombies
113
+ #define SNAPFLAG_SERVERCOUNT 4 // toggled every map_restart so transitions can be detected
114
+
115
+ //
116
+ // per-level limits
117
+ //
118
+ #define MAX_CLIENTS 64 // absolute limit
119
+ #define MAX_LOCATIONS 64
120
+
121
+ #define GENTITYNUM_BITS 10 // don't need to send any more
122
+ #define MAX_GENTITIES (1<<GENTITYNUM_BITS)
123
+
124
+ // entitynums are communicated with GENTITY_BITS, so any reserved
125
+ // values that are going to be communcated over the net need to
126
+ // also be in this range
127
+ #define ENTITYNUM_NONE (MAX_GENTITIES-1)
128
+ #define ENTITYNUM_WORLD (MAX_GENTITIES-2)
129
+ #define ENTITYNUM_MAX_NORMAL (MAX_GENTITIES-2)
130
+
131
+
132
+ #define MAX_MODELS 256 // these are sent over the net as 8 bits
133
+ #define MAX_SOUNDS 256 // so they cannot be blindly increased
134
+
135
+
136
+ #define MAX_CONFIGSTRINGS 1024
137
+
138
+ // these are the only configstrings that the system reserves, all the
139
+ // other ones are strictly for servergame to clientgame communication
140
+ #define CS_SERVERINFO 0 // an info string with all the serverinfo cvars
141
+ #define CS_SYSTEMINFO 1 // an info string for server system to client system configuration (timescale, etc)
142
+
143
+ #define RESERVED_CONFIGSTRINGS 2 // game can't modify below this, only the system can
144
+
145
+ #define MAX_GAMESTATE_CHARS 16000
146
+ typedef struct {
147
+ int stringOffsets[MAX_CONFIGSTRINGS];
148
+ char stringData[MAX_GAMESTATE_CHARS];
149
+ int dataCount;
150
+ } gameState_t;
151
+
152
+ //=========================================================
153
+
154
+ // bit field limits
155
+ #define MAX_STATS 16
156
+ #define MAX_PERSISTANT 16
157
+ #define MAX_POWERUPS 16
158
+ #define MAX_WEAPONS 16
159
+
160
+ #define MAX_PS_EVENTS 2
161
+
162
+ #define PS_PMOVEFRAMECOUNTBITS 6
163
+
164
+ // playerState_t is the information needed by both the client and server
165
+ // to predict player motion and actions
166
+ // nothing outside of pmove should modify these, or some degree of prediction error
167
+ // will occur
168
+
169
+ // you can't add anything to this without modifying the code in msg.c
170
+
171
+ // playerState_t is a full superset of entityState_t as it is used by players,
172
+ // so if a playerState_t is transmitted, the entityState_t can be fully derived
173
+ // from it.
174
+ typedef struct playerState_s {
175
+ int commandTime; // cmd->serverTime of last executed command
176
+ int pm_type;
177
+ int bobCycle; // for view bobbing and footstep generation
178
+ int pm_flags; // ducked, jump_held, etc
179
+ int pm_time;
180
+
181
+ vec3_t origin;
182
+ vec3_t velocity;
183
+ int weaponTime;
184
+ int gravity;
185
+ int speed;
186
+ int delta_angles[3]; // add to command angles to get view direction
187
+ // changed by spawns, rotating objects, and teleporters
188
+
189
+ int groundEntityNum;// ENTITYNUM_NONE = in air
190
+
191
+ int legsTimer; // don't change low priority animations until this runs out
192
+ int legsAnim; // mask off ANIM_TOGGLEBIT
193
+
194
+ int torsoTimer; // don't change low priority animations until this runs out
195
+ int torsoAnim; // mask off ANIM_TOGGLEBIT
196
+
197
+ int movementDir; // a number 0 to 7 that represents the reletive angle
198
+ // of movement to the view angle (axial and diagonals)
199
+ // when at rest, the value will remain unchanged
200
+ // used to twist the legs during strafing
201
+
202
+ vec3_t grapplePoint; // location of grapple to pull towards if PMF_GRAPPLE_PULL
203
+
204
+ int eFlags; // copied to entityState_t->eFlags
205
+
206
+ int eventSequence; // pmove generated events
207
+ int events[MAX_PS_EVENTS];
208
+ int eventParms[MAX_PS_EVENTS];
209
+
210
+ int externalEvent; // events set on player from another source
211
+ int externalEventParm;
212
+ int externalEventTime;
213
+
214
+ int clientNum; // ranges from 0 to MAX_CLIENTS-1
215
+ int weapon; // copied to entityState_t->weapon
216
+ int weaponstate;
217
+
218
+ vec3_t viewangles; // for fixed views
219
+ int viewheight;
220
+
221
+ // damage feedback
222
+ int damageEvent; // when it changes, latch the other parms
223
+ int damageYaw;
224
+ int damagePitch;
225
+ int damageCount;
226
+
227
+ int stats[MAX_STATS];
228
+ int persistant[MAX_PERSISTANT]; // stats that aren't cleared on death
229
+ int powerups[MAX_POWERUPS]; // level.time that the powerup runs out
230
+ int ammo[MAX_WEAPONS];
231
+
232
+ int generic1;
233
+ int loopSound;
234
+ int jumppad_ent; // jumppad entity hit this frame
235
+
236
+ // not communicated over the net at all
237
+ int ping; // server to game info for scoreboard
238
+ int pmove_framecount; // FIXME: don't transmit over the network
239
+ int jumppad_frame;
240
+ int entityEventSequence;
241
+ } playerState_t;
242
+
243
+ //===================================================================
244
+
245
+ // if entityState->solid == SOLID_BMODEL, modelindex is an inline model number
246
+ #define SOLID_BMODEL 0xffffff
247
+
248
+ typedef enum {
249
+ TR_STATIONARY,
250
+ TR_INTERPOLATE, // non-parametric, but interpolate between snapshots
251
+ TR_LINEAR,
252
+ TR_LINEAR_STOP,
253
+ TR_SINE, // value = base + sin( time / duration ) * delta
254
+ TR_GRAVITY
255
+ } trType_t;
256
+
257
+ typedef struct {
258
+ trType_t trType;
259
+ int trTime;
260
+ int trDuration; // if non 0, trTime + trDuration = stop time
261
+ vec3_t trBase;
262
+ vec3_t trDelta; // velocity, etc
263
+ } trajectory_t;
264
+
265
+ // entityState_t is the information conveyed from the server
266
+ // in an update message about entities that the client will
267
+ // need to render in some way
268
+ // Different eTypes may use the information in different ways
269
+ // The messages are delta compressed, so it doesn't really matter if
270
+ // the structure size is fairly large
271
+
272
+ typedef struct entityState_s {
273
+ int number; // entity index
274
+ int eType; // entityType_t
275
+ int eFlags;
276
+
277
+ trajectory_t pos; // for calculating position
278
+ trajectory_t apos; // for calculating angles
279
+
280
+ int time;
281
+ int time2;
282
+
283
+ vec3_t origin;
284
+ vec3_t origin2;
285
+
286
+ vec3_t angles;
287
+ vec3_t angles2;
288
+
289
+ int otherEntityNum; // shotgun sources, etc
290
+ int otherEntityNum2;
291
+
292
+ int groundEntityNum; // -1 = in air
293
+
294
+ int constantLight; // r + (g<<8) + (b<<16) + (intensity<<24)
295
+ int loopSound; // constantly loop this sound
296
+
297
+ int modelindex;
298
+ int modelindex2;
299
+ int clientNum; // 0 to (MAX_CLIENTS - 1), for players and corpses
300
+ int frame;
301
+
302
+ int solid; // for client side prediction, trap_linkentity sets this properly
303
+
304
+ int event; // impulse events -- muzzle flashes, footsteps, etc
305
+ int eventParm;
306
+
307
+ // for players
308
+ int powerups; // bit flags
309
+ int weapon; // determines weapon and flash model, etc
310
+ int legsAnim; // mask off ANIM_TOGGLEBIT
311
+ int torsoAnim; // mask off ANIM_TOGGLEBIT
312
+
313
+ int generic1;
314
+ } entityState_t;
315
+
316
+ // ========================================================================================
317
+
318
+ //
319
+ // config strings are a general means of communicating variable length strings
320
+ // from the server to all connected clients.
321
+ //
322
+
323
+ // CS_SERVERINFO and CS_SYSTEMINFO are defined in q_shared.h
324
+ #define CS_MUSIC 2
325
+ #define CS_MESSAGE 3 // from the map worldspawn's message field
326
+ #define CS_MOTD 4 // g_motd string for server message of the day
327
+ #define CS_WARMUP 5 // server time when the match will be restarted
328
+ #define CS_SCORES1 6
329
+ #define CS_SCORES2 7
330
+ #define CS_VOTE_TIME 8
331
+ #define CS_VOTE_STRING 9
332
+ #define CS_VOTE_YES 10
333
+ #define CS_VOTE_NO 11
334
+
335
+ #define CS_TEAMVOTE_TIME 12
336
+ #define CS_TEAMVOTE_STRING 14
337
+ #define CS_TEAMVOTE_YES 16
338
+ #define CS_TEAMVOTE_NO 18
339
+
340
+ #define CS_GAME_VERSION 20
341
+ #define CS_LEVEL_START_TIME 21 // so the timer only shows the current level
342
+ #define CS_INTERMISSION 22 // when 1, fraglimit/timelimit has been hit and intermission will start in a second or two
343
+ #define CS_FLAGSTATUS 23 // string indicating flag status in CTF
344
+ #define CS_SHADERSTATE 24
345
+ #define CS_BOTINFO 25
346
+
347
+ #define CS_ITEMS 27 // string of 0's and 1's that tell which items are present
348
+
349
+ #define CS_MODELS 32
350
+ #define CS_SOUNDS (CS_MODELS+MAX_MODELS)
351
+ #define CS_PLAYERS (CS_SOUNDS+MAX_SOUNDS)
352
+ #define CS_LOCATIONS (CS_PLAYERS+MAX_CLIENTS)
353
+ #define CS_PARTICLES (CS_LOCATIONS+MAX_LOCATIONS)
354
+
355
+ #define CS_MAX (CS_PARTICLES+MAX_LOCATIONS)
356
+
357
+ #if (CS_MAX) > MAX_CONFIGSTRINGS
358
+ #error overflow: (CS_MAX) > MAX_CONFIGSTRINGS
359
+ #endif
360
+
361
+ typedef enum {
362
+ GT_FFA, // free for all
363
+ GT_TOURNAMENT, // one on one tournament
364
+ GT_SINGLE_PLAYER, // single player ffa
365
+
366
+ //-- team games go after this --
367
+
368
+ GT_TEAM, // team deathmatch
369
+ GT_CTF, // capture the flag
370
+ GT_1FCTF,
371
+ GT_OBELISK,
372
+ GT_HARVESTER,
373
+ GT_MAX_GAME_TYPE
374
+ } gametype_t;
375
+
376
+ typedef enum { GENDER_MALE, GENDER_FEMALE, GENDER_NEUTER } gender_t;
377
+
378
+ // entityState_t->event values
379
+ // entity events are for effects that take place reletive
380
+ // to an existing entities origin. Very network efficient.
381
+
382
+ // two bits at the top of the entityState->event field
383
+ // will be incremented with each change in the event so
384
+ // that an identical event started twice in a row can
385
+ // be distinguished. And off the value with ~EV_EVENT_BITS
386
+ // to retrieve the actual event number
387
+ #define EV_EVENT_BIT1 0x00000100
388
+ #define EV_EVENT_BIT2 0x00000200
389
+ #define EV_EVENT_BITS (EV_EVENT_BIT1|EV_EVENT_BIT2)
390
+
391
+ #define EVENT_VALID_MSEC 300
392
+
393
+ typedef enum {
394
+ EV_NONE,
395
+
396
+ EV_FOOTSTEP,
397
+ EV_FOOTSTEP_METAL,
398
+ EV_FOOTSPLASH,
399
+ EV_FOOTWADE,
400
+ EV_SWIM,
401
+
402
+ EV_STEP_4,
403
+ EV_STEP_8,
404
+ EV_STEP_12,
405
+ EV_STEP_16,
406
+
407
+ EV_FALL_SHORT,
408
+ EV_FALL_MEDIUM,
409
+ EV_FALL_FAR,
410
+
411
+ EV_JUMP_PAD, // boing sound at origin, jump sound on player
412
+
413
+ EV_JUMP,
414
+ EV_WATER_TOUCH, // foot touches
415
+ EV_WATER_LEAVE, // foot leaves
416
+ EV_WATER_UNDER, // head touches
417
+ EV_WATER_CLEAR, // head leaves
418
+
419
+ EV_ITEM_PICKUP, // normal item pickups are predictable
420
+ EV_GLOBAL_ITEM_PICKUP, // powerup / team sounds are broadcast to everyone
421
+
422
+ EV_NOAMMO,
423
+ EV_CHANGE_WEAPON,
424
+ EV_FIRE_WEAPON,
425
+
426
+ EV_USE_ITEM0,
427
+ EV_USE_ITEM1,
428
+ EV_USE_ITEM2,
429
+ EV_USE_ITEM3,
430
+ EV_USE_ITEM4,
431
+ EV_USE_ITEM5,
432
+ EV_USE_ITEM6,
433
+ EV_USE_ITEM7,
434
+ EV_USE_ITEM8,
435
+ EV_USE_ITEM9,
436
+ EV_USE_ITEM10,
437
+ EV_USE_ITEM11,
438
+ EV_USE_ITEM12,
439
+ EV_USE_ITEM13,
440
+ EV_USE_ITEM14,
441
+ EV_USE_ITEM15,
442
+
443
+ EV_ITEM_RESPAWN,
444
+ EV_ITEM_POP,
445
+ EV_PLAYER_TELEPORT_IN,
446
+ EV_PLAYER_TELEPORT_OUT,
447
+
448
+ EV_GRENADE_BOUNCE, // eventParm will be the soundindex
449
+
450
+ EV_GENERAL_SOUND,
451
+ EV_GLOBAL_SOUND, // no attenuation
452
+ EV_GLOBAL_TEAM_SOUND,
453
+
454
+ EV_BULLET_HIT_FLESH,
455
+ EV_BULLET_HIT_WALL,
456
+
457
+ EV_MISSILE_HIT,
458
+ EV_MISSILE_MISS,
459
+ EV_MISSILE_MISS_METAL,
460
+ EV_RAILTRAIL,
461
+ EV_SHOTGUN,
462
+ EV_BULLET, // otherEntity is the shooter
463
+
464
+ EV_PAIN,
465
+ EV_DEATH1,
466
+ EV_DEATH2,
467
+ EV_DEATH3,
468
+ EV_OBITUARY,
469
+
470
+ EV_POWERUP_QUAD,
471
+ EV_POWERUP_BATTLESUIT,
472
+ EV_POWERUP_REGEN,
473
+
474
+ EV_GIB_PLAYER, // gib a previously living player
475
+ EV_SCOREPLUM, // score plum
476
+
477
+ //#ifdef MISSIONPACK
478
+ EV_PROXIMITY_MINE_STICK,
479
+ EV_PROXIMITY_MINE_TRIGGER,
480
+ EV_KAMIKAZE, // kamikaze explodes
481
+ EV_OBELISKEXPLODE, // obelisk explodes
482
+ EV_OBELISKPAIN, // obelisk is in pain
483
+ EV_INVUL_IMPACT, // invulnerability sphere impact
484
+ EV_JUICED, // invulnerability juiced effect
485
+ EV_LIGHTNINGBOLT, // lightning bolt bounced of invulnerability sphere
486
+ //#endif
487
+
488
+ EV_DEBUG_LINE,
489
+ EV_STOPLOOPINGSOUND,
490
+ EV_TAUNT,
491
+ EV_TAUNT_YES,
492
+ EV_TAUNT_NO,
493
+ EV_TAUNT_FOLLOWME,
494
+ EV_TAUNT_GETFLAG,
495
+ EV_TAUNT_GUARDBASE,
496
+ EV_TAUNT_PATROL
497
+
498
+ } entity_event_t;
499
+
500
+ // means of death
501
+ typedef enum {
502
+ MOD_UNKNOWN,
503
+ MOD_SHOTGUN,
504
+ MOD_GAUNTLET,
505
+ MOD_MACHINEGUN,
506
+ MOD_GRENADE,
507
+ MOD_GRENADE_SPLASH,
508
+ MOD_ROCKET,
509
+ MOD_ROCKET_SPLASH,
510
+ MOD_PLASMA,
511
+ MOD_PLASMA_SPLASH,
512
+ MOD_RAILGUN,
513
+ MOD_LIGHTNING,
514
+ MOD_BFG,
515
+ MOD_BFG_SPLASH,
516
+ MOD_WATER,
517
+ MOD_SLIME,
518
+ MOD_LAVA,
519
+ MOD_CRUSH,
520
+ MOD_TELEFRAG,
521
+ MOD_FALLING,
522
+ MOD_SUICIDE,
523
+ MOD_TARGET_LASER,
524
+ MOD_TRIGGER_HURT,
525
+ #ifdef MISSIONPACK
526
+ MOD_NAIL,
527
+ MOD_CHAINGUN,
528
+ MOD_PROXIMITY_MINE,
529
+ MOD_KAMIKAZE,
530
+ MOD_JUICED,
531
+ #endif
532
+ MOD_GRAPPLE
533
+ } meansOfDeath_t;
534
+
535
+ //
536
+ // entityState_t->eType
537
+ //
538
+ typedef enum {
539
+ ET_GENERAL,
540
+ ET_PLAYER,
541
+ ET_ITEM,
542
+ ET_MISSILE,
543
+ ET_MOVER,
544
+ ET_BEAM,
545
+ ET_PORTAL,
546
+ ET_SPEAKER,
547
+ ET_PUSH_TRIGGER,
548
+ ET_TELEPORT_TRIGGER,
549
+ ET_INVISIBLE,
550
+ ET_GRAPPLE, // grapple hooked on wall
551
+ ET_TEAM,
552
+
553
+ ET_EVENTS // any of the EV_* events can be added freestanding
554
+ // by setting eType to ET_EVENTS + eventNum
555
+ // this avoids having to set eFlags and eventNum
556
+ } entityType_t;
557
+
558
+ char * COM_Parse( char **data_p );
559
+
560
+ char * CopyString( const char *in );
561
+
562
+ int Cmd_Argc( void );
563
+ char * Cmd_Argv( int arg );
564
+ char * Cmd_Args( void );
565
+ void Cmd_TokenizeString( char *text );
566
+
567
+ void Info_Print( const char *s );
568
+