Debian Codegraph @

code/cgame/cg_local.h

raw symbols SCIP
1 /*
2 ===========================================================================
3 Copyright (C) 1999-2005 Id Software, Inc.
4
5 This file is part of Quake III Arena source code.
6
7 Quake III Arena source code is free software; you can redistribute it
8 and/or modify it under the terms of the GNU General Public License as
9 published by the Free Software Foundation; either version 2 of the License,
10 or (at your option) any later version.
11
12 Quake III Arena source code is distributed in the hope that it will be
13 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with Quake III Arena source code; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 ===========================================================================
21 */
22 //
23 #include "../qcommon/q_shared.h"
24 #include "../renderercommon/tr_types.h"
25 #include "../game/bg_public.h"
26 #include "cg_public.h"
27
28
29 // The entire cgame module is unloaded and reloaded on each level change,
30 // so there is NO persistant data between levels on the client side.
31 // If you absolutely need something stored, it can either be kept
32 // by the server in the server stored userinfos, or stashed in a cvar.
33
34 #define POWERUP_BLINKS 5
35
36 #define POWERUP_BLINK_TIME 1000
37 #define FADE_TIME 200
38 #define PULSE_TIME 200
39 #define DAMAGE_DEFLECT_TIME 100
40 #define DAMAGE_RETURN_TIME 400
41 #define DAMAGE_TIME 500
42 #define LAND_DEFLECT_TIME 150
43 #define LAND_RETURN_TIME 300
44 #define STEP_TIME 200
45 #define DUCK_TIME 100
46 #define PAIN_TWITCH_TIME 200
47 #define WEAPON_SELECT_TIME 1400
48 #define ITEM_SCALEUP_TIME 1000
49 #define ZOOM_TIME 150
50 #define ITEM_BLOB_TIME 200
51 #define MUZZLE_FLASH_TIME 20
52 #define SINK_TIME 1000 // time for fragments to sink into ground before going away
53 #define ATTACKER_HEAD_TIME 10000
54 #define REWARD_TIME 3000
55
56 #define PULSE_SCALE 1.5 // amount to scale up the icons when activating
57
58 #define MAX_STEP_CHANGE 32
59
60 #define MAX_VERTS_ON_POLY 10
61 #define MAX_MARK_POLYS 256
62
63 #define STAT_MINUS 10 // num frame for '-' stats digit
64
65 #define ICON_SIZE 48
66 #undef CHAR_WIDTH // ignore define from libc
67 #define CHAR_WIDTH 32
68 #define CHAR_HEIGHT 48
69 #define TEXT_ICON_SPACE 4
70
71 #define TEAMCHAT_WIDTH 80
72 #define TEAMCHAT_HEIGHT 8
73
74 // very large characters
75 #define GIANT_WIDTH 32
76 #define GIANT_HEIGHT 48
77
78 #define NUM_CROSSHAIRS 10
79
80 #define TEAM_OVERLAY_MAXNAME_WIDTH 12
81 #define TEAM_OVERLAY_MAXLOCATION_WIDTH 16
82
83 #define DEFAULT_MODEL "sarge"
84 #ifdef MISSIONPACK
85 #define DEFAULT_TEAM_MODEL "james"
86 #define DEFAULT_TEAM_HEAD "*james"
87 #else
88 #define DEFAULT_TEAM_MODEL "sarge"
89 #define DEFAULT_TEAM_HEAD "sarge"
90 #endif
91
92 #define DEFAULT_REDTEAM_NAME "Stroggs"
93 #define DEFAULT_BLUETEAM_NAME "Pagans"
94
95 typedef enum {
96 FOOTSTEP_NORMAL,
97 FOOTSTEP_BOOT,
98 FOOTSTEP_FLESH,
99 FOOTSTEP_MECH,
100 FOOTSTEP_ENERGY,
101 FOOTSTEP_METAL,
102 FOOTSTEP_SPLASH,
103
104 FOOTSTEP_TOTAL
105 } footstep_t;
106
107 typedef enum {
108 IMPACTSOUND_DEFAULT,
109 IMPACTSOUND_METAL,
110 IMPACTSOUND_FLESH
111 } impactSound_t;
112
113 //=================================================
114
115 // player entities need to track more information
116 // than any other type of entity.
117
118 // note that not every player entity is a client entity,
119 // because corpses after respawn are outside the normal
120 // client numbering range
121
122 // when changing animation, set animationTime to frameTime + lerping time
123 // The current lerp will finish out, then it will lerp to the new animation
124 typedef struct {
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 typedef struct {
145 lerpFrame_t legs, torso, flag;
146 int painTime;
147 int painDirection; // flip from 0 to 1
148 int lightningFiring;
149
150 int railFireTime;
151
152 // machinegun spinning
153 float barrelAngle;
154 int barrelTime;
155 qboolean barrelSpinning;
156 } playerEntity_t;
157
158 //=================================================
159
160
161
162 // centity_t have a direct corespondence with gentity_t in the game, but
163 // only the entityState_t is directly communicated to the cgame
164 typedef struct centity_s {
165 entityState_t currentState; // from cg.frame
166 entityState_t nextState; // from cg.nextFrame, if available
167 qboolean interpolate; // true if next is valid to interpolate to
168 qboolean currentValid; // true if cg.frame holds this entity
169
170 int muzzleFlashTime; // move to playerEntity?
171 int previousEvent;
172 int teleportFlag;
173
174 int trailTime; // so missile trails can handle dropped initial packets
175 int dustTrailTime;
176 int miscTime;
177
178 int snapShotTime; // last time this entity was found in a snapshot
179
180 playerEntity_t pe;
181
182 int errorTime; // decay the error from this time
183 vec3_t errorOrigin;
184 vec3_t errorAngles;
185
186 qboolean extrapolated; // false if origin / angles is an interpolation
187 vec3_t rawOrigin;
188 vec3_t rawAngles;
189
190 vec3_t beamEnd;
191
192 // exact interpolated position of entity on this frame
193 vec3_t lerpOrigin;
194 vec3_t lerpAngles;
195 } centity_t;
196
197
198 //======================================================================
199
200 // local entities are created as a result of events or predicted actions,
201 // and live independently from all server transmitted entities
202
203 typedef struct markPoly_s {
204 struct markPoly_s *prevMark, *nextMark;
205 int time;
206 qhandle_t markShader;
207 qboolean alphaFade; // fade alpha instead of rgb
208 float color[4];
209 poly_t poly;
210 polyVert_t verts[MAX_VERTS_ON_POLY];
211 } markPoly_t;
212
213
214 typedef enum {
215 LE_MARK,
216 LE_EXPLOSION,
217 LE_SPRITE_EXPLOSION,
218 LE_FRAGMENT,
219 LE_MOVE_SCALE_FADE,
220 LE_FALL_SCALE_FADE,
221 LE_FADE_RGB,
222 LE_SCALE_FADE,
223 LE_SCOREPLUM,
224 #ifdef MISSIONPACK
225 LE_KAMIKAZE,
226 LE_INVULIMPACT,
227 LE_INVULJUICED,
228 LE_SHOWREFENTITY
229 #endif
230 } leType_t;
231
232 typedef enum {
233 LEF_PUFF_DONT_SCALE = 0x0001, // do not scale size over time
234 LEF_TUMBLE = 0x0002, // tumble over time, used for ejecting shells
235 LEF_SOUND1 = 0x0004, // sound 1 for kamikaze
236 LEF_SOUND2 = 0x0008 // sound 2 for kamikaze
237 } leFlag_t;
238
239 typedef enum {
240 LEMT_NONE,
241 LEMT_BURN,
242 LEMT_BLOOD
243 } leMarkType_t; // fragment local entities can leave marks on walls
244
245 typedef enum {
246 LEBS_NONE,
247 LEBS_BLOOD,
248 LEBS_BRASS
249 } leBounceSoundType_t; // fragment local entities can make sounds on impacts
250
251 typedef struct localEntity_s {
252 struct localEntity_s *prev, *next;
253 leType_t leType;
254 int leFlags;
255
256 int startTime;
257 int endTime;
258 int fadeInTime;
259
260 float lifeRate; // 1.0 / (endTime - startTime)
261
262 trajectory_t pos;
263 trajectory_t angles;
264
265 float bounceFactor; // 0.0 = no bounce, 1.0 = perfect
266
267 float color[4];
268
269 float radius;
270
271 float light;
272 vec3_t lightColor;
273
274 leMarkType_t leMarkType; // mark to leave on fragment impact
275 leBounceSoundType_t leBounceSoundType;
276
277 refEntity_t refEntity;
278 } localEntity_t;
279
280 //======================================================================
281
282
283 typedef struct {
284 int client;
285 int score;
286 int ping;
287 int time;
288 int scoreFlags;
289 int powerUps;
290 int accuracy;
291 int impressiveCount;
292 int excellentCount;
293 int guantletCount;
294 int defendCount;
295 int assistCount;
296 int captures;
297 qboolean perfect;
298 int team;
299 } score_t;
300
301 // each client has an associated clientInfo_t
302 // that contains media references necessary to present the
303 // client model and other color coded effects
304 // this is regenerated each time a client's configstring changes,
305 // usually as a result of a userinfo (name, model, etc) change
306 #define MAX_CUSTOM_SOUNDS 32
307
308 typedef struct {
309 qboolean infoValid;
310
311 char name[MAX_QPATH];
312 team_t team;
313
314 int botSkill; // 0 = not bot, 1-5 = bot
315
316 vec3_t color1;
317 vec3_t color2;
318
319 byte c1RGBA[4];
320 byte c2RGBA[4];
321
322 int score; // updated by score servercmds
323 int location; // location index for team mode
324 int health; // you only get this info about your teammates
325 int armor;
326 int curWeapon;
327
328 int handicap;
329 int wins, losses; // in tourney mode
330
331 int teamTask; // task in teamplay (offence/defence)
332 qboolean teamLeader; // true when this is a team leader
333
334 int powerups; // so can display quad/flag status
335
336 int medkitUsageTime;
337 int invulnerabilityStartTime;
338 int invulnerabilityStopTime;
339
340 int breathPuffTime;
341
342 // when clientinfo is changed, the loading of models/skins/sounds
343 // can be deferred until you are dead, to prevent hitches in
344 // gameplay
345 char modelName[MAX_QPATH];
346 char skinName[MAX_QPATH];
347 char headModelName[MAX_QPATH];
348 char headSkinName[MAX_QPATH];
349 char redTeam[MAX_TEAMNAME];
350 char blueTeam[MAX_TEAMNAME];
351 qboolean deferred;
352
353 qboolean newAnims; // true if using the new mission pack animations
354 qboolean fixedlegs; // true if legs yaw is always the same as torso yaw
355 qboolean fixedtorso; // true if torso never changes yaw
356
357 vec3_t headOffset; // move head in icon views
358 footstep_t footsteps;
359 gender_t gender; // from model
360
361 qhandle_t legsModel;
362 qhandle_t legsSkin;
363
364 qhandle_t torsoModel;
365 qhandle_t torsoSkin;
366
367 qhandle_t headModel;
368 qhandle_t headSkin;
369
370 qhandle_t modelIcon;
371
372 animation_t animations[MAX_TOTALANIMATIONS];
373
374 sfxHandle_t sounds[MAX_CUSTOM_SOUNDS];
375 } clientInfo_t;
376
377
378 // each WP_* weapon enum has an associated weaponInfo_t
379 // that contains media references necessary to present the
380 // weapon and its effects
381 typedef struct weaponInfo_s {
382 qboolean registered;
383 gitem_t *item;
384
385 qhandle_t handsModel; // the hands don't actually draw, they just position the weapon
386 qhandle_t weaponModel;
387 qhandle_t barrelModel;
388 qhandle_t flashModel;
389
390 vec3_t weaponMidpoint; // so it will rotate centered instead of by tag
391
392 float flashDlight;
393 vec3_t flashDlightColor;
394 sfxHandle_t flashSound[4]; // fast firing weapons randomly choose
395
396 qhandle_t weaponIcon;
397 qhandle_t ammoIcon;
398
399 qhandle_t ammoModel;
400
401 qhandle_t missileModel;
402 sfxHandle_t missileSound;
403 void (*missileTrailFunc)( centity_t *, const struct weaponInfo_s *wi );
404 float missileDlight;
405 vec3_t missileDlightColor;
406 int missileRenderfx;
407
408 void (*ejectBrassFunc)( centity_t * );
409
410 float trailRadius;
411 float wiTrailTime;
412
413 sfxHandle_t readySound;
414 sfxHandle_t firingSound;
415 } weaponInfo_t;
416
417
418 // each IT_* item has an associated itemInfo_t
419 // that constains media references necessary to present the
420 // item and its effects
421 typedef struct {
422 qboolean registered;
423 qhandle_t models[MAX_ITEM_MODELS];
424 qhandle_t icon;
425 } itemInfo_t;
426
427
428 typedef struct {
429 int itemNum;
430 } powerupInfo_t;
431
432
433 #define MAX_SKULLTRAIL 10
434
435 typedef struct {
436 vec3_t positions[MAX_SKULLTRAIL];
437 int numpositions;
438 } skulltrail_t;
439
440
441 #define MAX_REWARDSTACK 10
442 #define MAX_SOUNDBUFFER 20
443
444 //======================================================================
445
446 // all cg.stepTime, cg.duckTime, cg.landTime, etc are set to cg.time when the action
447 // occurs, and they will have visible effects for #define STEP_TIME or whatever msec after
448
449 #define MAX_PREDICTED_EVENTS 16
450
451 typedef struct {
452 int clientFrame; // incremented each frame
453
454 int clientNum;
455
456 qboolean demoPlayback;
457 qboolean levelShot; // taking a level menu screenshot
458 int deferredPlayerLoading;
459 qboolean loading; // don't defer players at initial startup
460 qboolean intermissionStarted; // don't play voice rewards, because game will end shortly
461
462 // there are only one or two snapshot_t that are relevant at a time
463 int latestSnapshotNum; // the number of snapshots the client system has received
464 int latestSnapshotTime; // the time from latestSnapshotNum, so we don't need to read the snapshot yet
465
466 snapshot_t *snap; // cg.snap->serverTime <= cg.time
467 snapshot_t *nextSnap; // cg.nextSnap->serverTime > cg.time, or NULL
468 snapshot_t activeSnapshots[2];
469
470 float frameInterpolation; // (float)( cg.time - cg.frame->serverTime ) / (cg.nextFrame->serverTime - cg.frame->serverTime)
471
472 qboolean thisFrameTeleport;
473 qboolean nextFrameTeleport;
474
475 int frametime; // cg.time - cg.oldTime
476
477 int time; // this is the time value that the client
478 // is rendering at.
479 int oldTime; // time at last frame, used for missile trails and prediction checking
480
481 int physicsTime; // either cg.snap->time or cg.nextSnap->time
482
483 int timelimitWarnings; // 5 min, 1 min, overtime
484 int fraglimitWarnings;
485
486 qboolean mapRestart; // set on a map restart to set back the weapon
487
488 qboolean renderingThirdPerson; // during deaths, chasecams, etc
489
490 // prediction state
491 qboolean hyperspace; // true if prediction has hit a trigger_teleport
492 playerState_t predictedPlayerState;
493 centity_t predictedPlayerEntity;
494 qboolean validPPS; // clear until the first call to CG_PredictPlayerState
495 int predictedErrorTime;
496 vec3_t predictedError;
497
498 int eventSequence;
499 int predictableEvents[MAX_PREDICTED_EVENTS];
500
501 float stepChange; // for stair up smoothing
502 int stepTime;
503
504 float duckChange; // for duck viewheight smoothing
505 int duckTime;
506
507 float landChange; // for landing hard
508 int landTime;
509
510 // input state sent to server
511 int weaponSelect;
512
513 // auto rotating items
514 vec3_t autoAngles;
515 vec3_t autoAxis[3];
516 vec3_t autoAnglesFast;
517 vec3_t autoAxisFast[3];
518
519 // view rendering
520 refdef_t refdef;
521 vec3_t refdefViewAngles; // will be converted to refdef.viewaxis
522
523 // zoom key
524 qboolean zoomed;
525 int zoomTime;
526 float zoomSensitivity;
527
528 // information screen text during loading
529 char infoScreenText[MAX_STRING_CHARS];
530
531 // scoreboard
532 int scoresRequestTime;
533 int numScores;
534 int selectedScore;
535 int teamScores[2];
536 score_t scores[MAX_CLIENTS];
537 qboolean showScores;
538 qboolean scoreBoardShowing;
539 int scoreFadeTime;
540 char killerName[MAX_NAME_LENGTH];
541 char spectatorList[MAX_STRING_CHARS]; // list of names
542 int spectatorLen; // length of list
543 float spectatorWidth; // width in device units
544 int spectatorTime; // next time to offset
545 int spectatorPaintX; // current paint x
546 int spectatorPaintX2; // current paint x
547 int spectatorOffset; // current offset from start
548 int spectatorPaintLen; // current offset from start
549
550 #ifdef MISSIONPACK
551 // skull trails
552 skulltrail_t skulltrails[MAX_CLIENTS];
553 #endif
554
555 // centerprinting
556 int centerPrintTime;
557 int centerPrintCharWidth;
558 int centerPrintY;
559 char centerPrint[1024];
560 int centerPrintLines;
561
562 // low ammo warning state
563 int lowAmmoWarning; // 1 = low, 2 = empty
564
565 // crosshair client ID
566 int crosshairClientNum;
567 int crosshairClientTime;
568
569 // powerup active flashing
570 int powerupActive;
571 int powerupTime;
572
573 // attacking player
574 int attackerTime;
575 int voiceTime;
576
577 // reward medals
578 int rewardStack;
579 int rewardTime;
580 int rewardCount[MAX_REWARDSTACK];
581 qhandle_t rewardShader[MAX_REWARDSTACK];
582 qhandle_t rewardSound[MAX_REWARDSTACK];
583
584 // sound buffer mainly for announcer sounds
585 int soundBufferIn;
586 int soundBufferOut;
587 int soundTime;
588 qhandle_t soundBuffer[MAX_SOUNDBUFFER];
589
590 #ifdef MISSIONPACK
591 // for voice chat buffer
592 int voiceChatTime;
593 int voiceChatBufferIn;
594 int voiceChatBufferOut;
595 #endif
596
597 // warmup countdown
598 int warmup;
599 int warmupCount;
600
601 //==========================
602
603 int itemPickup;
604 int itemPickupTime;
605 int itemPickupBlendTime; // the pulse around the crosshair is timed separately
606
607 int weaponSelectTime;
608 int weaponAnimation;
609 int weaponAnimationTime;
610
611 // blend blobs
612 float damageTime;
613 float damageX, damageY, damageValue;
614
615 // status bar head
616 float headYaw;
617 float headEndPitch;
618 float headEndYaw;
619 int headEndTime;
620 float headStartPitch;
621 float headStartYaw;
622 int headStartTime;
623
624 // view movement
625 float v_dmg_time;
626 float v_dmg_pitch;
627 float v_dmg_roll;
628
629 // temp working variables for player view
630 float bobfracsin;
631 int bobcycle;
632 float xyspeed;
633 int nextOrbitTime;
634
635 //qboolean cameraMode; // if rendering from a loaded camera
636
637
638 // development tool
639 refEntity_t testModelEntity;
640 char testModelName[MAX_QPATH];
641 qboolean testGun;
642
643 } cg_t;
644
645
646 // all of the model, shader, and sound references that are
647 // loaded at gamestate time are stored in cgMedia_t
648 // Other media that can be tied to clients, weapons, or items are
649 // stored in the clientInfo_t, itemInfo_t, weaponInfo_t, and powerupInfo_t
650 typedef struct {
651 qhandle_t charsetShader;
652 qhandle_t charsetProp;
653 qhandle_t charsetPropGlow;
654 qhandle_t charsetPropB;
655 qhandle_t whiteShader;
656
657 #ifdef MISSIONPACK
658 qhandle_t redCubeModel;
659 qhandle_t blueCubeModel;
660 qhandle_t redCubeIcon;
661 qhandle_t blueCubeIcon;
662 #endif
663 qhandle_t redFlagModel;
664 qhandle_t blueFlagModel;
665 qhandle_t neutralFlagModel;
666 qhandle_t redFlagShader[3];
667 qhandle_t blueFlagShader[3];
668 qhandle_t flagShader[4];
669
670 qhandle_t flagPoleModel;
671 qhandle_t flagFlapModel;
672
673 qhandle_t redFlagFlapSkin;
674 qhandle_t blueFlagFlapSkin;
675 qhandle_t neutralFlagFlapSkin;
676
677 qhandle_t redFlagBaseModel;
678 qhandle_t blueFlagBaseModel;
679 qhandle_t neutralFlagBaseModel;
680
681 #ifdef MISSIONPACK
682 qhandle_t overloadBaseModel;
683 qhandle_t overloadTargetModel;
684 qhandle_t overloadLightsModel;
685 qhandle_t overloadEnergyModel;
686
687 qhandle_t harvesterModel;
688 qhandle_t harvesterRedSkin;
689 qhandle_t harvesterBlueSkin;
690 qhandle_t harvesterNeutralModel;
691 #endif
692
693 qhandle_t armorModel;
694 qhandle_t armorIcon;
695
696 qhandle_t teamStatusBar;
697
698 qhandle_t deferShader;
699
700 // gib explosions
701 qhandle_t gibAbdomen;
702 qhandle_t gibArm;
703 qhandle_t gibChest;
704 qhandle_t gibFist;
705 qhandle_t gibFoot;
706 qhandle_t gibForearm;
707 qhandle_t gibIntestine;
708 qhandle_t gibLeg;
709 qhandle_t gibSkull;
710 qhandle_t gibBrain;
711
712 qhandle_t smoke2;
713
714 qhandle_t machinegunBrassModel;
715 qhandle_t shotgunBrassModel;
716
717 qhandle_t railRingsShader;
718 qhandle_t railCoreShader;
719
720 qhandle_t lightningShader;
721
722 qhandle_t friendShader;
723
724 qhandle_t balloonShader;
725 qhandle_t connectionShader;
726
727 qhandle_t selectShader;
728 qhandle_t viewBloodShader;
729 qhandle_t tracerShader;
730 qhandle_t crosshairShader[NUM_CROSSHAIRS];
731 qhandle_t lagometerShader;
732 qhandle_t backTileShader;
733 qhandle_t noammoShader;
734
735 qhandle_t smokePuffShader;
736 qhandle_t smokePuffRageProShader;
737 qhandle_t shotgunSmokePuffShader;
738 qhandle_t plasmaBallShader;
739 qhandle_t waterBubbleShader;
740 qhandle_t bloodTrailShader;
741 #ifdef MISSIONPACK
742 qhandle_t nailPuffShader;
743 qhandle_t blueProxMine;
744 #endif
745
746 qhandle_t numberShaders[11];
747
748 qhandle_t shadowMarkShader;
749
750 qhandle_t botSkillShaders[5];
751
752 // wall mark shaders
753 qhandle_t wakeMarkShader;
754 qhandle_t bloodMarkShader;
755 qhandle_t bulletMarkShader;
756 qhandle_t burnMarkShader;
757 qhandle_t holeMarkShader;
758 qhandle_t energyMarkShader;
759
760 // powerup shaders
761 qhandle_t quadShader;
762 qhandle_t redQuadShader;
763 qhandle_t quadWeaponShader;
764 qhandle_t invisShader;
765 qhandle_t regenShader;
766 qhandle_t battleSuitShader;
767 qhandle_t battleWeaponShader;
768 qhandle_t hastePuffShader;
769 #ifdef MISSIONPACK
770 qhandle_t redKamikazeShader;
771 qhandle_t blueKamikazeShader;
772 #endif
773
774 // weapon effect models
775 qhandle_t bulletFlashModel;
776 qhandle_t ringFlashModel;
777 qhandle_t dishFlashModel;
778 qhandle_t lightningExplosionModel;
779
780 // weapon effect shaders
781 qhandle_t railExplosionShader;
782 qhandle_t plasmaExplosionShader;
783 qhandle_t bulletExplosionShader;
784 qhandle_t rocketExplosionShader;
785 qhandle_t grenadeExplosionShader;
786 qhandle_t bfgExplosionShader;
787 qhandle_t bloodExplosionShader;
788
789 // special effects models
790 qhandle_t teleportEffectModel;
791 qhandle_t teleportEffectShader;
792 #ifdef MISSIONPACK
793 qhandle_t kamikazeEffectModel;
794 qhandle_t kamikazeShockWave;
795 qhandle_t kamikazeHeadModel;
796 qhandle_t kamikazeHeadTrail;
797 qhandle_t guardPowerupModel;
798 qhandle_t scoutPowerupModel;
799 qhandle_t doublerPowerupModel;
800 qhandle_t ammoRegenPowerupModel;
801 qhandle_t invulnerabilityImpactModel;
802 qhandle_t invulnerabilityJuicedModel;
803 qhandle_t medkitUsageModel;
804 qhandle_t dustPuffShader;
805 qhandle_t heartShader;
806 qhandle_t invulnerabilityPowerupModel;
807 #endif
808
809 // scoreboard headers
810 qhandle_t scoreboardName;
811 qhandle_t scoreboardPing;
812 qhandle_t scoreboardScore;
813 qhandle_t scoreboardTime;
814
815 // medals shown during gameplay
816 qhandle_t medalImpressive;
817 qhandle_t medalExcellent;
818 qhandle_t medalGauntlet;
819 qhandle_t medalDefend;
820 qhandle_t medalAssist;
821 qhandle_t medalCapture;
822
823 // sounds
824 sfxHandle_t quadSound;
825 sfxHandle_t tracerSound;
826 sfxHandle_t selectSound;
827 sfxHandle_t useNothingSound;
828 sfxHandle_t wearOffSound;
829 sfxHandle_t footsteps[FOOTSTEP_TOTAL][4];
830 sfxHandle_t sfx_lghit1;
831 sfxHandle_t sfx_lghit2;
832 sfxHandle_t sfx_lghit3;
833 sfxHandle_t sfx_ric1;
834 sfxHandle_t sfx_ric2;
835 sfxHandle_t sfx_ric3;
836 //sfxHandle_t sfx_railg;
837 sfxHandle_t sfx_rockexp;
838 sfxHandle_t sfx_plasmaexp;
839 #ifdef MISSIONPACK
840 sfxHandle_t sfx_proxexp;
841 sfxHandle_t sfx_nghit;
842 sfxHandle_t sfx_nghitflesh;
843 sfxHandle_t sfx_nghitmetal;
844 sfxHandle_t sfx_chghit;
845 sfxHandle_t sfx_chghitflesh;
846 sfxHandle_t sfx_chghitmetal;
847 sfxHandle_t kamikazeExplodeSound;
848 sfxHandle_t kamikazeImplodeSound;
849 sfxHandle_t kamikazeFarSound;
850 sfxHandle_t useInvulnerabilitySound;
851 sfxHandle_t invulnerabilityImpactSound1;
852 sfxHandle_t invulnerabilityImpactSound2;
853 sfxHandle_t invulnerabilityImpactSound3;
854 sfxHandle_t invulnerabilityJuicedSound;
855 sfxHandle_t obeliskHitSound1;
856 sfxHandle_t obeliskHitSound2;
857 sfxHandle_t obeliskHitSound3;
858 sfxHandle_t obeliskRespawnSound;
859 sfxHandle_t winnerSound;
860 sfxHandle_t loserSound;
861 #endif
862 sfxHandle_t gibSound;
863 sfxHandle_t gibBounce1Sound;
864 sfxHandle_t gibBounce2Sound;
865 sfxHandle_t gibBounce3Sound;
866 sfxHandle_t teleInSound;
867 sfxHandle_t teleOutSound;
868 sfxHandle_t noAmmoSound;
869 sfxHandle_t respawnSound;
870 sfxHandle_t talkSound;
871 sfxHandle_t landSound;
872 sfxHandle_t fallSound;
873 sfxHandle_t jumpPadSound;
874
875 sfxHandle_t oneMinuteSound;
876 sfxHandle_t fiveMinuteSound;
877 sfxHandle_t suddenDeathSound;
878
879 sfxHandle_t threeFragSound;
880 sfxHandle_t twoFragSound;
881 sfxHandle_t oneFragSound;
882
883 sfxHandle_t hitSound;
884 sfxHandle_t hitSoundHighArmor;
885 sfxHandle_t hitSoundLowArmor;
886 sfxHandle_t hitTeamSound;
887 sfxHandle_t impressiveSound;
888 sfxHandle_t excellentSound;
889 sfxHandle_t deniedSound;
890 sfxHandle_t humiliationSound;
891 sfxHandle_t assistSound;
892 sfxHandle_t defendSound;
893 sfxHandle_t firstImpressiveSound;
894 sfxHandle_t firstExcellentSound;
895 sfxHandle_t firstHumiliationSound;
896
897 sfxHandle_t takenLeadSound;
898 sfxHandle_t tiedLeadSound;
899 sfxHandle_t lostLeadSound;
900
901 sfxHandle_t voteNow;
902 sfxHandle_t votePassed;
903 sfxHandle_t voteFailed;
904
905 sfxHandle_t watrInSound;
906 sfxHandle_t watrOutSound;
907 sfxHandle_t watrUnSound;
908
909 sfxHandle_t flightSound;
910 sfxHandle_t medkitSound;
911
912 #ifdef MISSIONPACK
913 sfxHandle_t weaponHoverSound;
914 #endif
915
916 // teamplay sounds
917 sfxHandle_t captureAwardSound;
918 sfxHandle_t redScoredSound;
919 sfxHandle_t blueScoredSound;
920 sfxHandle_t redLeadsSound;
921 sfxHandle_t blueLeadsSound;
922 sfxHandle_t teamsTiedSound;
923
924 sfxHandle_t captureYourTeamSound;
925 sfxHandle_t captureOpponentSound;
926 sfxHandle_t returnYourTeamSound;
927 sfxHandle_t returnOpponentSound;
928 sfxHandle_t takenYourTeamSound;
929 sfxHandle_t takenOpponentSound;
930
931 sfxHandle_t redFlagReturnedSound;
932 sfxHandle_t blueFlagReturnedSound;
933 #ifdef MISSIONPACK
934 sfxHandle_t neutralFlagReturnedSound;
935 #endif
936 sfxHandle_t enemyTookYourFlagSound;
937 sfxHandle_t yourTeamTookEnemyFlagSound;
938 sfxHandle_t youHaveFlagSound;
939 #ifdef MISSIONPACK
940 sfxHandle_t enemyTookTheFlagSound;
941 sfxHandle_t yourTeamTookTheFlagSound;
942 sfxHandle_t yourBaseIsUnderAttackSound;
943 #endif
944 sfxHandle_t holyShitSound;
945
946 // tournament sounds
947 sfxHandle_t count3Sound;
948 sfxHandle_t count2Sound;
949 sfxHandle_t count1Sound;
950 sfxHandle_t countFightSound;
951 sfxHandle_t countPrepareSound;
952
953 #ifdef MISSIONPACK
954 // new stuff
955 qhandle_t patrolShader;
956 qhandle_t assaultShader;
957 qhandle_t campShader;
958 qhandle_t followShader;
959 qhandle_t defendShader;
960 qhandle_t teamLeaderShader;
961 qhandle_t retrieveShader;
962 qhandle_t escortShader;
963 qhandle_t flagShaders[3];
964 sfxHandle_t countPrepareTeamSound;
965
966 sfxHandle_t ammoregenSound;
967 sfxHandle_t doublerSound;
968 sfxHandle_t guardSound;
969 sfxHandle_t scoutSound;
970
971 qhandle_t cursor;
972 qhandle_t selectCursor;
973 qhandle_t sizeCursor;
974 #endif
975
976 sfxHandle_t regenSound;
977 sfxHandle_t protectSound;
978 sfxHandle_t n_healthSound;
979 sfxHandle_t hgrenb1aSound;
980 sfxHandle_t hgrenb2aSound;
981 sfxHandle_t wstbimplSound;
982 sfxHandle_t wstbimpmSound;
983 sfxHandle_t wstbimpdSound;
984 sfxHandle_t wstbactvSound;
985
986 } cgMedia_t;
987
988
989 // The client game static (cgs) structure hold everything
990 // loaded or calculated from the gamestate. It will NOT
991 // be cleared when a tournement restart is done, allowing
992 // all clients to begin playing instantly
993 typedef struct {
994 gameState_t gameState; // gamestate from server
995 glconfig_t glconfig; // rendering configuration
996 float screenXScale; // derived from glconfig
997 float screenYScale;
998 float screenXBias;
999
1000 int serverCommandSequence; // reliable command stream counter
1001 int processedSnapshotNum;// the number of snapshots cgame has requested
1002
1003 qboolean localServer; // detected on startup by checking sv_running
1004
1005 // parsed from serverinfo
1006 gametype_t gametype;
1007 int dmflags;
1008 int teamflags;
1009 int fraglimit;
1010 int capturelimit;
1011 int timelimit;
1012 int maxclients;
1013 char mapname[MAX_QPATH];
1014 char redTeam[MAX_QPATH];
1015 char blueTeam[MAX_QPATH];
1016
1017 int voteTime;
1018 int voteYes;
1019 int voteNo;
1020 qboolean voteModified; // beep whenever changed
1021 char voteString[MAX_STRING_TOKENS];
1022
1023 int teamVoteTime[2];
1024 int teamVoteYes[2];
1025 int teamVoteNo[2];
1026 qboolean teamVoteModified[2]; // beep whenever changed
1027 char teamVoteString[2][MAX_STRING_TOKENS];
1028
1029 int levelStartTime;
1030
1031 int scores1, scores2; // from configstrings
1032 int redflag, blueflag; // flag status from configstrings
1033 int flagStatus;
1034
1035 qboolean newHud;
1036
1037 //
1038 // locally derived information from gamestate
1039 //
1040 qhandle_t gameModels[MAX_MODELS];
1041 sfxHandle_t gameSounds[MAX_SOUNDS];
1042
1043 int numInlineModels;
1044 qhandle_t inlineDrawModel[MAX_MODELS];
1045 vec3_t inlineModelMidpoints[MAX_MODELS];
1046
1047 clientInfo_t clientinfo[MAX_CLIENTS];
1048
1049 // teamchat width is *3 because of embedded color codes
1050 char teamChatMsgs[TEAMCHAT_HEIGHT][TEAMCHAT_WIDTH*3+1];
1051 int teamChatMsgTimes[TEAMCHAT_HEIGHT];
1052 int teamChatPos;
1053 int teamLastChatPos;
1054
1055 int cursorX;
1056 int cursorY;
1057 qboolean eventHandling;
1058 qboolean mouseCaptured;
1059 qboolean sizingHud;
1060 void *capturedItem;
1061 qhandle_t activeCursor;
1062
1063 // orders
1064 int currentOrder;
1065 qboolean orderPending;
1066 int orderTime;
1067 int currentVoiceClient;
1068 int acceptOrderTime;
1069 int acceptTask;
1070 int acceptLeader;
1071 char acceptVoice[MAX_NAME_LENGTH];
1072
1073 // media
1074 cgMedia_t media;
1075
1076 } cgs_t;
1077
1078 //==============================================================================
1079
1080 extern cgs_t cgs;
1081 extern cg_t cg;
1082 extern centity_t cg_entities[MAX_GENTITIES];
1083 extern weaponInfo_t cg_weapons[MAX_WEAPONS];
1084 extern itemInfo_t cg_items[MAX_ITEMS];
1085 extern markPoly_t cg_markPolys[MAX_MARK_POLYS];
1086
1087 extern vmCvar_t cg_centertime;
1088 extern vmCvar_t cg_runpitch;
1089 extern vmCvar_t cg_runroll;
1090 extern vmCvar_t cg_bobup;
1091 extern vmCvar_t cg_bobpitch;
1092 extern vmCvar_t cg_bobroll;
1093 extern vmCvar_t cg_swingSpeed;
1094 extern vmCvar_t cg_shadows;
1095 extern vmCvar_t cg_gibs;
1096 extern vmCvar_t cg_drawTimer;
1097 extern vmCvar_t cg_drawFPS;
1098 extern vmCvar_t cg_drawSnapshot;
1099 extern vmCvar_t cg_draw3dIcons;
1100 extern vmCvar_t cg_drawIcons;
1101 extern vmCvar_t cg_drawAmmoWarning;
1102 extern vmCvar_t cg_drawCrosshair;
1103 extern vmCvar_t cg_drawCrosshairNames;
1104 extern vmCvar_t cg_drawRewards;
1105 extern vmCvar_t cg_drawTeamOverlay;
1106 extern vmCvar_t cg_teamOverlayUserinfo;
1107 extern vmCvar_t cg_crosshairX;
1108 extern vmCvar_t cg_crosshairY;
1109 extern vmCvar_t cg_crosshairSize;
1110 extern vmCvar_t cg_crosshairHealth;
1111 extern vmCvar_t cg_drawStatus;
1112 extern vmCvar_t cg_draw2D;
1113 extern vmCvar_t cg_animSpeed;
1114 extern vmCvar_t cg_debugAnim;
1115 extern vmCvar_t cg_debugPosition;
1116 extern vmCvar_t cg_debugEvents;
1117 extern vmCvar_t cg_railTrailTime;
1118 extern vmCvar_t cg_errorDecay;
1119 extern vmCvar_t cg_nopredict;
1120 extern vmCvar_t cg_noPlayerAnims;
1121 extern vmCvar_t cg_showmiss;
1122 extern vmCvar_t cg_footsteps;
1123 extern vmCvar_t cg_addMarks;
1124 extern vmCvar_t cg_brassTime;
1125 extern vmCvar_t cg_gun_frame;
1126 extern vmCvar_t cg_gun_x;
1127 extern vmCvar_t cg_gun_y;
1128 extern vmCvar_t cg_gun_z;
1129 extern vmCvar_t cg_drawGun;
1130 extern vmCvar_t cg_viewsize;
1131 extern vmCvar_t cg_tracerChance;
1132 extern vmCvar_t cg_tracerWidth;
1133 extern vmCvar_t cg_tracerLength;
1134 extern vmCvar_t cg_autoswitch;
1135 extern vmCvar_t cg_ignore;
1136 extern vmCvar_t cg_simpleItems;
1137 extern vmCvar_t cg_fov;
1138 extern vmCvar_t cg_zoomFov;
1139 extern vmCvar_t cg_thirdPersonRange;
1140 extern vmCvar_t cg_thirdPersonAngle;
1141 extern vmCvar_t cg_thirdPerson;
1142 extern vmCvar_t cg_lagometer;
1143 extern vmCvar_t cg_drawAttacker;
1144 extern vmCvar_t cg_synchronousClients;
1145 extern vmCvar_t cg_teamChatTime;
1146 extern vmCvar_t cg_teamChatHeight;
1147 extern vmCvar_t cg_stats;
1148 extern vmCvar_t cg_forceModel;
1149 extern vmCvar_t cg_buildScript;
1150 extern vmCvar_t cg_paused;
1151 extern vmCvar_t cg_blood;
1152 extern vmCvar_t cg_predictItems;
1153 extern vmCvar_t cg_deferPlayers;
1154 extern vmCvar_t cg_drawFriend;
1155 extern vmCvar_t cg_teamChatsOnly;
1156 #ifdef MISSIONPACK
1157 extern vmCvar_t cg_noVoiceChats;
1158 extern vmCvar_t cg_noVoiceText;
1159 #endif
1160 extern vmCvar_t cg_scorePlum;
1161 extern vmCvar_t cg_smoothClients;
1162 extern vmCvar_t pmove_fixed;
1163 extern vmCvar_t pmove_msec;
1164 //extern vmCvar_t cg_pmove_fixed;
1165 extern vmCvar_t cg_cameraOrbit;
1166 extern vmCvar_t cg_cameraOrbitDelay;
1167 extern vmCvar_t cg_timescaleFadeEnd;
1168 extern vmCvar_t cg_timescaleFadeSpeed;
1169 extern vmCvar_t cg_timescale;
1170 extern vmCvar_t cg_cameraMode;
1171 #ifdef MISSIONPACK
1172 extern vmCvar_t cg_smallFont;
1173 extern vmCvar_t cg_bigFont;
1174 extern vmCvar_t cg_noTaunt;
1175 #endif
1176 extern vmCvar_t cg_noProjectileTrail;
1177 extern vmCvar_t cg_oldRail;
1178 extern vmCvar_t cg_oldRocket;
1179 extern vmCvar_t cg_oldPlasma;
1180 extern vmCvar_t cg_trueLightning;
1181 #ifdef MISSIONPACK
1182 extern vmCvar_t cg_redTeamName;
1183 extern vmCvar_t cg_blueTeamName;
1184 extern vmCvar_t cg_currentSelectedPlayer;
1185 extern vmCvar_t cg_currentSelectedPlayerName;
1186 extern vmCvar_t cg_singlePlayer;
1187 extern vmCvar_t cg_enableDust;
1188 extern vmCvar_t cg_enableBreath;
1189 extern vmCvar_t cg_singlePlayerActive;
1190 extern vmCvar_t cg_recordSPDemo;
1191 extern vmCvar_t cg_recordSPDemoName;
1192 extern vmCvar_t cg_obeliskRespawnDelay;
1193 #endif
1194
1195 //
1196 // cg_main.c
1197 //
1198 const char *CG_ConfigString( int index );
1199 const char *CG_Argv( int arg );
1200
1201 void QDECL CG_Printf( const char *msg, ... ) Q_PRINTF_FUNC(1, 2);
1202 void QDECL CG_Error( const char *msg, ... ) Q_NO_RETURN Q_PRINTF_FUNC(1, 2);
1203
1204 void CG_StartMusic( void );
1205
1206 void CG_UpdateCvars( void );
1207
1208 int CG_CrosshairPlayer( void );
1209 int CG_LastAttacker( void );
1210 void CG_LoadMenus(const char *menuFile);
1211 void CG_KeyEvent(int key, qboolean down);
1212 void CG_MouseEvent(int x, int y);
1213 void CG_EventHandling(int type);
1214 void CG_RankRunFrame( void );
1215 void CG_SetScoreSelection(void *menu);
1216 score_t *CG_GetSelectedScore( void );
1217 void CG_BuildSpectatorString( void );
1218
1219
1220 //
1221 // cg_view.c
1222 //
1223 void CG_TestModel_f (void);
1224 void CG_TestGun_f (void);
1225 void CG_TestModelNextFrame_f (void);
1226 void CG_TestModelPrevFrame_f (void);
1227 void CG_TestModelNextSkin_f (void);
1228 void CG_TestModelPrevSkin_f (void);
1229 void CG_ZoomDown_f( void );
1230 void CG_ZoomUp_f( void );
1231 void CG_AddBufferedSound( sfxHandle_t sfx);
1232
1233 void CG_DrawActiveFrame( int serverTime, stereoFrame_t stereoView, qboolean demoPlayback );
1234
1235
1236 //
1237 // cg_drawtools.c
1238 //
1239 void CG_AdjustFrom640( float *x, float *y, float *w, float *h );
1240 void CG_FillRect( float x, float y, float width, float height, const float *color );
1241 void CG_DrawPic( float x, float y, float width, float height, qhandle_t hShader );
1242 void CG_DrawString( float x, float y, const char *string,
1243 float charWidth, float charHeight, const float *modulate );
1244
1245
1246 void CG_DrawStringExt( int x, int y, const char *string, const float *setColor,
1247 qboolean forceColor, qboolean shadow, int charWidth, int charHeight, int maxChars );
1248 void CG_DrawBigString( int x, int y, const char *s, float alpha );
1249 void CG_DrawBigStringColor( int x, int y, const char *s, vec4_t color );
1250 void CG_DrawSmallString( int x, int y, const char *s, float alpha );
1251 void CG_DrawSmallStringColor( int x, int y, const char *s, vec4_t color );
1252
1253 int CG_DrawStrlen( const char *str );
1254
1255 float *CG_FadeColor( int startMsec, int totalMsec );
1256 float *CG_TeamColor( int team );
1257 void CG_TileClear( void );
1258 void CG_ColorForHealth( vec4_t hcolor );
1259 void CG_GetColorForHealth( int health, int armor, vec4_t hcolor );
1260
1261 void UI_DrawProportionalString( int x, int y, const char* str, int style, vec4_t color );
1262 void CG_DrawRect( float x, float y, float width, float height, float size, const float *color );
1263 void CG_DrawSides(float x, float y, float w, float h, float size);
1264 void CG_DrawTopBottom(float x, float y, float w, float h, float size);
1265
1266
1267 //
1268 // cg_draw.c, cg_newDraw.c
1269 //
1270 extern int sortedTeamPlayers[TEAM_MAXOVERLAY];
1271 extern int numSortedTeamPlayers;
1272 extern int drawTeamOverlayModificationCount;
1273 extern char systemChat[256];
1274 extern char teamChat1[256];
1275 extern char teamChat2[256];
1276
1277 void CG_AddLagometerFrameInfo( void );
1278 void CG_AddLagometerSnapshotInfo( snapshot_t *snap );
1279 void CG_CenterPrint( const char *str, int y, int charWidth );
1280 void CG_DrawHead( float x, float y, float w, float h, int clientNum, vec3_t headAngles );
1281 void CG_DrawActive( stereoFrame_t stereoView );
1282 void CG_DrawFlagModel( float x, float y, float w, float h, int team, qboolean force2D );
1283 void CG_DrawTeamBackground( int x, int y, int w, int h, float alpha, int team );
1284 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, float scale, vec4_t color, qhandle_t shader, int textStyle);
1285 void CG_Text_Paint(float x, float y, float scale, vec4_t color, const char *text, float adjust, int limit, int style);
1286 int CG_Text_Width(const char *text, float scale, int limit);
1287 int CG_Text_Height(const char *text, float scale, int limit);
1288 void CG_SelectPrevPlayer( void );
1289 void CG_SelectNextPlayer( void );
1290 float CG_GetValue(int ownerDraw);
1291 qboolean CG_OwnerDrawVisible(int flags);
1292 void CG_RunMenuScript(char **args);
1293 void CG_ShowResponseHead( void );
1294 void CG_SetPrintString(int type, const char *p);
1295 void CG_InitTeamChat( void );
1296 void CG_GetTeamColor(vec4_t *color);
1297 const char *CG_GetGameStatusText( void );
1298 const char *CG_GetKillerText( void );
1299 void CG_Draw3DModel(float x, float y, float w, float h, qhandle_t model, qhandle_t skin, vec3_t origin, vec3_t angles);
1300 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);
1301 void CG_CheckOrderPending( void );
1302 const char *CG_GameTypeString( void );
1303 qboolean CG_YourTeamHasFlag( void );
1304 qboolean CG_OtherTeamHasFlag( void );
1305 qhandle_t CG_StatusHandle(int task);
1306
1307
1308
1309 //
1310 // cg_player.c
1311 //
1312 void CG_Player( centity_t *cent );
1313 void CG_ResetPlayerEntity( centity_t *cent );
1314 void CG_AddRefEntityWithPowerups( refEntity_t *ent, entityState_t *state, int team );
1315 void CG_NewClientInfo( int clientNum );
1316 sfxHandle_t CG_CustomSound( int clientNum, const char *soundName );
1317
1318 //
1319 // cg_predict.c
1320 //
1321 void CG_BuildSolidList( void );
1322 int CG_PointContents( const vec3_t point, int passEntityNum );
1323 void CG_Trace( trace_t *result, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end,
1324 int skipNumber, int mask );
1325 void CG_PredictPlayerState( void );
1326 void CG_LoadDeferredPlayers( void );
1327
1328
1329 //
1330 // cg_events.c
1331 //
1332 void CG_CheckEvents( centity_t *cent );
1333 const char *CG_PlaceString( int rank );
1334 void CG_EntityEvent( centity_t *cent, vec3_t position );
1335 void CG_PainEvent( centity_t *cent, int health );
1336
1337
1338 //
1339 // cg_ents.c
1340 //
1341 void CG_SetEntitySoundPosition( centity_t *cent );
1342 void CG_AddPacketEntities( void );
1343 void CG_Beam( centity_t *cent );
1344 void CG_AdjustPositionForMover(const vec3_t in, int moverNum, int fromTime, int toTime, vec3_t out, vec3_t angles_in, vec3_t angles_out);
1345
1346 void CG_PositionEntityOnTag( refEntity_t *entity, const refEntity_t *parent,
1347 qhandle_t parentModel, char *tagName );
1348 void CG_PositionRotatedEntityOnTag( refEntity_t *entity, const refEntity_t *parent,
1349 qhandle_t parentModel, char *tagName );
1350
1351
1352
1353 //
1354 // cg_weapons.c
1355 //
1356 void CG_NextWeapon_f( void );
1357 void CG_PrevWeapon_f( void );
1358 void CG_Weapon_f( void );
1359
1360 void CG_RegisterWeapon( int weaponNum );
1361 void CG_RegisterItemVisuals( int itemNum );
1362
1363 void CG_FireWeapon( centity_t *cent );
1364 void CG_MissileHitWall( int weapon, int clientNum, vec3_t origin, vec3_t dir, impactSound_t soundType );
1365 void CG_MissileHitPlayer( int weapon, vec3_t origin, vec3_t dir, int entityNum );
1366 void CG_ShotgunFire( entityState_t *es );
1367 void CG_Bullet( vec3_t origin, int sourceEntityNum, vec3_t normal, qboolean flesh, int fleshEntityNum );
1368
1369 void CG_RailTrail( clientInfo_t *ci, vec3_t start, vec3_t end );
1370 void CG_GrappleTrail( centity_t *ent, const weaponInfo_t *wi );
1371 void CG_AddViewWeapon (playerState_t *ps);
1372 void CG_AddPlayerWeapon( refEntity_t *parent, playerState_t *ps, centity_t *cent, int team );
1373 void CG_DrawWeaponSelect( void );
1374
1375 void CG_OutOfAmmoChange( void ); // should this be in pmove?
1376
1377 //
1378 // cg_marks.c
1379 //
1380 void CG_InitMarkPolys( void );
1381 void CG_AddMarks( void );
1382 void CG_ImpactMark( qhandle_t markShader,
1383 const vec3_t origin, const vec3_t dir,
1384 float orientation,
1385 float r, float g, float b, float a,
1386 qboolean alphaFade,
1387 float radius, qboolean temporary );
1388
1389 //
1390 // cg_localents.c
1391 //
1392 void CG_InitLocalEntities( void );
1393 localEntity_t *CG_AllocLocalEntity( void );
1394 void CG_AddLocalEntities( void );
1395
1396 //
1397 // cg_effects.c
1398 //
1399 localEntity_t *CG_SmokePuff( const vec3_t p,
1400 const vec3_t vel,
1401 float radius,
1402 float r, float g, float b, float a,
1403 float duration,
1404 int startTime,
1405 int fadeInTime,
1406 int leFlags,
1407 qhandle_t hShader );
1408 void CG_BubbleTrail( vec3_t start, vec3_t end, float spacing );
1409 void CG_SpawnEffect( vec3_t org );
1410 #ifdef MISSIONPACK
1411 void CG_KamikazeEffect( vec3_t org );
1412 void CG_ObeliskExplode( vec3_t org, int entityNum );
1413 void CG_ObeliskPain( vec3_t org );
1414 void CG_InvulnerabilityImpact( vec3_t org, vec3_t angles );
1415 void CG_InvulnerabilityJuiced( vec3_t org );
1416 void CG_LightningBoltBeam( vec3_t start, vec3_t end );
1417 #endif
1418 void CG_ScorePlum( int client, vec3_t org, int score );
1419
1420 void CG_GibPlayer( vec3_t playerOrigin );
1421 void CG_BigExplode( vec3_t playerOrigin );
1422
1423 void CG_Bleed( vec3_t origin, int entityNum );
1424
1425 localEntity_t *CG_MakeExplosion( vec3_t origin, vec3_t dir,
1426 qhandle_t hModel, qhandle_t shader, int msec,
1427 qboolean isSprite );
1428
1429 //
1430 // cg_snapshot.c
1431 //
1432 void CG_ProcessSnapshots( void );
1433
1434 //
1435 // cg_info.c
1436 //
1437 void CG_LoadingString( const char *s );
1438 void CG_LoadingItem( int itemNum );
1439 void CG_LoadingClient( int clientNum );
1440 void CG_DrawInformation( void );
1441
1442 //
1443 // cg_scoreboard.c
1444 //
1445 qboolean CG_DrawOldScoreboard( void );
1446 void CG_DrawTourneyScoreboard( void );
1447
1448 //
1449 // cg_consolecmds.c
1450 //
1451 qboolean CG_ConsoleCommand( void );
1452 void CG_InitConsoleCommands( void );
1453
1454 //
1455 // cg_servercmds.c
1456 //
1457 void CG_ExecuteNewServerCommands( int latestSequence );
1458 void CG_ParseServerinfo( void );
1459 void CG_SetConfigValues( void );
1460 void CG_ShaderStateChanged(void);
1461 #ifdef MISSIONPACK
1462 void CG_LoadVoiceChats( void );
1463 void CG_VoiceChatLocal( int mode, qboolean voiceOnly, int clientNum, int color, const char *cmd );
1464 void CG_PlayBufferedVoiceChats( void );
1465 #endif
1466
1467 //
1468 // cg_playerstate.c
1469 //
1470 void CG_Respawn( void );
1471 void CG_TransitionPlayerState( playerState_t *ps, playerState_t *ops );
1472 void CG_CheckChangedPredictableEvents( playerState_t *ps );
1473
1474
1475 //===============================================
1476
1477 //
1478 // system traps
1479 // These functions are how the cgame communicates with the main game system
1480 //
1481
1482 // print message on the local console
1483 void trap_Print( const char *fmt );
1484
1485 // abort the game
1486 void trap_Error(const char *fmt) Q_NO_RETURN;
1487
1488 // milliseconds should only be used for performance tuning, never
1489 // for anything game related. Get time from the CG_DrawActiveFrame parameter
1490 int trap_Milliseconds( void );
1491
1492 // console variable interaction
1493 void trap_Cvar_Register( vmCvar_t *vmCvar, const char *varName, const char *defaultValue, int flags );
1494 void trap_Cvar_Update( vmCvar_t *vmCvar );
1495 void trap_Cvar_Set( const char *var_name, const char *value );
1496 void trap_Cvar_VariableStringBuffer( const char *var_name, char *buffer, int bufsize );
1497
1498 // ServerCommand and ConsoleCommand parameter access
1499 int trap_Argc( void );
1500 void trap_Argv( int n, char *buffer, int bufferLength );
1501 void trap_Args( char *buffer, int bufferLength );
1502
1503 // filesystem access
1504 // returns length of file
1505 int trap_FS_FOpenFile( const char *qpath, fileHandle_t *f, fsMode_t mode );
1506 void trap_FS_Read( void *buffer, int len, fileHandle_t f );
1507 void trap_FS_Write( const void *buffer, int len, fileHandle_t f );
1508 void trap_FS_FCloseFile( fileHandle_t f );
1509 int trap_FS_Seek( fileHandle_t f, long offset, int origin ); // fsOrigin_t
1510
1511 // add commands to the local console as if they were typed in
1512 // for map changing, etc. The command is not executed immediately,
1513 // but will be executed in order the next time console commands
1514 // are processed
1515 void trap_SendConsoleCommand( const char *text );
1516
1517 // register a command name so the console can perform command completion.
1518 // FIXME: replace this with a normal console command "defineCommand"?
1519 void trap_AddCommand( const char *cmdName );
1520 void trap_RemoveCommand( const char *cmdName );
1521
1522 // send a string to the server over the network
1523 void trap_SendClientCommand( const char *s );
1524
1525 // force a screen update, only used during gamestate load
1526 void trap_UpdateScreen( void );
1527
1528 // model collision
1529 void trap_CM_LoadMap( const char *mapname );
1530 int trap_CM_NumInlineModels( void );
1531 clipHandle_t trap_CM_InlineModel( int index ); // 0 = world, 1+ = bmodels
1532 clipHandle_t trap_CM_TempBoxModel( const vec3_t mins, const vec3_t maxs );
1533 int trap_CM_PointContents( const vec3_t p, clipHandle_t model );
1534 int trap_CM_TransformedPointContents( const vec3_t p, clipHandle_t model, const vec3_t origin, const vec3_t angles );
1535 void trap_CM_BoxTrace( trace_t *results, const vec3_t start, const vec3_t end,
1536 const vec3_t mins, const vec3_t maxs,
1537 clipHandle_t model, int brushmask );
1538 void trap_CM_CapsuleTrace( trace_t *results, const vec3_t start, const vec3_t end,
1539 const vec3_t mins, const vec3_t maxs,
1540 clipHandle_t model, int brushmask );
1541 void trap_CM_TransformedBoxTrace( trace_t *results, const vec3_t start, const vec3_t end,
1542 const vec3_t mins, const vec3_t maxs,
1543 clipHandle_t model, int brushmask,
1544 const vec3_t origin, const vec3_t angles );
1545 void trap_CM_TransformedCapsuleTrace( trace_t *results, const vec3_t start, const vec3_t end,
1546 const vec3_t mins, const vec3_t maxs,
1547 clipHandle_t model, int brushmask,
1548 const vec3_t origin, const vec3_t angles );
1549
1550 // Returns the projection of a polygon onto the solid brushes in the world
1551 int trap_CM_MarkFragments( int numPoints, const vec3_t *points,
1552 const vec3_t projection,
1553 int maxPoints, vec3_t pointBuffer,
1554 int maxFragments, markFragment_t *fragmentBuffer );
1555
1556 // normal sounds will have their volume dynamically changed as their entity
1557 // moves and the listener moves
1558 void trap_S_StartSound( vec3_t origin, int entityNum, int entchannel, sfxHandle_t sfx );
1559 void trap_S_StopLoopingSound(int entnum);
1560
1561 // a local sound is always played full volume
1562 void trap_S_StartLocalSound( sfxHandle_t sfx, int channelNum );
1563 void trap_S_ClearLoopingSounds( qboolean killall );
1564 void trap_S_AddLoopingSound( int entityNum, const vec3_t origin, const vec3_t velocity, sfxHandle_t sfx );
1565 void trap_S_AddRealLoopingSound( int entityNum, const vec3_t origin, const vec3_t velocity, sfxHandle_t sfx );
1566 void trap_S_UpdateEntityPosition( int entityNum, const vec3_t origin );
1567
1568 // respatialize recalculates the volumes of sound as they should be heard by the
1569 // given entityNum and position
1570 void trap_S_Respatialize( int entityNum, const vec3_t origin, vec3_t axis[3], int inwater );
1571 sfxHandle_t trap_S_RegisterSound( const char *sample, qboolean compressed ); // returns buzz if not found
1572 void trap_S_StartBackgroundTrack( const char *intro, const char *loop ); // empty name stops music
1573 void trap_S_StopBackgroundTrack( void );
1574
1575
1576 void trap_R_LoadWorldMap( const char *mapname );
1577
1578 // all media should be registered during level startup to prevent
1579 // hitches during gameplay
1580 qhandle_t trap_R_RegisterModel( const char *name ); // returns rgb axis if not found
1581 qhandle_t trap_R_RegisterSkin( const char *name ); // returns all white if not found
1582 qhandle_t trap_R_RegisterShader( const char *name ); // returns all white if not found
1583 qhandle_t trap_R_RegisterShaderNoMip( const char *name ); // returns all white if not found
1584
1585 // a scene is built up by calls to R_ClearScene and the various R_Add functions.
1586 // Nothing is drawn until R_RenderScene is called.
1587 void trap_R_ClearScene( void );
1588 void trap_R_AddRefEntityToScene( const refEntity_t *re );
1589
1590 // polys are intended for simple wall marks, not really for doing
1591 // significant construction
1592 void trap_R_AddPolyToScene( qhandle_t hShader , int numVerts, const polyVert_t *verts );
1593 void trap_R_AddPolysToScene( qhandle_t hShader , int numVerts, const polyVert_t *verts, int numPolys );
1594 void trap_R_AddLightToScene( const vec3_t org, float intensity, float r, float g, float b );
1595 void trap_R_AddAdditiveLightToScene( const vec3_t org, float intensity, float r, float g, float b );
1596 int trap_R_LightForPoint( vec3_t point, vec3_t ambientLight, vec3_t directedLight, vec3_t lightDir );
1597 void trap_R_RenderScene( const refdef_t *fd );
1598 void trap_R_SetColor( const float *rgba ); // NULL = 1,1,1,1
1599 void trap_R_DrawStretchPic( float x, float y, float w, float h,
1600 float s1, float t1, float s2, float t2, qhandle_t hShader );
1601 void trap_R_ModelBounds( clipHandle_t model, vec3_t mins, vec3_t maxs );
1602 int trap_R_LerpTag( orientation_t *tag, clipHandle_t mod, int startFrame, int endFrame,
1603 float frac, const char *tagName );
1604 void trap_R_RemapShader( const char *oldShader, const char *newShader, const char *timeOffset );
1605 qboolean trap_R_inPVS( const vec3_t p1, const vec3_t p2 );
1606
1607 // The glconfig_t will not change during the life of a cgame.
1608 // If it needs to change, the entire cgame will be restarted, because
1609 // all the qhandle_t are then invalid.
1610 void trap_GetGlconfig( glconfig_t *glconfig );
1611
1612 // the gamestate should be grabbed at startup, and whenever a
1613 // configstring changes
1614 void trap_GetGameState( gameState_t *gamestate );
1615
1616 // cgame will poll each frame to see if a newer snapshot has arrived
1617 // that it is interested in. The time is returned separately so that
1618 // snapshot latency can be calculated.
1619 void trap_GetCurrentSnapshotNumber( int *snapshotNumber, int *serverTime );
1620
1621 // a snapshot get can fail if the snapshot (or the entties it holds) is so
1622 // old that it has fallen out of the client system queue
1623 qboolean trap_GetSnapshot( int snapshotNumber, snapshot_t *snapshot );
1624
1625 // retrieve a text command from the server stream
1626 // the current snapshot will hold the number of the most recent command
1627 // qfalse can be returned if the client system handled the command
1628 // argc() / argv() can be used to examine the parameters of the command
1629 qboolean trap_GetServerCommand( int serverCommandNumber );
1630
1631 // returns the most recent command number that can be passed to GetUserCmd
1632 // this will always be at least one higher than the number in the current
1633 // snapshot, and it may be quite a few higher if it is a fast computer on
1634 // a lagged connection
1635 int trap_GetCurrentCmdNumber( void );
1636
1637 qboolean trap_GetUserCmd( int cmdNumber, usercmd_t *ucmd );
1638
1639 // used for the weapon select and zoom
1640 void trap_SetUserCmdValue( int stateValue, float sensitivityScale );
1641
1642 // aids for VM testing
1643 void testPrintInt( char *string, int i );
1644 void testPrintFloat( char *string, float f );
1645
1646 int trap_MemoryRemaining( void );
1647 void trap_R_RegisterFont(const char *fontName, int pointSize, fontInfo_t *font);
1648 qboolean trap_Key_IsDown( int keynum );
1649 int trap_Key_GetCatcher( void );
1650 void trap_Key_SetCatcher( int catcher );
1651 int trap_Key_GetKey( const char *binding );
1652
1653
1654 typedef enum {
1655 SYSTEM_PRINT,
1656 CHAT_PRINT,
1657 TEAMCHAT_PRINT
1658 } q3print_t;
1659
1660
1661 int trap_CIN_PlayCinematic( const char *arg0, int xpos, int ypos, int width, int height, int bits);
1662 e_status trap_CIN_StopCinematic(int handle);
1663 e_status trap_CIN_RunCinematic (int handle);
1664 void trap_CIN_DrawCinematic (int handle);
1665 void trap_CIN_SetExtents (int handle, int x, int y, int w, int h);
1666
1667 int trap_RealTime(qtime_t *qtime);
1668 void trap_SnapVector( float *v );
1669
1670 qboolean trap_loadCamera(const char *name);
1671 void trap_startCamera(int time);
1672 qboolean trap_getCameraInfo(int time, vec3_t *origin, vec3_t *angles);
1673
1674 qboolean trap_GetEntityToken( char *buffer, int bufferSize );
1675
1676 void CG_ClearParticles (void);
1677 void CG_AddParticles (void);
1678 void CG_ParticleSnow (qhandle_t pshader, vec3_t origin, vec3_t origin2, int turb, float range, int snum);
1679 void CG_ParticleSmoke (qhandle_t pshader, centity_t *cent);
1680 void CG_AddParticleShrapnel (localEntity_t *le);
1681 void CG_ParticleSnowFlurry (qhandle_t pshader, centity_t *cent);
1682 void CG_ParticleBulletDebris (vec3_t org, vec3_t vel, int duration);
1683 void CG_ParticleSparks (vec3_t org, vec3_t vel, int duration, float x, float y, float speed);
1684 void CG_ParticleDust (centity_t *cent, vec3_t origin, vec3_t dir);
1685 void CG_ParticleMisc (qhandle_t pshader, vec3_t origin, int size, int duration, float alpha);
1686 void CG_ParticleExplosion (char *animStr, vec3_t origin, vec3_t vel, int duration, int sizeStart, int sizeEnd);
1687 extern qboolean initparticles;
1688 int CG_NewParticleArea ( int num );
1689
1690