home *** CD-ROM | disk | FTP | other *** search
/ Gambler 19 / GAMBLERCD19.BIN / UTILS / 3D / BRONIE / DUAL_LAU.ZIP / src / q_shared.h < prev   
C/C++ Source or Header  |  1997-11-25  |  27KB  |  934 lines

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