|
|
1.1 root 1:
2: // q_shared.h -- included first by ALL program modules
3:
4: #ifdef _WIN32
5: // unknown pragmas are SUPPOSED to be ignored, but....
6: #pragma warning(disable : 4244) // MIPS
7: #pragma warning(disable : 4136) // X86
8: #pragma warning(disable : 4051) // ALPHA
9:
10: #pragma warning(disable : 4018) // signed/unsigned mismatch
11: #pragma warning(disable : 4305) // truncation from const double to float
12:
13: #endif
14:
15: #include <assert.h>
16: #include <math.h>
17: #include <stdio.h>
18: #include <stdarg.h>
19: #include <string.h>
20: #include <stdlib.h>
21: #include <time.h>
22:
23: #if (defined _M_IX86 || defined __i386__) && !defined C_ONLY && !defined __sun__
24: #define id386 1
25: #else
26: #define id386 0
27: #endif
28:
29: #if defined _M_ALPHA && !defined C_ONLY
30: #define idaxp 1
31: #else
32: #define idaxp 0
33: #endif
34:
35: typedef unsigned char byte;
36: typedef enum {false, true} qboolean;
37:
38:
39: #ifndef NULL
40: #define NULL ((void *)0)
41: #endif
42:
43:
44: // angle indexes
45: #define PITCH 0 // up / down
46: #define YAW 1 // left / right
47: #define ROLL 2 // fall over
48:
49: #define MAX_STRING_CHARS 1024 // max length of a string passed to Cmd_TokenizeString
50: #define MAX_STRING_TOKENS 80 // max tokens resulting from Cmd_TokenizeString
51: #define MAX_TOKEN_CHARS 128 // max length of an individual token
52:
53: #define MAX_QPATH 64 // max length of a quake game pathname
54: #define MAX_OSPATH 128 // max length of a filesystem pathname
55:
56: //
57: // per-level limits
58: //
59: #define MAX_CLIENTS 256 // absolute limit
60: #define MAX_EDICTS 1024 // must change protocol to increase more
61: #define MAX_LIGHTSTYLES 256
62: #define MAX_MODELS 256 // these are sent over the net as bytes
63: #define MAX_SOUNDS 256 // so they cannot be blindly increased
64: #define MAX_IMAGES 256
65: #define MAX_ITEMS 256
66: #define MAX_GENERAL (MAX_CLIENTS*2) // general config strings
67:
68:
69: // game print flags
70: #define PRINT_LOW 0 // pickup messages
71: #define PRINT_MEDIUM 1 // death messages
72: #define PRINT_HIGH 2 // critical messages
73: #define PRINT_CHAT 3 // chat messages
74:
75:
76:
77: #define ERR_FATAL 0 // exit the entire game with a popup window
78: #define ERR_DROP 1 // print to console and disconnect from game
79: #define ERR_DISCONNECT 2 // don't kill server
80:
81: #define PRINT_ALL 0
82: #define PRINT_DEVELOPER 1 // only print when "developer 1"
83: #define PRINT_ALERT 2
84:
85:
86: // destination class for gi.multicast()
87: typedef enum
88: {
89: MULTICAST_ALL,
90: MULTICAST_PHS,
91: MULTICAST_PVS,
92: MULTICAST_ALL_R,
93: MULTICAST_PHS_R,
94: MULTICAST_PVS_R
95: } multicast_t;
96:
97:
98: /*
99: ==============================================================
100:
101: MATHLIB
102:
103: ==============================================================
104: */
105:
106: typedef float vec_t;
107: typedef vec_t vec3_t[3];
108: typedef vec_t vec5_t[5];
109:
110: typedef int fixed4_t;
111: typedef int fixed8_t;
112: typedef int fixed16_t;
113:
114: #ifndef M_PI
115: #define M_PI 3.14159265358979323846 // matches value in gcc v2 math.h
116: #endif
117:
118: struct cplane_s;
119:
120: extern vec3_t vec3_origin;
121:
122: #define nanmask (255<<23)
123:
124: #define IS_NAN(x) (((*(int *)&x)&nanmask)==nanmask)
125:
126: // microsoft's fabs seems to be ungodly slow...
127: //float Q_fabs (float f);
128: //#define fabs(f) Q_fabs(f)
129: #if !defined C_ONLY && !defined __linux__ && !defined __sgi
130: extern long Q_ftol( float f );
131: #else
132: #define Q_ftol( f ) ( long ) (f)
133: #endif
134:
135: #define DotProduct(x,y) (x[0]*y[0]+x[1]*y[1]+x[2]*y[2])
136: #define VectorSubtract(a,b,c) (c[0]=a[0]-b[0],c[1]=a[1]-b[1],c[2]=a[2]-b[2])
137: #define VectorAdd(a,b,c) (c[0]=a[0]+b[0],c[1]=a[1]+b[1],c[2]=a[2]+b[2])
138: #define VectorCopy(a,b) (b[0]=a[0],b[1]=a[1],b[2]=a[2])
139: #define VectorClear(a) (a[0]=a[1]=a[2]=0)
140: #define VectorNegate(a,b) (b[0]=-a[0],b[1]=-a[1],b[2]=-a[2])
141: #define VectorSet(v, x, y, z) (v[0]=(x), v[1]=(y), v[2]=(z))
142:
143: void VectorMA (vec3_t veca, float scale, vec3_t vecb, vec3_t vecc);
144:
145: // just in case you do't want to use the macros
146: vec_t _DotProduct (vec3_t v1, vec3_t v2);
147: void _VectorSubtract (vec3_t veca, vec3_t vecb, vec3_t out);
148: void _VectorAdd (vec3_t veca, vec3_t vecb, vec3_t out);
149: void _VectorCopy (vec3_t in, vec3_t out);
150:
151: void ClearBounds (vec3_t mins, vec3_t maxs);
152: void AddPointToBounds (vec3_t v, vec3_t mins, vec3_t maxs);
153: int VectorCompare (vec3_t v1, vec3_t v2);
154: vec_t VectorLength (vec3_t v);
155: void CrossProduct (vec3_t v1, vec3_t v2, vec3_t cross);
156: vec_t VectorNormalize (vec3_t v); // returns vector length
157: vec_t VectorNormalize2 (vec3_t v, vec3_t out);
158: void VectorInverse (vec3_t v);
159: void VectorScale (vec3_t in, vec_t scale, vec3_t out);
160: int Q_log2(int val);
161:
162: void R_ConcatRotations (float in1[3][3], float in2[3][3], float out[3][3]);
163: void R_ConcatTransforms (float in1[3][4], float in2[3][4], float out[3][4]);
164:
165: void AngleVectors (vec3_t angles, vec3_t forward, vec3_t right, vec3_t up);
166: int BoxOnPlaneSide (vec3_t emins, vec3_t emaxs, struct cplane_s *plane);
167: float anglemod(float a);
168: float LerpAngle (float a1, float a2, float frac);
169:
170: #define BOX_ON_PLANE_SIDE(emins, emaxs, p) \
171: (((p)->type < 3)? \
172: ( \
173: ((p)->dist <= (emins)[(p)->type])? \
174: 1 \
175: : \
176: ( \
177: ((p)->dist >= (emaxs)[(p)->type])?\
178: 2 \
179: : \
180: 3 \
181: ) \
182: ) \
183: : \
184: BoxOnPlaneSide( (emins), (emaxs), (p)))
185:
186: void ProjectPointOnPlane( vec3_t dst, const vec3_t p, const vec3_t normal );
187: void PerpendicularVector( vec3_t dst, const vec3_t src );
188: void RotatePointAroundVector( vec3_t dst, const vec3_t dir, const vec3_t point, float degrees );
189:
190:
191: //=============================================
192:
193: char *COM_SkipPath (char *pathname);
194: void COM_StripExtension (char *in, char *out);
195: void COM_FileBase (char *in, char *out);
196: void COM_FilePath (char *in, char *out);
197: void COM_DefaultExtension (char *path, char *extension);
198:
199: char *COM_Parse (char **data_p);
200: // data is an in/out parm, returns a parsed out token
201:
202: void Com_sprintf (char *dest, int size, char *fmt, ...);
203:
204: void Com_PageInMemory (byte *buffer, int size);
205:
206: //=============================================
207:
208: // portable case insensitive compare
209: int Q_stricmp (char *s1, char *s2);
210: int Q_strcasecmp (char *s1, char *s2);
211: int Q_strncasecmp (char *s1, char *s2, int n);
212:
213: //=============================================
214:
215: short BigShort(short l);
216: short LittleShort(short l);
217: int BigLong (int l);
218: int LittleLong (int l);
219: float BigFloat (float l);
220: float LittleFloat (float l);
221:
222: void Swap_Init (void);
223: char *va(char *format, ...);
224:
225: //=============================================
226:
227: //
228: // key / value info strings
229: //
230: #define MAX_INFO_KEY 64
231: #define MAX_INFO_VALUE 64
232: #define MAX_INFO_STRING 512
233:
234: char *Info_ValueForKey (char *s, char *key);
235: void Info_RemoveKey (char *s, char *key);
236: void Info_SetValueForKey (char *s, char *key, char *value);
237: qboolean Info_Validate (char *s);
238:
239: /*
240: ==============================================================
241:
242: SYSTEM SPECIFIC
243:
244: ==============================================================
245: */
246:
247: extern int curtime; // time returned by last Sys_Milliseconds
248:
249: int Sys_Milliseconds (void);
250: void Sys_Mkdir (char *path);
251:
252: // large block stack allocation routines
253: void *Hunk_Begin (int maxsize);
254: void *Hunk_Alloc (int size);
255: void Hunk_Free (void *buf);
256: int Hunk_End (void);
257:
258: // directory searching
259: #define SFF_ARCH 0x01
260: #define SFF_HIDDEN 0x02
261: #define SFF_RDONLY 0x04
262: #define SFF_SUBDIR 0x08
263: #define SFF_SYSTEM 0x10
264:
265: /*
266: ** pass in an attribute mask of things you wish to REJECT
267: */
268: char *Sys_FindFirst (char *path, unsigned musthave, unsigned canthave );
269: char *Sys_FindNext ( unsigned musthave, unsigned canthave );
270: void Sys_FindClose (void);
271:
272:
273: // this is only here so the functions in q_shared.c and q_shwin.c can link
274: void Sys_Error (char *error, ...);
275: void Com_Printf (char *msg, ...);
276:
277:
278: /*
279: ==========================================================
280:
281: CVARS (console variables)
282:
283: ==========================================================
284: */
285:
286: #ifndef CVAR
287: #define CVAR
288:
289: #define CVAR_ARCHIVE 1 // set to cause it to be saved to vars.rc
290: #define CVAR_USERINFO 2 // added to userinfo when changed
291: #define CVAR_SERVERINFO 4 // added to serverinfo when changed
292: #define CVAR_NOSET 8 // don't allow change from console at all,
293: // but can be set from the command line
294: #define CVAR_LATCH 16 // save changes until server restart
295:
296: // nothing outside the Cvar_*() functions should modify these fields!
297: typedef struct cvar_s
298: {
299: char *name;
300: char *string;
301: char *latched_string; // for CVAR_LATCH vars
302: int flags;
303: qboolean modified; // set each time the cvar is changed
304: float value;
305: struct cvar_s *next;
306: } cvar_t;
307:
308: #endif // CVAR
309:
310: /*
311: ==============================================================
312:
313: COLLISION DETECTION
314:
315: ==============================================================
316: */
317:
318: // lower bits are stronger, and will eat weaker brushes completely
319: #define CONTENTS_SOLID 1 // an eye is never valid in a solid
320: #define CONTENTS_WINDOW 2 // translucent, but not watery
321: #define CONTENTS_AUX 4
322: #define CONTENTS_LAVA 8
323: #define CONTENTS_SLIME 16
324: #define CONTENTS_WATER 32
325: #define CONTENTS_MIST 64
326: #define LAST_VISIBLE_CONTENTS 64
327:
328: // remaining contents are non-visible, and don't eat brushes
329:
330: #define CONTENTS_AREAPORTAL 0x8000
331:
332: #define CONTENTS_PLAYERCLIP 0x10000
333: #define CONTENTS_MONSTERCLIP 0x20000
334:
335: // currents can be added to any other contents, and may be mixed
336: #define CONTENTS_CURRENT_0 0x40000
337: #define CONTENTS_CURRENT_90 0x80000
338: #define CONTENTS_CURRENT_180 0x100000
339: #define CONTENTS_CURRENT_270 0x200000
340: #define CONTENTS_CURRENT_UP 0x400000
341: #define CONTENTS_CURRENT_DOWN 0x800000
342:
343: #define CONTENTS_ORIGIN 0x1000000 // removed before bsping an entity
344:
345: #define CONTENTS_MONSTER 0x2000000 // should never be on a brush, only in game
346: #define CONTENTS_DEADMONSTER 0x4000000
347: #define CONTENTS_DETAIL 0x8000000 // brushes to be added after vis leafs
348: #define CONTENTS_TRANSLUCENT 0x10000000 // auto set if any surface has trans
349: #define CONTENTS_LADDER 0x20000000
350:
351:
352:
353: #define SURF_LIGHT 0x1 // value will hold the light strength
354:
355: #define SURF_SLICK 0x2 // effects game physics
356:
357: #define SURF_SKY 0x4 // don't draw, but add to skybox
358: #define SURF_WARP 0x8 // turbulent water warp
359: #define SURF_TRANS33 0x10
360: #define SURF_TRANS66 0x20
361: #define SURF_FLOWING 0x40 // scroll towards angle
362: #define SURF_NODRAW 0x80 // don't bother referencing the texture
363:
364:
365:
366: // content masks
367: #define MASK_ALL (-1)
368: #define MASK_SOLID (CONTENTS_SOLID|CONTENTS_WINDOW)
369: #define MASK_PLAYERSOLID (CONTENTS_SOLID|CONTENTS_PLAYERCLIP|CONTENTS_WINDOW|CONTENTS_MONSTER)
370: #define MASK_DEADSOLID (CONTENTS_SOLID|CONTENTS_PLAYERCLIP|CONTENTS_WINDOW)
371: #define MASK_MONSTERSOLID (CONTENTS_SOLID|CONTENTS_MONSTERCLIP|CONTENTS_WINDOW|CONTENTS_MONSTER)
372: #define MASK_WATER (CONTENTS_WATER|CONTENTS_LAVA|CONTENTS_SLIME)
373: #define MASK_OPAQUE (CONTENTS_SOLID|CONTENTS_SLIME|CONTENTS_LAVA)
374: #define MASK_SHOT (CONTENTS_SOLID|CONTENTS_MONSTER|CONTENTS_WINDOW|CONTENTS_DEADMONSTER)
375: #define MASK_CURRENT (CONTENTS_CURRENT_0|CONTENTS_CURRENT_90|CONTENTS_CURRENT_180|CONTENTS_CURRENT_270|CONTENTS_CURRENT_UP|CONTENTS_CURRENT_DOWN)
376:
377:
378: // gi.BoxEdicts() can return a list of either solid or trigger entities
379: // FIXME: eliminate AREA_ distinction?
380: #define AREA_SOLID 1
381: #define AREA_TRIGGERS 2
382:
383:
384: // plane_t structure
385: // !!! if this is changed, it must be changed in asm code too !!!
386: typedef struct cplane_s
387: {
388: vec3_t normal;
389: float dist;
390: byte type; // for fast side tests
391: byte signbits; // signx + (signy<<1) + (signz<<1)
392: byte pad[2];
393: } cplane_t;
394:
395: // structure offset for asm code
396: #define CPLANE_NORMAL_X 0
397: #define CPLANE_NORMAL_Y 4
398: #define CPLANE_NORMAL_Z 8
399: #define CPLANE_DIST 12
400: #define CPLANE_TYPE 16
401: #define CPLANE_SIGNBITS 17
402: #define CPLANE_PAD0 18
403: #define CPLANE_PAD1 19
404:
405: typedef struct cmodel_s
406: {
407: vec3_t mins, maxs;
408: vec3_t origin; // for sounds or lights
409: int headnode;
410: } cmodel_t;
411:
412: typedef struct csurface_s
413: {
414: char name[16];
415: int flags;
416: int value;
417: } csurface_t;
418:
419: typedef struct mapsurface_s // used internally due to name len probs //ZOID
420: {
421: csurface_t c;
422: char rname[32];
423: } mapsurface_t;
424:
425: // a trace is returned when a box is swept through the world
426: typedef struct
427: {
428: qboolean allsolid; // if true, plane is not valid
429: qboolean startsolid; // if true, the initial point was in a solid area
430: float fraction; // time completed, 1.0 = didn't hit anything
431: vec3_t endpos; // final position
432: cplane_t plane; // surface normal at impact
433: csurface_t *surface; // surface hit
434: int contents; // contents on other side of surface hit
435: struct edict_s *ent; // not set by CM_*() functions
436: } trace_t;
437:
438:
439:
440: // pmove_state_t is the information necessary for client side movement
441: // prediction
442: typedef enum
443: {
444: // can accelerate and turn
445: PM_NORMAL,
446: PM_SPECTATOR,
447: // no acceleration or turning
448: PM_DEAD,
449: PM_GIB, // different bounding box
450: PM_FREEZE
451: } pmtype_t;
452:
453: // pmove->pm_flags
454: #define PMF_DUCKED 1
455: #define PMF_JUMP_HELD 2
456: #define PMF_ON_GROUND 4
457: #define PMF_TIME_WATERJUMP 8 // pm_time is waterjump
458: #define PMF_TIME_LAND 16 // pm_time is time before rejump
459: #define PMF_TIME_TELEPORT 32 // pm_time is non-moving time
460: #define PMF_NO_PREDICTION 64 // temporarily disables prediction (used for grappling hook)
461:
462: // this structure needs to be communicated bit-accurate
463: // from the server to the client to guarantee that
464: // prediction stays in sync, so no floats are used.
465: // if any part of the game code modifies this struct, it
466: // will result in a prediction error of some degree.
467: typedef struct
468: {
469: pmtype_t pm_type;
470:
471: short origin[3]; // 12.3
472: short velocity[3]; // 12.3
473: byte pm_flags; // ducked, jump_held, etc
474: byte pm_time; // each unit = 8 ms
475: short gravity;
476: short delta_angles[3]; // add to command angles to get view direction
477: // changed by spawns, rotating objects, and teleporters
478: } pmove_state_t;
479:
480:
481: //
482: // button bits
483: //
484: #define BUTTON_ATTACK 1
485: #define BUTTON_USE 2
486: #define BUTTON_ANY 128 // any key whatsoever
487:
488:
489: // usercmd_t is sent to the server each client frame
490: typedef struct usercmd_s
491: {
492: byte msec;
493: byte buttons;
494: short angles[3];
495: short forwardmove, sidemove, upmove;
496: byte impulse; // remove?
497: byte lightlevel; // light level the player is standing on
498: } usercmd_t;
499:
500:
501: #define MAXTOUCH 32
502: typedef struct
503: {
504: // state (in / out)
505: pmove_state_t s;
506:
507: // command (in)
508: usercmd_t cmd;
509: qboolean snapinitial; // if s has been changed outside pmove
510:
511: // results (out)
512: int numtouch;
513: struct edict_s *touchents[MAXTOUCH];
514:
515: vec3_t viewangles; // clamped
516: float viewheight;
517:
518: vec3_t mins, maxs; // bounding box size
519:
520: struct edict_s *groundentity;
521: int watertype;
522: int waterlevel;
523:
524: // callbacks to test the world
525: trace_t (*trace) (vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end);
526: int (*pointcontents) (vec3_t point);
527: } pmove_t;
528:
529:
530: // entity_state_t->effects
531: // Effects are things handled on the client side (lights, particles, frame animations)
532: // that happen constantly on the given entity.
533: // An entity that has effects will be sent to the client
534: // even if it has a zero index model.
535: #define EF_ROTATE 0x00000001 // rotate (bonus items)
536: #define EF_GIB 0x00000002 // leave a trail
537: #define EF_BLASTER 0x00000008 // redlight + trail
538: #define EF_ROCKET 0x00000010 // redlight + trail
539: #define EF_GRENADE 0x00000020
540: #define EF_HYPERBLASTER 0x00000040
541: #define EF_BFG 0x00000080
542: #define EF_COLOR_SHELL 0x00000100
543: #define EF_POWERSCREEN 0x00000200
544: #define EF_ANIM01 0x00000400 // automatically cycle between frames 0 and 1 at 2 hz
545: #define EF_ANIM23 0x00000800 // automatically cycle between frames 2 and 3 at 2 hz
546: #define EF_ANIM_ALL 0x00001000 // automatically cycle through all frames at 2hz
547: #define EF_ANIM_ALLFAST 0x00002000 // automatically cycle through all frames at 10hz
548: #define EF_FLIES 0x00004000
549: #define EF_QUAD 0x00008000
550: #define EF_PENT 0x00010000
551: #define EF_TELEPORTER 0x00020000 // particle fountain
552: #define EF_FLAG1 0x00040000
553: #define EF_FLAG2 0x00080000
554: // RAFAEL
555: #define EF_IONRIPPER 0x00100000
556: #define EF_GREENGIB 0x00200000
557: #define EF_BLUEHYPERBLASTER 0x00400000
558: #define EF_SPINNINGLIGHTS 0x00800000
559: #define EF_PLASMA 0x01000000
560: #define EF_TRAP 0x02000000
561:
562: // entity_state_t->renderfx flags
563: #define RF_MINLIGHT 1 // allways have some light (viewmodel)
564: #define RF_VIEWERMODEL 2 // don't draw through eyes, only mirrors
565: #define RF_WEAPONMODEL 4 // only draw through eyes
566: #define RF_FULLBRIGHT 8 // allways draw full intensity
567: #define RF_DEPTHHACK 16 // for view weapon Z crunching
568: #define RF_TRANSLUCENT 32
569: #define RF_FRAMELERP 64
570: #define RF_BEAM 128
571: #define RF_CUSTOMSKIN 256 // skin is an index in image_precache
572: #define RF_GLOW 512 // pulse lighting for bonus items
573: #define RF_SHELL_RED 1024
574: #define RF_SHELL_GREEN 2048
575: #define RF_SHELL_BLUE 4096
576:
577: // player_state_t->refdef flags
578: #define RDF_UNDERWATER 1 // warp the screen as apropriate
579: #define RDF_NOWORLDMODEL 2 // used for player configuration screen
580:
581: //
582: // muzzle flashes / player effects
583: //
584: #define MZ_BLASTER 0
585: #define MZ_MACHINEGUN 1
586: #define MZ_SHOTGUN 2
587: #define MZ_CHAINGUN1 3
588: #define MZ_CHAINGUN2 4
589: #define MZ_CHAINGUN3 5
590: #define MZ_RAILGUN 6
591: #define MZ_ROCKET 7
592: #define MZ_GRENADE 8
593: #define MZ_LOGIN 9
594: #define MZ_LOGOUT 10
595: #define MZ_RESPAWN 11
596: #define MZ_BFG 12
597: #define MZ_SSHOTGUN 13
598: #define MZ_HYPERBLASTER 14
599: #define MZ_ITEMRESPAWN 15
600: // RAFAEL
601: #define MZ_IONRIPPER 16
602: #define MZ_BLUEHYPERBLASTER 17
603: #define MZ_PHALANX 18
604: #define MZ_SILENCED 128 // bit flag ORed with one of the above numbers
605:
606: //
607: // monster muzzle flashes
608: //
609: #define MZ2_TANK_BLASTER_1 1
610: #define MZ2_TANK_BLASTER_2 2
611: #define MZ2_TANK_BLASTER_3 3
612: #define MZ2_TANK_MACHINEGUN_1 4
613: #define MZ2_TANK_MACHINEGUN_2 5
614: #define MZ2_TANK_MACHINEGUN_3 6
615: #define MZ2_TANK_MACHINEGUN_4 7
616: #define MZ2_TANK_MACHINEGUN_5 8
617: #define MZ2_TANK_MACHINEGUN_6 9
618: #define MZ2_TANK_MACHINEGUN_7 10
619: #define MZ2_TANK_MACHINEGUN_8 11
620: #define MZ2_TANK_MACHINEGUN_9 12
621: #define MZ2_TANK_MACHINEGUN_10 13
622: #define MZ2_TANK_MACHINEGUN_11 14
623: #define MZ2_TANK_MACHINEGUN_12 15
624: #define MZ2_TANK_MACHINEGUN_13 16
625: #define MZ2_TANK_MACHINEGUN_14 17
626: #define MZ2_TANK_MACHINEGUN_15 18
627: #define MZ2_TANK_MACHINEGUN_16 19
628: #define MZ2_TANK_MACHINEGUN_17 20
629: #define MZ2_TANK_MACHINEGUN_18 21
630: #define MZ2_TANK_MACHINEGUN_19 22
631: #define MZ2_TANK_ROCKET_1 23
632: #define MZ2_TANK_ROCKET_2 24
633: #define MZ2_TANK_ROCKET_3 25
634:
635: #define MZ2_INFANTRY_MACHINEGUN_1 26
636: #define MZ2_INFANTRY_MACHINEGUN_2 27
637: #define MZ2_INFANTRY_MACHINEGUN_3 28
638: #define MZ2_INFANTRY_MACHINEGUN_4 29
639: #define MZ2_INFANTRY_MACHINEGUN_5 30
640: #define MZ2_INFANTRY_MACHINEGUN_6 31
641: #define MZ2_INFANTRY_MACHINEGUN_7 32
642: #define MZ2_INFANTRY_MACHINEGUN_8 33
643: #define MZ2_INFANTRY_MACHINEGUN_9 34
644: #define MZ2_INFANTRY_MACHINEGUN_10 35
645: #define MZ2_INFANTRY_MACHINEGUN_11 36
646: #define MZ2_INFANTRY_MACHINEGUN_12 37
647: #define MZ2_INFANTRY_MACHINEGUN_13 38
648:
649: #define MZ2_SOLDIER_BLASTER_1 39
650: #define MZ2_SOLDIER_BLASTER_2 40
651: #define MZ2_SOLDIER_SHOTGUN_1 41
652: #define MZ2_SOLDIER_SHOTGUN_2 42
653: #define MZ2_SOLDIER_MACHINEGUN_1 43
654: #define MZ2_SOLDIER_MACHINEGUN_2 44
655:
656: #define MZ2_GUNNER_MACHINEGUN_1 45
657: #define MZ2_GUNNER_MACHINEGUN_2 46
658: #define MZ2_GUNNER_MACHINEGUN_3 47
659: #define MZ2_GUNNER_MACHINEGUN_4 48
660: #define MZ2_GUNNER_MACHINEGUN_5 49
661: #define MZ2_GUNNER_MACHINEGUN_6 50
662: #define MZ2_GUNNER_MACHINEGUN_7 51
663: #define MZ2_GUNNER_MACHINEGUN_8 52
664: #define MZ2_GUNNER_GRENADE_1 53
665: #define MZ2_GUNNER_GRENADE_2 54
666: #define MZ2_GUNNER_GRENADE_3 55
667: #define MZ2_GUNNER_GRENADE_4 56
668:
669: #define MZ2_CHICK_ROCKET_1 57
670:
671: #define MZ2_FLYER_BLASTER_1 58
672: #define MZ2_FLYER_BLASTER_2 59
673:
674: #define MZ2_MEDIC_BLASTER_1 60
675:
676: #define MZ2_GLADIATOR_RAILGUN_1 61
677:
678: #define MZ2_HOVER_BLASTER_1 62
679:
680: #define MZ2_ACTOR_MACHINEGUN_1 63
681:
682: #define MZ2_SUPERTANK_MACHINEGUN_1 64
683: #define MZ2_SUPERTANK_MACHINEGUN_2 65
684: #define MZ2_SUPERTANK_MACHINEGUN_3 66
685: #define MZ2_SUPERTANK_MACHINEGUN_4 67
686: #define MZ2_SUPERTANK_MACHINEGUN_5 68
687: #define MZ2_SUPERTANK_MACHINEGUN_6 69
688: #define MZ2_SUPERTANK_ROCKET_1 70
689: #define MZ2_SUPERTANK_ROCKET_2 71
690: #define MZ2_SUPERTANK_ROCKET_3 72
691:
692: #define MZ2_BOSS2_MACHINEGUN_L1 73
693: #define MZ2_BOSS2_MACHINEGUN_L2 74
694: #define MZ2_BOSS2_MACHINEGUN_L3 75
695: #define MZ2_BOSS2_MACHINEGUN_L4 76
696: #define MZ2_BOSS2_MACHINEGUN_L5 77
697: #define MZ2_BOSS2_ROCKET_1 78
698: #define MZ2_BOSS2_ROCKET_2 79
699: #define MZ2_BOSS2_ROCKET_3 80
700: #define MZ2_BOSS2_ROCKET_4 81
701:
702: #define MZ2_FLOAT_BLASTER_1 82
703:
704: #define MZ2_SOLDIER_BLASTER_3 83
705: #define MZ2_SOLDIER_SHOTGUN_3 84
706: #define MZ2_SOLDIER_MACHINEGUN_3 85
707: #define MZ2_SOLDIER_BLASTER_4 86
708: #define MZ2_SOLDIER_SHOTGUN_4 87
709: #define MZ2_SOLDIER_MACHINEGUN_4 88
710: #define MZ2_SOLDIER_BLASTER_5 89
711: #define MZ2_SOLDIER_SHOTGUN_5 90
712: #define MZ2_SOLDIER_MACHINEGUN_5 91
713: #define MZ2_SOLDIER_BLASTER_6 92
714: #define MZ2_SOLDIER_SHOTGUN_6 93
715: #define MZ2_SOLDIER_MACHINEGUN_6 94
716: #define MZ2_SOLDIER_BLASTER_7 95
717: #define MZ2_SOLDIER_SHOTGUN_7 96
718: #define MZ2_SOLDIER_MACHINEGUN_7 97
719: #define MZ2_SOLDIER_BLASTER_8 98
720: #define MZ2_SOLDIER_SHOTGUN_8 99
721: #define MZ2_SOLDIER_MACHINEGUN_8 100
722:
723: // --- Xian shit below ---
724: #define MZ2_MAKRON_BFG 101
725: #define MZ2_MAKRON_BLASTER_1 102
726: #define MZ2_MAKRON_BLASTER_2 103
727: #define MZ2_MAKRON_BLASTER_3 104
728: #define MZ2_MAKRON_BLASTER_4 105
729: #define MZ2_MAKRON_BLASTER_5 106
730: #define MZ2_MAKRON_BLASTER_6 107
731: #define MZ2_MAKRON_BLASTER_7 108
732: #define MZ2_MAKRON_BLASTER_8 109
733: #define MZ2_MAKRON_BLASTER_9 110
734: #define MZ2_MAKRON_BLASTER_10 111
735: #define MZ2_MAKRON_BLASTER_11 112
736: #define MZ2_MAKRON_BLASTER_12 113
737: #define MZ2_MAKRON_BLASTER_13 114
738: #define MZ2_MAKRON_BLASTER_14 115
739: #define MZ2_MAKRON_BLASTER_15 116
740: #define MZ2_MAKRON_BLASTER_16 117
741: #define MZ2_MAKRON_BLASTER_17 118
742: #define MZ2_MAKRON_RAILGUN_1 119
743: #define MZ2_JORG_MACHINEGUN_L1 120
744: #define MZ2_JORG_MACHINEGUN_L2 121
745: #define MZ2_JORG_MACHINEGUN_L3 122
746: #define MZ2_JORG_MACHINEGUN_L4 123
747: #define MZ2_JORG_MACHINEGUN_L5 124
748: #define MZ2_JORG_MACHINEGUN_L6 125
749: #define MZ2_JORG_MACHINEGUN_R1 126
750: #define MZ2_JORG_MACHINEGUN_R2 127
751: #define MZ2_JORG_MACHINEGUN_R3 128
752: #define MZ2_JORG_MACHINEGUN_R4 129
753: #define MZ2_JORG_MACHINEGUN_R5 130
754: #define MZ2_JORG_MACHINEGUN_R6 131
755: #define MZ2_JORG_BFG_1 132
756: #define MZ2_BOSS2_MACHINEGUN_R1 133
757: #define MZ2_BOSS2_MACHINEGUN_R2 134
758: #define MZ2_BOSS2_MACHINEGUN_R3 135
759: #define MZ2_BOSS2_MACHINEGUN_R4 136
760: #define MZ2_BOSS2_MACHINEGUN_R5 137
761:
762: extern vec3_t monster_flash_offset [];
763:
764:
765: // temp entity events
766: //
767: // Temp entity events are for things that happen
768: // at a location seperate from any existing entity.
769: // Temporary entity messages are explicitly constructed
770: // and broadcast.
771: typedef enum
772: {
773: TE_GUNSHOT,
774: TE_BLOOD,
775: TE_BLASTER,
776: TE_RAILTRAIL,
777: TE_SHOTGUN,
778: TE_EXPLOSION1,
779: TE_EXPLOSION2,
780: TE_ROCKET_EXPLOSION,
781: TE_GRENADE_EXPLOSION,
782: TE_SPARKS,
783: TE_SPLASH,
784: TE_BUBBLETRAIL,
785: TE_SCREEN_SPARKS,
786: TE_SHIELD_SPARKS,
787: TE_BULLET_SPARKS,
788: TE_LASER_SPARKS,
789: TE_PARASITE_ATTACK,
790: TE_ROCKET_EXPLOSION_WATER,
791: TE_GRENADE_EXPLOSION_WATER,
792: TE_MEDIC_CABLE_ATTACK,
793: TE_BFG_EXPLOSION,
794: TE_BFG_BIGEXPLOSION,
795: TE_BOSSTPORT, // used as '22' in a map, so DON'T RENUMBER!!!
796: TE_BFG_LASER,
797: TE_GRAPPLE_CABLE,
798: TE_WELDING_SPARKS,
799: TE_GREENBLOOD,
800: TE_BLUEHYPERBLASTER,
801: TE_PLASMA_EXPLOSION,
802: TE_TUNNEL_SPARKS
803: } temp_event_t;
804:
805: #define SPLASH_UNKNOWN 0
806: #define SPLASH_SPARKS 1
807: #define SPLASH_BLUE_WATER 2
808: #define SPLASH_BROWN_WATER 3
809: #define SPLASH_SLIME 4
810: #define SPLASH_LAVA 5
811: #define SPLASH_BLOOD 6
812:
813:
814: // sound channels
815: // channel 0 never willingly overrides
816: // other channels (1-7) allways override a playing sound on that channel
817: #define CHAN_AUTO 0
818: #define CHAN_WEAPON 1
819: #define CHAN_VOICE 2
820: #define CHAN_ITEM 3
821: #define CHAN_BODY 4
822: // modifier flags
823: #define CHAN_NO_PHS_ADD 8 // send to all clients, not just ones in PHS (ATTN 0 will also do this)
824: #define CHAN_RELIABLE 16 // send by reliable message, not datagram
825:
826:
827: // sound attenuation values
828: #define ATTN_NONE 0 // full volume the entire level
829: #define ATTN_NORM 1
830: #define ATTN_IDLE 2
831: #define ATTN_STATIC 3 // diminish very rapidly with distance
832:
833:
834: // player_state->stats[] indexes
835: #define STAT_HEALTH_ICON 0
836: #define STAT_HEALTH 1
837: #define STAT_AMMO_ICON 2
838: #define STAT_AMMO 3
839: #define STAT_ARMOR_ICON 4
840: #define STAT_ARMOR 5
841: #define STAT_SELECTED_ICON 6
842: #define STAT_PICKUP_ICON 7
843: #define STAT_PICKUP_STRING 8
844: #define STAT_TIMER_ICON 9
845: #define STAT_TIMER 10
846: #define STAT_HELPICON 11
847: #define STAT_SELECTED_ITEM 12
848: #define STAT_LAYOUTS 13
849: #define STAT_FRAGS 14
850: #define STAT_FLASHES 15 // cleared each frame, 1 = health, 2 = armor
851:
852: #define MAX_STATS 32
853:
854:
855: // dmflags->value flags
856: #define DF_NO_HEALTH 1
857: #define DF_NO_ITEMS 2
858: #define DF_WEAPONS_STAY 4
859: #define DF_NO_FALLING 8
860: #define DF_INSTANT_ITEMS 16
861: #define DF_SAME_LEVEL 32
862: #define DF_SKINTEAMS 64
863: #define DF_MODELTEAMS 128
864: #define DF_NO_FRIENDLY_FIRE 256
865: #define DF_SPAWN_FARTHEST 512
866: #define DF_FORCE_RESPAWN 1024
867: #define DF_NO_ARMOR 2048
868: #define DF_ALLOW_EXIT 4096
869: #define DF_INFINITE_AMMO 8192
870: #define DF_QUAD_DROP 16384
871: #define DF_FIXED_FOV 32768
872:
873: /*
874: ==========================================================
875:
876: ELEMENTS COMMUNICATED ACROSS THE NET
877:
878: ==========================================================
879: */
880:
881: #define ANGLE2SHORT(x) ((int)((x)*65536/360) & 65535)
882: #define SHORT2ANGLE(x) ((x)*(360.0/65536))
883:
884:
885: //
886: // config strings are a general means of communication from
887: // the server to all connected clients.
888: // Each config string can be at most MAX_QPATH characters.
889: //
890: #define CS_NAME 0
891: #define CS_CDTRACK 1
892: #define CS_SKY 2
893: #define CS_SKYAXIS 3 // %f %f %f format
894: #define CS_SKYROTATE 4
895: #define CS_STATUSBAR 5 // display program string
896:
897: #define CS_MAXCLIENTS 30
898: #define CS_MAPCHECKSUM 31 // for catching cheater maps
899:
900: #define CS_MODELS 32
901: #define CS_SOUNDS (CS_MODELS+MAX_MODELS)
902: #define CS_IMAGES (CS_SOUNDS+MAX_SOUNDS)
903: #define CS_LIGHTS (CS_IMAGES+MAX_IMAGES)
904: #define CS_ITEMS (CS_LIGHTS+MAX_LIGHTSTYLES)
905: #define CS_PLAYERSKINS (CS_ITEMS+MAX_ITEMS)
906: #define CS_GENERAL (CS_PLAYERSKINS+MAX_CLIENTS)
907: #define MAX_CONFIGSTRINGS (CS_GENERAL+MAX_GENERAL)
908:
909:
910: //==============================================
911:
912:
913: // entity_state_t->event values
914: // ertity events are for effects that take place reletive
915: // to an existing entities origin. Very network efficient.
916: // All muzzle flashes really should be converted to events...
917: typedef enum
918: {
919: EV_NONE,
920: EV_ITEM_RESPAWN,
921: EV_FOOTSTEP,
922: EV_FALLSHORT,
923: EV_FALL,
924: EV_FALLFAR,
925: EV_PLAYER_TELEPORT,
926: EV_OTHER_TELEPORT
927: } entity_event_t;
928:
929:
930: // entity_state_t is the information conveyed from the server
931: // in an update message about entities that the client will
932: // need to render in some way
933: typedef struct entity_state_s
934: {
935: int number; // edict index
936:
937: vec3_t origin;
938: vec3_t angles;
939: vec3_t old_origin; // for lerping
940: int modelindex;
941: int modelindex2, modelindex3, modelindex4; // weapons, CTF flags, etc
942: int frame;
943: int skinnum;
944: int effects;
945: int renderfx;
946: int solid; // for client side prediction, 8*(bits 0-4) is x/y radius
947: // 8*(bits 5-9) is z down distance, 8(bits10-15) is z up
948: // gi.linkentity sets this properly
949: int sound; // for looping sounds, to guarantee shutoff
950: int event; // impulse events -- muzzle flashes, footsteps, etc
951: // events only go out for a single frame, they
952: // are automatically cleared each frame
953: } entity_state_t;
954:
955: //==============================================
956:
957:
958: // player_state_t is the information needed in addition to pmove_state_t
959: // to rendered a view. There will only be 10 player_state_t sent each second,
960: // but the number of pmove_state_t changes will be reletive to client
961: // frame rates
962: typedef struct
963: {
964: pmove_state_t pmove; // for prediction
965:
966: // these fields do not need to be communicated bit-precise
967:
968: vec3_t viewangles; // for fixed views
969: vec3_t viewoffset; // add to pmovestate->origin
970: vec3_t kick_angles; // add to view direction to get render angles
971: // set by weapon kicks, pain effects, etc
972:
973: vec3_t gunangles;
974: vec3_t gunoffset;
975: int gunindex;
976: int gunframe;
977:
978: float blend[4]; // rgba full screen effect
979:
980: float fov; // horizontal field of view
981:
982: int rdflags; // refdef flags
983:
984: short stats[MAX_STATS]; // fast status bar updates
985: } player_state_t;
986:
987:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.