1 /*
2 ===========================================================================
3 Copyright (C) 1999-2005 Id Software, Inc.
4 Copyright (C) 2000-2006 Tim Angus
5 
6 This file is part of Tremulous.
7 
8 Tremulous is free software; you can redistribute it
9 and/or modify it under the terms of the GNU General Public License as
10 published by the Free Software Foundation; either version 2 of the License,
11 or (at your option) any later version.
12 
13 Tremulous is distributed in the hope that it will be
14 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 GNU General Public License for more details.
17 
18 You should have received a copy of the GNU General Public License
19 along with Tremulous; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21 ===========================================================================
22 */
23 
24 
25 #include "../qcommon/q_shared.h"
26 #include "../renderer/tr_types.h"
27 #include "../game/bg_public.h"
28 #include "cg_public.h"
29 #include "../ui/ui_shared.h"
30 
31 // The entire cgame module is unloaded and reloaded on each level change,
32 // so there is NO persistant data between levels on the client side.
33 // If you absolutely need something stored, it can either be kept
34 // by the server in the server stored userinfos, or stashed in a cvar.
35 
36 #define CG_FONT_THRESHOLD 0.1
37 
38 #define POWERUP_BLINKS      5
39 
40 #define POWERUP_BLINK_TIME  1000
41 #define FADE_TIME           200
42 #define PULSE_TIME          200
43 #define DAMAGE_DEFLECT_TIME 100
44 #define DAMAGE_RETURN_TIME  400
45 #define DAMAGE_TIME         500
46 #define LAND_DEFLECT_TIME   150
47 #define LAND_RETURN_TIME    300
48 #define DUCK_TIME           100
49 #define PAIN_TWITCH_TIME    200
50 #define WEAPON_SELECT_TIME  1400
51 #define ITEM_SCALEUP_TIME   1000
52 #define ZOOM_TIME           150
53 #define ITEM_BLOB_TIME      200
54 #define MUZZLE_FLASH_TIME   20
55 #define SINK_TIME           1000    // time for fragments to sink into ground before going away
56 #define ATTACKER_HEAD_TIME  10000
57 #define REWARD_TIME         3000
58 
59 #define PULSE_SCALE         1.5     // amount to scale up the icons when activating
60 
61 #define MAX_STEP_CHANGE     32
62 
63 #define MAX_VERTS_ON_POLY   10
64 #define MAX_MARK_POLYS      256
65 
66 #define STAT_MINUS          10  // num frame for '-' stats digit
67 
68 #define ICON_SIZE           48
69 #define CHAR_WIDTH          32
70 #define CHAR_HEIGHT         48
71 #define TEXT_ICON_SPACE     4
72 
73 #define TEAMCHAT_WIDTH      80
74 #define TEAMCHAT_HEIGHT     8
75 
76 // very large characters
77 #define GIANT_WIDTH         32
78 #define GIANT_HEIGHT        48
79 
80 #define NUM_CROSSHAIRS      10
81 
82 #define TEAM_OVERLAY_MAXNAME_WIDTH  12
83 #define TEAM_OVERLAY_MAXLOCATION_WIDTH  16
84 
85 #define DEFAULT_MODEL       "sarge"
86 #define DEFAULT_TEAM_MODEL  "sarge"
87 #define DEFAULT_TEAM_HEAD   "sarge"
88 
89 #define DEFAULT_REDTEAM_NAME    "Stroggs"
90 #define DEFAULT_BLUETEAM_NAME   "Pagans"
91 
92 typedef enum
93 {
94   FOOTSTEP_NORMAL,
95   FOOTSTEP_FLESH,
96   FOOTSTEP_METAL,
97   FOOTSTEP_SPLASH,
98   FOOTSTEP_CUSTOM,
99   FOOTSTEP_NONE,
100 
101   FOOTSTEP_TOTAL
102 } footstep_t;
103 
104 typedef enum
105 {
106   IMPACTSOUND_DEFAULT,
107   IMPACTSOUND_METAL,
108   IMPACTSOUND_FLESH
109 } impactSound_t;
110 
111 typedef enum
112 {
113   JPS_OFF,
114   JPS_DESCENDING,
115   JPS_HOVERING,
116   JPS_ASCENDING
117 } jetPackState_t;
118 
119 //======================================================================
120 
121 // when changing animation, set animationTime to frameTime + lerping time
122 // The current lerp will finish out, then it will lerp to the new animation
123 typedef struct
124 {
125   int         oldFrame;
126   int         oldFrameTime;     // time when ->oldFrame was exactly on
127 
128   int         frame;
129   int         frameTime;        // time when ->frame will be exactly on
130 
131   float       backlerp;
132 
133   float       yawAngle;
134   qboolean    yawing;
135   float       pitchAngle;
136   qboolean    pitching;
137 
138   int         animationNumber;  // may include ANIM_TOGGLEBIT
139   animation_t *animation;
140   int         animationTime;    // time when the first frame of the animation will be exact
141 } lerpFrame_t;
142 
143 //======================================================================
144 
145 //attachment system
146 typedef enum
147 {
148   AT_STATIC,
149   AT_TAG,
150   AT_CENT,
151   AT_PARTICLE
152 } attachmentType_t;
153 
154 //forward declaration for particle_t
155 struct particle_s;
156 
157 typedef struct attachment_s
158 {
159   attachmentType_t  type;
160   qboolean          attached;
161 
162   qboolean          staticValid;
163   qboolean          tagValid;
164   qboolean          centValid;
165   qboolean          particleValid;
166 
167   qboolean          hasOffset;
168   vec3_t            offset;
169 
170   vec3_t            lastValidAttachmentPoint;
171 
172   //AT_STATIC
173   vec3_t            origin;
174 
175   //AT_TAG
176   refEntity_t       re;     //FIXME: should be pointers?
177   refEntity_t       parent; //
178   qhandle_t         model;
179   char              tagName[ MAX_STRING_CHARS ];
180 
181   //AT_CENT
182   int               centNum;
183 
184   //AT_PARTICLE
185   struct particle_s *particle;
186 } attachment_t;
187 
188 //======================================================================
189 
190 //particle system stuff
191 #define MAX_PARTICLE_FILES        128
192 
193 #define MAX_PS_SHADER_FRAMES      32
194 #define MAX_PS_MODELS             8
195 #define MAX_EJECTORS_PER_SYSTEM   4
196 #define MAX_PARTICLES_PER_EJECTOR 4
197 
198 #define MAX_BASEPARTICLE_SYSTEMS  192
199 #define MAX_BASEPARTICLE_EJECTORS MAX_BASEPARTICLE_SYSTEMS*MAX_EJECTORS_PER_SYSTEM
200 #define MAX_BASEPARTICLES         MAX_BASEPARTICLE_EJECTORS*MAX_PARTICLES_PER_EJECTOR
201 
202 #define MAX_PARTICLE_SYSTEMS      48
203 #define MAX_PARTICLE_EJECTORS     MAX_PARTICLE_SYSTEMS*MAX_EJECTORS_PER_SYSTEM
204 #define MAX_PARTICLES             MAX_PARTICLE_EJECTORS*5
205 
206 #define PARTICLES_INFINITE        -1
207 #define PARTICLES_SAME_AS_INITIAL -2
208 
209 //COMPILE TIME STRUCTURES
210 typedef enum
211 {
212   PMT_STATIC,
213   PMT_STATIC_TRANSFORM,
214   PMT_TAG,
215   PMT_CENT_ANGLES,
216   PMT_NORMAL
217 } pMoveType_t;
218 
219 typedef enum
220 {
221   PMD_LINEAR,
222   PMD_POINT
223 } pDirType_t;
224 
225 typedef struct pMoveValues_u
226 {
227   pDirType_t  dirType;
228 
229   //PMD_LINEAR
230   vec3_t      dir;
231   float       dirRandAngle;
232 
233   //PMD_POINT
234   vec3_t      point;
235   float       pointRandAngle;
236 
237   float       mag;
238   float       magRandFrac;
239 
240   float       parentVelFrac;
241   float       parentVelFracRandFrac;
242 } pMoveValues_t;
243 
244 typedef struct pLerpValues_s
245 {
246   int   delay;
247   float delayRandFrac;
248 
249   float initial;
250   float initialRandFrac;
251 
252   float final;
253   float finalRandFrac;
254 
255   float randFrac;
256 } pLerpValues_t;
257 
258 //particle template
259 typedef struct baseParticle_s
260 {
261   vec3_t          displacement;
262   float           randDisplacement;
263   float           normalDisplacement;
264 
265   pMoveType_t     velMoveType;
266   pMoveValues_t   velMoveValues;
267 
268   pMoveType_t     accMoveType;
269   pMoveValues_t   accMoveValues;
270 
271   int             lifeTime;
272   float           lifeTimeRandFrac;
273 
274   float           bounceFrac;
275   float           bounceFracRandFrac;
276   qboolean        bounceCull;
277 
278   char            bounceMarkName[ MAX_QPATH ];
279   qhandle_t       bounceMark;
280   float           bounceMarkRadius;
281   float           bounceMarkRadiusRandFrac;
282   float           bounceMarkCount;
283   float           bounceMarkCountRandFrac;
284 
285   char            bounceSoundName[ MAX_QPATH ];
286   qhandle_t       bounceSound;
287   float           bounceSoundCount;
288   float           bounceSoundCountRandFrac;
289 
290   pLerpValues_t   radius;
291   pLerpValues_t   alpha;
292   pLerpValues_t   rotation;
293 
294   qboolean        dynamicLight;
295   pLerpValues_t   dLightRadius;
296   byte            dLightColor[ 3 ];
297 
298   int             colorDelay;
299   float           colorDelayRandFrac;
300   byte            initialColor[ 3 ];
301   byte            finalColor[ 3 ];
302 
303   char            childSystemName[ MAX_QPATH ];
304   qhandle_t       childSystemHandle;
305 
306   char            onDeathSystemName[ MAX_QPATH ];
307   qhandle_t       onDeathSystemHandle;
308 
309   char            childTrailSystemName[ MAX_QPATH ];
310   qhandle_t       childTrailSystemHandle;
311 
312   //particle invariant stuff
313   char            shaderNames[ MAX_PS_SHADER_FRAMES ][ MAX_QPATH ];
314   qhandle_t       shaders[ MAX_PS_SHADER_FRAMES ];
315   int             numFrames;
316   float           framerate;
317 
318   char            modelNames[ MAX_PS_MODELS ][ MAX_QPATH ];
319   qhandle_t       models[ MAX_PS_MODELS ];
320   int             numModels;
321   animation_t     modelAnimation;
322 
323   qboolean        overdrawProtection;
324   qboolean        realLight;
325   qboolean        cullOnStartSolid;
326 } baseParticle_t;
327 
328 
329 //ejector template
330 typedef struct baseParticleEjector_s
331 {
332   baseParticle_t  *particles[ MAX_PARTICLES_PER_EJECTOR ];
333   int             numParticles;
334 
335   pLerpValues_t   eject;          //zero period indicates creation of all particles at once
336 
337   int             totalParticles;         //can be infinite
338   float           totalParticlesRandFrac;
339 } baseParticleEjector_t;
340 
341 
342 //particle system template
343 typedef struct baseParticleSystem_s
344 {
345   char                  name[ MAX_QPATH ];
346   baseParticleEjector_t *ejectors[ MAX_EJECTORS_PER_SYSTEM ];
347   int                   numEjectors;
348 
349   qboolean              thirdPersonOnly;
350   qboolean              registered; //whether or not the assets for this particle have been loaded
351 } baseParticleSystem_t;
352 
353 
354 //RUN TIME STRUCTURES
355 typedef struct particleSystem_s
356 {
357   baseParticleSystem_t  *class;
358 
359   attachment_t          attachment;
360 
361   qboolean              valid;
362   qboolean              lazyRemove; //mark this system for later removal
363 
364   //for PMT_NORMAL
365   qboolean              normalValid;
366   vec3_t                normal;
367 } particleSystem_t;
368 
369 
370 typedef struct particleEjector_s
371 {
372   baseParticleEjector_t *class;
373   particleSystem_t      *parent;
374 
375   pLerpValues_t         ejectPeriod;
376 
377   int                   count;
378   int                   totalParticles;
379 
380   int                   nextEjectionTime;
381 
382   qboolean              valid;
383 } particleEjector_t;
384 
385 
386 //used for actual particle evaluation
387 typedef struct particle_s
388 {
389   baseParticle_t    *class;
390   particleEjector_t *parent;
391 
392   int               birthTime;
393   int               lifeTime;
394 
395   float             bounceMarkRadius;
396   int               bounceMarkCount;
397   int               bounceSoundCount;
398   qboolean          atRest;
399 
400   vec3_t            origin;
401   vec3_t            velocity;
402 
403   pMoveType_t       accMoveType;
404   pMoveValues_t     accMoveValues;
405 
406   int               lastEvalTime;
407 
408   int               nextChildTime;
409 
410   pLerpValues_t     radius;
411   pLerpValues_t     alpha;
412   pLerpValues_t     rotation;
413 
414   pLerpValues_t     dLightRadius;
415 
416   int               colorDelay;
417 
418   qhandle_t         model;
419   lerpFrame_t       lf;
420   vec3_t            lastAxis[ 3 ];
421 
422   qboolean          valid;
423   int               frameWhenInvalidated;
424 
425   int               sortKey;
426 } particle_t;
427 
428 //======================================================================
429 
430 //trail system stuff
431 #define MAX_TRAIL_FILES           128
432 
433 #define MAX_BEAMS_PER_SYSTEM      4
434 
435 #define MAX_BASETRAIL_SYSTEMS     64
436 #define MAX_BASETRAIL_BEAMS       MAX_BASETRAIL_SYSTEMS*MAX_BEAMS_PER_SYSTEM
437 
438 #define MAX_TRAIL_SYSTEMS         32
439 #define MAX_TRAIL_BEAMS           MAX_TRAIL_SYSTEMS*MAX_BEAMS_PER_SYSTEM
440 #define MAX_TRAIL_BEAM_NODES      128
441 
442 #define MAX_TRAIL_BEAM_JITTERS    4
443 
444 typedef enum
445 {
446   TBTT_STRETCH,
447   TBTT_REPEAT
448 } trailBeamTextureType_t;
449 
450 typedef struct baseTrailJitter_s
451 {
452   float   magnitude;
453   int     period;
454 } baseTrailJitter_t;
455 
456 //beam template
457 typedef struct baseTrailBeam_s
458 {
459   int                     numSegments;
460   float                   frontWidth;
461   float                   backWidth;
462   float                   frontAlpha;
463   float                   backAlpha;
464   byte                    frontColor[ 3 ];
465   byte                    backColor[ 3 ];
466 
467   // the time it takes for a segment to vanish (single attached only)
468   int                     segmentTime;
469 
470   // the time it takes for a beam to fade out (double attached only)
471   int                     fadeOutTime;
472 
473   char                    shaderName[ MAX_QPATH ];
474   qhandle_t               shader;
475 
476   trailBeamTextureType_t  textureType;
477 
478   //TBTT_STRETCH
479   float                   frontTextureCoord;
480   float                   backTextureCoord;
481 
482   //TBTT_REPEAT
483   float                   repeatLength;
484   qboolean                clampToBack;
485 
486   qboolean                realLight;
487 
488   int                     numJitters;
489   baseTrailJitter_t       jitters[ MAX_TRAIL_BEAM_JITTERS ];
490   qboolean                jitterAttachments;
491 } baseTrailBeam_t;
492 
493 
494 //trail system template
495 typedef struct baseTrailSystem_s
496 {
497   char            name[ MAX_QPATH ];
498   baseTrailBeam_t *beams[ MAX_BEAMS_PER_SYSTEM ];
499   int             numBeams;
500 
501   qboolean        thirdPersonOnly;
502   qboolean        registered; //whether or not the assets for this trail have been loaded
503 } baseTrailSystem_t;
504 
505 typedef struct trailSystem_s
506 {
507   baseTrailSystem_t   *class;
508 
509   attachment_t        frontAttachment;
510   attachment_t        backAttachment;
511 
512   int                 destroyTime;
513   qboolean            valid;
514 } trailSystem_t;
515 
516 typedef struct trailBeamNode_s
517 {
518   vec3_t                  refPosition;
519   vec3_t                  position;
520 
521   int                     timeLeft;
522 
523   float                   textureCoord;
524   float                   halfWidth;
525   byte                    alpha;
526   byte                    color[ 3 ];
527 
528   vec2_t                  jitters[ MAX_TRAIL_BEAM_JITTERS ];
529 
530   struct trailBeamNode_s  *prev;
531   struct trailBeamNode_s  *next;
532 
533   qboolean                used;
534 } trailBeamNode_t;
535 
536 typedef struct trailBeam_s
537 {
538   baseTrailBeam_t   *class;
539   trailSystem_t     *parent;
540 
541   trailBeamNode_t   nodePool[ MAX_TRAIL_BEAM_NODES ];
542   trailBeamNode_t   *nodes;
543 
544   int               lastEvalTime;
545 
546   qboolean          valid;
547 
548   int               nextJitterTimes[ MAX_TRAIL_BEAM_JITTERS ];
549 } trailBeam_t;
550 
551 //======================================================================
552 
553 // player entities need to track more information
554 // than any other type of entity.
555 
556 // note that not every player entity is a client entity,
557 // because corpses after respawn are outside the normal
558 // client numbering range
559 
560 //TA: smoothing of view and model for WW transitions
561 #define   MAXSMOOTHS          32
562 
563 typedef struct
564 {
565   float     time;
566   float     timeMod;
567 
568   vec3_t    rotAxis;
569   float     rotAngle;
570 } smooth_t;
571 
572 
573 typedef struct
574 {
575   lerpFrame_t legs, torso, flag, nonseg;
576   int         painTime;
577   int         painDirection;  // flip from 0 to 1
578 
579   // machinegun spinning
580   float       barrelAngle;
581   int         barrelTime;
582   qboolean    barrelSpinning;
583 
584   vec3_t      lastNormal;
585   vec3_t      lastAxis[ 3 ];
586   smooth_t    sList[ MAXSMOOTHS ];
587 } playerEntity_t;
588 
589 typedef struct lightFlareStatus_s
590 {
591   float     lastRadius;    //caching of likely flare radius
592   float     lastRatio;     //caching of likely flare ratio
593   int       lastTime;      //last time flare was visible/occluded
594   qboolean  status;        //flare is visble?
595 } lightFlareStatus_t;
596 
597 //=================================================
598 
599 // centity_t have a direct corespondence with gentity_t in the game, but
600 // only the entityState_t is directly communicated to the cgame
601 typedef struct centity_s
602 {
603   entityState_t         currentState;     // from cg.frame
604   entityState_t         nextState;        // from cg.nextFrame, if available
605   qboolean              interpolate;      // true if next is valid to interpolate to
606   qboolean              currentValid;     // true if cg.frame holds this entity
607 
608   int                   muzzleFlashTime;  // move to playerEntity?
609   int                   muzzleFlashTime2; // move to playerEntity?
610   int                   muzzleFlashTime3; // move to playerEntity?
611   int                   previousEvent;
612   int                   teleportFlag;
613 
614   int                   trailTime;        // so missile trails can handle dropped initial packets
615   int                   dustTrailTime;
616   int                   miscTime;
617   int                   snapShotTime;     // last time this entity was found in a snapshot
618 
619   playerEntity_t        pe;
620 
621   int                   errorTime;        // decay the error from this time
622   vec3_t                errorOrigin;
623   vec3_t                errorAngles;
624 
625   qboolean              extrapolated;     // false if origin / angles is an interpolation
626   vec3_t                rawOrigin;
627   vec3_t                rawAngles;
628 
629   vec3_t                beamEnd;
630 
631   // exact interpolated position of entity on this frame
632   vec3_t                lerpOrigin;
633   vec3_t                lerpAngles;
634 
635   lerpFrame_t           lerpFrame;
636 
637   //TA:
638   buildableAnimNumber_t buildableAnim;    //persistant anim number
639   buildableAnimNumber_t oldBuildableAnim; //to detect when new anims are set
640   particleSystem_t      *buildablePS;
641   float                 lastBuildableHealthScale;
642   int                   lastBuildableDamageSoundTime;
643 
644   lightFlareStatus_t    lfs;
645 
646   qboolean              doorState;
647 
648   particleSystem_t      *muzzlePS;
649   qboolean              muzzlePsTrigger;
650 
651   particleSystem_t      *jetPackPS;
652   jetPackState_t        jetPackState;
653 
654   particleSystem_t      *entityPS;
655   qboolean              entityPSMissing;
656 
657   trailSystem_t         *level2ZapTS[ 3 ];
658 
659   trailSystem_t         *muzzleTS; //used for the tesla and reactor
660   int                   muzzleTSDeathTime;
661 
662   qboolean              valid;
663   qboolean              oldValid;
664 } centity_t;
665 
666 
667 //======================================================================
668 
669 typedef struct markPoly_s
670 {
671   struct markPoly_s *prevMark, *nextMark;
672   int               time;
673   qhandle_t         markShader;
674   qboolean          alphaFade;    // fade alpha instead of rgb
675   float             color[ 4 ];
676   poly_t            poly;
677   polyVert_t        verts[ MAX_VERTS_ON_POLY ];
678 } markPoly_t;
679 
680 //======================================================================
681 
682 
683 typedef struct
684 {
685   int       client;
686   int       score;
687   int       ping;
688   int       time;
689   int       team;
690   weapon_t  weapon;
691   upgrade_t upgrade;
692 } score_t;
693 
694 // each client has an associated clientInfo_t
695 // that contains media references necessary to present the
696 // client model and other color coded effects
697 // this is regenerated each time a client's configstring changes,
698 // usually as a result of a userinfo (name, model, etc) change
699 #define MAX_CUSTOM_SOUNDS 32
700 typedef struct
701 {
702   qboolean    infoValid;
703 
704   char        name[ MAX_QPATH ];
705   pTeam_t     team;
706 
707   int         botSkill;                   // 0 = not bot, 1-5 = bot
708 
709   vec3_t      color1;
710   vec3_t      color2;
711 
712   int         score;                      // updated by score servercmds
713   int         location;                   // location index for team mode
714   int         health;                     // you only get this info about your teammates
715   int         armor;
716   int         curWeapon;
717 
718   int         handicap;
719   int         wins, losses;               // in tourney mode
720 
721   int         teamTask;                   // task in teamplay (offence/defence)
722   qboolean    teamLeader;                 // true when this is a team leader
723 
724   int         powerups;                   // so can display quad/flag status
725 
726   int         medkitUsageTime;
727   int         invulnerabilityStartTime;
728   int         invulnerabilityStopTime;
729 
730   int         breathPuffTime;
731 
732   // when clientinfo is changed, the loading of models/skins/sounds
733   // can be deferred until you are dead, to prevent hitches in
734   // gameplay
735   char        modelName[ MAX_QPATH ];
736   char        skinName[ MAX_QPATH ];
737   char        headModelName[ MAX_QPATH ];
738   char        headSkinName[ MAX_QPATH ];
739   char        redTeam[ MAX_TEAMNAME ];
740   char        blueTeam[ MAX_TEAMNAME ];
741 
742   qboolean    newAnims;                   // true if using the new mission pack animations
743   qboolean    fixedlegs;                  // true if legs yaw is always the same as torso yaw
744   qboolean    fixedtorso;                 // true if torso never changes yaw
745   qboolean    nonsegmented;               // true if model is Q2 style nonsegmented
746 
747   vec3_t      headOffset;                 // move head in icon views
748   footstep_t  footsteps;
749   gender_t    gender;                     // from model
750 
751   qhandle_t   legsModel;
752   qhandle_t   legsSkin;
753 
754   qhandle_t   torsoModel;
755   qhandle_t   torsoSkin;
756 
757   qhandle_t   headModel;
758   qhandle_t   headSkin;
759 
760   qhandle_t   nonSegModel;                //non-segmented model system
761   qhandle_t   nonSegSkin;                 //non-segmented model system
762 
763   qhandle_t   modelIcon;
764 
765   animation_t animations[ MAX_PLAYER_TOTALANIMATIONS ];
766 
767   sfxHandle_t sounds[ MAX_CUSTOM_SOUNDS ];
768 
769   sfxHandle_t customFootsteps[ 4 ];
770   sfxHandle_t customMetalFootsteps[ 4 ];
771 } clientInfo_t;
772 
773 
774 typedef struct weaponInfoMode_s
775 {
776   float       flashDlight;
777   vec3_t      flashDlightColor;
778   sfxHandle_t flashSound[ 4 ];  // fast firing weapons randomly choose
779   qboolean    continuousFlash;
780 
781   qhandle_t   missileModel;
782   sfxHandle_t missileSound;
783   float       missileDlight;
784   vec3_t      missileDlightColor;
785   int         missileRenderfx;
786   qboolean    usesSpriteMissle;
787   qhandle_t   missileSprite;
788   int         missileSpriteSize;
789   qhandle_t   missileParticleSystem;
790   qhandle_t   missileTrailSystem;
791   qboolean    missileRotates;
792   qboolean    missileAnimates;
793   int         missileAnimStartFrame;
794   int         missileAnimNumFrames;
795   int         missileAnimFrameRate;
796   int         missileAnimLooping;
797 
798   sfxHandle_t firingSound;
799   qboolean    loopFireSound;
800 
801   qhandle_t   muzzleParticleSystem;
802 
803   qboolean    alwaysImpact;
804   qhandle_t   impactParticleSystem;
805   qhandle_t   impactMark;
806   qhandle_t   impactMarkSize;
807   sfxHandle_t impactSound[ 4 ]; //random impact sound
808   sfxHandle_t impactFleshSound[ 4 ]; //random impact sound
809 } weaponInfoMode_t;
810 
811 // each WP_* weapon enum has an associated weaponInfo_t
812 // that contains media references necessary to present the
813 // weapon and its effects
814 typedef struct weaponInfo_s
815 {
816   qboolean          registered;
817   char              *humanName;
818 
819   qhandle_t         handsModel;       // the hands don't actually draw, they just position the weapon
820   qhandle_t         weaponModel;
821   qhandle_t         barrelModel;
822   qhandle_t         flashModel;
823 
824   vec3_t            weaponMidpoint;   // so it will rotate centered instead of by tag
825 
826   qhandle_t         weaponIcon;
827   qhandle_t         ammoIcon;
828 
829   qhandle_t         crossHair;
830   int               crossHairSize;
831 
832   sfxHandle_t       readySound;
833 
834   qboolean          disableIn3rdPerson;
835 
836   weaponInfoMode_t  wim[ WPM_NUM_WEAPONMODES ];
837 } weaponInfo_t;
838 
839 typedef struct upgradeInfo_s
840 {
841   qboolean    registered;
842   char        *humanName;
843 
844   qhandle_t   upgradeIcon;
845 } upgradeInfo_t;
846 
847 typedef struct
848 {
849   qboolean    looped;
850   qboolean    enabled;
851 
852   sfxHandle_t sound;
853 } sound_t;
854 
855 typedef struct
856 {
857   qhandle_t   models[ MAX_BUILDABLE_MODELS ];
858   animation_t animations[ MAX_BUILDABLE_ANIMATIONS ];
859 
860   //same number of sounds as animations
861   sound_t     sounds[ MAX_BUILDABLE_ANIMATIONS ];
862 } buildableInfo_t;
863 
864 #define MAX_REWARDSTACK   10
865 #define MAX_SOUNDBUFFER   20
866 
867 //======================================================================
868 
869 //TA:
870 typedef struct
871 {
872   vec3_t    alienBuildablePos[ MAX_GENTITIES ];
873   int       alienBuildableTimes[ MAX_GENTITIES ];
874   int       numAlienBuildables;
875 
876   vec3_t    humanBuildablePos[ MAX_GENTITIES ];
877   int       numHumanBuildables;
878 
879   vec3_t    alienClientPos[ MAX_CLIENTS ];
880   int       numAlienClients;
881 
882   vec3_t    humanClientPos[ MAX_CLIENTS ];
883   int       numHumanClients;
884 
885   int       lastUpdateTime;
886   vec3_t    origin;
887   vec3_t    vangles;
888 } entityPos_t;
889 
890 typedef struct
891 {
892   int time;
893   int length;
894 } consoleLine_t;
895 
896 #define MAX_CONSOLE_TEXT  8192
897 #define MAX_CONSOLE_LINES 32
898 
899 // all cg.stepTime, cg.duckTime, cg.landTime, etc are set to cg.time when the action
900 // occurs, and they will have visible effects for #define STEP_TIME or whatever msec after
901 
902 #define MAX_PREDICTED_EVENTS  16
903 
904 typedef struct
905 {
906   int           clientFrame;                        // incremented each frame
907 
908   int           clientNum;
909 
910   qboolean      demoPlayback;
911   qboolean      levelShot;                          // taking a level menu screenshot
912   int           deferredPlayerLoading;
913   qboolean      loading;                            // don't defer players at initial startup
914   qboolean      intermissionStarted;                // don't play voice rewards, because game will end shortly
915 
916   // there are only one or two snapshot_t that are relevent at a time
917   int           latestSnapshotNum;                  // the number of snapshots the client system has received
918   int           latestSnapshotTime;                 // the time from latestSnapshotNum, so we don't need to read the snapshot yet
919 
920   snapshot_t    *snap;                              // cg.snap->serverTime <= cg.time
921   snapshot_t    *nextSnap;                          // cg.nextSnap->serverTime > cg.time, or NULL
922   snapshot_t    activeSnapshots[ 2 ];
923 
924   float         frameInterpolation;                 // (float)( cg.time - cg.frame->serverTime ) /
925                                                     // (cg.nextFrame->serverTime - cg.frame->serverTime)
926 
927   qboolean      thisFrameTeleport;
928   qboolean      nextFrameTeleport;
929 
930   int           frametime;                          // cg.time - cg.oldTime
931 
932   int           time;                               // this is the time value that the client
933                                                     // is rendering at.
934   int           oldTime;                            // time at last frame, used for missile trails and prediction checking
935 
936   int           physicsTime;                        // either cg.snap->time or cg.nextSnap->time
937 
938   int           timelimitWarnings;                  // 5 min, 1 min, overtime
939   int           fraglimitWarnings;
940 
941   qboolean      mapRestart;                         // set on a map restart to set back the weapon
942 
943   qboolean      renderingThirdPerson;               // during deaths, chasecams, etc
944 
945   // prediction state
946   qboolean      hyperspace;                         // true if prediction has hit a trigger_teleport
947   playerState_t predictedPlayerState;
948   centity_t     predictedPlayerEntity;
949   qboolean      validPPS;                           // clear until the first call to CG_PredictPlayerState
950   int           predictedErrorTime;
951   vec3_t        predictedError;
952 
953   int           eventSequence;
954   int           predictableEvents[MAX_PREDICTED_EVENTS];
955 
956   float         stepChange;                         // for stair up smoothing
957   int           stepTime;
958 
959   float         duckChange;                         // for duck viewheight smoothing
960   int           duckTime;
961 
962   float         landChange;                         // for landing hard
963   int           landTime;
964 
965   // input state sent to server
966   int           weaponSelect;
967 
968   // auto rotating items
969   vec3_t        autoAngles;
970   vec3_t        autoAxis[ 3 ];
971   vec3_t        autoAnglesFast;
972   vec3_t        autoAxisFast[ 3 ];
973 
974   // view rendering
975   refdef_t      refdef;
976   vec3_t        refdefViewAngles;                   // will be converted to refdef.viewaxis
977 
978   // zoom key
979   qboolean      zoomed;
980   int           zoomTime;
981   float         zoomSensitivity;
982 
983   // information screen text during loading
984   char          infoScreenText[ MAX_STRING_CHARS ];
985 
986   // scoreboard
987   int           scoresRequestTime;
988   int           numScores;
989   int           selectedScore;
990   int           teamScores[ 2 ];
991   score_t       scores[MAX_CLIENTS];
992   qboolean      showScores;
993   qboolean      scoreBoardShowing;
994   int           scoreFadeTime;
995   char          killerName[ MAX_NAME_LENGTH ];
996   char          spectatorList[ MAX_STRING_CHARS ];  // list of names
997   int           spectatorLen;                       // length of list
998   float         spectatorWidth;                     // width in device units
999   int           spectatorTime;                      // next time to offset
1000   int           spectatorPaintX;                    // current paint x
1001   int           spectatorPaintX2;                   // current paint x
1002   int           spectatorOffset;                    // current offset from start
1003   int           spectatorPaintLen;                  // current offset from start
1004 
1005   // centerprinting
1006   int           centerPrintTime;
1007   int           centerPrintCharWidth;
1008   int           centerPrintY;
1009   char          centerPrint[ 1024 ];
1010   int           centerPrintLines;
1011 
1012   // low ammo warning state
1013   int           lowAmmoWarning;   // 1 = low, 2 = empty
1014 
1015   // kill timers for carnage reward
1016   int           lastKillTime;
1017 
1018   // crosshair client ID
1019   int           crosshairClientNum;
1020   int           crosshairClientTime;
1021 
1022   // powerup active flashing
1023   int           powerupActive;
1024   int           powerupTime;
1025 
1026   // attacking player
1027   int           attackerTime;
1028   int           voiceTime;
1029 
1030   // reward medals
1031   int           rewardStack;
1032   int           rewardTime;
1033   int           rewardCount[ MAX_REWARDSTACK ];
1034   qhandle_t     rewardShader[ MAX_REWARDSTACK ];
1035   qhandle_t     rewardSound[ MAX_REWARDSTACK ];
1036 
1037   // sound buffer mainly for announcer sounds
1038   int           soundBufferIn;
1039   int           soundBufferOut;
1040   int           soundTime;
1041   qhandle_t     soundBuffer[ MAX_SOUNDBUFFER ];
1042 
1043   // for voice chat buffer
1044   int           voiceChatTime;
1045   int           voiceChatBufferIn;
1046   int           voiceChatBufferOut;
1047 
1048   // warmup countdown
1049   int           warmup;
1050   int           warmupCount;
1051 
1052   //==========================
1053 
1054   int           itemPickup;
1055   int           itemPickupTime;
1056   int           itemPickupBlendTime;                // the pulse around the crosshair is timed seperately
1057 
1058   int           weaponSelectTime;
1059   int           weaponAnimation;
1060   int           weaponAnimationTime;
1061 
1062   // blend blobs
1063   float         damageTime;
1064   float         damageX, damageY, damageValue;
1065 
1066   // status bar head
1067   float         headYaw;
1068   float         headEndPitch;
1069   float         headEndYaw;
1070   int           headEndTime;
1071   float         headStartPitch;
1072   float         headStartYaw;
1073   int           headStartTime;
1074 
1075   // view movement
1076   float         v_dmg_time;
1077   float         v_dmg_pitch;
1078   float         v_dmg_roll;
1079 
1080   vec3_t        kick_angles;                        // weapon kicks
1081   vec3_t        kick_origin;
1082 
1083   // temp working variables for player view
1084   float         bobfracsin;
1085   int           bobcycle;
1086   float         xyspeed;
1087   int           nextOrbitTime;
1088 
1089   // development tool
1090   refEntity_t   testModelEntity;
1091   refEntity_t   testModelBarrelEntity;
1092   char          testModelName[MAX_QPATH];
1093   char          testModelBarrelName[MAX_QPATH];
1094   qboolean      testGun;
1095 
1096   int           spawnTime;                          //TA: fovwarp
1097   int           weapon1Time;                        //TA: time when BUTTON_ATTACK went t->f f->t
1098   int           weapon2Time;                        //TA: time when BUTTON_ATTACK2 went t->f f->t
1099   int           weapon3Time;                        //TA: time when BUTTON_USE_HOLDABLE went t->f f->t
1100   qboolean      weapon1Firing;
1101   qboolean      weapon2Firing;
1102   qboolean      weapon3Firing;
1103 
1104   int           poisonedTime;
1105 
1106   vec3_t        lastNormal;                         //TA: view smoothage
1107   vec3_t        lastVangles;                        //TA: view smoothage
1108   smooth_t      sList[ MAXSMOOTHS ];                //TA: WW smoothing
1109 
1110   int           forwardMoveTime;                    //TA: for struggling
1111   int           rightMoveTime;
1112   int           upMoveTime;
1113 
1114   float         charModelFraction;                  //TA: loading percentages
1115   float         mediaFraction;
1116   float         buildablesFraction;
1117 
1118   int           lastBuildAttempt;
1119   int           lastEvolveAttempt;
1120 
1121   char          consoleText[ MAX_CONSOLE_TEXT ];
1122   consoleLine_t consoleLines[ MAX_CONSOLE_LINES ];
1123   int           numConsoleLines;
1124 
1125   particleSystem_t  *poisonCloudPS;
1126 
1127   float         painBlendValue;
1128   float         painBlendTarget;
1129   int           lastHealth;
1130 } cg_t;
1131 
1132 
1133 // all of the model, shader, and sound references that are
1134 // loaded at gamestate time are stored in cgMedia_t
1135 // Other media that can be tied to clients, weapons, or items are
1136 // stored in the clientInfo_t, itemInfo_t, weaponInfo_t, and powerupInfo_t
1137 typedef struct
1138 {
1139   qhandle_t   charsetShader;
1140   qhandle_t   whiteShader;
1141   qhandle_t   outlineShader;
1142 
1143   qhandle_t   level2ZapTS;
1144 
1145   qhandle_t   balloonShader;
1146   qhandle_t   connectionShader;
1147 
1148   qhandle_t   viewBloodShader;
1149   qhandle_t   tracerShader;
1150   qhandle_t   crosshairShader[ WP_NUM_WEAPONS ];
1151   qhandle_t   backTileShader;
1152 
1153   qhandle_t   creepShader;
1154 
1155   qhandle_t   scannerShader;
1156   qhandle_t   scannerBlipShader;
1157   qhandle_t   scannerLineShader;
1158 
1159 
1160   qhandle_t   numberShaders[ 11 ];
1161 
1162   qhandle_t   shadowMarkShader;
1163   qhandle_t   wakeMarkShader;
1164 
1165   // buildable shaders
1166   qhandle_t   greenBuildShader;
1167   qhandle_t   redBuildShader;
1168   qhandle_t   noPowerShader;
1169   qhandle_t   humanSpawningShader;
1170 
1171   // disconnect
1172   qhandle_t   disconnectPS;
1173   qhandle_t   disconnectSound;
1174 
1175   // sounds
1176   sfxHandle_t tracerSound;
1177   sfxHandle_t selectSound;
1178   sfxHandle_t footsteps[ FOOTSTEP_TOTAL ][ 4 ];
1179   sfxHandle_t talkSound;
1180   sfxHandle_t alienTalkSound;
1181   sfxHandle_t humanTalkSound;
1182   sfxHandle_t landSound;
1183   sfxHandle_t fallSound;
1184 
1185   sfxHandle_t hardBounceSound1;
1186   sfxHandle_t hardBounceSound2;
1187 
1188   sfxHandle_t voteNow;
1189   sfxHandle_t votePassed;
1190   sfxHandle_t voteFailed;
1191 
1192   sfxHandle_t watrInSound;
1193   sfxHandle_t watrOutSound;
1194   sfxHandle_t watrUnSound;
1195 
1196   sfxHandle_t jetpackDescendSound;
1197   sfxHandle_t jetpackIdleSound;
1198   sfxHandle_t jetpackAscendSound;
1199 
1200   qhandle_t   jetPackDescendPS;
1201   qhandle_t   jetPackHoverPS;
1202   qhandle_t   jetPackAscendPS;
1203 
1204   sfxHandle_t medkitUseSound;
1205 
1206   sfxHandle_t alienStageTransition;
1207   sfxHandle_t humanStageTransition;
1208 
1209   sfxHandle_t alienOvermindAttack;
1210   sfxHandle_t alienOvermindDying;
1211   sfxHandle_t alienOvermindSpawns;
1212 
1213   sfxHandle_t alienBuildableExplosion;
1214   sfxHandle_t alienBuildableDamage;
1215   sfxHandle_t alienBuildablePrebuild;
1216   sfxHandle_t humanBuildableExplosion;
1217   sfxHandle_t humanBuildablePrebuild;
1218   sfxHandle_t humanBuildableDamage[ 4 ];
1219 
1220   sfxHandle_t alienL1Grab;
1221   sfxHandle_t alienL4ChargePrepare;
1222   sfxHandle_t alienL4ChargeStart;
1223 
1224   qhandle_t   cursor;
1225   qhandle_t   selectCursor;
1226   qhandle_t   sizeCursor;
1227 
1228   //light armour
1229   qhandle_t larmourHeadSkin;
1230   qhandle_t larmourLegsSkin;
1231   qhandle_t larmourTorsoSkin;
1232 
1233   qhandle_t jetpackModel;
1234   qhandle_t jetpackFlashModel;
1235   qhandle_t battpackModel;
1236 
1237   sfxHandle_t repeaterUseSound;
1238 
1239   sfxHandle_t buildableRepairSound;
1240   sfxHandle_t buildableRepairedSound;
1241 
1242   qhandle_t   poisonCloudPS;
1243   qhandle_t   alienEvolvePS;
1244   qhandle_t   alienAcidTubePS;
1245 
1246   sfxHandle_t alienEvolveSound;
1247 
1248   qhandle_t   humanBuildableDamagedPS;
1249   qhandle_t   humanBuildableDestroyedPS;
1250   qhandle_t   alienBuildableDamagedPS;
1251   qhandle_t   alienBuildableDestroyedPS;
1252 
1253   qhandle_t   alienBleedPS;
1254   qhandle_t   humanBleedPS;
1255 
1256   qhandle_t   teslaZapTS;
1257 
1258   sfxHandle_t lCannonWarningSound;
1259 
1260   qhandle_t   buildWeaponTimerPie[ 8 ];
1261   qhandle_t   upgradeClassIconShader;
1262 } cgMedia_t;
1263 
1264 
1265 // The client game static (cgs) structure hold everything
1266 // loaded or calculated from the gamestate.  It will NOT
1267 // be cleared when a tournement restart is done, allowing
1268 // all clients to begin playing instantly
1269 typedef struct
1270 {
1271   gameState_t   gameState;              // gamestate from server
1272   glconfig_t    glconfig;               // rendering configuration
1273   float         screenXScale;           // derived from glconfig
1274   float         screenYScale;
1275   float         screenXBias;
1276 
1277   int           serverCommandSequence;  // reliable command stream counter
1278   int           processedSnapshotNum;   // the number of snapshots cgame has requested
1279 
1280   qboolean      localServer;            // detected on startup by checking sv_running
1281 
1282   // parsed from serverinfo
1283   int           dmflags;
1284   int           teamflags;
1285   int           timelimit;
1286   int           maxclients;
1287   char          mapname[ MAX_QPATH ];
1288 
1289   int           voteTime;
1290   int           voteYes;
1291   int           voteNo;
1292   qboolean      voteModified;           // beep whenever changed
1293   char          voteString[ MAX_STRING_TOKENS ];
1294 
1295   int           teamVoteTime[ 2 ];
1296   int           teamVoteYes[ 2 ];
1297   int           teamVoteNo[ 2 ];
1298   qboolean      teamVoteModified[ 2 ];  // beep whenever changed
1299   char          teamVoteString[ 2 ][ MAX_STRING_TOKENS ];
1300 
1301   int           levelStartTime;
1302 
1303   int           scores1, scores2;   // from configstrings
1304 
1305   qboolean      newHud;
1306 
1307   int           alienBuildPoints;
1308   int           alienBuildPointsTotal;
1309   int           humanBuildPoints;
1310   int           humanBuildPointsTotal;
1311   int           humanBuildPointsPowered;
1312 
1313   int           alienStage;
1314   int           humanStage;
1315   int           alienKills;
1316   int           humanKills;
1317   int           alienNextStageThreshold;
1318   int           humanNextStageThreshold;
1319 
1320   int           numAlienSpawns;
1321   int           numHumanSpawns;
1322 
1323   //
1324   // locally derived information from gamestate
1325   //
1326   qhandle_t     gameModels[ MAX_MODELS ];
1327   qhandle_t     gameShaders[ MAX_GAME_SHADERS ];
1328   qhandle_t     gameParticleSystems[ MAX_GAME_PARTICLE_SYSTEMS ];
1329   sfxHandle_t   gameSounds[ MAX_SOUNDS ];
1330 
1331   int           numInlineModels;
1332   qhandle_t     inlineDrawModel[ MAX_MODELS ];
1333   vec3_t        inlineModelMidpoints[ MAX_MODELS ];
1334 
1335   clientInfo_t  clientinfo[ MAX_CLIENTS ];
1336 
1337   //TA: corpse info
1338   clientInfo_t  corpseinfo[ MAX_CLIENTS ];
1339 
1340   // teamchat width is *3 because of embedded color codes
1341   char          teamChatMsgs[ TEAMCHAT_HEIGHT ][ TEAMCHAT_WIDTH * 3 + 1 ];
1342   int           teamChatMsgTimes[ TEAMCHAT_HEIGHT ];
1343   int           teamChatPos;
1344   int           teamLastChatPos;
1345 
1346   int           cursorX;
1347   int           cursorY;
1348   qboolean      eventHandling;
1349   qboolean      mouseCaptured;
1350   qboolean      sizingHud;
1351   void          *capturedItem;
1352   qhandle_t     activeCursor;
1353 
1354   // media
1355   cgMedia_t           media;
1356 } cgs_t;
1357 
1358 //==============================================================================
1359 
1360 extern  cgs_t     cgs;
1361 extern  cg_t      cg;
1362 extern  centity_t cg_entities[ MAX_GENTITIES ];
1363 
1364 //TA: weapon limit expanded:
1365 //extern  weaponInfo_t  cg_weapons[MAX_WEAPONS];
1366 extern  weaponInfo_t    cg_weapons[ 32 ];
1367 //TA: upgrade infos:
1368 extern  upgradeInfo_t   cg_upgrades[ 32 ];
1369 
1370 //TA: buildable infos:
1371 extern  buildableInfo_t cg_buildables[ BA_NUM_BUILDABLES ];
1372 
1373 extern  markPoly_t      cg_markPolys[ MAX_MARK_POLYS ];
1374 
1375 extern  vmCvar_t    cg_centertime;
1376 extern  vmCvar_t    cg_runpitch;
1377 extern  vmCvar_t    cg_runroll;
1378 extern  vmCvar_t    cg_bobup;
1379 extern  vmCvar_t    cg_bobpitch;
1380 extern  vmCvar_t    cg_bobroll;
1381 extern  vmCvar_t    cg_swingSpeed;
1382 extern  vmCvar_t    cg_shadows;
1383 extern  vmCvar_t    cg_gibs;
1384 extern  vmCvar_t    cg_drawTimer;
1385 extern  vmCvar_t    cg_drawFPS;
1386 extern  vmCvar_t    cg_drawDemoState;
1387 extern  vmCvar_t    cg_drawSnapshot;
1388 extern  vmCvar_t    cg_draw3dIcons;
1389 extern  vmCvar_t    cg_drawIcons;
1390 extern  vmCvar_t    cg_drawAmmoWarning;
1391 extern  vmCvar_t    cg_drawCrosshair;
1392 extern  vmCvar_t    cg_drawCrosshairNames;
1393 extern  vmCvar_t    cg_drawRewards;
1394 extern  vmCvar_t    cg_drawTeamOverlay;
1395 extern  vmCvar_t    cg_teamOverlayUserinfo;
1396 extern  vmCvar_t    cg_crosshairX;
1397 extern  vmCvar_t    cg_crosshairY;
1398 extern  vmCvar_t    cg_drawStatus;
1399 extern  vmCvar_t    cg_draw2D;
1400 extern  vmCvar_t    cg_animSpeed;
1401 extern  vmCvar_t    cg_debugAnim;
1402 extern  vmCvar_t    cg_debugPosition;
1403 extern  vmCvar_t    cg_debugEvents;
1404 extern  vmCvar_t    cg_teslaTrailTime;
1405 extern  vmCvar_t    cg_railTrailTime;
1406 extern  vmCvar_t    cg_errorDecay;
1407 extern  vmCvar_t    cg_nopredict;
1408 extern  vmCvar_t    cg_debugMove;
1409 extern  vmCvar_t    cg_noPlayerAnims;
1410 extern  vmCvar_t    cg_showmiss;
1411 extern  vmCvar_t    cg_footsteps;
1412 extern  vmCvar_t    cg_addMarks;
1413 extern  vmCvar_t    cg_brassTime;
1414 extern  vmCvar_t    cg_gun_frame;
1415 extern  vmCvar_t    cg_gun_x;
1416 extern  vmCvar_t    cg_gun_y;
1417 extern  vmCvar_t    cg_gun_z;
1418 extern  vmCvar_t    cg_drawGun;
1419 extern  vmCvar_t    cg_viewsize;
1420 extern  vmCvar_t    cg_tracerChance;
1421 extern  vmCvar_t    cg_tracerWidth;
1422 extern  vmCvar_t    cg_tracerLength;
1423 extern  vmCvar_t    cg_autoswitch;
1424 extern  vmCvar_t    cg_ignore;
1425 extern  vmCvar_t    cg_simpleItems;
1426 extern  vmCvar_t    cg_fov;
1427 extern  vmCvar_t    cg_zoomFov;
1428 extern  vmCvar_t    cg_thirdPersonRange;
1429 extern  vmCvar_t    cg_thirdPersonAngle;
1430 extern  vmCvar_t    cg_thirdPerson;
1431 extern  vmCvar_t    cg_stereoSeparation;
1432 extern  vmCvar_t    cg_lagometer;
1433 extern  vmCvar_t    cg_drawAttacker;
1434 extern  vmCvar_t    cg_synchronousClients;
1435 extern  vmCvar_t    cg_teamChatTime;
1436 extern  vmCvar_t    cg_teamChatHeight;
1437 extern  vmCvar_t    cg_stats;
1438 extern  vmCvar_t    cg_forceModel;
1439 extern  vmCvar_t    cg_buildScript;
1440 extern  vmCvar_t    cg_paused;
1441 extern  vmCvar_t    cg_blood;
1442 extern  vmCvar_t    cg_predictItems;
1443 extern  vmCvar_t    cg_deferPlayers;
1444 extern  vmCvar_t    cg_drawFriend;
1445 extern  vmCvar_t    cg_teamChatsOnly;
1446 extern  vmCvar_t    cg_noVoiceChats;
1447 extern  vmCvar_t    cg_noVoiceText;
1448 extern  vmCvar_t    cg_scorePlum;
1449 extern  vmCvar_t    cg_smoothClients;
1450 extern  vmCvar_t    pmove_fixed;
1451 extern  vmCvar_t    pmove_msec;
1452 //extern  vmCvar_t    cg_pmove_fixed;
1453 extern  vmCvar_t    cg_cameraOrbit;
1454 extern  vmCvar_t    cg_cameraOrbitDelay;
1455 extern  vmCvar_t    cg_timescaleFadeEnd;
1456 extern  vmCvar_t    cg_timescaleFadeSpeed;
1457 extern  vmCvar_t    cg_timescale;
1458 extern  vmCvar_t    cg_cameraMode;
1459 extern  vmCvar_t    cg_smallFont;
1460 extern  vmCvar_t    cg_bigFont;
1461 extern  vmCvar_t    cg_noTaunt;
1462 extern  vmCvar_t    cg_noProjectileTrail;
1463 extern  vmCvar_t    cg_oldRail;
1464 extern  vmCvar_t    cg_oldRocket;
1465 extern  vmCvar_t    cg_oldPlasma;
1466 extern  vmCvar_t    cg_trueLightning;
1467 extern  vmCvar_t    cg_creepRes;
1468 extern  vmCvar_t    cg_drawSurfNormal;
1469 extern  vmCvar_t    cg_drawBBOX;
1470 extern  vmCvar_t    cg_debugAlloc;
1471 extern  vmCvar_t    cg_wwSmoothTime;
1472 extern  vmCvar_t    cg_wwFollow;
1473 extern  vmCvar_t    cg_wwToggle;
1474 extern  vmCvar_t    cg_depthSortParticles;
1475 extern  vmCvar_t    cg_consoleLatency;
1476 extern  vmCvar_t    cg_lightFlare;
1477 extern  vmCvar_t    cg_debugParticles;
1478 extern  vmCvar_t    cg_debugTrails;
1479 extern  vmCvar_t    cg_debugPVS;
1480 extern  vmCvar_t    cg_disableWarningDialogs;
1481 extern  vmCvar_t    cg_disableScannerPlane;
1482 extern  vmCvar_t    cg_tutorial;
1483 
1484 extern  vmCvar_t    cg_painBlendUpRate;
1485 extern  vmCvar_t    cg_painBlendDownRate;
1486 extern  vmCvar_t    cg_painBlendMax;
1487 extern  vmCvar_t    cg_painBlendScale;
1488 extern  vmCvar_t    cg_painBlendZoom;
1489 
1490 //TA: hack to get class an carriage through to UI module
1491 extern  vmCvar_t    ui_currentClass;
1492 extern  vmCvar_t    ui_carriage;
1493 extern  vmCvar_t    ui_stages;
1494 extern  vmCvar_t    ui_dialog;
1495 extern  vmCvar_t    ui_loading;
1496 extern  vmCvar_t    ui_voteActive;
1497 extern  vmCvar_t    ui_alienTeamVoteActive;
1498 extern  vmCvar_t    ui_humanTeamVoteActive;
1499 
1500 extern  vmCvar_t    cg_debugRandom;
1501 
1502 //
1503 // cg_main.c
1504 //
1505 const char  *CG_ConfigString( int index );
1506 const char  *CG_Argv( int arg );
1507 
1508 void QDECL  CG_Printf( const char *msg, ... );
1509 void QDECL  CG_Error( const char *msg, ... );
1510 
1511 void        CG_StartMusic( void );
1512 int         CG_PlayerCount( void );
1513 
1514 void        CG_UpdateCvars( void );
1515 
1516 int         CG_CrosshairPlayer( void );
1517 int         CG_LastAttacker( void );
1518 void        CG_LoadMenus( const char *menuFile );
1519 void        CG_KeyEvent( int key, qboolean down );
1520 void        CG_MouseEvent( int x, int y );
1521 void        CG_EventHandling( int type );
1522 void        CG_SetScoreSelection( void *menu );
1523 void        CG_BuildSpectatorString( void );
1524 
1525 qboolean    CG_FileExists( char *filename );
1526 void        CG_RemoveNotifyLine( void );
1527 void        CG_AddNotifyText( void );
1528 
1529 
1530 //
1531 // cg_view.c
1532 //
1533 void        CG_addSmoothOp( vec3_t rotAxis, float rotAngle, float timeMod ); //TA
1534 void        CG_TestModel_f( void );
1535 void        CG_TestGun_f( void );
1536 void        CG_TestModelNextFrame_f( void );
1537 void        CG_TestModelPrevFrame_f( void );
1538 void        CG_TestModelNextSkin_f( void );
1539 void        CG_TestModelPrevSkin_f( void );
1540 void        CG_ZoomDown_f( void );
1541 void        CG_ZoomUp_f( void );
1542 void        CG_AddBufferedSound( sfxHandle_t sfx );
1543 void        CG_DrawActiveFrame( int serverTime, stereoFrame_t stereoView, qboolean demoPlayback );
1544 
1545 
1546 //
1547 // cg_drawtools.c
1548 //
1549 void        CG_DrawPlane( vec3_t origin, vec3_t down, vec3_t right, qhandle_t shader );
1550 void        CG_AdjustFrom640( float *x, float *y, float *w, float *h );
1551 void        CG_FillRect( float x, float y, float width, float height, const float *color );
1552 void        CG_DrawPic( float x, float y, float width, float height, qhandle_t hShader );
1553 void        CG_DrawFadePic( float x, float y, float width, float height, vec4_t fcolor,
1554                             vec4_t tcolor, float amount, qhandle_t hShader );
1555 
1556 int         CG_DrawStrlen( const char *str );
1557 
1558 float       *CG_FadeColor( int startMsec, int totalMsec );
1559 void        CG_TileClear( void );
1560 void        CG_ColorForHealth( vec4_t hcolor );
1561 void        CG_GetColorForHealth( int health, int armor, vec4_t hcolor );
1562 
1563 void        CG_DrawRect( float x, float y, float width, float height, float size, const float *color );
1564 void        CG_DrawSides(float x, float y, float w, float h, float size);
1565 void        CG_DrawTopBottom(float x, float y, float w, float h, float size);
1566 
1567 
1568 //
1569 // cg_draw.c
1570 //
1571 extern  int sortedTeamPlayers[ TEAM_MAXOVERLAY ];
1572 extern  int numSortedTeamPlayers;
1573 extern  char systemChat[ 256 ];
1574 extern  char teamChat1[ 256 ];
1575 extern  char teamChat2[ 256 ];
1576 
1577 void        CG_AddLagometerFrameInfo( void );
1578 void        CG_AddLagometerSnapshotInfo( snapshot_t *snap );
1579 void        CG_CenterPrint( const char *str, int y, int charWidth );
1580 void        CG_DrawActive( stereoFrame_t stereoView );
1581 void        CG_OwnerDraw( float x, float y, float w, float h, float text_x, float text_y,
1582                           int ownerDraw, int ownerDrawFlags, int align, float special,
1583                           float scale, vec4_t color, qhandle_t shader, int textStyle);
1584 void        CG_Text_Paint( float x, float y, float scale, vec4_t color, const char *text, float adjust, int limit, int style );
1585 int         CG_Text_Width( const char *text, float scale, int limit );
1586 int         CG_Text_Height( const char *text, float scale, int limit );
1587 float       CG_GetValue(int ownerDraw);
1588 void        CG_RunMenuScript(char **args);
1589 void        CG_SetPrintString( int type, const char *p );
1590 void        CG_InitTeamChat( void );
1591 void        CG_GetTeamColor( vec4_t *color );
1592 const char  *CG_GetKillerText( void );
1593 void        CG_Text_PaintChar( float x, float y, float width, float height, float scale,
1594                                float s, float t, float s2, float t2, qhandle_t hShader );
1595 void        CG_DrawLoadingScreen( void );
1596 void        CG_UpdateMediaFraction( float newFract );
1597 void        CG_ResetPainBlend( void );
1598 
1599 //
1600 // cg_players.c
1601 //
1602 void        CG_Player( centity_t *cent );
1603 void        CG_Corpse( centity_t *cent );
1604 void        CG_ResetPlayerEntity( centity_t *cent );
1605 void        CG_AddRefEntityWithPowerups( refEntity_t *ent, int powerups, int team );
1606 void        CG_NewClientInfo( int clientNum );
1607 void        CG_PrecacheClientInfo( pClass_t class, char *model, char *skin );
1608 sfxHandle_t CG_CustomSound( int clientNum, const char *soundName );
1609 void        CG_PlayerDisconnect( vec3_t org );
1610 void        CG_Bleed( vec3_t origin, vec3_t normal, int entityNum );
1611 qboolean    CG_AtHighestClass( void );
1612 
1613 //
1614 // cg_buildable.c
1615 //
1616 void        CG_GhostBuildable( buildable_t buildable );
1617 void        CG_Buildable( centity_t *cent );
1618 void        CG_InitBuildables( void );
1619 void        CG_HumanBuildableExplosion( vec3_t origin, vec3_t dir );
1620 void        CG_AlienBuildableExplosion( vec3_t origin, vec3_t dir );
1621 
1622 //
1623 // cg_animation.c
1624 //
1625 void        CG_RunLerpFrame( lerpFrame_t *lf );
1626 
1627 //
1628 // cg_animmapobj.c
1629 //
1630 void        CG_AnimMapObj( centity_t *cent );
1631 void        CG_ModelDoor( centity_t *cent );
1632 
1633 //
1634 // cg_predict.c
1635 //
1636 
1637 #define MAGIC_TRACE_HACK -2
1638 
1639 void        CG_BuildSolidList( void );
1640 int         CG_PointContents( const vec3_t point, int passEntityNum );
1641 void        CG_Trace( trace_t *result, const vec3_t start, const vec3_t mins, const vec3_t maxs,
1642                 const vec3_t end, int skipNumber, int mask );
1643 void        CG_CapTrace( trace_t *result, const vec3_t start, const vec3_t mins, const vec3_t maxs,
1644                 const vec3_t end, int skipNumber, int mask );
1645 void        CG_BiSphereTrace( trace_t *result, const vec3_t start, const vec3_t end,
1646                 const float startRadius, const float endRadius, int skipNumber, int mask );
1647 void        CG_PredictPlayerState( void );
1648 
1649 
1650 //
1651 // cg_events.c
1652 //
1653 void        CG_CheckEvents( centity_t *cent );
1654 void        CG_EntityEvent( centity_t *cent, vec3_t position );
1655 void        CG_PainEvent( centity_t *cent, int health );
1656 
1657 
1658 //
1659 // cg_ents.c
1660 //
1661 void        CG_DrawBoundingBox( vec3_t origin, vec3_t mins, vec3_t maxs );
1662 void        CG_SetEntitySoundPosition( centity_t *cent );
1663 void        CG_AddPacketEntities( void );
1664 void        CG_Beam( centity_t *cent );
1665 void        CG_AdjustPositionForMover( const vec3_t in, int moverNum, int fromTime, int toTime, vec3_t out );
1666 
1667 void        CG_PositionEntityOnTag( refEntity_t *entity, const refEntity_t *parent,
1668                                     qhandle_t parentModel, char *tagName );
1669 void        CG_PositionRotatedEntityOnTag( refEntity_t *entity, const refEntity_t *parent,
1670                                            qhandle_t parentModel, char *tagName );
1671 
1672 
1673 
1674 
1675 //
1676 // cg_weapons.c
1677 //
1678 void        CG_NextWeapon_f( void );
1679 void        CG_PrevWeapon_f( void );
1680 void        CG_Weapon_f( void );
1681 
1682 void        CG_InitUpgrades( void );
1683 void        CG_RegisterUpgrade( int upgradeNum );
1684 void        CG_InitWeapons( void );
1685 void        CG_RegisterWeapon( int weaponNum );
1686 
1687 void        CG_FireWeapon( centity_t *cent, weaponMode_t weaponMode );
1688 void        CG_MissileHitWall( weapon_t weapon, weaponMode_t weaponMode, int clientNum,
1689                                vec3_t origin, vec3_t dir, impactSound_t soundType );
1690 void        CG_MissileHitPlayer( weapon_t weapon, weaponMode_t weaponMode, vec3_t origin, vec3_t dir, int entityNum );
1691 void        CG_Bullet( vec3_t origin, int sourceEntityNum, vec3_t normal, qboolean flesh, int fleshEntityNum );
1692 void        CG_ShotgunFire( entityState_t *es );
1693 
1694 void        CG_AddViewWeapon (playerState_t *ps);
1695 void        CG_AddPlayerWeapon( refEntity_t *parent, playerState_t *ps, centity_t *cent );
1696 void        CG_DrawItemSelect( rectDef_t *rect, vec4_t color );
1697 void        CG_DrawItemSelectText( rectDef_t *rect, float scale, int textStyle );
1698 
1699 
1700 //
1701 // cg_scanner.c
1702 //
1703 void        CG_UpdateEntityPositions( void );
1704 void        CG_Scanner( rectDef_t *rect, qhandle_t shader, vec4_t color );
1705 void        CG_AlienSense( rectDef_t *rect );
1706 
1707 //
1708 // cg_marks.c
1709 //
1710 void        CG_InitMarkPolys( void );
1711 void        CG_AddMarks( void );
1712 void        CG_ImpactMark( qhandle_t markShader,
1713                            const vec3_t origin, const vec3_t dir,
1714                            float orientation,
1715                            float r, float g, float b, float a,
1716                            qboolean alphaFade,
1717                            float radius, qboolean temporary );
1718 
1719 //
1720 // cg_snapshot.c
1721 //
1722 void          CG_ProcessSnapshots( void );
1723 
1724 //
1725 // cg_consolecmds.c
1726 //
1727 qboolean      CG_ConsoleCommand( void );
1728 void          CG_InitConsoleCommands( void );
1729 qboolean      CG_RequestScores( void );
1730 
1731 //
1732 // cg_servercmds.c
1733 //
1734 void          CG_ExecuteNewServerCommands( int latestSequence );
1735 void          CG_ParseServerinfo( void );
1736 void          CG_SetConfigValues( void );
1737 void          CG_ShaderStateChanged(void);
1738 
1739 //
1740 // cg_playerstate.c
1741 //
1742 void          CG_Respawn( void );
1743 void          CG_TransitionPlayerState( playerState_t *ps, playerState_t *ops );
1744 void          CG_CheckChangedPredictableEvents( playerState_t *ps );
1745 
1746 //
1747 // cg_mem.c
1748 //
1749 void          CG_InitMemory( void );
1750 void          *CG_Alloc( int size );
1751 void          CG_Free( void *ptr );
1752 void          CG_DefragmentMemory( void );
1753 
1754 //
1755 // cg_attachment.c
1756 //
1757 qboolean    CG_AttachmentPoint( attachment_t *a, vec3_t v );
1758 qboolean    CG_AttachmentDir( attachment_t *a, vec3_t v );
1759 qboolean    CG_AttachmentAxis( attachment_t *a, vec3_t axis[ 3 ] );
1760 qboolean    CG_AttachmentVelocity( attachment_t *a, vec3_t v );
1761 int         CG_AttachmentCentNum( attachment_t *a );
1762 
1763 qboolean    CG_Attached( attachment_t *a );
1764 
1765 void        CG_AttachToPoint( attachment_t *a );
1766 void        CG_AttachToCent( attachment_t *a );
1767 void        CG_AttachToTag( attachment_t *a );
1768 void        CG_AttachToParticle( attachment_t *a );
1769 void        CG_SetAttachmentPoint( attachment_t *a, vec3_t v );
1770 void        CG_SetAttachmentCent( attachment_t *a, centity_t *cent );
1771 void        CG_SetAttachmentTag( attachment_t *a, refEntity_t parent,
1772                 qhandle_t model, char *tagName );
1773 void        CG_SetAttachmentParticle( attachment_t *a, particle_t *p );
1774 
1775 void        CG_SetAttachmentOffset( attachment_t *a, vec3_t v );
1776 
1777 //
1778 // cg_particles.c
1779 //
1780 void                CG_LoadParticleSystems( void );
1781 qhandle_t           CG_RegisterParticleSystem( char *name );
1782 
1783 particleSystem_t    *CG_SpawnNewParticleSystem( qhandle_t psHandle );
1784 void                CG_DestroyParticleSystem( particleSystem_t **ps );
1785 
1786 qboolean            CG_IsParticleSystemInfinite( particleSystem_t *ps );
1787 qboolean            CG_IsParticleSystemValid( particleSystem_t **ps );
1788 
1789 void                CG_SetParticleSystemNormal( particleSystem_t *ps, vec3_t normal );
1790 
1791 void                CG_AddParticles( void );
1792 
1793 void                CG_ParticleSystemEntity( centity_t *cent );
1794 
1795 void                CG_TestPS_f( void );
1796 void                CG_DestroyTestPS_f( void );
1797 
1798 //
1799 // cg_trails.c
1800 //
1801 void                CG_LoadTrailSystems( void );
1802 qhandle_t           CG_RegisterTrailSystem( char *name );
1803 
1804 trailSystem_t       *CG_SpawnNewTrailSystem( qhandle_t psHandle );
1805 void                CG_DestroyTrailSystem( trailSystem_t **ts );
1806 
1807 qboolean            CG_IsTrailSystemValid( trailSystem_t **ts );
1808 
1809 void                CG_AddTrails( void );
1810 
1811 void                CG_TestTS_f( void );
1812 void                CG_DestroyTestTS_f( void );
1813 
1814 //
1815 // cg_ptr.c
1816 //
1817 int   CG_ReadPTRCode( void );
1818 void  CG_WritePTRCode( int code );
1819 
1820 //
1821 // cg_tutorial.c
1822 //
1823 const char *CG_TutorialText( void );
1824 
1825 //
1826 //===============================================
1827 
1828 //
1829 // system traps
1830 // These functions are how the cgame communicates with the main game system
1831 //
1832 
1833 
1834 // print message on the local console
1835 void          trap_Print( const char *fmt );
1836 
1837 // abort the game
1838 void          trap_Error( const char *fmt );
1839 
1840 // milliseconds should only be used for performance tuning, never
1841 // for anything game related.  Get time from the CG_DrawActiveFrame parameter
1842 int           trap_Milliseconds( void );
1843 
1844 // console variable interaction
1845 void          trap_Cvar_Register( vmCvar_t *vmCvar, const char *varName, const char *defaultValue, int flags );
1846 void          trap_Cvar_Update( vmCvar_t *vmCvar );
1847 void          trap_Cvar_Set( const char *var_name, const char *value );
1848 void          trap_Cvar_VariableStringBuffer( const char *var_name, char *buffer, int bufsize );
1849 
1850 // ServerCommand and ConsoleCommand parameter access
1851 int           trap_Argc( void );
1852 void          trap_Argv( int n, char *buffer, int bufferLength );
1853 void          trap_Args( char *buffer, int bufferLength );
1854 void          trap_LiteralArgs( char *buffer, int bufferLength );
1855 
1856 // filesystem access
1857 // returns length of file
1858 int           trap_FS_FOpenFile( const char *qpath, fileHandle_t *f, fsMode_t mode );
1859 void          trap_FS_Read( void *buffer, int len, fileHandle_t f );
1860 void          trap_FS_Write( const void *buffer, int len, fileHandle_t f );
1861 void          trap_FS_FCloseFile( fileHandle_t f );
1862 void          trap_FS_Seek( fileHandle_t f, long offset, fsOrigin_t origin ); // fsOrigin_t
1863 int           trap_FS_GetFileList( const char *path, const char *extension,
1864                                    char *listbuf, int bufsize );
1865 
1866 // add commands to the local console as if they were typed in
1867 // for map changing, etc.  The command is not executed immediately,
1868 // but will be executed in order the next time console commands
1869 // are processed
1870 void          trap_SendConsoleCommand( const char *text );
1871 
1872 // register a command name so the console can perform command completion.
1873 // FIXME: replace this with a normal console command "defineCommand"?
1874 void          trap_AddCommand( const char *cmdName );
1875 
1876 // send a string to the server over the network
1877 void          trap_SendClientCommand( const char *s );
1878 
1879 // force a screen update, only used during gamestate load
1880 void          trap_UpdateScreen( void );
1881 
1882 // model collision
1883 void          trap_CM_LoadMap( const char *mapname );
1884 int           trap_CM_NumInlineModels( void );
1885 clipHandle_t  trap_CM_InlineModel( int index );    // 0 = world, 1+ = bmodels
1886 clipHandle_t  trap_CM_TempBoxModel( const vec3_t mins, const vec3_t maxs );
1887 int           trap_CM_PointContents( const vec3_t p, clipHandle_t model );
1888 int           trap_CM_TransformedPointContents( const vec3_t p, clipHandle_t model, const vec3_t origin, const vec3_t angles );
1889 void          trap_CM_BoxTrace( trace_t *results, const vec3_t start, const vec3_t end,
1890                                 const vec3_t mins, const vec3_t maxs,
1891                                 clipHandle_t model, int brushmask );
1892 void          trap_CM_TransformedBoxTrace( trace_t *results, const vec3_t start, const vec3_t end,
1893                                            const vec3_t mins, const vec3_t maxs,
1894                                            clipHandle_t model, int brushmask,
1895                                            const vec3_t origin, const vec3_t angles );
1896 void          trap_CM_CapsuleTrace( trace_t *results, const vec3_t start, const vec3_t end,
1897                 const vec3_t mins, const vec3_t maxs,
1898                 clipHandle_t model, int brushmask );
1899 void          trap_CM_TransformedCapsuleTrace( trace_t *results, const vec3_t start, const vec3_t end,
1900                 const vec3_t mins, const vec3_t maxs,
1901                 clipHandle_t model, int brushmask,
1902                 const vec3_t origin, const vec3_t angles );
1903 void          trap_CM_BiSphereTrace( trace_t *results, const vec3_t start,
1904                 const vec3_t end, float startRad, float endRad,
1905                 clipHandle_t model, int mask );
1906 void          trap_CM_TransformedBiSphereTrace( trace_t *results, const vec3_t start,
1907                 const vec3_t end, float startRad, float endRad,
1908                 clipHandle_t model, int mask,
1909                 const vec3_t origin );
1910 
1911 // Returns the projection of a polygon onto the solid brushes in the world
1912 int           trap_CM_MarkFragments( int numPoints, const vec3_t *points,
1913                                      const vec3_t projection,
1914                                      int maxPoints, vec3_t pointBuffer,
1915                                      int maxFragments, markFragment_t *fragmentBuffer );
1916 
1917 // normal sounds will have their volume dynamically changed as their entity
1918 // moves and the listener moves
1919 void          trap_S_StartSound( vec3_t origin, int entityNum, int entchannel, sfxHandle_t sfx );
1920 void          trap_S_StopLoopingSound( int entnum );
1921 
1922 // a local sound is always played full volume
1923 void          trap_S_StartLocalSound( sfxHandle_t sfx, int channelNum );
1924 void          trap_S_ClearLoopingSounds( qboolean killall );
1925 void          trap_S_AddLoopingSound( int entityNum, const vec3_t origin, const vec3_t velocity, sfxHandle_t sfx );
1926 void          trap_S_AddRealLoopingSound( int entityNum, const vec3_t origin, const vec3_t velocity, sfxHandle_t sfx );
1927 void          trap_S_UpdateEntityPosition( int entityNum, const vec3_t origin );
1928 
1929 // respatialize recalculates the volumes of sound as they should be heard by the
1930 // given entityNum and position
1931 void          trap_S_Respatialize( int entityNum, const vec3_t origin, vec3_t axis[3], int inwater );
1932 sfxHandle_t   trap_S_RegisterSound( const char *sample, qboolean compressed );    // returns buzz if not found
1933 void          trap_S_StartBackgroundTrack( const char *intro, const char *loop ); // empty name stops music
1934 void          trap_S_StopBackgroundTrack( void );
1935 
1936 
1937 void          trap_R_LoadWorldMap( const char *mapname );
1938 
1939 // all media should be registered during level startup to prevent
1940 // hitches during gameplay
1941 qhandle_t     trap_R_RegisterModel( const char *name );     // returns rgb axis if not found
1942 qhandle_t     trap_R_RegisterSkin( const char *name );      // returns all white if not found
1943 qhandle_t     trap_R_RegisterShader( const char *name );      // returns all white if not found
1944 qhandle_t     trap_R_RegisterShaderNoMip( const char *name );     // returns all white if not found
1945 
1946 // a scene is built up by calls to R_ClearScene and the various R_Add functions.
1947 // Nothing is drawn until R_RenderScene is called.
1948 void          trap_R_ClearScene( void );
1949 void          trap_R_AddRefEntityToScene( const refEntity_t *re );
1950 
1951 // polys are intended for simple wall marks, not really for doing
1952 // significant construction
1953 void          trap_R_AddPolyToScene( qhandle_t hShader , int numVerts, const polyVert_t *verts );
1954 void          trap_R_AddPolysToScene( qhandle_t hShader , int numVerts, const polyVert_t *verts, int numPolys );
1955 void          trap_R_AddLightToScene( const vec3_t org, float intensity, float r, float g, float b );
1956 void          trap_R_AddAdditiveLightToScene( const vec3_t org, float intensity, float r, float g, float b );
1957 int           trap_R_LightForPoint( vec3_t point, vec3_t ambientLight, vec3_t directedLight, vec3_t lightDir );
1958 void          trap_R_RenderScene( const refdef_t *fd );
1959 void          trap_R_SetColor( const float *rgba ); // NULL = 1,1,1,1
1960 void          trap_R_DrawStretchPic( float x, float y, float w, float h,
1961                                      float s1, float t1, float s2, float t2, qhandle_t hShader );
1962 void          trap_R_ModelBounds( clipHandle_t model, vec3_t mins, vec3_t maxs );
1963 int           trap_R_LerpTag( orientation_t *tag, clipHandle_t mod, int startFrame, int endFrame,
1964                               float frac, const char *tagName );
1965 void          trap_R_RemapShader( const char *oldShader, const char *newShader, const char *timeOffset );
1966 
1967 // The glconfig_t will not change during the life of a cgame.
1968 // If it needs to change, the entire cgame will be restarted, because
1969 // all the qhandle_t are then invalid.
1970 void          trap_GetGlconfig( glconfig_t *glconfig );
1971 
1972 // the gamestate should be grabbed at startup, and whenever a
1973 // configstring changes
1974 void          trap_GetGameState( gameState_t *gamestate );
1975 
1976 // cgame will poll each frame to see if a newer snapshot has arrived
1977 // that it is interested in.  The time is returned seperately so that
1978 // snapshot latency can be calculated.
1979 void          trap_GetCurrentSnapshotNumber( int *snapshotNumber, int *serverTime );
1980 
1981 // a snapshot get can fail if the snapshot (or the entties it holds) is so
1982 // old that it has fallen out of the client system queue
1983 qboolean      trap_GetSnapshot( int snapshotNumber, snapshot_t *snapshot );
1984 
1985 // retrieve a text command from the server stream
1986 // the current snapshot will hold the number of the most recent command
1987 // qfalse can be returned if the client system handled the command
1988 // argc() / argv() can be used to examine the parameters of the command
1989 qboolean      trap_GetServerCommand( int serverCommandNumber );
1990 
1991 // returns the most recent command number that can be passed to GetUserCmd
1992 // this will always be at least one higher than the number in the current
1993 // snapshot, and it may be quite a few higher if it is a fast computer on
1994 // a lagged connection
1995 int           trap_GetCurrentCmdNumber( void );
1996 
1997 qboolean      trap_GetUserCmd( int cmdNumber, usercmd_t *ucmd );
1998 
1999 // used for the weapon select and zoom
2000 void          trap_SetUserCmdValue( int stateValue, float sensitivityScale );
2001 
2002 // aids for VM testing
2003 void          testPrintInt( char *string, int i );
2004 void          testPrintFloat( char *string, float f );
2005 
2006 int           trap_MemoryRemaining( void );
2007 void          trap_R_RegisterFont(const char *fontName, int pointSize, fontInfo_t *font);
2008 qboolean      trap_Key_IsDown( int keynum );
2009 int           trap_Key_GetCatcher( void );
2010 void          trap_Key_SetCatcher( int catcher );
2011 int           trap_Key_GetKey( const char *binding );
2012 void          trap_Key_KeynumToStringBuf( int keynum, char *buf, int buflen );
2013 void          trap_Key_GetBindingBuf( int keynum, char *buf, int buflen );
2014 void          trap_Key_SetBinding( int keynum, const char *binding );
2015 
2016 typedef enum
2017 {
2018   SYSTEM_PRINT,
2019   CHAT_PRINT,
2020   TEAMCHAT_PRINT
2021 } q3print_t;
2022 
2023 
2024 int           trap_CIN_PlayCinematic( const char *arg0, int xpos, int ypos, int width, int height, int bits );
2025 e_status      trap_CIN_StopCinematic( int handle );
2026 e_status      trap_CIN_RunCinematic( int handle );
2027 void          trap_CIN_DrawCinematic( int handle );
2028 void          trap_CIN_SetExtents( int handle, int x, int y, int w, int h );
2029 
2030 void          trap_SnapVector( float *v );
2031 
2032 qboolean      trap_loadCamera( const char *name );
2033 void          trap_startCamera( int time );
2034 qboolean      trap_getCameraInfo( int time, vec3_t *origin, vec3_t *angles );
2035 
2036 qboolean      trap_GetEntityToken( char *buffer, int bufferSize );
2037 
2038 int           trap_GetDemoState( void );
2039 int           trap_GetDemoPos( void );
2040 void          trap_GetDemoName( char *buffer, int size );
2041