1 /*
2 ===========================================================================
3 
4 Return to Castle Wolfenstein single player GPL Source Code
5 Copyright (C) 1999-2010 id Software LLC, a ZeniMax Media company.
6 
7 This file is part of the Return to Castle Wolfenstein single player GPL Source Code (“RTCW SP Source Code”).
8 
9 RTCW SP Source Code is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13 
14 RTCW SP Source Code is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 GNU General Public License for more details.
18 
19 You should have received a copy of the GNU General Public License
20 along with RTCW SP Source Code.  If not, see <http://www.gnu.org/licenses/>.
21 
22 In addition, the RTCW SP Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the RTCW SP Source Code.  If not, please request a copy in writing from id Software at the address below.
23 
24 If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
25 
26 ===========================================================================
27 */
28 
29 /*
30  * name:	cg_local.h
31  *
32  * desc:	The entire cgame module is unloaded and reloaded on each level change,
33  *			so there is NO persistant data between levels on the client side.
34  *			If you absolutely need something stored, it can either be kept
35  *			by the server in the server stored userinfos, or stashed in a cvar.
36 
37  *
38 */
39 
40 #include "../qcommon/q_shared.h"
41 #include "../renderer/tr_types.h"
42 #include "../game/bg_public.h"
43 #include "cg_public.h"
44 
45 
46 #define POWERUP_BLINKS      5
47 
48 #define POWERUP_BLINK_TIME  1000
49 #define FADE_TIME           200
50 #define PULSE_TIME          200
51 #define DAMAGE_DEFLECT_TIME 100
52 #define DAMAGE_RETURN_TIME  400
53 #define DAMAGE_TIME         500
54 #define LAND_DEFLECT_TIME   150
55 #define LAND_RETURN_TIME    300
56 #define STEP_TIME           200
57 #define DUCK_TIME           100
58 #define PAIN_TWITCH_TIME    200
59 #define WEAPON_SELECT_TIME  1400
60 #define HOLDABLE_SELECT_TIME 1400   //----(SA)	for drawing holdable icons
61 #define ITEM_SCALEUP_TIME   1000
62 #define ZOOM_TIME           150
63 #define ITEM_BLOB_TIME      200
64 #define MUZZLE_FLASH_TIME   30      //----(SA)
65 #define SINK_TIME           1000        // time for fragments to sink into ground before going away
66 #define ATTACKER_HEAD_TIME  10000
67 #define REWARD_TIME         3000
68 
69 #define PULSE_SCALE         1.5         // amount to scale up the icons when activating
70 
71 #define MAX_STEP_CHANGE     32
72 
73 #define MAX_VERTS_ON_POLY   10
74 #define MAX_MARK_POLYS      1024
75 
76 #define STAT_MINUS          10  // num frame for '-' stats digit
77 
78 #define ICON_SIZE           48
79 #define CHAR_WIDTH          32
80 #define CHAR_HEIGHT         48
81 #define TEXT_ICON_SPACE     4
82 
83 #define TEAMCHAT_WIDTH      80
84 #define TEAMCHAT_HEIGHT     8
85 
86 // very large characters
87 #define GIANT_WIDTH         32
88 #define GIANT_HEIGHT        48
89 
90 #define NUM_CROSSHAIRS      10
91 
92 // Ridah, trails
93 #define STYPE_STRETCH   0
94 #define STYPE_REPEAT    1
95 
96 #define TJFL_FADEIN     ( 1 << 0 )
97 #define TJFL_CROSSOVER  ( 1 << 1 )
98 #define TJFL_NOCULL     ( 1 << 2 )
99 #define TJFL_FIXDISTORT ( 1 << 3 )
100 #define TJFL_SPARKHEADFLARE ( 1 << 4 )
101 #define TJFL_NOPOLYMERGE    ( 1 << 5 )
102 // done.
103 
104 // NERVE - SMF - limbo mode 3d view position
105 #define LIMBO_3D_X  10
106 #define LIMBO_3D_Y  120
107 #define LIMBO_3D_W  420
108 #define LIMBO_3D_H  330
109 // -NERVE - SMF
110 
111 //=================================================
112 
113 // player entities need to track more information
114 // than any other type of entity.
115 
116 // note that not every player entity is a client entity,
117 // because corpses after respawn are outside the normal
118 // client numbering range
119 
120 // when changing animation, set animationTime to frameTime + lerping time
121 // The current lerp will finish out, then it will lerp to the new animation
122 typedef struct {
123 	int oldFrame;
124 	int oldFrameTime;               // time when ->oldFrame was exactly on
125 
126 	int frame;
127 	int frameTime;                  // time when ->frame will be exactly on
128 
129 	float backlerp;
130 
131 	float yawAngle;
132 	qboolean yawing;
133 	float pitchAngle;
134 	qboolean pitching;
135 
136 	int animationNumber;            // may include ANIM_TOGGLEBIT
137 	int oldAnimationNumber;         // may include ANIM_TOGGLEBIT
138 	animation_t *animation;
139 	int animationTime;              // time when the first frame of the animation will be exact
140 
141 	// Ridah, variable speed anims
142 	vec3_t oldFramePos;
143 	float animSpeedScale;
144 	int oldFrameSnapshotTime;
145 	headAnimation_t *headAnim;
146 	// done.
147 
148 	animation_t *cgAnim;    // pointer to the root of the animation array to use (*animation above points at the current sequence)	//----(SA)	added
149 } lerpFrame_t;
150 
151 // Ridah, effect defines
152 #define MAX_ZOMBIE_SPIRITS          4
153 #define MAX_ZOMBIE_DEATH_TRAILS     16
154 
155 #define MAX_LOPER_LIGHTNING_POINTS  24
156 
157 #define MAX_TESLA_BOLTS             4
158 
159 #define MAX_EFFECT_ENTS             20
160 
161 typedef struct {
162 	lerpFrame_t legs, torso;
163 
164 	// Ridah, talking animations
165 	lerpFrame_t head;
166 	// done.
167 
168 	lerpFrame_t weap;       //----(SA)	autonomous weapon animations
169 
170 	int lastTime;                   // last time we were processed/ If the time goes backwards, reset.
171 
172 	int painTime;
173 	int painDuration;
174 	int painDirection;              // flip from 0 to 1
175 	int painAnimTorso;
176 	int painAnimLegs;
177 	int lightningFiring;
178 
179 	int	railFireTime;
180 
181 	// machinegun spinning
182 	float barrelAngle;
183 	int barrelTime;
184 	qboolean barrelSpinning;
185 
186 	//----(SA) machinegun bolt sliding
187 	float boltPosition;
188 	int boltTime;
189 	int boltSliding;
190 	//----(SA) end
191 
192 	//----(SA) 'spinner' spinning (body part)
193 	float spinnerAngle;
194 	int spinnerTime;
195 	qboolean spinnerSpinning;
196 	//----(SA)	end
197 
198 	// Ridah, so we can do fast tag grabbing
199 	refEntity_t legsRefEnt, torsoRefEnt, headRefEnt, gunRefEnt;
200 	int gunRefEntFrame;
201 
202 	float animSpeed;            // for manual adjustment
203 
204 	// Zombie spirit effect
205 	// !!FIXME: these effects will be restarted by a *_restart command, can we save this data somehow?
206 	qboolean cueZombieSpirit;               // if this is qfalse, and the zombie effect flag is set, then we need to start a new attack
207 	int zombieSpiritStartTime;              // time the effect was started, so we can fade things in
208 	int zombieSpiritTrailHead[MAX_ZOMBIE_SPIRITS];
209 	int zombieSpiritRotationTimes[MAX_ZOMBIE_SPIRITS];
210 	int zombieSpiritRadiusCycleTimes[MAX_ZOMBIE_SPIRITS];
211 	int lastZombieSpirit;
212 	int nextZombieSpiritSound;
213 	int zombieSpiritEndTime;                // time the effect was disabled
214 	vec3_t zombieSpiritPos[MAX_ZOMBIE_SPIRITS];
215 	vec3_t zombieSpiritDir[MAX_ZOMBIE_SPIRITS];
216 	float zombieSpiritSpeed[MAX_ZOMBIE_SPIRITS];
217 	int zombieSpiritStartTimes[MAX_ZOMBIE_SPIRITS];
218 
219 	// Zombie death effect
220 	// !!FIXME: these effects will be restarted by a *_restart command, can we save this data somehow?
221 	qboolean cueZombieDeath;            // if this is qfalse, and the zombie effect flag is set, then we need to start a new attack
222 	int zombieDeathStartTime;               // time the effect was started, so we can fade things in
223 	int zombieDeathEndTime;             // time the effect was disabled
224 	int lastZombieDeath;
225 	int zombieDeathFadeStart;
226 	int zombieDeathFadeEnd;
227 	int zombieDeathTrailHead[MAX_ZOMBIE_DEATH_TRAILS];
228 	int zombieDeathRotationTimes[MAX_ZOMBIE_DEATH_TRAILS];
229 	int zombieDeathRadiusCycleTimes[MAX_ZOMBIE_DEATH_TRAILS];
230 
231 	// loper effects
232 	int loperLastGroundChargeTime;
233 	byte loperGroundChargeToggle;
234 	int loperGroundValidTime;
235 
236 	vec3_t headLookIdeal;
237 	vec3_t headLookOffset;
238 	float headLookSpeed;
239 	int headLookStopTime;
240 	float headLookSpeedMax;
241 
242 	// tesla coil effects
243 	vec3_t teslaEndPoints[MAX_TESLA_BOLTS];
244 	int teslaEndPointTimes[MAX_TESLA_BOLTS];            // time the bolt stays valid
245 	vec3_t teslaOffsetDirs[MAX_TESLA_BOLTS];            // bending direction from center or direct beam
246 	float teslaOffsets[MAX_TESLA_BOLTS];                // amount to offset from center
247 	int teslaOffsetTimes[MAX_TESLA_BOLTS];              // time the offset stays valid
248 	int teslaEnemy[MAX_TESLA_BOLTS];
249 	int teslaDamageApplyTime;
250 
251 	int teslaDamagedTime;                   // time we were last hit by a tesla bolt
252 
253 	// misc effects
254 	int effectEnts[MAX_EFFECT_ENTS];
255 	int numEffectEnts;
256 	int effect1EndTime;
257 	vec3_t lightningPoints[MAX_LOPER_LIGHTNING_POINTS];
258 	int lightningTimes[MAX_LOPER_LIGHTNING_POINTS];
259 	int lightningSoundTime;
260 
261 	qboolean forceLOD;
262 
263 } playerEntity_t;
264 
265 //----(SA)
266 typedef struct {
267 	char type[MAX_QPATH];           // md3_lower, md3_lbelt, md3_rbelt, etc.
268 	char model[MAX_QPATH];          // lower.md3, belt1.md3, etc.
269 } skinModel_t;
270 //----(SA) end
271 
272 
273 //=================================================
274 
275 
276 
277 // centity_t have a direct corespondence with gentity_t in the game, but
278 // only the entityState_t is directly communicated to the cgame
279 typedef struct centity_s {
280 	entityState_t currentState;     // from cg.frame
281 	entityState_t nextState;        // from cg.nextFrame, if available
282 	qboolean interpolate;           // true if next is valid to interpolate to
283 	qboolean currentValid;          // true if cg.frame holds this entity
284 
285 	int muzzleFlashTime;                // move to playerEntity?
286 	int overheatTime;
287 	int previousEvent;
288 	int previousEventSequence;              // Ridah
289 	int teleportFlag;
290 
291 	int trailTime;                  // so missile trails can handle dropped initial packets
292 	int miscTime;
293 
294 	playerEntity_t pe;
295 
296 	int errorTime;                  // decay the error from this time
297 	vec3_t errorOrigin;
298 	vec3_t errorAngles;
299 
300 	qboolean extrapolated;          // false if origin / angles is an interpolation
301 	vec3_t rawOrigin;
302 	vec3_t rawAngles;
303 
304 	vec3_t beamEnd;
305 
306 	// exact interpolated position of entity on this frame
307 	vec3_t lerpOrigin;
308 	vec3_t lerpAngles;
309 
310 	vec3_t lastLerpAngles;          // (SA) for remembering the last position when a state changes
311 
312 	// Ridah, trail effects
313 	int headJuncIndex, headJuncIndex2;
314 	int lastTrailTime;
315 	// done.
316 
317 	// Ridah
318 	float loopSoundVolume;
319 	vec3_t fireRiseDir;             // if standing still this will be up, otherwise it'll point away from movement dir
320 	int lastWeaponClientFrame;
321 	int lastFuseSparkTime;
322 	vec3_t lastFuseSparkOrg;
323 
324 	// client side dlights
325 	int dl_frame;
326 	int dl_oldframe;
327 	float dl_backlerp;
328 	int dl_time;
329 	char dl_stylestring[64];
330 	int dl_sound;
331 	int dl_atten;
332 
333 	lerpFrame_t lerpFrame;      //----(SA)	added
334 	vec3_t highlightOrigin;             // center of the geometry.  for things like corona placement on treasure
335 	qboolean usehighlightOrigin;
336 
337 	refEntity_t refEnt;
338 	int processedFrame;                 // frame we were last added to the scene
339 
340 	// client-side lightning
341 	int boltTimes[MAX_TESLA_BOLTS];
342 	vec3_t boltLocs[MAX_TESLA_BOLTS];
343 	vec3_t boltCrawlDirs[MAX_TESLA_BOLTS];
344 
345 	// item highlighting
346 
347 	int highlightTime;
348 	qboolean highlighted;
349 
350 	animation_t centAnim[2];
351 
352 	// (SA) added to help akimbo effects attach to the correct model
353 	qboolean akimboFire;
354 } centity_t;
355 
356 
357 //======================================================================
358 
359 // local entities are created as a result of events or predicted actions,
360 // and live independantly from all server transmitted entities
361 
362 typedef struct markPoly_s {
363 	struct markPoly_s   *prevMark, *nextMark;
364 	int time;
365 	qhandle_t markShader;
366 	qboolean alphaFade;         // fade alpha instead of rgb
367 	float color[4];
368 	poly_t poly;
369 	polyVert_t verts[MAX_VERTS_ON_POLY];
370 
371 	int duration;           // Ridah
372 } markPoly_t;
373 
374 //----(SA)	moved in from cg_view.c
375 typedef enum {
376 	ZOOM_NONE,
377 	ZOOM_BINOC,
378 	ZOOM_SNIPER,
379 	ZOOM_SNOOPER,
380 	ZOOM_FG42SCOPE,
381 	ZOOM_MG42,
382 	ZOOM_MAX_ZOOMS
383 } EZoom_t;
384 
385 typedef enum {
386 	ZOOM_OUT,   // widest angle
387 	ZOOM_IN // tightest angle (approaching 0)
388 } EZoomInOut_t;
389 
390 extern float zoomTable[ZOOM_MAX_ZOOMS][2];
391 
392 //----(SA)	end
393 
394 typedef enum {
395 	LE_MARK,
396 	LE_EXPLOSION,
397 	LE_SPRITE_EXPLOSION,
398 	LE_FRAGMENT,
399 	LE_MOVE_SCALE_FADE,
400 	LE_FALL_SCALE_FADE,
401 	LE_FADE_RGB,
402 	LE_SCALE_FADE,
403 	LE_SPARK,
404 	LE_DEBRIS,
405 	LE_BLOOD,
406 	LE_FUSE_SPARK,
407 	LE_ZOMBIE_SPIRIT,
408 	LE_HELGA_SPIRIT,
409 	LE_ZOMBIE_BAT,
410 	LE_MOVING_TRACER,
411 	LE_EMITTER,
412 	LE_SPIRIT_VIEWFLASH
413 } leType_t;
414 
415 typedef enum {
416 	LEF_PUFF_DONT_SCALE  = 0x0001           // do not scale size over time
417 	,LEF_TUMBLE          = 0x0002           // tumble over time, used for ejecting shells
418 	,LEF_NOFADEALPHA     = 0x0004           // Ridah, sparks
419 	,LEF_SMOKING         = 0x0008           // (SA) smoking
420 	,LEF_NOTOUCHPARENT   = 0x0010           // (SA) when tracing to eval trajectory, ignore parent cent
421 	,LEF_PLAYER_DAMAGE   = 0x0020           // hurt the player on impact
422 } leFlag_t;
423 
424 typedef enum {
425 	LEMT_NONE,
426 	LEMT_BLOOD
427 } leMarkType_t;         // fragment local entities can leave marks on walls
428 
429 typedef enum {
430 	LEBS_NONE,
431 	LEBS_BLOOD,
432 	LEBS_ROCK,
433 	LEBS_WOOD,
434 	LEBS_BRASS,
435 	LEBS_BONE
436 } leBounceSoundType_t;  // fragment local entities can make sounds on impacts
437 
438 #define MAX_OLD_POS     3
439 
440 typedef struct localEntity_s {
441 	struct localEntity_s    *prev, *next;
442 	leType_t leType;
443 	int leFlags;
444 
445 	int startTime;
446 	int endTime;
447 	int fadeInTime;
448 
449 	float lifeRate;                     // 1.0 / (endTime - startTime)
450 
451 	trajectory_t pos;
452 	trajectory_t angles;
453 
454 	float bounceFactor;                 // 0.0 = no bounce, 1.0 = perfect
455 
456 	float color[4];
457 
458 	float radius;
459 
460 	float light;
461 	vec3_t lightColor;
462 
463 	leMarkType_t leMarkType;            // mark to leave on fragment impact
464 	leBounceSoundType_t leBounceSoundType;
465 
466 	refEntity_t refEntity;
467 
468 	// Ridah
469 	int lightOverdraw;
470 	int lastTrailTime;
471 	int headJuncIndex, headJuncIndex2;
472 	float effectWidth;
473 	int effectFlags;
474 	struct localEntity_s    *chain;     // used for grouping entities (like for flamethrower junctions)
475 	int onFireStart, onFireEnd;
476 	int ownerNum;
477 	int lastSpiritDmgTime;
478 
479 	int loopingSound;
480 
481 	int breakCount;                     // break-up this many times before we can break no more
482 	float sizeScale;
483 
484 	char validOldPos[MAX_OLD_POS];
485 	vec3_t oldPos[MAX_OLD_POS];
486 	int oldPosHead;
487 	// done.
488 
489 } localEntity_t;
490 
491 //======================================================================
492 
493 
494 typedef struct {
495 	int client;
496 	int score;
497 	int ping;
498 	int time;
499 	int scoreFlags;
500 	int powerUps;
501 	int accuracy;
502 	int impressiveCount;
503 	int excellentCount;
504 	int guantletCount;
505 	int defendCount;
506 	int assistCount;
507 	int captures;
508 	qboolean perfect;
509 	int team;
510 } score_t;
511 
512 
513 typedef enum {
514 	ACC_BELT_LEFT,  // belt left (lower)
515 	ACC_BELT_RIGHT, // belt right (lower)
516 	ACC_BELT,       // belt (upper)
517 	ACC_BACK,       // back (upper)
518 	ACC_WEAPON,     // weapon (upper)
519 	ACC_WEAPON2,    // weapon2 (upper)
520 	ACC_HAT,        // hat (head)
521 	ACC_MOUTH2,     //
522 	ACC_MOUTH3,     //
523 	//
524 	ACC_MAX     // this is bound by network limits, must change network stream to increase this
525 				// (SA) No, really?  that's not true is it?  isn't this client-side only?
526 } accType_t;
527 
528 #define ACC_NUM_MOUTH 3 // matches the above count (hat/mouth2/mouth3)
529 
530 
531 
532 
533 // each client has an associated clientInfo_t
534 // that contains media references necessary to present the
535 // client model and other color coded effects
536 // this is regenerated each time a client's configstring changes,
537 // usually as a result of a userinfo (name, model, etc) change
538 #define MAX_CUSTOM_SOUNDS   32
539 #define MAX_GIB_MODELS      16
540 typedef struct {
541 	qboolean infoValid;
542 
543 	int clientNum;
544 
545 	char name[MAX_QPATH];
546 	team_t team;
547 
548 	int botSkill;                   // 0 = not bot, 1-5 = bot
549 
550 	vec3_t color;
551 
552 	byte c1RGBA[4];
553 
554 	int score;                      // updated by score servercmds
555 	int location;                   // location index for team mode
556 	int health;                     // you only get this info about your teammates
557 	int armor;
558 	int curWeapon;
559 
560 	int handicap;
561 	int wins, losses;               // in tourney mode
562 
563 	int powerups;                   // so can display quad/flag status
564 
565 	int breathPuffTime;
566 
567 	// when clientinfo is changed, the loading of models/skins/sounds
568 	// can be deferred until you are dead, to prevent hitches in
569 	// gameplay
570 	char modelName[MAX_QPATH];
571 	char skinName[MAX_QPATH];
572 	char hSkinName[MAX_QPATH];
573 	qboolean deferred;
574 
575 	qhandle_t legsModel;
576 	qhandle_t legsSkin;
577 
578 	qhandle_t torsoModel;
579 	qhandle_t torsoSkin;
580 
581 	qboolean isSkeletal;
582 
583 	//----(SA) added accessory models/skins for belts/backpacks/etc.
584 	qhandle_t accModels[ACC_MAX];       // see def of ACC_MAX for index descriptions
585 	qhandle_t accSkins[ACC_MAX];        // FIXME: put the #define for number of accessory models somewhere. (SA)
586 
587 	//----(SA)	additional parts for specialized characters (the loper's spinning trunk for example)
588 	qhandle_t partModels[9];        // [0-7] are optionally called in scripts, [8] is reserved for internal use
589 	qhandle_t partSkins[9];
590 	//----(SA)	end
591 
592 	qhandle_t headModel;
593 	qhandle_t headSkin;
594 
595 	qhandle_t modelIcon;
596 
597 	// RF, may be shared by multiple clients/characters
598 	animModelInfo_t *modelInfo;
599 
600 	sfxHandle_t sounds[MAX_CUSTOM_SOUNDS];
601 
602 	qhandle_t gibModels[MAX_GIB_MODELS];
603 
604 	vec3_t playermodelScale;            //----(SA)	set in the skin.  client-side only
605 
606 	int blinkTime;              //----(SA)
607 } clientInfo_t;
608 
609 
610 
611 typedef enum {
612 	W_PART_1,
613 	W_PART_2,
614 	W_PART_3,
615 	W_PART_4,
616 	W_PART_5,
617 	W_PART_6,
618 	W_PART_7,
619 	W_MAX_PARTS
620 } barrelType_t;
621 
622 typedef enum {
623 	W_TP_MODEL,         //	third person model
624 	W_FP_MODEL,         //	first person model
625 	W_PU_MODEL,         //	pickup model
626 	W_FP_MODEL_SWAP,    //	swap out model
627 	W_SKTP_MODEL,       //	SKELETAL version third person model
628 	W_NUM_TYPES
629 } modelViewType_t;
630 
631 // each WP_* weapon enum has an associated weaponInfo_t
632 // that contains media references necessary to present the
633 // weapon and its effects
634 typedef struct weaponInfo_s {
635 	qboolean registered;
636 	gitem_t         *item;
637 
638 //----(SA)	weapon animation sequences loaded from the weapon.cfg
639 	animation_t weapAnimations[MAX_WP_ANIMATIONS];
640 //----(SA)	end
641 
642 	qhandle_t handsModel;               // the hands don't actually draw, they just position the weapon
643 
644 	qhandle_t standModel;               // not drawn.  tags used for positioning weapons for pickup
645 
646 //----(SA) mod for 1st/3rd person weap views
647 	qhandle_t weaponModel[W_NUM_TYPES];
648 	qhandle_t wpPartModels[W_NUM_TYPES][W_MAX_PARTS];
649 	qhandle_t flashModel[W_NUM_TYPES];
650 	qhandle_t modModel[W_NUM_TYPES];        // like the scope for the rifles
651 //----(SA) end
652 
653 	pose_t position;                    // wolf locations (high, low, knife, pistol, shoulder, throw)  defines are WPOS_HIGH, WPOS_LOW, WPOS_KNIFE, WPOS_PISTOL, WPOS_SHOULDER, WPOS_THROW
654 
655 	vec3_t weaponMidpoint;              // so it will rotate centered instead of by tag
656 
657 	float flashDlight;
658 	vec3_t flashDlightColor;
659 	sfxHandle_t flashSound[4];          // fast firing weapons randomly choose
660 	sfxHandle_t flashEchoSound[4];      //----(SA)	added - distant gun firing sound
661 	sfxHandle_t lastShotSound[4];       // sound of the last shot can be different (mauser doesn't have bolt action on last shot for example)
662 
663 	sfxHandle_t switchSound[4];     //----(SA)	added
664 
665 	qhandle_t weaponIcon[2];            //----(SA)	[0] is weap icon, [1] is highlight icon
666 	qhandle_t ammoIcon;
667 
668 	qhandle_t ammoModel;
669 
670 	qhandle_t missileModel;
671 	sfxHandle_t missileSound;
672 	void ( *missileTrailFunc )( centity_t *, const struct weaponInfo_s *wi );
673 	float missileDlight;
674 	vec3_t missileDlightColor;
675 	int missileRenderfx;
676 
677 	void ( *ejectBrassFunc )( centity_t * );
678 
679 	float trailRadius;
680 	float wiTrailTime;
681 
682 	sfxHandle_t readySound;             // an amibient sound the weapon makes when it's /not/ firing
683 	sfxHandle_t firingSound;
684 	sfxHandle_t overheatSound;
685 	sfxHandle_t reloadSound;
686 
687 	sfxHandle_t spinupSound;        //----(SA)	added // sound started when fire button goes down, and stepped on when the first fire event happens
688 	sfxHandle_t spindownSound;      //----(SA)	added // sound called if the above is running but player doesn't follow through and fire
689 } weaponInfo_t;
690 
691 
692 // each IT_* item has an associated itemInfo_t
693 // that constains media references necessary to present the
694 // item and its effects
695 typedef struct {
696 	qboolean registered;
697 	qhandle_t models[MAX_ITEM_MODELS];
698 	qhandle_t icons[MAX_ITEM_ICONS];
699 } itemInfo_t;
700 
701 
702 typedef struct {
703 	int itemNum;
704 } powerupInfo_t;
705 
706 #define MAX_VIEWDAMAGE  8
707 typedef struct {
708 	int damageTime, damageDuration;
709 	float damageX, damageY, damageValue;
710 } viewDamage_t;
711 
712 #define MAX_CAMERA_SHAKE    4
713 typedef struct {
714 	int time;
715 	float scale;
716 	float length;
717 	float radius;
718 	vec3_t src;
719 } cameraShake_t;
720 
721 //======================================================================
722 
723 // all cg.stepTime, cg.duckTime, cg.landTime, etc are set to cg.time when the action
724 // occurs, and they will have visible effects for #define STEP_TIME or whatever msec after
725 
726 #define MAX_PREDICTED_EVENTS    16
727 
728 typedef struct {
729 	int clientFrame;                // incremented each frame
730 
731 	int clientNum;
732 
733 	qboolean demoPlayback;
734 	qboolean levelShot;             // taking a level menu screenshot
735 	int deferredPlayerLoading;
736 	qboolean loading;               // don't defer players at initial startup
737 	qboolean intermissionStarted;       // don't play voice rewards, because game will end shortly
738 
739 	// there are only one or two snapshot_t that are relevent at a time
740 	int latestSnapshotNum;          // the number of snapshots the client system has received
741 	int latestSnapshotTime;         // the time from latestSnapshotNum, so we don't need to read the snapshot yet
742 
743 	snapshot_t  *snap;              // cg.snap->serverTime <= cg.time
744 	snapshot_t  *nextSnap;          // cg.nextSnap->serverTime > cg.time, or NULL
745 	snapshot_t activeSnapshots[2];
746 
747 	float frameInterpolation;       // (float)( cg.time - cg.frame->serverTime ) / (cg.nextFrame->serverTime - cg.frame->serverTime)
748 
749 	qboolean thisFrameTeleport;
750 	qboolean nextFrameTeleport;
751 
752 	int frametime;              // cg.time - cg.oldTime
753 
754 	int time;                   // this is the time value that the client
755 								// is rendering at.
756 	int oldTime;                // time at last frame, used for missile trails and prediction checking
757 
758 	int physicsTime;            // either cg.snap->time or cg.nextSnap->time
759 
760 	int timelimitWarnings;          // 5 min, 1 min, overtime
761 	int fraglimitWarnings;
762 
763 	qboolean mapRestart;            // set on a map restart to set back the weapon
764 
765 	qboolean renderingThirdPerson;          // during deaths, chasecams, etc
766 
767 	// prediction state
768 	qboolean hyperspace;                // true if prediction has hit a trigger_teleport
769 	playerState_t predictedPlayerState;
770 	centity_t predictedPlayerEntity;
771 	qboolean validPPS;                  // clear until the first call to CG_PredictPlayerState
772 	int predictedErrorTime;
773 	vec3_t predictedError;
774 
775 	int eventSequence;
776 	int predictableEvents[MAX_PREDICTED_EVENTS];
777 
778 	float stepChange;                   // for stair up smoothing
779 	int stepTime;
780 
781 	float duckChange;                   // for duck viewheight smoothing
782 	int duckTime;
783 
784 	float landChange;                   // for landing hard
785 	int landTime;
786 
787 	// input state sent to server
788 	int weaponSelect;
789 	int holdableSelect;                 // (SA) which holdable item is currently held ("selected").  When the client is ready to use it, send "use item <holdableSelect>"
790 
791 	// auto rotating items
792 	vec3_t autoAnglesSlow;
793 	vec3_t autoAxisSlow[3];
794 	vec3_t autoAngles;
795 	vec3_t autoAxis[3];
796 	vec3_t autoAnglesFast;
797 	vec3_t autoAxisFast[3];
798 
799 	// view rendering
800 	refdef_t refdef;
801 	vec3_t refdefViewAngles;	// will be converted to refdef.viewaxis
802 	float fov;			// either range checked cg_fov or forced value
803 
804 	// zoom key
805 	qboolean zoomed;
806 	qboolean zoomedBinoc;
807 	int zoomedScope;            //----(SA)	changed to int
808 	int zoomTime;
809 	float zoomSensitivity;
810 	float zoomval;
811 
812 
813 	// information screen text during loading
814 	char infoScreenText[MAX_STRING_CHARS];
815 
816 	// scoreboard
817 	int scoresRequestTime;
818 	int numScores;
819 	int selectedScore;
820 	int teamScores[2];
821 	score_t scores[MAX_CLIENTS];
822 	qboolean showScores;
823 	qboolean scoreBoardShowing;
824 	int scoreFadeTime;
825 	char killerName[MAX_NAME_LENGTH];
826 	char spectatorList[MAX_STRING_CHARS];                   // list of names
827 	int spectatorLen;                                                           // length of list
828 	float spectatorWidth;                                                   // width in device units
829 	int spectatorTime;                                                      // next time to offset
830 	int spectatorPaintX;                                                    // current paint x
831 	int spectatorPaintX2;                                                   // current paint x
832 	int spectatorOffset;                                                    // current offset from start
833 	int spectatorPaintLen;                                              // current offset from start
834 
835 	qboolean showItems;
836 	int itemFadeTime;
837 
838 	qboolean lightstylesInited;
839 
840 	// centerprinting
841 	int centerPrintTime;
842 	int centerPrintCharWidth;
843 	int centerPrintY;
844 	char centerPrint[1024];
845 	int centerPrintLines;
846 
847 	// fade in/out
848 	int fadeTime;
849 	float fadeRate;
850 	vec4_t fadeColor1;
851 	vec4_t fadeColor2;
852 
853 //----(SA)	added
854 	// game stats
855 	int exitStatsTime;
856 	int exitStatsFade;
857 	// just a copy of what's on the server, updated by configstring.  better way to communicate/store this I'm sure
858 	int playTimeH;
859 	int playTimeM;
860 	int playTimeS;
861 	int attempts;
862 	int numObjectives;
863 	int numObjectivesFound;
864 	int numSecrets;
865 	int numSecretsFound;
866 	int numTreasure;
867 	int numTreasureFound;
868 	int numArtifacts;
869 	int numArtifactsFound;
870 //----(SA)	end
871 
872 
873 	// low ammo warning state
874 	int lowAmmoWarning;             // 1 = low, 2 = empty
875 
876 	// crosshair client ID
877 	int crosshairClientNum;
878 	int crosshairClientTime;
879 
880 	int crosshairPowerupNum;
881 	int crosshairPowerupTime;
882 
883 //----(SA)	added
884 	// cursorhints
885 	int cursorHintIcon;
886 	int cursorHintTime;
887 	int cursorHintFade;
888 	int cursorHintValue;
889 //----(SA)	end
890 
891 	// powerup active flashing
892 	int powerupActive;
893 	int powerupTime;
894 
895 	// attacking player
896 	int attackerTime;
897 	int voiceTime;
898 
899 	// reward medals
900 	int rewardTime;
901 	int rewardCount;
902 	qhandle_t rewardShader;
903 
904 	// warmup countdown
905 	int warmup;
906 	int warmupCount;
907 
908 	// message icon popup time	//----(SA)	added
909 	int yougotmailTime;
910 
911 	//==========================
912 
913 	int itemPickup;
914 	int itemPickupTime;
915 	int itemPickupBlendTime;            // the pulse around the crosshair is timed seperately
916 
917 	int holdableSelectTime;             //----(SA)	for holdable item icon drawing
918 
919 	int weaponSelectTime;
920 	int weaponAnimation;
921 	int weaponAnimationTime;
922 
923 	// blend blobs
924 	viewDamage_t viewDamage[MAX_VIEWDAMAGE];
925 	float damageTime;           // last time any kind of damage was recieved
926 	int damageIndex;            // slot that was filled in
927 	float damageX, damageY, damageValue;
928 	float viewFade;
929 
930 	int grenLastTime;
931 
932 	int switchbackWeapon;
933 	int lastFiredWeapon;
934 	int lastWeapSelInBank[MAX_WEAP_BANKS];          // remember which weapon was last selected in a bank for 'weaponbank' commands //----(SA)	added
935 // JPW FIXME NOTE: max_weap_banks > max_weap_banks_mp so this should be OK, but if that changes, change this too
936 
937 	// status bar head
938 	float headYaw;
939 	float headEndPitch;
940 	float headEndYaw;
941 	int headEndTime;
942 	float headStartPitch;
943 	float headStartYaw;
944 	int headStartTime;
945 
946 	// view movement
947 	float v_dmg_time;
948 	float v_dmg_pitch;
949 	float v_dmg_roll;
950 
951 	// RF, view flames when getting burnt
952 	int v_fireTime, v_noFireTime;
953 	vec3_t v_fireRiseDir;
954 
955 	// temp working variables for player view
956 	float bobfracsin;
957 	int bobcycle;
958 	float xyspeed;
959 	int nextOrbitTime;
960 
961 	// development tool
962 	refEntity_t testModelEntity;
963 	char testModelName[MAX_QPATH];
964 	qboolean testGun;
965 
966 	// RF, new kick angles
967 	vec3_t kickAVel;            // for damage feedback, weapon recoil, etc
968 								// This is the angular velocity, to give a smooth
969 								// rotational feedback, rather than sudden jerks
970 	vec3_t kickAngles;          // for damage feedback, weapon recoil, etc
971 								// NOTE: this is not transmitted through MSG.C stream
972 								// since weapon kicks are client-side, and damage feedback
973 								// is rare enough that we can transmit that as an event
974 	float recoilPitch, recoilPitchAngle;
975 
976 	// Duffy
977 	qboolean cameraMode;        // if rendering from a camera
978 	// Duffy end
979 
980 	unsigned int cld;
981 	qboolean limboMenu;
982 
983 	int oidTeam;
984 	int oidPrintTime;
985 	int oidPrintCharWidth;
986 	int oidPrintY;
987 	char oidPrint[1024];
988 	int oidPrintLines;
989 
990 	cameraShake_t cameraShake[MAX_CAMERA_SHAKE];
991 	float cameraShakePhase;
992 	vec3_t cameraShakeAngles;
993 
994 	float rumbleScale;          //RUMBLE FX using new shakeCamera code
995 
996 } cg_t;
997 
998 #define NUM_FUNNEL_SPRITES  21
999 #define MAX_LOCKER_DEBRIS   5
1000 
1001 // all of the model, shader, and sound references that are
1002 // loaded at gamestate time are stored in cgMedia_t
1003 // Other media that can be tied to clients, weapons, or items are
1004 // stored in the clientInfo_t, itemInfo_t, weaponInfo_t, and powerupInfo_t
1005 typedef struct {
1006 	qhandle_t charsetShader;
1007 	// JOSEPH 4-17-00
1008 	qhandle_t menucharsetShader;
1009 	// END JOSEPH
1010 	qhandle_t charsetProp;
1011 	qhandle_t charsetPropGlow;
1012 	qhandle_t charsetPropB;
1013 	qhandle_t whiteShader;
1014 
1015 	qhandle_t redFlagModel;
1016 	qhandle_t blueFlagModel;
1017 
1018 	qhandle_t armorModel;
1019 
1020 	qhandle_t teamStatusBar;
1021 
1022 	qhandle_t deferShader;
1023 
1024 	// gib explosions
1025 	qhandle_t gibAbdomen;
1026 	qhandle_t gibArm;
1027 	qhandle_t gibChest;
1028 	qhandle_t gibFist;
1029 	qhandle_t gibFoot;
1030 	qhandle_t gibForearm;
1031 	qhandle_t gibIntestine;
1032 	qhandle_t gibLeg;
1033 	qhandle_t gibSkull;
1034 	qhandle_t gibBrain;
1035 
1036 	// debris
1037 	qhandle_t debBlock[6];
1038 	qhandle_t debRock[3];
1039 	qhandle_t debFabric[3];
1040 	qhandle_t debWood[6];
1041 
1042 	qhandle_t targetEffectExplosionShader;
1043 
1044 	qhandle_t machinegunBrassModel;
1045 	qhandle_t panzerfaustBrassModel;    //----(SA)	added
1046 
1047 	// Rafael
1048 	qhandle_t smallgunBrassModel;
1049 
1050 	qhandle_t shotgunBrassModel;
1051 
1052 	qhandle_t railRingsShader;
1053 	qhandle_t railCoreShader;
1054 
1055 	qhandle_t lightningShader;
1056 
1057 	qhandle_t friendShader;
1058 
1059 //	qhandle_t medicReviveShader;	//----(SA)	commented out from MP
1060 	qhandle_t balloonShader;
1061 	qhandle_t connectionShader;
1062 
1063 	qhandle_t aiStateShaders[MAX_AISTATES];
1064 
1065 	qhandle_t selectShader;
1066 	qhandle_t viewBloodShader;
1067 	qhandle_t tracerShader;
1068 	qhandle_t crosshairShader[NUM_CROSSHAIRS];
1069 	qhandle_t crosshairFriendly;    //----(SA)	added
1070 	qhandle_t lagometerShader;
1071 	qhandle_t backTileShader;
1072 	qhandle_t noammoShader;
1073 
1074 	qhandle_t reticleShader;
1075 //	qhandle_t reticleShaderSimple;
1076 	qhandle_t reticleShaderSimpleQ;
1077 //	qhandle_t snooperShader;
1078 	qhandle_t snooperShaderSimple;
1079 //	qhandle_t binocShaderSimple;
1080 	qhandle_t binocShaderSimpleQ;   // same as above, but quartered.  (trying to save texture space)
1081 
1082 	qhandle_t smokePuffShader;
1083 	qhandle_t smokePuffRageProShader;
1084 	qhandle_t shotgunSmokePuffShader;
1085 	qhandle_t waterBubbleShader;
1086 	qhandle_t bloodTrailShader;
1087 
1088 	qhandle_t nailPuffShader;
1089 
1090 	//----(SA)	cursor hints
1091 	// would be nice to specify these in the menu scripts instead of permanent handles...
1092 	qhandle_t hintShaders[HINT_NUM_HINTS];
1093 
1094 	qhandle_t youGotMailShader;         // '!' - new entry in notebook
1095 	qhandle_t youGotObjectiveShader;    // '<checkmark> - you completed objective
1096 //----(SA)	end
1097 
1098 	// Rafael
1099 	qhandle_t snowShader;
1100 	qhandle_t oilParticle;
1101 	qhandle_t oilSlick;
1102 	// done.
1103 
1104 	// Rafael - cannon
1105 	qhandle_t smokePuffShaderdirty;
1106 	qhandle_t smokePuffShaderb1;
1107 	qhandle_t smokePuffShaderb2;
1108 	qhandle_t smokePuffShaderb3;
1109 	qhandle_t smokePuffShaderb4;
1110 	qhandle_t smokePuffShaderb5;
1111 	// done
1112 
1113 	// Rafael - blood pool
1114 	qhandle_t bloodPool;
1115 
1116 	// Ridah, viewscreen blood animation
1117 	qhandle_t viewBloodAni[5];
1118 	qhandle_t viewFlashBlood;
1119 	qhandle_t viewFlashFire[16];
1120 	// done
1121 
1122 	// Rafael bats
1123 	qhandle_t bats[10];
1124 	// done
1125 
1126 	// Rafael shards
1127 	qhandle_t shardGlass1;
1128 	qhandle_t shardGlass2;
1129 	qhandle_t shardWood1;
1130 	qhandle_t shardWood2;
1131 	qhandle_t shardMetal1;
1132 	qhandle_t shardMetal2;
1133 	qhandle_t shardCeramic1;
1134 	qhandle_t shardCeramic2;
1135 	// done
1136 
1137 	qhandle_t shardRubble1;
1138 	qhandle_t shardRubble2;
1139 	qhandle_t shardRubble3;
1140 
1141 
1142 	qhandle_t shardJunk[MAX_LOCKER_DEBRIS];
1143 
1144 	qhandle_t numberShaders[11];
1145 
1146 	qhandle_t shadowMarkShader;
1147 	qhandle_t shadowFootShader;
1148 	qhandle_t shadowTorsoShader;
1149 
1150 	qhandle_t botSkillShaders[5];
1151 
1152 	// wall mark shaders
1153 	qhandle_t wakeMarkShader;
1154 	qhandle_t wakeMarkShaderAnim;
1155 	qhandle_t bloodMarkShaders[5];
1156 	qhandle_t bloodDotShaders[5];
1157 	qhandle_t bulletMarkShader;
1158 	qhandle_t bulletMarkShaderMetal;
1159 	qhandle_t bulletMarkShaderWood;
1160 	qhandle_t bulletMarkShaderCeramic;
1161 	qhandle_t bulletMarkShaderGlass;
1162 	qhandle_t burnMarkShader;
1163 	qhandle_t holeMarkShader;
1164 	qhandle_t energyMarkShader;
1165 
1166 	// powerup shaders
1167 	qhandle_t quadShader;
1168 	qhandle_t redQuadShader;
1169 	qhandle_t quadWeaponShader;
1170 	qhandle_t invisShader;
1171 	qhandle_t regenShader;
1172 	qhandle_t battleSuitShader;
1173 	qhandle_t battleWeaponShader;
1174 	qhandle_t hastePuffShader;
1175 
1176 	// weapon effect models
1177 	qhandle_t spearModel;   //----(SA)
1178 
1179 	qhandle_t bulletFlashModel;
1180 	qhandle_t ringFlashModel;
1181 	qhandle_t dishFlashModel;
1182 	qhandle_t lightningExplosionModel;
1183 
1184 	qhandle_t zombieLoogie;
1185 	qhandle_t flamebarrel;
1186 	qhandle_t mg42muzzleflash;
1187 	//qhandle_t	mg42muzzleflashgg;
1188 	qhandle_t planemuzzleflash;
1189 
1190 	// Rafael
1191 	qhandle_t crowbar;
1192 
1193 	qhandle_t waterSplashModel;
1194 	qhandle_t waterSplashShader;
1195 
1196 	qhandle_t thirdPersonBinocModel;    //----(SA)	added
1197 	qhandle_t cigModel;     //----(SA)	added
1198 
1199 	qhandle_t batModel;
1200 	qhandle_t spiritSkullModel;
1201 	qhandle_t helgaGhostModel;
1202 
1203 	// weapon effect shaders
1204 	qhandle_t railExplosionShader;
1205 	qhandle_t bulletExplosionShader;
1206 	qhandle_t rocketExplosionShader;
1207 	qhandle_t grenadeExplosionShader;
1208 	qhandle_t bfgExplosionShader;
1209 	qhandle_t bloodExplosionShader;
1210 
1211 	qhandle_t flameThrowerhitShader;
1212 
1213 	// special effects models
1214 	qhandle_t teleportEffectModel;
1215 	qhandle_t teleportEffectShader;
1216 
1217 	// scoreboard headers
1218 	qhandle_t scoreboardName;
1219 	qhandle_t scoreboardPing;
1220 	qhandle_t scoreboardScore;
1221 	qhandle_t scoreboardTime;
1222 	// Ridah
1223 	qhandle_t bloodCloudShader;
1224 	qhandle_t sparkParticleShader;
1225 	qhandle_t smokeTrailShader;
1226 	qhandle_t fireTrailShader;
1227 	qhandle_t lightningBoltShader;
1228 	qhandle_t lightningBoltShaderGreen;
1229 	qhandle_t flamethrowerFireStream;
1230 	qhandle_t flamethrowerBlueStream;
1231 	qhandle_t flamethrowerFuelStream;
1232 	qhandle_t flamethrowerFuelShader;
1233 	qhandle_t onFireShader, onFireShader2;
1234 	//qhandle_t	dripWetShader, dripWetShader2;
1235 	qhandle_t viewFadeBlack;
1236 	qhandle_t sparkFlareShader;
1237 	qhandle_t funnelFireShader[NUM_FUNNEL_SPRITES];
1238 	qhandle_t spotLightShader;
1239 	qhandle_t spotLightBeamShader;
1240 	qhandle_t spotLightBaseModel;       //----(SA)	added
1241 	qhandle_t spotLightLightModel;      //----(SA)	added
1242 	qhandle_t spotLightLightModelBroke;     //----(SA)	added
1243 
1244 	qhandle_t lightningHitWallShader;
1245 	qhandle_t lightningWaveShader;
1246 	qhandle_t bulletParticleTrailShader;
1247 	qhandle_t smokeParticleShader;
1248 
1249 	// DHM - Nerve :: bullet hitting dirt
1250 	qhandle_t dirtParticle1Shader;
1251 	qhandle_t dirtParticle2Shader;
1252 	qhandle_t dirtParticle3Shader;
1253 
1254 	qhandle_t zombieSpiritWallShader;
1255 	qhandle_t zombieSpiritTrailShader;
1256 	qhandle_t zombieSpiritSkullShader;
1257 	qhandle_t zombieDeathDustShader;
1258 	qhandle_t zombieBodyFadeShader;
1259 	qhandle_t zombieHeadFadeShader;
1260 
1261 	qhandle_t helgaSpiritSkullShader;
1262 	qhandle_t helgaSpiritTrailShader;
1263 
1264 	qhandle_t ssSpiritSkullModel;
1265 
1266 	qhandle_t skeletonSkinShader;
1267 	qhandle_t skeletonLegsModel;
1268 	qhandle_t skeletonTorsoModel;
1269 	qhandle_t skeletonHeadModel;
1270 	qhandle_t skeletonLegsSkin;
1271 	qhandle_t skeletonTorsoSkin;
1272 	qhandle_t skeletonHeadSkin;
1273 
1274 	qhandle_t loperGroundChargeShader;
1275 
1276 	qhandle_t teslaDamageEffectShader;
1277 	qhandle_t teslaAltDamageEffectShader;
1278 	qhandle_t viewTeslaDamageEffectShader;
1279 	qhandle_t viewTeslaAltDamageEffectShader;
1280 	// done.
1281 
1282 //----(SA)
1283 	// proto/super/heini armor parts
1284 	qhandle_t protoArmor[9 * 3];        // 9 parts, 3 sections each	(nodam, dam1, dam2)
1285 	qhandle_t superArmor[16 * 3];       // 14 parts, 3 sections each
1286 	qhandle_t heinrichArmor[22 * 3];    // 20 parts, 3 sections each
1287 //----(SA)	end
1288 
1289 	// medals shown during gameplay
1290 	qhandle_t medalImpressive;
1291 	qhandle_t medalExcellent;
1292 	qhandle_t medalGauntlet;
1293 
1294 	// sounds
1295 	sfxHandle_t n_health;
1296 	sfxHandle_t noFireUnderwater;
1297 	sfxHandle_t snipersound;
1298 	sfxHandle_t quadSound;
1299 	sfxHandle_t tracerSound;
1300 	sfxHandle_t selectSound;
1301 	sfxHandle_t useNothingSound;
1302 	sfxHandle_t wearOffSound;
1303 	sfxHandle_t footsteps[FOOTSTEP_TOTAL][4];
1304 	sfxHandle_t sfx_lghit1;
1305 	sfxHandle_t sfx_lghit2;
1306 	sfxHandle_t sfx_lghit3;
1307 	sfxHandle_t sfx_ric1;
1308 	sfxHandle_t sfx_ric2;
1309 	sfxHandle_t sfx_ric3;
1310 	//sfxHandle_t sfx_railg;
1311 	sfxHandle_t sfx_rockexp;
1312 	sfxHandle_t sfx_dynamiteexp;
1313 	sfxHandle_t sfx_dynamiteexpDist;    //----(SA)	added
1314 	sfxHandle_t sfx_spearhit;
1315 	sfxHandle_t sfx_knifehit[5];
1316 	sfxHandle_t sfx_bullet_metalhit[3];
1317 	sfxHandle_t sfx_bullet_woodhit[3];
1318 	sfxHandle_t sfx_bullet_roofhit[3];
1319 	sfxHandle_t sfx_bullet_ceramichit[3];
1320 	sfxHandle_t sfx_bullet_glasshit[3];
1321 	sfxHandle_t gibSound;
1322 	sfxHandle_t gibBounce1Sound;
1323 	sfxHandle_t gibBounce2Sound;
1324 	sfxHandle_t gibBounce3Sound;
1325 	sfxHandle_t teleInSound;
1326 	sfxHandle_t teleOutSound;
1327 	sfxHandle_t noAmmoSound;
1328 	sfxHandle_t respawnSound;
1329 	sfxHandle_t talkSound;
1330 	sfxHandle_t landSound;
1331 	sfxHandle_t fallSound;
1332 	sfxHandle_t jumpPadSound;
1333 
1334 	sfxHandle_t oneMinuteSound;
1335 	sfxHandle_t fiveMinuteSound;
1336 	sfxHandle_t suddenDeathSound;
1337 
1338 	sfxHandle_t threeFragSound;
1339 	sfxHandle_t twoFragSound;
1340 	sfxHandle_t oneFragSound;
1341 
1342 	sfxHandle_t hitSound;
1343 	sfxHandle_t hitTeamSound;
1344 	sfxHandle_t impressiveSound;
1345 	sfxHandle_t excellentSound;
1346 	sfxHandle_t deniedSound;
1347 	sfxHandle_t humiliationSound;
1348 
1349 	sfxHandle_t takenLeadSound;
1350 	sfxHandle_t tiedLeadSound;
1351 	sfxHandle_t lostLeadSound;
1352 
1353 	sfxHandle_t watrInSound;
1354 	sfxHandle_t watrOutSound;
1355 	sfxHandle_t watrUnSound;
1356 
1357 //	sfxHandle_t flightSound;
1358 	sfxHandle_t underWaterSound;
1359 	sfxHandle_t medkitSound;
1360 	sfxHandle_t wineSound;
1361 	sfxHandle_t bookSound;      //----(SA)	added
1362 	sfxHandle_t staminaSound;   //----(SA)	added
1363 	sfxHandle_t elecSound;
1364 	sfxHandle_t fireSound;
1365 	sfxHandle_t waterSound;
1366 
1367 	// teamplay sounds
1368 	sfxHandle_t redLeadsSound;
1369 	sfxHandle_t blueLeadsSound;
1370 	sfxHandle_t teamsTiedSound;
1371 
1372 	// tournament sounds
1373 	sfxHandle_t count3Sound;
1374 	sfxHandle_t count2Sound;
1375 	sfxHandle_t count1Sound;
1376 	sfxHandle_t countFightSound;
1377 	sfxHandle_t countPrepareSound;
1378 
1379 	//----(SA) added
1380 	sfxHandle_t debBounce1Sound;
1381 	sfxHandle_t debBounce2Sound;
1382 	sfxHandle_t debBounce3Sound;
1383 	//----(SA) end
1384 
1385 	//----(SA)	added
1386 	sfxHandle_t grenadePulseSound4;
1387 	sfxHandle_t grenadePulseSound3;
1388 	sfxHandle_t grenadePulseSound2;
1389 	sfxHandle_t grenadePulseSound1;
1390 	//----(SA)
1391 
1392 //----(SA)	added
1393 	sfxHandle_t sparkSounds[2];
1394 //----(SA)
1395 
1396 	// Ridah
1397 	sfxHandle_t flameSound;
1398 	sfxHandle_t flameBlowSound;
1399 	sfxHandle_t flameStartSound;
1400 	sfxHandle_t flameStreamSound;
1401 	sfxHandle_t lightningSounds[3];
1402 	sfxHandle_t lightningZap;
1403 	sfxHandle_t flameCrackSound;
1404 	sfxHandle_t boneBounceSound;
1405 
1406 	sfxHandle_t zombieSpiritSound;
1407 	sfxHandle_t zombieSpiritLoopSound;
1408 	sfxHandle_t zombieDeathSound;
1409 
1410 	sfxHandle_t helgaSpiritLoopSound;
1411 	sfxHandle_t helgaSpiritSound;
1412 	sfxHandle_t helgaGaspSound;
1413 
1414 	sfxHandle_t heinrichArmorBreak; //----(SA)
1415 	sfxHandle_t protoArmorBreak;    //----(SA)
1416 	sfxHandle_t superArmorBreak;    //----(SA)
1417 
1418 
1419 	sfxHandle_t debrisHitSound;
1420 
1421 	sfxHandle_t loperLightningSounds[3];
1422 	sfxHandle_t loperLightningZap;
1423 
1424 	sfxHandle_t lightningClap[5];
1425 
1426 	sfxHandle_t batsFlyingLoopSound;
1427 
1428 //	sfxHandle_t grenadebounce1;
1429 //	sfxHandle_t grenadebounce2;
1430 	sfxHandle_t grenadebounce[GRENBOUNCE_TOTAL][2]; //----(SA)	modified
1431 
1432 	sfxHandle_t dynamitebounce1;    //----(SA)	added
1433 
1434 	sfxHandle_t fbarrelexp1;
1435 	sfxHandle_t fbarrelexp2;
1436 
1437 	sfxHandle_t fkickwall;
1438 	sfxHandle_t fkickflesh;
1439 	sfxHandle_t fkickmiss;
1440 
1441 	int bulletHitFleshScript;
1442 	int bulletHitFleshMetalScript;
1443 
1444 	int teslaZapScript;
1445 	sfxHandle_t teslaLoopSound;
1446 	// done.
1447 
1448 	qhandle_t cursor;
1449 	qhandle_t selectCursor;
1450 	qhandle_t sizeCursor;
1451 
1452 } cgMedia_t;
1453 
1454 
1455 //
1456 // SOUND SCRIPTING
1457 //
1458 
1459 typedef struct soundScriptSound_s
1460 {
1461 	char filename[MAX_QPATH];
1462 	sfxHandle_t sfxHandle;
1463 	int lastPlayed;
1464 
1465 	struct soundScriptSound_s   *next;
1466 } soundScriptSound_t;
1467 
1468 
1469 #define MAX_SOUND_SCRIPT_SOUNDS 8192
1470 extern soundScriptSound_t soundScriptSounds[MAX_SOUND_SCRIPT_SOUNDS];
1471 //DAJ defined in cg_sound.c int	numSoundScriptSounds;
1472 
1473 
1474 typedef struct soundScript_s
1475 {
1476 	int index;
1477 	char name[MAX_QPATH];
1478 	int channel;
1479 	int attenuation;
1480 	qboolean streaming;
1481 	qboolean looping;
1482 	float shakeScale;
1483 	float shakeRadius;
1484 	int shakeDuration;
1485 	qboolean random;    // TODO
1486 	int numSounds;
1487 	soundScriptSound_t  *soundList;         // pointer into the global list of soundScriptSounds (defined below)
1488 
1489 	struct soundScript_s    *nextHash;      // next soundScript in our hashTable list position
1490 } soundScript_t;
1491 
1492 // we have to define these static lists, since we can't alloc memory within the cgame
1493 
1494 #define FILE_HASH_SIZE          1024
1495 extern soundScript_t*      hashTable[FILE_HASH_SIZE];
1496 
1497 #define MAX_SOUND_SCRIPTS       4096
1498 extern soundScript_t soundScripts[MAX_SOUND_SCRIPTS];
1499 //DAJ defined in cg_sound.c int	numSoundScripts;
1500 
1501 extern soundScript_t soundScripts[MAX_SOUND_SCRIPTS];
1502 
1503 
1504 
1505 
1506 
1507 // The client game static (cgs) structure hold everything
1508 // loaded or calculated from the gamestate.  It will NOT
1509 // be cleared when a tournement restart is done, allowing
1510 // all clients to begin playing instantly
1511 typedef struct {
1512 	gameState_t gameState;              // gamestate from server
1513 	glconfig_t glconfig;                // rendering configuration
1514 	float screenXScale;                 // derived from glconfig
1515 	float screenYScale;
1516 	float screenXBias;
1517 	float screenYBias;
1518 	float screenXScaleStretch;
1519 	float screenYScaleStretch;
1520 
1521 	int serverCommandSequence;              // reliable command stream counter
1522 	int processedSnapshotNum;            // the number of snapshots cgame has requested
1523 
1524 	qboolean localServer;               // detected on startup by checking sv_running
1525 
1526 	// parsed from serverinfo
1527 	gametype_t gametype;
1528 
1529 	// Rafael gameskill
1530 	gameskill_t gameskill;
1531 	// done
1532 
1533 	int dmflags;
1534 	int teamflags;
1535 	int fraglimit;
1536 	int capturelimit;
1537 	int timelimit;
1538 	int maxclients;
1539 	char mapname[MAX_QPATH];
1540 	char redTeam[MAX_QPATH];                // A team
1541 	char blueTeam[MAX_QPATH];               // B team
1542 
1543 	int voteTime;
1544 	int voteYes;
1545 	int voteNo;
1546 	qboolean voteModified;                  // beep whenever changed
1547 	char voteString[MAX_STRING_TOKENS];
1548 
1549 	int teamVoteTime[2];
1550 	int teamVoteYes[2];
1551 	int teamVoteNo[2];
1552 	qboolean teamVoteModified[2];           // beep whenever changed
1553 	char teamVoteString[2][MAX_STRING_TOKENS];
1554 
1555 	int levelStartTime;
1556 
1557 	int scores1, scores2;                   // from configstrings
1558 
1559 	//
1560 	// locally derived information from gamestate
1561 	//
1562 	qhandle_t gameModels[MAX_MODELS];
1563 	sfxHandle_t gameSounds[MAX_SOUNDS];
1564 	int gameSoundTypes[MAX_SOUNDS];             //----(SA)	added
1565 
1566 	int numInlineModels;
1567 	qhandle_t inlineDrawModel[MAX_MODELS];
1568 	vec3_t inlineModelMidpoints[MAX_MODELS];
1569 
1570 	clientInfo_t clientinfo[MAX_CLIENTS];
1571 
1572 	// teamchat width is *3 because of embedded color codes
1573 	char teamChatMsgs[TEAMCHAT_HEIGHT][TEAMCHAT_WIDTH * 3 + 1];
1574 	int teamChatMsgTimes[TEAMCHAT_HEIGHT];
1575 	int teamChatPos;
1576 	int teamLastChatPos;
1577 
1578 	char itemPrintNames[MAX_ITEMS][32];             //----(SA)	added
1579 
1580 	int cursorX;
1581 	int cursorY;
1582 	qboolean eventHandling;
1583 	qboolean mouseCaptured;
1584 	qboolean sizingHud;
1585 	void *capturedItem;
1586 	qhandle_t activeCursor;
1587 
1588 	// screen fading
1589 	//----(SA)	modified just in name so global searching is easier to narrow down (added 'scrF')
1590 	float scrFadeAlpha, scrFadeAlphaCurrent;
1591 	int scrFadeStartTime;
1592 	int scrFadeDuration;
1593 
1594 	// media
1595 	cgMedia_t media;
1596 
1597 	// player/AI model scripting (client repository)
1598 	animScriptData_t animScriptData;
1599 
1600 } cgs_t;
1601 
1602 //==============================================================================
1603 
1604 extern cgs_t cgs;
1605 extern cg_t cg;
1606 extern centity_t cg_entities[MAX_GENTITIES];
1607 extern weaponInfo_t cg_weapons[MAX_WEAPONS];
1608 extern itemInfo_t cg_items[MAX_ITEMS];
1609 extern markPoly_t cg_markPolys[MAX_MARK_POLYS];
1610 
1611 extern vmCvar_t cg_centertime;
1612 extern vmCvar_t cg_runpitch;
1613 extern vmCvar_t cg_runroll;
1614 extern vmCvar_t cg_bobup;
1615 extern vmCvar_t cg_bobpitch;
1616 extern vmCvar_t cg_bobroll;
1617 extern vmCvar_t cg_swingSpeed;
1618 extern vmCvar_t cg_shadows;
1619 extern vmCvar_t cg_gibs;
1620 extern vmCvar_t cg_drawTimer;
1621 extern vmCvar_t cg_drawFPS;
1622 extern vmCvar_t cg_drawSnapshot;
1623 extern vmCvar_t cg_draw3dIcons;
1624 extern vmCvar_t cg_drawIcons;
1625 extern vmCvar_t cg_youGotMail;          //----(SA)	added
1626 extern vmCvar_t cg_drawAmmoWarning;
1627 extern vmCvar_t cg_drawCrosshair;
1628 extern vmCvar_t cg_drawCrosshairBinoc;
1629 extern vmCvar_t cg_drawCrosshairNames;
1630 extern vmCvar_t cg_drawCrosshairPickups;
1631 extern vmCvar_t cg_drawCrosshairReticle;
1632 extern vmCvar_t cg_hudAlpha;
1633 extern vmCvar_t cg_useWeapsForZoom;
1634 extern vmCvar_t cg_weaponCycleDelay;            //----(SA)	added
1635 extern vmCvar_t cg_cycleAllWeaps;
1636 extern vmCvar_t cg_drawAllWeaps;
1637 extern vmCvar_t cg_drawRewards;
1638 extern vmCvar_t cg_drawTeamOverlay;
1639 extern vmCvar_t cg_crosshairX;
1640 extern vmCvar_t cg_crosshairY;
1641 extern vmCvar_t cg_crosshairSize;
1642 extern vmCvar_t cg_crosshairAlpha;          //----(SA)	added
1643 extern vmCvar_t cg_crosshairHealth;
1644 extern vmCvar_t cg_drawStatus;
1645 extern vmCvar_t cg_draw2D;
1646 extern vmCvar_t cg_drawFrags;
1647 extern vmCvar_t cg_animSpeed;
1648 extern vmCvar_t cg_debugAnim;
1649 extern vmCvar_t cg_debugPosition;
1650 extern vmCvar_t cg_debugEvents;
1651 extern vmCvar_t cg_drawSpreadScale;
1652 extern vmCvar_t cg_railTrailTime;
1653 extern vmCvar_t cg_errorDecay;
1654 extern vmCvar_t cg_nopredict;
1655 extern vmCvar_t cg_noPlayerAnims;
1656 extern vmCvar_t cg_showmiss;
1657 extern vmCvar_t cg_footsteps;
1658 extern vmCvar_t cg_markTime;
1659 extern vmCvar_t cg_brassTime;
1660 extern vmCvar_t cg_gun_frame;
1661 extern vmCvar_t cg_gun_x;
1662 extern vmCvar_t cg_gun_y;
1663 extern vmCvar_t cg_gun_z;
1664 extern vmCvar_t cg_drawGun;
1665 extern vmCvar_t cg_drawFPGun;
1666 extern vmCvar_t cg_drawGamemodels;
1667 extern vmCvar_t cg_cursorHints;
1668 extern vmCvar_t cg_hintFadeTime;            //----(SA)	added
1669 extern vmCvar_t cg_viewsize;
1670 extern vmCvar_t cg_letterbox;           //----(SA)	added
1671 extern vmCvar_t cg_tracerChance;
1672 extern vmCvar_t cg_tracerWidth;
1673 extern vmCvar_t cg_tracerLength;
1674 extern vmCvar_t cg_tracerSpeed;
1675 extern vmCvar_t cg_autoswitch;
1676 extern vmCvar_t cg_ignore;
1677 extern vmCvar_t cg_simpleItems;
1678 extern vmCvar_t cg_fov;
1679 extern vmCvar_t cg_fixedAspect;
1680 extern vmCvar_t cg_fixedAspectFOV;
1681 extern vmCvar_t cg_oldWolfUI;
1682 extern vmCvar_t cg_drawStatusHead;
1683 extern vmCvar_t cg_zoomFov;
1684 extern vmCvar_t cg_zoomDefaultBinoc;
1685 extern vmCvar_t cg_zoomDefaultSniper;
1686 extern vmCvar_t cg_zoomDefaultFG;
1687 extern vmCvar_t cg_zoomDefaultSnooper;
1688 extern vmCvar_t cg_zoomStepBinoc;
1689 extern vmCvar_t cg_zoomStepSniper;
1690 extern vmCvar_t cg_zoomStepSnooper;
1691 extern vmCvar_t cg_zoomStepFG;
1692 extern vmCvar_t cg_reticles;
1693 extern vmCvar_t cg_reticleBrightness;
1694 extern vmCvar_t cg_thirdPersonRange;
1695 extern vmCvar_t cg_thirdPersonAngle;
1696 extern vmCvar_t cg_thirdPerson;
1697 extern vmCvar_t cg_lagometer;
1698 extern vmCvar_t cg_drawAttacker;
1699 extern vmCvar_t cg_synchronousClients;
1700 extern vmCvar_t cg_teamChatTime;
1701 extern vmCvar_t cg_teamChatHeight;
1702 extern vmCvar_t cg_stats;
1703 extern vmCvar_t cg_forceModel;
1704 extern vmCvar_t cg_coronafardist;
1705 extern vmCvar_t cg_coronas;
1706 extern vmCvar_t cg_buildScript;
1707 extern vmCvar_t cg_paused;
1708 extern vmCvar_t cg_blood;
1709 extern vmCvar_t cg_predictItems;
1710 extern vmCvar_t cg_deferPlayers;
1711 extern vmCvar_t cg_teamChatsOnly;
1712 extern vmCvar_t cg_enableBreath;
1713 extern vmCvar_t cg_autoactivate;
1714 extern vmCvar_t cg_emptyswitch;
1715 extern vmCvar_t cg_useSuggestedWeapons;         //----(SA)	added
1716 extern vmCvar_t cg_particleDist;
1717 extern vmCvar_t cg_particleLOD;
1718 extern vmCvar_t cg_smoothClients;
1719 extern vmCvar_t pmove_fixed;
1720 extern vmCvar_t pmove_msec;
1721 
1722 extern vmCvar_t cg_cameraOrbit;
1723 extern vmCvar_t cg_cameraOrbitDelay;
1724 extern vmCvar_t cg_timescaleFadeEnd;
1725 extern vmCvar_t cg_timescaleFadeSpeed;
1726 extern vmCvar_t cg_timescale;
1727 extern vmCvar_t cg_cameraMode;
1728 extern vmCvar_t cg_smallFont;
1729 extern vmCvar_t cg_bigFont;
1730 
1731 extern vmCvar_t cg_blinktime;           //----(SA)	added
1732 
1733 extern vmCvar_t cg_currentSelectedPlayer;
1734 extern vmCvar_t cg_currentSelectedPlayerName;
1735 
1736 // Rafael - particle switch
1737 extern vmCvar_t cg_wolfparticles;
1738 // done
1739 
1740 // Ridah
1741 extern vmCvar_t cg_gameType;
1742 extern vmCvar_t cg_bloodTime;
1743 extern vmCvar_t cg_norender;
1744 extern vmCvar_t cg_skybox;
1745 
1746 // Rafael gameskill
1747 extern vmCvar_t cg_gameSkill;
1748 // done
1749 
1750 extern vmCvar_t cg_reloading;           //----(SA)	added
1751 
1752 // JPW NERVE
1753 extern vmCvar_t cg_medicChargeTime;
1754 extern vmCvar_t cg_engineerChargeTime;
1755 extern vmCvar_t cg_LTChargeTime;
1756 extern vmCvar_t cg_soldierChargeTime;
1757 extern vmCvar_t cg_redlimbotime;
1758 extern vmCvar_t cg_bluelimbotime;
1759 // jpw
1760 
1761 extern vmCvar_t cg_hunkUsed;
1762 extern vmCvar_t cg_soundAdjust;
1763 extern vmCvar_t cg_expectedhunkusage;
1764 
1765 extern vmCvar_t cg_showAIState;
1766 
1767 extern vmCvar_t cg_notebook;
1768 extern vmCvar_t cg_notebookpages;           // bitflags for the currently accessable pages.  if they wanna cheat, let 'em.  Most won't, or will wait 'til they actually play it.
1769 
1770 extern vmCvar_t cg_animState;
1771 extern vmCvar_t cg_missionStats;
1772 extern vmCvar_t cg_waitForFire;
1773 
1774 extern vmCvar_t cg_loadWeaponSelect;
1775 
1776 // NERVE - SMF - Wolf multiplayer configuration cvars
1777 extern vmCvar_t mp_playerType;
1778 extern vmCvar_t mp_weapon;
1779 extern vmCvar_t mp_item1;
1780 extern vmCvar_t mp_item2;
1781 extern vmCvar_t mp_mapDesc;
1782 extern vmCvar_t mp_mapTitle;
1783 // -NERVE - SMF
1784 
1785 //
1786 // cg_main.c
1787 //
1788 const char *CG_ConfigString( int index );
1789 const char *CG_Argv( int arg );
1790 
1791 void QDECL CG_Printf( const char *msg, ... ) __attribute__ ((format (printf, 1, 2)));
1792 void QDECL CG_Error( const char *msg, ... ) __attribute__ ((noreturn, format (printf, 1, 2)));
1793 
1794 void CG_StartMusic( void );
1795 void CG_QueueMusic( void ); //----(SA)	added
1796 
1797 void CG_UpdateCvars( void );
1798 
1799 int CG_CrosshairPlayer( void );
1800 int CG_LastAttacker( void );
1801 void CG_LoadMenus( const char *menuFile );
1802 void CG_KeyEvent( int key, qboolean down );
1803 void CG_MouseEvent( int x, int y );
1804 void CG_EventHandling( int type );
1805 
1806 qboolean CG_GetTag( int clientNum, char *tagname, orientation_t * or );
1807 qboolean CG_GetWeaponTag( int clientNum, char *tagname, orientation_t * or );
1808 
1809 //
1810 // cg_view.c
1811 //
1812 void CG_TestModel_f( void );
1813 void CG_TestGun_f( void );
1814 void CG_TestModelNextFrame_f( void );
1815 void CG_TestModelPrevFrame_f( void );
1816 void CG_TestModelNextSkin_f( void );
1817 void CG_TestModelPrevSkin_f( void );
1818 void CG_ZoomDown_f( void );
1819 void CG_ZoomIn_f( void );
1820 void CG_ZoomOut_f( void );
1821 void CG_ZoomUp_f( void );
1822 
1823 void CG_DrawActiveFrame( int serverTime, stereoFrame_t stereoView, qboolean demoPlayback );
1824 
1825 void CG_Concussive( centity_t *cent );
1826 
1827 //
1828 // cg_drawtools.c
1829 //
1830 void CG_SetScreenPlacement(screenPlacement_e hpos, screenPlacement_e vpos);
1831 
1832 void CG_AdjustFrom640( float *x, float *y, float *w, float *h );
1833 void CG_FillRect( float x, float y, float width, float height, const float *color );
1834 void CG_HorizontalPercentBar( float x, float y, float width, float height, float percent );
1835 void CG_DrawPic( float x, float y, float width, float height, qhandle_t hShader );
1836 void CG_FilledBar( float x, float y, float w, float h, const float *startColorIn, float *endColor, const float *bgColor, float frac, int flags );
1837 // JOSEPH 10-26-99
1838 void CG_DrawStretchPic( float x, float y, float width, float height, qhandle_t hShader );
1839 // END JOSEPH
1840 void CG_DrawString( float x, float y, const char *string,
1841 					float charWidth, float charHeight, const float *modulate );
1842 
1843 
1844 void CG_DrawStringExt( int x, int y, const char *string, const float *setColor,
1845 					   qboolean forceColor, qboolean shadow, int charWidth, int charHeight, int maxChars );
1846 // JOSEPH 4-17-00
1847 void CG_DrawStringExt2( int x, int y, const char *string, const float *setColor,
1848 						qboolean forceColor, qboolean shadow, int charWidth, int charHeight, int maxChars );
1849 // END JOSEPH
1850 void CG_DrawBigString( int x, int y, const char *s, float alpha );
1851 void CG_DrawBigStringColor( int x, int y, const char *s, vec4_t color );
1852 void CG_DrawSmallString( int x, int y, const char *s, float alpha );
1853 void CG_DrawSmallStringColor( int x, int y, const char *s, vec4_t color );
1854 // JOSEPH 4-25-00
1855 void CG_DrawBigString2( int x, int y, const char *s, float alpha );
1856 void CG_DrawBigStringColor2( int x, int y, const char *s, vec4_t color );
1857 // END JOSEPH
1858 int CG_DrawStrlen( const char *str );
1859 
1860 float   *CG_FadeColor( int startMsec, int totalMsec );
1861 float *CG_TeamColor( int team );
1862 void CG_TileClear( void );
1863 void CG_ColorForHealth( vec4_t hcolor );
1864 void CG_GetColorForHealth( int health, int armor, vec4_t hcolor );
1865 
1866 void UI_DrawProportionalString( int x, int y, const char* str, int style, vec4_t color );
1867 
1868 // new hud stuff
1869 void CG_DrawRect( float x, float y, float width, float height, float size, const float *color );
1870 void CG_DrawSides( float x, float y, float w, float h, float size );
1871 void CG_DrawTopBottom( float x, float y, float w, float h, float size );
1872 
1873 
1874 
1875 //
1876 // cg_draw.c, cg_newDraw.c
1877 //
1878 extern int sortedTeamPlayers[TEAM_MAXOVERLAY];
1879 extern int numSortedTeamPlayers;
1880 extern int drawTeamOverlayModificationCount;
1881 extern char systemChat[256];
1882 extern char teamChat1[256];
1883 extern char teamChat2[256];
1884 
1885 void CG_AddLagometerFrameInfo( void );
1886 void CG_AddLagometerSnapshotInfo( snapshot_t *snap );
1887 void CG_CenterPrint( const char *str, int y, int charWidth );
1888 void CG_ObjectivePrint( const char *str, int charWidth, int team );     // NERVE - SMF
1889 void CG_DrawHead( float x, float y, float w, float h, int clientNum, vec3_t headAngles );
1890 void CG_DrawActive( stereoFrame_t stereoView );
1891 void CG_DrawFlagModel( float x, float y, float w, float h, int team );
1892 
1893 void CG_DrawTeamBackground( int x, int y, int w, int h, float alpha, int team );
1894 void CG_OwnerDraw( float x, float y, float w, float h, float text_x, float text_y, int ownerDraw, int ownerDrawFlags, int align, float special, int font, float scale, vec4_t color, qhandle_t shader, int textStyle );
1895 void CG_Text_Paint( float x, float y, int font, float scale, vec4_t color, const char *text, float adjust, int limit, int style );    //----(SA)	modified
1896 int CG_Text_Width( const char *text, int font, float scale, int limit );
1897 int CG_Text_Height( const char *text, int font, float scale, int limit );
1898 void CG_SelectPrevPlayer( void );
1899 void CG_SelectNextPlayer( void );
1900 float CG_GetValue( int ownerDraw, int type ); // 'type' is relative or absolute (fractional-'0.5' or absolute- '50' health)
1901 qboolean CG_OwnerDrawVisible( int flags );
1902 void CG_RunMenuScript( char **args );
1903 void CG_ShowResponseHead( void );
1904 void CG_SetPrintString( int type, const char *p );
1905 void CG_InitTeamChat( void );
1906 void CG_GetTeamColor( vec4_t *color );
1907 const char *CG_GetGameStatusText( void );
1908 const char *CG_GetKillerText( void );
1909 void CG_Draw3DModel(float x, float y, float w, float h, qhandle_t model, qhandle_t skin, vec3_t origin, vec3_t angles);
1910 void CG_Text_PaintChar( float x, float y, float width, float height, float scale, float s, float t, float s2, float t2, qhandle_t hShader );
1911 void CG_CheckOrderPending( void );
1912 const char *CG_GameTypeString( void );
1913 qboolean CG_YourTeamHasFlag( void );
1914 qboolean CG_OtherTeamHasFlag( void );
1915 qhandle_t CG_StatusHandle( int task );
1916 void CG_Fade( int r, int g, int b, int a, int time, int duration ); //----(SA)	modified
1917 
1918 void CG_CalcShakeCamera( void );
1919 void CG_ApplyShakeCamera( void );
1920 
1921 
1922 
1923 //
1924 // cg_player.c
1925 //
1926 qboolean CG_EntOnFire( centity_t *cent );    // Ridah
1927 void CG_Player( centity_t *cent );
1928 void CG_ResetPlayerEntity( centity_t *cent );
1929 void CG_AddRefEntityWithPowerups( refEntity_t *ent, int powerups, int team, entityState_t *es, const vec3_t fireRiseDir );
1930 void CG_NewClientInfo( int clientNum );
1931 sfxHandle_t CG_CustomSound( int clientNum, const char *soundName );
1932 
1933 // Rafael particles
1934 extern qboolean initparticles;
1935 int CG_NewParticleArea( int num );
1936 
1937 //
1938 // cg_predict.c
1939 //
1940 void CG_BuildSolidList( void );
1941 int CG_PointContents( const vec3_t point, int passEntityNum );
1942 void CG_Trace( trace_t *result, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end,
1943 			   int skipNumber, int mask );
1944 void CG_PredictPlayerState( void );
1945 void CG_LoadDeferredPlayers( void );
1946 
1947 
1948 //
1949 // cg_events.c
1950 //
1951 void CG_CheckEvents( centity_t *cent );
1952 const char  *CG_PlaceString( int rank );
1953 void CG_EntityEvent( centity_t *cent, vec3_t position );
1954 void CG_PainEvent( centity_t *cent, int health, qboolean crouching );
1955 
1956 
1957 //
1958 // cg_ents.c
1959 //
1960 void CG_SetEntitySoundPosition( centity_t *cent );
1961 void CG_AddPacketEntities( void );
1962 void CG_Beam( centity_t *cent );
1963 void CG_AdjustPositionForMover( const vec3_t in, int moverNum, int fromTime, int toTime, vec3_t out, vec3_t angles_in, vec3_t angles_out, vec3_t outDeltaAngles );
1964 
1965 void CG_PositionEntityOnTag( refEntity_t *entity, const refEntity_t *parent,
1966 							 char *tagName, int startIndex, vec3_t *offset );
1967 void CG_PositionRotatedEntityOnTag( refEntity_t *entity, const refEntity_t *parent, char *tagName );
1968 
1969 
1970 //----(SA)
1971 void CG_AttachedPartChange( centity_t *cent );
1972 void CG_NextItem_f( void );
1973 void CG_PrevItem_f( void );
1974 void CG_Item_f( void );
1975 //----(SA)	end
1976 
1977 
1978 //
1979 // cg_weapons.c
1980 //
1981 void CG_LastWeaponUsed_f( void );     //----(SA)	added
1982 void CG_NextWeaponInBank_f( void );   //----(SA)	added
1983 void CG_PrevWeaponInBank_f( void );   //----(SA)	added
1984 void CG_AltWeapon_f( void );
1985 void CG_NextWeapon_f( void );
1986 void CG_PrevWeapon_f( void );
1987 void CG_Weapon_f( void );
1988 void CG_WeaponBank_f( void );
1989 void CG_WeaponSuggest( int weap );
1990 
1991 void CG_FinishWeaponChange( int lastweap, int newweap );
1992 
1993 void CG_RegisterWeapon( int weaponNum );
1994 void CG_RegisterItemVisuals( int itemNum );
1995 
1996 void CG_FireWeapon( centity_t *cent );   //----(SA)	modified.
1997 //void CG_EndFireWeapon( centity_t *cent, int firemode );	//----(SA)	added
1998 void CG_MissileHitWall( int weapon, int clientNum, vec3_t origin, vec3_t dir, int surfaceFlags );   //	(SA) modified to send missilehitwall surface parameters
1999 
2000 void CG_MissileHitWallSmall( int weapon, int clientNum, vec3_t origin, vec3_t dir );
2001 void CG_DrawTracer( vec3_t start, vec3_t finish );
2002 
2003 // Rafael
2004 void CG_MG42EFX( centity_t *cent );
2005 
2006 void CG_FLAKEFX( centity_t *cent, int whichgun );
2007 
2008 void CG_MortarEFX( centity_t *cent );
2009 
2010 // Ridah
2011 qboolean CG_MonsterUsingWeapon( centity_t *cent, int aiChar, int weaponNum );
2012 
2013 // Rafael
2014 void CG_MissileHitWall2( int weapon, int clientNum, vec3_t origin, vec3_t dir );
2015 // done
2016 
2017 void CG_MissileHitPlayer( centity_t *cent, int weapon, vec3_t origin, vec3_t dir, int entityNum );
2018 //----(SA)
2019 void CG_VenomFire( entityState_t *es, qboolean fullmode );
2020 //----(SA)
2021 void CG_Bullet( vec3_t origin, int sourceEntityNum, vec3_t normal, qboolean flesh, int fleshEntityNum, qboolean wolfkick, int otherEntNum2 );
2022 
2023 void CG_RailTrail( clientInfo_t *ci, vec3_t start, vec3_t end, int type );   //----(SA)	added 'type'
2024 void CG_GrappleTrail( centity_t *ent, const weaponInfo_t *wi );
2025 void CG_AddViewWeapon( playerState_t *ps );
2026 void CG_AddPlayerWeapon( refEntity_t *parent, playerState_t *ps, centity_t *cent );
2027 void CG_DrawWeaponSelect( void );
2028 void CG_DrawHoldableSelect( void );
2029 
2030 void CG_OutOfAmmoChange( void );
2031 void CG_HoldableUsedupChange( void ); //----(SA)	added
2032 
2033 //----(SA) added to header to access from outside cg_weapons.c
2034 void CG_AddDebris( vec3_t origin, vec3_t dir, int speed, int duration, int count );
2035 //----(SA) done
2036 
2037 void CG_ClientDamage( int entnum, int enemynum, int id );
2038 
2039 void CG_AddBulletParticles( vec3_t origin, vec3_t dir, int speed, int duration, int count, float randScale );
2040 
2041 //
2042 // cg_marks.c
2043 //
2044 void    CG_InitMarkPolys( void );
2045 void    CG_AddMarks( void );
2046 void    CG_ImpactMark( qhandle_t markShader,
2047 					   const vec3_t origin, const vec3_t dir,
2048 					   float orientation,
2049 					   float r, float g, float b, float a,
2050 					   qboolean alphaFade,
2051 					   float radius, qboolean temporary, int duration );
2052 
2053 // Rafael particles
2054 //
2055 // cg_particles.c
2056 //
2057 void    CG_ClearParticles( void );
2058 void    CG_AddParticles( void );
2059 void    CG_ParticleSnow( qhandle_t pshader, vec3_t origin, vec3_t origin2, int turb, float range, int snum );
2060 void    CG_ParticleSmoke( qhandle_t pshader, centity_t *cent );
2061 void    CG_AddParticleShrapnel( localEntity_t *le );
2062 void    CG_ParticleSnowFlurry( qhandle_t pshader, centity_t *cent );
2063 void    CG_ParticleBulletDebris( vec3_t org, vec3_t vel, int duration );
2064 void    CG_ParticleDirtBulletDebris( vec3_t org, vec3_t vel, int duration );     // DHM - Nerve
2065 void    CG_ParticleDirtBulletDebris_Core( vec3_t org, vec3_t vel, int duration, float width, float height, float alpha, char *shadername );  // NERVE - SMF // JPW addtnl params
2066 void    CG_ParticleSparks( vec3_t org, vec3_t vel, int duration, float x, float y, float speed );
2067 void    CG_ParticleDust( centity_t *cent, vec3_t origin, vec3_t dir );
2068 void    CG_ParticleMisc( qhandle_t pshader, vec3_t origin, int size, int duration, float alpha );
2069 
2070 // Ridah
2071 void CG_ParticleExplosion( char *animStr, vec3_t origin, vec3_t vel, int duration, int sizeStart, int sizeEnd );
2072 
2073 // Rafael snow pvs check
2074 void    CG_SnowLink( centity_t *cent, qboolean particleOn );
2075 // done.
2076 
2077 // Rafael bats
2078 void CG_ParticleBat( centity_t *cent );
2079 void    CG_ParticleBats( qhandle_t pshader, centity_t *cent );
2080 void    CG_BatsUpdatePosition( centity_t *cent );
2081 void CG_ParticleImpactSmokePuff( qhandle_t pshader, vec3_t origin );
2082 void CG_ParticleImpactSmokePuffExtended( qhandle_t pshader, vec3_t origin, vec3_t dir, int radius, int lifetime, int vel, int acc, int maxroll, float alpha );       // (SA) so I can add more parameters without screwing up the one that's there
2083 void CG_Particle_Bleed( qhandle_t pshader, vec3_t start, vec3_t dir, int fleshEntityNum, int duration );
2084 void CG_GetBleedOrigin( vec3_t head_origin, vec3_t torso_origin, vec3_t legs_origin, int fleshEntityNum );
2085 void CG_Particle_OilParticle( qhandle_t pshader, vec3_t origin, vec3_t origin2, int ptime, int snum );
2086 void CG_Particle_OilSlick( qhandle_t pshader, centity_t *cent );
2087 void CG_OilSlickRemove( centity_t *cent );
2088 void CG_BloodPool( localEntity_t *le, qhandle_t pshader, trace_t *tr );
2089 void CG_ParticleBloodCloudZombie( centity_t *cent, vec3_t origin, vec3_t dir );
2090 void CG_ParticleBloodCloud( centity_t *cent, vec3_t origin, vec3_t dir );
2091 // done
2092 
2093 // Ridah, trails
2094 //
2095 // cg_trails.c
2096 //
2097 int CG_AddTrailJunc( int headJuncIndex, qhandle_t shader, int spawnTime, int sType, vec3_t pos, int trailLife, float alphaStart, float alphaEnd, float startWidth, float endWidth, int flags, vec3_t colorStart, vec3_t colorEnd, float sRatio, float animSpeed );
2098 int CG_AddSparkJunc( int headJuncIndex, qhandle_t shader, vec3_t pos, int trailLife, float alphaStart, float alphaEnd, float startWidth, float endWidth );
2099 int CG_AddSmokeJunc( int headJuncIndex, qhandle_t shader, vec3_t pos, int trailLife, float alpha, float startWidth, float endWidth );
2100 int CG_AddFireJunc( int headJuncIndex, qhandle_t shader, vec3_t pos, int trailLife, float alpha, float startWidth, float endWidth );
2101 void CG_AddTrails( void );
2102 void CG_ClearTrails( void );
2103 // done.
2104 
2105 // Ridah, sound scripting
2106 int CG_SoundScriptPrecache( const char *name );
2107 qboolean CG_SoundPlaySoundScript( const char *name, vec3_t org, int entnum );
2108 void CG_SoundPlayIndexedScript( int index, vec3_t org, int entnum );
2109 void CG_SoundInit( void );
2110 // done.
2111 
2112 // Ridah, flamethrower
2113 void CG_FireFlameChunks( centity_t *cent, vec3_t origin, vec3_t angles, float speedScale, qboolean firing, int flags ); //----(SA)	added 'flags'
2114 void CG_InitFlameChunks( void );
2115 void CG_AddFlameChunks( void );
2116 void CG_UpdateFlamethrowerSounds( void );
2117 void CG_FlameDamage( int owner, vec3_t org, float radius );
2118 // done.
2119 
2120 //
2121 // cg_localents.c
2122 //
2123 void    CG_InitLocalEntities( void );
2124 localEntity_t   *CG_AllocLocalEntity( void );
2125 void    CG_AddLocalEntities( void );
2126 
2127 //
2128 // cg_effects.c
2129 //
2130 int CG_GetOriginForTag( centity_t * cent, refEntity_t * parent, char *tagName, int startIndex, vec3_t org, vec3_t axis[3] );
2131 localEntity_t *CG_SmokePuff( const vec3_t p,
2132 							 const vec3_t vel,
2133 							 float radius,
2134 							 float r, float g, float b, float a,
2135 							 float duration,
2136 							 int startTime,
2137 							 int fadeInTime,
2138 							 int leFlags,
2139 							 qhandle_t hShader );
2140 
2141 void CG_BubbleTrail( vec3_t start, vec3_t end, float size, float spacing );
2142 void CG_SpawnEffect( vec3_t org );
2143 void CG_GibPlayer( centity_t *cent, vec3_t playerOrigin, vec3_t gdir );
2144 void CG_LoseHat( centity_t *cent, vec3_t dir );         //----(SA)	added
2145 void CG_GibHead( vec3_t headOrigin );
2146 
2147 void CG_Bleed( vec3_t origin, int entityNum );
2148 
2149 localEntity_t *CG_MakeExplosion( vec3_t origin, vec3_t dir,
2150 								 qhandle_t hModel, qhandle_t shader, int msec,
2151 								 qboolean isSprite );
2152 // Ridah
2153 void CG_DynamicLightningBolt( qhandle_t shader, vec3_t start, vec3_t pend, int numBolts, float maxWidth, qboolean fade, float startAlpha, int recursion, int randseed );
2154 void CG_SparklerSparks( vec3_t origin, int count );
2155 void CG_ClearFlameChunks( void );
2156 void CG_ProjectedSpotLight( vec3_t start, vec3_t dir );
2157 // done.
2158 
2159 //----(SA)
2160 void CG_Spotlight( centity_t *cent, float *color, vec3_t start, vec3_t dir, int segs, float range, int startWidth, float coneAngle, int flags );
2161 #define SL_NOTRACE          0x001   // don't do a trace check for shortening the beam, always draw at full 'range' length
2162 #define SL_NODLIGHT         0x002   // don't put a dlight at the end
2163 #define SL_NOSTARTCAP       0x004   // dont' cap the start circle
2164 #define SL_LOCKTRACETORANGE 0x010   // only trace out as far as the specified range (rather than to max spot range)
2165 #define SL_NOFLARE          0x020   // don't draw a flare when the light is pointing at the camera
2166 #define SL_NOIMPACT         0x040   // don't draw the impact mark
2167 #define SL_LOCKUV           0x080   // lock the texture coordinates at the 'true' length of the requested beam.
2168 #define SL_NOCORE           0x100   // don't draw the center 'core' beam
2169 #define SL_TRACEWORLDONLY   0x200
2170 //----(SA)	done
2171 
2172 void CG_RumbleEfx( float pitch, float yaw );
2173 
2174 //
2175 // cg_snapshot.c
2176 //
2177 void CG_ProcessSnapshots( void );
2178 
2179 //
2180 // cg_info.c
2181 //
2182 void CG_LoadingString( const char *s );
2183 void CG_LoadingItem( int itemNum );
2184 void CG_LoadingClient( int clientNum );
2185 void CG_DrawInformation( void );
2186 const char *CG_translateString( const char *str );
2187 
2188 //
2189 // cg_scoreboard.c
2190 //
2191 qboolean CG_DrawScoreboard( void );
2192 void CG_DrawTourneyScoreboard( void );
2193 
2194 //
2195 // cg_consolecmds.c
2196 //
2197 qboolean CG_ConsoleCommand( void );
2198 void CG_InitConsoleCommands( void );
2199 
2200 //
2201 // cg_servercmds.c
2202 //
2203 void CG_ExecuteNewServerCommands( int latestSequence );
2204 void CG_ParseServerinfo( void );
2205 void CG_SetConfigValues( void );
2206 void CG_ShaderStateChanged( void );
2207 void CG_SendMoveSpeed( animation_t *animList, int numAnims, char *modelName );
2208 
2209 //
2210 // cg_playerstate.c
2211 //
2212 void CG_Respawn( void );
2213 void CG_TransitionPlayerState( playerState_t *ps, playerState_t *ops );
2214 void CG_LoadClientInfo( int clientNum, clientInfo_t *ci );
2215 
2216 
2217 //===============================================
2218 
2219 //
2220 // system traps
2221 // These functions are how the cgame communicates with the main game system
2222 //
2223 
2224 // print message on the local console
2225 void	trap_Print( const char *fmt );
2226 
2227 // abort the game
2228 void	trap_Error(const char *fmt) __attribute__((noreturn));
2229 
2230 // exit game to main menu (credits/etc)
2231 void        trap_Endgame( void );   //----(SA)	added
2232 
2233 // milliseconds should only be used for performance tuning, never
2234 // for anything game related.  Get time from the CG_DrawActiveFrame parameter
2235 int         trap_Milliseconds( void );
2236 
2237 // console variable interaction
2238 void        trap_Cvar_Register( vmCvar_t *vmCvar, const char *varName, const char *defaultValue, int flags );
2239 void        trap_Cvar_Update( vmCvar_t *vmCvar );
2240 void        trap_Cvar_Set( const char *var_name, const char *value );
2241 void        trap_Cvar_VariableStringBuffer( const char *var_name, char *buffer, int bufsize );
2242 
2243 // ServerCommand and ConsoleCommand parameter access
2244 int         trap_Argc( void );
2245 void        trap_Argv( int n, char *buffer, int bufferLength );
2246 void        trap_Args( char *buffer, int bufferLength );
2247 
2248 // filesystem access
2249 // returns length of file
2250 int         trap_FS_FOpenFile( const char *qpath, fileHandle_t *f, fsMode_t mode );
2251 void        trap_FS_Read( void *buffer, int len, fileHandle_t f );
2252 void        trap_FS_Write( const void *buffer, int len, fileHandle_t f );
2253 void        trap_FS_FCloseFile( fileHandle_t f );
2254 void        trap_FS_CopyFile( char *from, char *to );   //DAJ
2255 
2256 // add commands to the local console as if they were typed in
2257 // for map changing, etc.  The command is not executed immediately,
2258 // but will be executed in order the next time console commands
2259 // are processed
2260 void        trap_SendConsoleCommand( const char *text );
2261 
2262 // register a command name so the console can perform command completion.
2263 // FIXME: replace this with a normal console command "defineCommand"?
2264 void	trap_AddCommand( const char *cmdName );
2265 void	trap_RemoveCommand( const char *cmdName );
2266 
2267 // send a string to the server over the network
2268 void        trap_SendClientCommand( const char *s );
2269 
2270 // force a screen update, only used during gamestate load
2271 void        trap_UpdateScreen( void );
2272 
2273 // model collision
2274 void        trap_CM_LoadMap( const char *mapname );
2275 int         trap_CM_NumInlineModels( void );
2276 clipHandle_t trap_CM_InlineModel( int index );      // 0 = world, 1+ = bmodels
2277 clipHandle_t trap_CM_TempBoxModel( const vec3_t mins, const vec3_t maxs );
2278 clipHandle_t trap_CM_TempCapsuleModel( const vec3_t mins, const vec3_t maxs );
2279 int         trap_CM_PointContents( const vec3_t p, clipHandle_t model );
2280 int         trap_CM_TransformedPointContents( const vec3_t p, clipHandle_t model, const vec3_t origin, const vec3_t angles );
2281 void        trap_CM_BoxTrace( trace_t *results, const vec3_t start, const vec3_t end,
2282 							  const vec3_t mins, const vec3_t maxs,
2283 							  clipHandle_t model, int brushmask );
2284 void        trap_CM_TransformedBoxTrace( trace_t *results, const vec3_t start, const vec3_t end,
2285 										 const vec3_t mins, const vec3_t maxs,
2286 										 clipHandle_t model, int brushmask,
2287 										 const vec3_t origin, const vec3_t angles );
2288 
2289 void        trap_CM_CapsuleTrace( trace_t *results, const vec3_t start, const vec3_t end,
2290 								  const vec3_t mins, const vec3_t maxs,
2291 								  clipHandle_t model, int brushmask );
2292 void        trap_CM_TransformedCapsuleTrace( trace_t *results, const vec3_t start, const vec3_t end,
2293 											 const vec3_t mins, const vec3_t maxs,
2294 											 clipHandle_t model, int brushmask,
2295 											 const vec3_t origin, const vec3_t angles );
2296 
2297 // Returns the projection of a polygon onto the solid brushes in the world
2298 int         trap_CM_MarkFragments( int numPoints, const vec3_t *points,
2299 								   const vec3_t projection,
2300 								   int maxPoints, vec3_t pointBuffer,
2301 								   int maxFragments, markFragment_t *fragmentBuffer );
2302 
2303 // normal sounds will have their volume dynamically changed as their entity
2304 // moves and the listener moves
2305 void        trap_S_StartSound( vec3_t origin, int entityNum, int entchannel, sfxHandle_t sfx );
2306 void        trap_S_StartSoundEx( vec3_t origin, int entityNum, int entchannel, sfxHandle_t sfx, int flags );
2307 void        trap_S_StopLoopingSound( int entnum );
2308 void        trap_S_StopStreamingSound( int entnum );  // usually AI.  character is talking and needs to be shut up /now/
2309 
2310 // a local sound is always played full volume
2311 void        trap_S_StartLocalSound( sfxHandle_t sfx, int channelNum );
2312 void        trap_S_ClearLoopingSounds( qboolean killall );
2313 void        trap_S_AddLoopingSound( int entityNum, const vec3_t origin, const vec3_t velocity, int range, sfxHandle_t sfx, int volume );
2314 //void        trap_S_AddRealLoopingSound( int entityNum, const vec3_t origin, const vec3_t velocity, int range, sfxHandle_t sfx, int volume );
2315 void        trap_S_UpdateEntityPosition( int entityNum, const vec3_t origin );
2316 
2317 // Ridah, talking animations
2318 int         trap_S_GetVoiceAmplitude( int entityNum );
2319 // done.
2320 
2321 // repatialize recalculates the volumes of sound as they should be heard by the
2322 // given entityNum and position
2323 void trap_S_Respatialize( int entityNum, const vec3_t origin, vec3_t axis[3], int inwater );
2324 sfxHandle_t trap_S_RegisterSound( const char *sample );     // returns buzz if not found
2325 void        trap_S_StartBackgroundTrack( const char *intro, const char *loop, int fadeupTime ); // empty name stops music
2326 void        trap_S_StopBackgroundTrack( void );
2327 void        trap_S_FadeBackgroundTrack( float targetvol, int time, int sound );  //----(SA)	added
2328 void        trap_S_StartStreamingSound( const char *intro, const char *loop, int entnum, int channel, int attenuation );
2329 void        trap_S_FadeAllSound( float targetvol, int time ); //----(SA)	added
2330 
2331 void        trap_R_LoadWorldMap( const char *mapname );
2332 
2333 // all media should be registered during level startup to prevent
2334 // hitches during gameplay
2335 qhandle_t   trap_R_RegisterModel( const char *name );           // returns rgb axis if not found
2336 qhandle_t   trap_R_RegisterSkin( const char *name );            // returns all white if not found
2337 qhandle_t   trap_R_RegisterShader( const char *name );          // returns all white if not found
2338 qhandle_t   trap_R_RegisterShaderNoMip( const char *name );         // returns all white if not found
2339 
2340 qboolean    trap_R_GetSkinModel( qhandle_t skinid, const char *type, char *name );   //----(SA) added
2341 qhandle_t   trap_R_GetShaderFromModel( qhandle_t modelid, int surfnum, int withlightmap );   //----(SA)	added
2342 
2343 // a scene is built up by calls to R_ClearScene and the various R_Add functions.
2344 // Nothing is drawn until R_RenderScene is called.
2345 void        trap_R_ClearScene( void );
2346 void        trap_R_AddRefEntityToScene( const refEntity_t *re );
2347 
2348 // polys are intended for simple wall marks, not really for doing
2349 // significant construction
2350 void        trap_R_AddPolyToScene( qhandle_t hShader, int numVerts, const polyVert_t *verts );
2351 // Ridah
2352 void        trap_R_AddPolysToScene( qhandle_t hShader, int numVerts, const polyVert_t *verts, int numPolys );
2353 void        trap_RB_ZombieFXAddNewHit( int entityNum, const vec3_t hitPos, const vec3_t hitDir );
2354 // done.
2355 void        trap_R_AddLightToScene( const vec3_t org, float intensity, float r, float g, float b, int overdraw );
2356 void	    trap_R_AddAdditiveLightToScene( const vec3_t org, float intensity, float r, float g, float b );
2357 void        trap_R_AddCoronaToScene( const vec3_t org, float r, float g, float b, float scale, int id, int flags );  //----(SA)	modified
2358 void        trap_R_RenderScene( const refdef_t *fd );
2359 void        trap_R_SetColor( const float *rgba );   // NULL = 1,1,1,1
2360 void        trap_R_DrawStretchPic( float x, float y, float w, float h,
2361 								   float s1, float t1, float s2, float t2, qhandle_t hShader );
2362 void        trap_R_DrawStretchPicGradient( float x, float y, float w, float h,
2363 										   float s1, float t1, float s2, float t2, qhandle_t hShader, const float *gradientColor, int gradientType );
2364 
2365 void        trap_R_ModelBounds( clipHandle_t model, vec3_t mins, vec3_t maxs );
2366 int         trap_R_LerpTag( orientation_t *tag, const refEntity_t *refent, const char *tagName, int startIndex );
2367 void        trap_R_RemapShader( const char *oldShader, const char *newShader, const char *timeOffset );
2368 qboolean    trap_R_inPVS( const vec3_t p1, const vec3_t p2 );
2369 
2370 //----(SA)
2371 void    trap_R_SetFog( int fogvar, int var1, int var2, float r, float g, float b, float density );
2372 
2373 //----(SA)
2374 
2375 // The glconfig_t will not change during the life of a cgame.
2376 // If it needs to change, the entire cgame will be restarted, because
2377 // all the qhandle_t are then invalid.
2378 void        trap_GetGlconfig( glconfig_t *glconfig );
2379 
2380 // the gamestate should be grabbed at startup, and whenever a
2381 // configstring changes
2382 void        trap_GetGameState( gameState_t *gamestate );
2383 
2384 // cgame will poll each frame to see if a newer snapshot has arrived
2385 // that it is interested in.  The time is returned seperately so that
2386 // snapshot latency can be calculated.
2387 void        trap_GetCurrentSnapshotNumber( int *snapshotNumber, int *serverTime );
2388 
2389 // a snapshot get can fail if the snapshot (or the entties it holds) is so
2390 // old that it has fallen out of the client system queue
2391 qboolean    trap_GetSnapshot( int snapshotNumber, snapshot_t *snapshot );
2392 
2393 // retrieve a text command from the server stream
2394 // the current snapshot will hold the number of the most recent command
2395 // qfalse can be returned if the client system handled the command
2396 // argc() / argv() can be used to examine the parameters of the command
2397 qboolean    trap_GetServerCommand( int serverCommandNumber );
2398 
2399 // returns the most recent command number that can be passed to GetUserCmd
2400 // this will always be at least one higher than the number in the current
2401 // snapshot, and it may be quite a few higher if it is a fast computer on
2402 // a lagged connection
2403 int         trap_GetCurrentCmdNumber( void );
2404 
2405 qboolean    trap_GetUserCmd( int cmdNumber, usercmd_t *ucmd );
2406 
2407 // used for the weapon/holdable select and zoom
2408 void        trap_SetUserCmdValue( int stateValue, int holdValue, float sensitivityScale, int cld );     // NERVE - SMF - added cld
2409 
2410 // aids for VM testing
2411 void        testPrintInt( char *string, int i );
2412 void        testPrintFloat( char *string, float f );
2413 
2414 int         trap_MemoryRemaining( void );
2415 void        trap_R_RegisterFont( const char *fontName, int pointSize, fontInfo_t *font );
2416 qboolean    trap_Key_IsDown( int keynum );
2417 int         trap_Key_GetCatcher( void );
2418 void        trap_Key_SetCatcher( int catcher );
2419 int         trap_Key_GetKey( const char *binding );
2420 
2421 void CG_S_AddLoopingSound( int entityNum, const vec3_t origin, const vec3_t velocity, sfxHandle_t sfx, int volume );
2422 void CG_S_AddRangedLoopingSound( int entityNum, const vec3_t origin, const vec3_t velocity, sfxHandle_t sfx, int range );
2423 void CG_S_AddRealLoopingSound( int entityNum, const vec3_t origin, const vec3_t velocity, sfxHandle_t sfx );
2424 
2425 // RF
2426 void trap_SendMoveSpeedsToGame( int entnum, char *movespeeds );
2427 
2428 typedef enum {
2429 	SYSTEM_PRINT,
2430 	CHAT_PRINT,
2431 	TEAMCHAT_PRINT
2432 } q3print_t;
2433 
2434 void trap_UI_Popup( const char *arg0 );   //----(SA)	added
2435 void trap_UI_ClosePopup( const char *arg0 );     // NERVE - SMF
2436 void trap_UI_LimboChat( const char *arg0 );     // NERVE - SMF
2437 
2438 int trap_CIN_PlayCinematic( const char *arg0, int xpos, int ypos, int width, int height, int bits );
2439 e_status trap_CIN_StopCinematic( int handle );
2440 e_status trap_CIN_RunCinematic( int handle );
2441 void trap_CIN_DrawCinematic( int handle );
2442 void trap_CIN_SetExtents( int handle, int x, int y, int w, int h );
2443 
2444 int	trap_RealTime(qtime_t *qtime);
2445 void trap_SnapVector( float *v );
2446 
2447 qboolean    trap_GetEntityToken( char *buffer, int bufferSize );
2448 
2449 // Duffy, camera stuff
2450 #define CAM_PRIMARY 0   // the main camera for cutscenes, etc.
2451 qboolean    trap_loadCamera( int camNum, const char *name );
2452 void        trap_startCamera( int camNum, int time );
2453 void        trap_stopCamera( int camNum );    //----(SA)	added
2454 qboolean    trap_getCameraInfo( int camNum, int time, vec3_t *origin, vec3_t *angles, float *fov );
2455 void        CG_StartCamera( const char *name, qboolean startBlack );
2456 void        CG_StopCamera( void );
2457 
2458 //----(SA)	added
2459 int         CG_LoadCamera( const char *name );
2460 void        CG_FreeCamera( int camNum );
2461 //----(SA)	end
2462 
2463 void CG_StartShakeCamera( float p, int duration, vec3_t src, float radius );
2464 
2465 qboolean    trap_GetModelInfo( int clientNum, char *modelName, animModelInfo_t **modelInfo );
2466 
2467 // New in IORTCW
2468 void		*trap_Alloc( int size );
2469