Debian Codegraph @

code/cgame/cg_draw.c

raw ◀ ▶
1 Debian patch touch this file
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 // cg_draw.c -- draw all of the graphical elements during
24 // active (after loading) gameplay
25
26 #include "cg_local.h"
27
28 #ifdef MISSIONPACK
29 #include "../ui/ui_shared.h"
30
31 // used for scoreboard
32 extern displayContextDef_t cgDC;
33 menuDef_t *menuScoreboard = NULL;
34 #else
35 int drawTeamOverlayModificationCount = -1;
36 #endif
37
38 int sortedTeamPlayers[TEAM_MAXOVERLAY];
39 int numSortedTeamPlayers;
40
41 char systemChat[256];
42 char teamChat1[256];
43 char teamChat2[256];
44
45 #ifdef MISSIONPACK
46
47 int CG_Text_Width(const char *text, float scale, int limit) {
48 int count,len;
49 float out;
50 glyphInfo_t *glyph;
51 float useScale;
52 // FIXME: see ui_main.c, same problem
53 // const unsigned char *s = text;
54 const char *s = text;
55 fontInfo_t *font = &cgDC.Assets.textFont;
56 if (scale <= cg_smallFont.value) {
57 font = &cgDC.Assets.smallFont;
58 } else if (scale > cg_bigFont.value) {
59 font = &cgDC.Assets.bigFont;
60 }
61 useScale = scale * font->glyphScale;
62 out = 0;
63 if (text) {
64 len = strlen(text);
65 if (limit > 0 && len > limit) {
66 len = limit;
67 }
68 count = 0;
69 while (s && *s && count < len) {
70 if ( Q_IsColorString(s) ) {
71 s += 2;
72 continue;
73 } else {
74 glyph = &font->glyphs[(int)*s]; // TTimo: FIXME: getting nasty warnings without the cast, hopefully this doesn't break the VM build
75 out += glyph->xSkip;
76 s++;
77 count++;
78 }
79 }
80 }
81 return out * useScale;
82 }
83
84 int CG_Text_Height(const char *text, float scale, int limit) {
85 int len, count;
86 float max;
87 glyphInfo_t *glyph;
88 float useScale;
89 // TTimo: FIXME
90 // const unsigned char *s = text;
91 const char *s = text;
92 fontInfo_t *font = &cgDC.Assets.textFont;
93 if (scale <= cg_smallFont.value) {
94 font = &cgDC.Assets.smallFont;
95 } else if (scale > cg_bigFont.value) {
96 font = &cgDC.Assets.bigFont;
97 }
98 useScale = scale * font->glyphScale;
99 max = 0;
100 if (text) {
101 len = strlen(text);
102 if (limit > 0 && len > limit) {
103 len = limit;
104 }
105 count = 0;
106 while (s && *s && count < len) {
107 if ( Q_IsColorString(s) ) {
108 s += 2;
109 continue;
110 } else {
111 glyph = &font->glyphs[(int)*s]; // TTimo: FIXME: getting nasty warnings without the cast, hopefully this doesn't break the VM build
112 if (max < glyph->height) {
113 max = glyph->height;
114 }
115 s++;
116 count++;
117 }
118 }
119 }
120 return max * useScale;
121 }
122
123 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) {
124 float w, h;
125 w = width * scale;
126 h = height * scale;
127 CG_AdjustFrom640( &x, &y, &w, &h );
128 trap_R_DrawStretchPic( x, y, w, h, s, t, s2, t2, hShader );
129 }
130
131 void CG_Text_Paint(float x, float y, float scale, vec4_t color, const char *text, float adjust, int limit, int style) {
132 int len, count;
133 vec4_t newColor;
134 glyphInfo_t *glyph;
135 float useScale;
136 fontInfo_t *font = &cgDC.Assets.textFont;
137 if (scale <= cg_smallFont.value) {
138 font = &cgDC.Assets.smallFont;
139 } else if (scale > cg_bigFont.value) {
140 font = &cgDC.Assets.bigFont;
141 }
142 useScale = scale * font->glyphScale;
143 if (text) {
144 // TTimo: FIXME
145 // const unsigned char *s = text;
146 const char *s = text;
147 trap_R_SetColor( color );
148 memcpy(&newColor[0], &color[0], sizeof(vec4_t));
149 len = strlen(text);
150 if (limit > 0 && len > limit) {
151 len = limit;
152 }
153 count = 0;
154 while (s && *s && count < len) {
155 glyph = &font->glyphs[(int)*s]; // TTimo: FIXME: getting nasty warnings without the cast, hopefully this doesn't break the VM build
156 //int yadj = Assets.textFont.glyphs[text[i]].bottom + Assets.textFont.glyphs[text[i]].top;
157 //float yadj = scale * (Assets.textFont.glyphs[text[i]].imageHeight - Assets.textFont.glyphs[text[i]].height);
158 if ( Q_IsColorString( s ) ) {
159 memcpy( newColor, g_color_table[ColorIndex(*(s+1))], sizeof( newColor ) );
160 newColor[3] = color[3];
161 trap_R_SetColor( newColor );
162 s += 2;
163 continue;
164 } else {
165 float yadj = useScale * glyph->top;
166 if (style == ITEM_TEXTSTYLE_SHADOWED || style == ITEM_TEXTSTYLE_SHADOWEDMORE) {
167 int ofs = style == ITEM_TEXTSTYLE_SHADOWED ? 1 : 2;
168 colorBlack[3] = newColor[3];
169 trap_R_SetColor( colorBlack );
170 CG_Text_PaintChar(x + ofs, y - yadj + ofs,
171 glyph->imageWidth,
172 glyph->imageHeight,
173 useScale,
174 glyph->s,
175 glyph->t,
176 glyph->s2,
177 glyph->t2,
178 glyph->glyph);
179 colorBlack[3] = 1.0;
180 trap_R_SetColor( newColor );
181 }
182 CG_Text_PaintChar(x, y - yadj,
183 glyph->imageWidth,
184 glyph->imageHeight,
185 useScale,
186 glyph->s,
187 glyph->t,
188 glyph->s2,
189 glyph->t2,
190 glyph->glyph);
191 // CG_DrawPic(x, y - yadj, scale * cgDC.Assets.textFont.glyphs[text[i]].imageWidth, scale * cgDC.Assets.textFont.glyphs[text[i]].imageHeight, cgDC.Assets.textFont.glyphs[text[i]].glyph);
192 x += (glyph->xSkip * useScale) + adjust;
193 s++;
194 count++;
195 }
196 }
197 trap_R_SetColor( NULL );
198 }
199 }
200
201
202 #endif
203
204 /*
205 ==============
206 CG_DrawField
207
208 Draws large numbers for status bar and powerups
209 ==============
210 */
211 #ifndef MISSIONPACK
212 static void CG_DrawField (int x, int y, int width, int value) {
213 char num[16], *ptr;
214 int l;
215 int frame;
216
217 if ( width < 1 ) {
218 return;
219 }
220
221 // draw number string
222 if ( width > 5 ) {
223 width = 5;
224 }
225
226 switch ( width ) {
227 case 1:
228 value = value > 9 ? 9 : value;
229 value = value < 0 ? 0 : value;
230 break;
231 case 2:
232 value = value > 99 ? 99 : value;
233 value = value < -9 ? -9 : value;
234 break;
235 case 3:
236 value = value > 999 ? 999 : value;
237 value = value < -99 ? -99 : value;
238 break;
239 case 4:
240 value = value > 9999 ? 9999 : value;
241 value = value < -999 ? -999 : value;
242 break;
243 }
244
245 Com_sprintf (num, sizeof(num), "%i", value);
246 l = strlen(num);
247 if (l > width)
248 l = width;
249 x += 2 + CHAR_WIDTH*(width - l);
250
251 ptr = num;
252 while (*ptr && l)
253 {
254 if (*ptr == '-')
255 frame = STAT_MINUS;
256 else
257 frame = *ptr -'0';
258
259 CG_DrawPic( x,y, CHAR_WIDTH, CHAR_HEIGHT, cgs.media.numberShaders[frame] );
260 x += CHAR_WIDTH;
261 ptr++;
262 l--;
263 }
264 }
265 #endif // MISSIONPACK
266
267 /*
268 ================
269 CG_Draw3DModel
270
271 ================
272 */
273 void CG_Draw3DModel( float x, float y, float w, float h, qhandle_t model, qhandle_t skin, vec3_t origin, vec3_t angles ) {
274 refdef_t refdef;
275 refEntity_t ent;
276
277 if ( !cg_draw3dIcons.integer || !cg_drawIcons.integer ) {
278 return;
279 }
280
281 CG_AdjustFrom640( &x, &y, &w, &h );
282
283 memset( &refdef, 0, sizeof( refdef ) );
284
285 memset( &ent, 0, sizeof( ent ) );
286 AnglesToAxis( angles, ent.axis );
287 VectorCopy( origin, ent.origin );
288 ent.hModel = model;
289 ent.customSkin = skin;
290 ent.renderfx = RF_NOSHADOW; // no stencil shadows
291
292 refdef.rdflags = RDF_NOWORLDMODEL;
293
294 AxisClear( refdef.viewaxis );
295
296 refdef.fov_x = 30;
297 refdef.fov_y = 30;
298
299 refdef.x = x;
300 refdef.y = y;
301 refdef.width = w;
302 refdef.height = h;
303
304 refdef.time = cg.time;
305
306 trap_R_ClearScene();
307 trap_R_AddRefEntityToScene( &ent );
308 trap_R_RenderScene( &refdef );
309 }
310
311 /*
312 ================
313 CG_DrawHead
314
315 Used for both the status bar and the scoreboard
316 ================
317 */
318 void CG_DrawHead( float x, float y, float w, float h, int clientNum, vec3_t headAngles ) {
319 clipHandle_t cm;
320 clientInfo_t *ci;
321 float len;
322 vec3_t origin;
323 vec3_t mins, maxs;
324
325 ci = &cgs.clientinfo[ clientNum ];
326
327 if ( cg_draw3dIcons.integer ) {
328 cm = ci->headModel;
329 if ( !cm ) {
330 return;
331 }
332
333 // offset the origin y and z to center the head
334 trap_R_ModelBounds( cm, mins, maxs );
335
336 origin[2] = -0.5 * ( mins[2] + maxs[2] );
337 origin[1] = 0.5 * ( mins[1] + maxs[1] );
338
339 // calculate distance so the head nearly fills the box
340 // assume heads are taller than wide
341 len = 0.7 * ( maxs[2] - mins[2] );
342 origin[0] = len / 0.268; // len / tan( fov/2 )
343
344 // allow per-model tweaking
345 VectorAdd( origin, ci->headOffset, origin );
346
347 CG_Draw3DModel( x, y, w, h, ci->headModel, ci->headSkin, origin, headAngles );
348 } else if ( cg_drawIcons.integer ) {
349 CG_DrawPic( x, y, w, h, ci->modelIcon );
350 }
351
352 // if they are deferred, draw a cross out
353 if ( ci->deferred ) {
354 CG_DrawPic( x, y, w, h, cgs.media.deferShader );
355 }
356 }
357
358 /*
359 ================
360 CG_DrawFlagModel
361
362 Used for both the status bar and the scoreboard
363 ================
364 */
365 void CG_DrawFlagModel( float x, float y, float w, float h, int team, qboolean force2D ) {
366 qhandle_t cm;
367 float len;
368 vec3_t origin, angles;
369 vec3_t mins, maxs;
370 qhandle_t handle;
371
372 if ( !force2D && cg_draw3dIcons.integer ) {
373
374 VectorClear( angles );
375
376 cm = cgs.media.redFlagModel;
377
378 // offset the origin y and z to center the flag
379 trap_R_ModelBounds( cm, mins, maxs );
380
381 origin[2] = -0.5 * ( mins[2] + maxs[2] );
382 origin[1] = 0.5 * ( mins[1] + maxs[1] );
383
384 // calculate distance so the flag nearly fills the box
385 // assume heads are taller than wide
386 len = 0.5 * ( maxs[2] - mins[2] );
387 origin[0] = len / 0.268; // len / tan( fov/2 )
388
389 angles[YAW] = 60 * sin( cg.time / 2000.0 );;
390
391 if( team == TEAM_RED ) {
392 handle = cgs.media.redFlagModel;
393 if(cgs.gametype == GT_DOUBLE_D){
394 if(cgs.redflag == TEAM_BLUE)
395 handle = cgs.media.blueFlagModel;
396 if(cgs.redflag == TEAM_FREE)
397 handle = cgs.media.neutralFlagModel;
398 if(cgs.redflag == TEAM_NONE)
399 handle = cgs.media.neutralFlagModel;
400 }
401 } else if( team == TEAM_BLUE ) {
402 handle = cgs.media.blueFlagModel;
403 if(cgs.gametype == GT_DOUBLE_D){
404 if(cgs.redflag == TEAM_BLUE)
405 handle = cgs.media.blueFlagModel;
406 if(cgs.redflag == TEAM_FREE)
407 handle = cgs.media.neutralFlagModel;
408 if(cgs.redflag == TEAM_NONE)
409 handle = cgs.media.neutralFlagModel;
410 }
411 } else if( team == TEAM_FREE ) {
412 handle = cgs.media.neutralFlagModel;
413 } else {
414 return;
415 }
416 CG_Draw3DModel( x, y, w, h, handle, 0, origin, angles );
417 } else if ( cg_drawIcons.integer ) {
418 gitem_t *item;
419
420 if( team == TEAM_RED ) {
421 item = BG_FindItemForPowerup( PW_REDFLAG );
422 } else if( team == TEAM_BLUE ) {
423 item = BG_FindItemForPowerup( PW_BLUEFLAG );
424 } else if( team == TEAM_FREE ) {
425 item = BG_FindItemForPowerup( PW_NEUTRALFLAG );
426 } else {
427 return;
428 }
429 if (item) {
430 CG_DrawPic( x, y, w, h, cg_items[ ITEM_INDEX(item) ].icon );
431 }
432 }
433 }
434
435 /*
436 ================
437 CG_DrawStatusBarHead
438
439 ================
440 */
441 #ifndef MISSIONPACK
442
443 static void CG_DrawStatusBarHead( float x ) {
444 vec3_t angles;
445 float size, stretch;
446 float frac;
447
448 VectorClear( angles );
449
450 if ( cg.damageTime && cg.time - cg.damageTime < DAMAGE_TIME ) {
451 frac = (float)(cg.time - cg.damageTime ) / DAMAGE_TIME;
452 size = ICON_SIZE * 1.25 * ( 1.5 - frac * 0.5 );
453
454 stretch = size - ICON_SIZE * 1.25;
455 // kick in the direction of damage
456 x -= stretch * 0.5 + cg.damageX * stretch * 0.5;
457
458 cg.headStartYaw = 180 + cg.damageX * 45;
459
460 cg.headEndYaw = 180 + 20 * cos( crandom()*M_PI );
461 cg.headEndPitch = 5 * cos( crandom()*M_PI );
462
463 cg.headStartTime = cg.time;
464 cg.headEndTime = cg.time + 100 + random() * 2000;
465 } else {
466 if ( cg.time >= cg.headEndTime ) {
467 // select a new head angle
468 cg.headStartYaw = cg.headEndYaw;
469 cg.headStartPitch = cg.headEndPitch;
470 cg.headStartTime = cg.headEndTime;
471 cg.headEndTime = cg.time + 100 + random() * 2000;
472
473 cg.headEndYaw = 180 + 20 * cos( crandom()*M_PI );
474 cg.headEndPitch = 5 * cos( crandom()*M_PI );
475 }
476
477 size = ICON_SIZE * 1.25;
478 }
479
480 // if the server was frozen for a while we may have a bad head start time
481 if ( cg.headStartTime > cg.time ) {
482 cg.headStartTime = cg.time;
483 }
484
485 frac = ( cg.time - cg.headStartTime ) / (float)( cg.headEndTime - cg.headStartTime );
486 frac = frac * frac * ( 3 - 2 * frac );
487 angles[YAW] = cg.headStartYaw + ( cg.headEndYaw - cg.headStartYaw ) * frac;
488 angles[PITCH] = cg.headStartPitch + ( cg.headEndPitch - cg.headStartPitch ) * frac;
489
490 CG_DrawHead( x, 480 - size, size, size,
491 cg.snap->ps.clientNum, angles );
492 }
493 #endif // MISSIONPACK
494
495 /*
496 ================
497 CG_DrawStatusBarFlag
498
499 ================
500 */
501 #ifndef MISSIONPACK
502 static void CG_DrawStatusBarFlag( float x, int team ) {
503 CG_DrawFlagModel( x, 480 - ICON_SIZE, ICON_SIZE, ICON_SIZE, team, qfalse );
504 }
505 #endif // MISSIONPACK
506
507 /*
508 ================
509 CG_DrawTeamBackground
510
511 ================
512 */
513 void CG_DrawTeamBackground( int x, int y, int w, int h, float alpha, int team )
514 {
515 vec4_t hcolor;
516
517 hcolor[3] = alpha;
518 if ( team == TEAM_RED ) {
519 hcolor[0] = 1;
520 hcolor[1] = 0;
521 hcolor[2] = 0;
522 } else if ( team == TEAM_BLUE ) {
523 hcolor[0] = 0;
524 hcolor[1] = 0;
525 hcolor[2] = 1;
526 } else {
527 return;
528 }
529 trap_R_SetColor( hcolor );
530 CG_DrawPic( x, y, w, h, cgs.media.teamStatusBar );
531 trap_R_SetColor( NULL );
532 }
533
534 /*
535 ================
536 CG_DrawStatusBar
537
538 ================
539 */
540 #ifndef MISSIONPACK
541 static void CG_DrawStatusBar( void ) {
542 int color;
543 centity_t *cent;
544 playerState_t *ps;
545 int value;
546 vec4_t hcolor;
547 vec3_t angles;
548 vec3_t origin;
549 qhandle_t handle;
550
551 static float colors[4][4] = {
552 // { 0.2, 1.0, 0.2, 1.0 } , { 1.0, 0.2, 0.2, 1.0 }, {0.5, 0.5, 0.5, 1} };
553 { 1.0f, 0.69f, 0.0f, 1.0f }, // normal
554 { 1.0f, 0.2f, 0.2f, 1.0f }, // low health
555 { 0.5f, 0.5f, 0.5f, 1.0f }, // weapon firing
556 { 1.0f, 1.0f, 1.0f, 1.0f } }; // health > 100
557
558 if ( cg_drawStatus.integer == 0 ) {
559 return;
560 }
561
562 // draw the team background
563 if ( !(cg.snap->ps.pm_flags & PMF_FOLLOW) ) //If not following anybody:
564 CG_DrawTeamBackground( 0, 420, 640, 60, 0.33f, cg.snap->ps.persistant[PERS_TEAM] );
565 else //Sago: If we follow find the teamcolor of the guy we follow. It might not be our own team!
566 CG_DrawTeamBackground( 0, 420, 640, 60, 0.33f, cgs.clientinfo[ cg.snap->ps.clientNum ].team );
567
568 cent = &cg_entities[cg.snap->ps.clientNum];
569 ps = &cg.snap->ps;
570
571 VectorClear( angles );
572
573 // draw any 3D icons first, so the changes back to 2D are minimized
574 if ( cent->currentState.weapon && cg_weapons[ cent->currentState.weapon ].ammoModel ) {
575 origin[0] = 70;
576 origin[1] = 0;
577 origin[2] = 0;
578 angles[YAW] = 90 + 20 * sin( cg.time / 1000.0 );
579 CG_Draw3DModel( CHAR_WIDTH*3 + TEXT_ICON_SPACE, 432, ICON_SIZE, ICON_SIZE,
580 cg_weapons[ cent->currentState.weapon ].ammoModel, 0, origin, angles );
581 }
582
583 CG_DrawStatusBarHead( 185 + CHAR_WIDTH*3 + TEXT_ICON_SPACE );
584
585 if( cg.predictedPlayerState.powerups[PW_REDFLAG] ) {
586 CG_DrawStatusBarFlag( 185 + CHAR_WIDTH*3 + TEXT_ICON_SPACE + ICON_SIZE, TEAM_RED );
587 } else if( cg.predictedPlayerState.powerups[PW_BLUEFLAG] ) {
588 CG_DrawStatusBarFlag( 185 + CHAR_WIDTH*3 + TEXT_ICON_SPACE + ICON_SIZE, TEAM_BLUE );
589 } else if( cg.predictedPlayerState.powerups[PW_NEUTRALFLAG] ) {
590 CG_DrawStatusBarFlag( 185 + CHAR_WIDTH*3 + TEXT_ICON_SPACE + ICON_SIZE, TEAM_FREE );
591 }
592
593 if ( ps->stats[ STAT_ARMOR ] ) {
594 origin[0] = 90;
595 origin[1] = 0;
596 origin[2] = -10;
597 angles[YAW] = ( cg.time & 2047 ) * 360 / 2048.0;
598 CG_Draw3DModel( 370 + CHAR_WIDTH*3 + TEXT_ICON_SPACE, 432, ICON_SIZE, ICON_SIZE,
599 cgs.media.armorModel, 0, origin, angles );
600 }
601
602 if( cgs.gametype == GT_HARVESTER ) {
603 origin[0] = 90;
604 origin[1] = 0;
605 origin[2] = -10;
606 angles[YAW] = ( cg.time & 2047 ) * 360 / 2048.0;
607 if( cg.snap->ps.persistant[PERS_TEAM] == TEAM_BLUE ) {
608 handle = cgs.media.redCubeModel;
609 } else {
610 handle = cgs.media.blueCubeModel;
611 }
612 CG_Draw3DModel( 470 + CHAR_WIDTH*3 + TEXT_ICON_SPACE, 432, ICON_SIZE, ICON_SIZE, handle, 0, origin, angles );
613 }
614
615
616 //
617 // ammo
618 //
619 if ( cent->currentState.weapon ) {
620 value = ps->ammo[cent->currentState.weapon];
621 if ( value > -1 ) {
622 if ( cg.predictedPlayerState.weaponstate == WEAPON_FIRING
623 && cg.predictedPlayerState.weaponTime > 100 ) {
624 // draw as dark grey when reloading
625 color = 2; // dark grey
626 } else {
627 if ( value >= 0 ) {
628 color = 0; // green
629 } else {
630 color = 1; // red
631 }
632 }
633 trap_R_SetColor( colors[color] );
634
635 CG_DrawField (0, 432, 3, value);
636 trap_R_SetColor( NULL );
637
638 // if we didn't draw a 3D icon, draw a 2D icon for ammo
639 if ( !cg_draw3dIcons.integer && cg_drawIcons.integer ) {
640 qhandle_t icon;
641
642 icon = cg_weapons[ cg.predictedPlayerState.weapon ].ammoIcon;
643 if ( icon ) {
644 CG_DrawPic( CHAR_WIDTH*3 + TEXT_ICON_SPACE, 432, ICON_SIZE, ICON_SIZE, icon );
645 }
646 }
647 }
648 }
649
650 //
651 // health
652 //
653 value = ps->stats[STAT_HEALTH];
654 if ( value > 100 ) {
655 trap_R_SetColor( colors[3] ); // white
656 } else if (value > 25) {
657 trap_R_SetColor( colors[0] ); // green
658 } else if (value > 0) {
659 color = (cg.time >> 8) & 1; // flash
660 trap_R_SetColor( colors[color] );
661 } else {
662 trap_R_SetColor( colors[1] ); // red
663 }
664
665 // stretch the health up when taking damage
666 CG_DrawField ( 185, 432, 3, value);
667 CG_ColorForHealth( hcolor );
668 trap_R_SetColor( hcolor );
669
670
671 //
672 // armor
673 //
674 value = ps->stats[STAT_ARMOR];
675 if (value > 0 ) {
676 trap_R_SetColor( colors[0] );
677 CG_DrawField (370, 432, 3, value);
678 trap_R_SetColor( NULL );
679 // if we didn't draw a 3D icon, draw a 2D icon for armor
680 if ( !cg_draw3dIcons.integer && cg_drawIcons.integer ) {
681 CG_DrawPic( 370 + CHAR_WIDTH*3 + TEXT_ICON_SPACE, 432, ICON_SIZE, ICON_SIZE, cgs.media.armorIcon );
682 }
683
684 }
685
686 //Skulls!
687 if(cgs.gametype == GT_HARVESTER)
688 {
689 value = ps->generic1;
690 if (value > 0 ) {
691 trap_R_SetColor( colors[0] );
692 CG_DrawField (470, 432, 3, value);
693 trap_R_SetColor( NULL );
694 // if we didn't draw a 3D icon, draw a 2D icon for skull
695 if ( !cg_draw3dIcons.integer && cg_drawIcons.integer ) {
696 if( cg.snap->ps.persistant[PERS_TEAM] == TEAM_BLUE ) {
697 handle = cgs.media.redCubeIcon;
698 } else {
699 handle = cgs.media.blueCubeIcon;
700 }
701 CG_DrawPic( 470 + CHAR_WIDTH*3 + TEXT_ICON_SPACE, 432, ICON_SIZE, ICON_SIZE, handle );
702 }
703
704 }
705 }
706 }
707 #endif
708
709 /*
710 ===========================================================================================
711
712 UPPER RIGHT CORNER
713
714 ===========================================================================================
715 */
716
717 /*
718 ================
719 CG_DrawAttacker
720
721 ================
722 */
723 static float CG_DrawAttacker( float y ) {
724 int t;
725 float size;
726 vec3_t angles;
727 const char *info;
728 const char *name;
729 int clientNum;
730
731 if ( cg.predictedPlayerState.stats[STAT_HEALTH] <= 0 ) {
732 return y;
733 }
734
735 if ( !cg.attackerTime ) {
736 return y;
737 }
738
739 clientNum = cg.predictedPlayerState.persistant[PERS_ATTACKER];
740 if ( clientNum < 0 || clientNum >= MAX_CLIENTS || clientNum == cg.snap->ps.clientNum ) {
741 return y;
742 }
743
744 t = cg.time - cg.attackerTime;
745 if ( t > ATTACKER_HEAD_TIME ) {
746 cg.attackerTime = 0;
747 return y;
748 }
749
750 size = ICON_SIZE * 1.25;
751
752 angles[PITCH] = 0;
753 angles[YAW] = 180;
754 angles[ROLL] = 0;
755 CG_DrawHead( 640 - size, y, size, size, clientNum, angles );
756
757 info = CG_ConfigString( CS_PLAYERS + clientNum );
758 name = Info_ValueForKey( info, "n" );
759 y += size;
760 CG_DrawBigString( 640 - ( Q_PrintStrlen( name ) * BIGCHAR_WIDTH), y, name, 0.5 );
761
762 return y + BIGCHAR_HEIGHT + 2;
763 }
764
765 /*
766 ================
767 CG_DrawSpeedMeter
768
769 ================
770 */
771 static float CG_DrawSpeedMeter( float y ) {
772 char *s;
773 int w;
774 vec_t *vel;
775 int speed;
776
777 /* speed meter can get in the way of the scoreboard */
778 if ( cg.scoreBoardShowing ) {
779 return y;
780 }
781
782 vel = cg.snap->ps.velocity;
783 /* ignore vertical component of velocity */
784 speed = sqrt(vel[0] * vel[0] + vel[1] * vel[1]);
785
786 s = va( "%iu/s", speed );
787
788 w = CG_DrawStrlen( s ) * BIGCHAR_WIDTH;
789
790 if (cg_drawSpeed.integer == 1) {
791 /* top left-hand corner of screen */
792 CG_DrawBigString( 635 - w, y + 2, s, 1.0F);
793 return y + BIGCHAR_HEIGHT + 4;
794 } else {
795 /* center of screen */
796 CG_DrawBigString( 320 - w / 2, 300, s, 1.0F);
797 return y;
798 }
799 }
800
801 /*
802 ==================
803 CG_DrawSnapshot
804 ==================
805 */
806 static float CG_DrawSnapshot( float y ) {
807 char *s;
808 int w;
809
810 s = va( "time:%i snap:%i cmd:%i", cg.snap->serverTime,
811 cg.latestSnapshotNum, cgs.serverCommandSequence );
812 w = CG_DrawStrlen( s ) * BIGCHAR_WIDTH;
813
814 CG_DrawBigString( 635 - w, y + 2, s, 1.0F);
815
816 return y + BIGCHAR_HEIGHT + 4;
817 }
818
819 /*
820 ==================
821 CG_DrawFPS
822 ==================
823 */
824 #define FPS_FRAMES 4
825 static float CG_DrawFPS( float y ) {
826 char *s;
827 int w;
828 static int previousTimes[FPS_FRAMES];
829 static int index;
830 int i, total;
831 int fps;
832 static int previous;
833 int t, frameTime;
834
835 // don't use serverTime, because that will be drifting to
836 // correct for internet lag changes, timescales, timedemos, etc
837 t = trap_Milliseconds();
838 frameTime = t - previous;
839 previous = t;
840
841 previousTimes[index % FPS_FRAMES] = frameTime;
842 index++;
843 if ( index > FPS_FRAMES ) {
844 // average multiple frames together to smooth changes out a bit
845 total = 0;
846 for ( i = 0 ; i < FPS_FRAMES ; i++ ) {
847 total += previousTimes[i];
848 }
849 if ( !total ) {
850 total = 1;
851 }
852 fps = 1000 * FPS_FRAMES / total;
853
854 s = va( "%ifps", fps );
855 w = CG_DrawStrlen( s ) * BIGCHAR_WIDTH;
856
857 CG_DrawBigString( 635 - w, y + 2, s, 1.0F);
858 }
859
860 return y + BIGCHAR_HEIGHT + 4;
861 }
862
863 /*
864 =================
865 CG_DrawTimer
866 =================
867 */
868 static float CG_DrawTimer( float y ) {
869 char *s;
870 int w;
871 int mins, seconds, tens;
872 int msec;
873
874 msec = cg.time - cgs.levelStartTime;
875
876 seconds = msec / 1000;
877 mins = seconds / 60;
878 seconds -= mins * 60;
879 tens = seconds / 10;
880 seconds -= tens * 10;
881
882 s = va( "%i:%i%i", mins, tens, seconds );
883 w = CG_DrawStrlen( s ) * BIGCHAR_WIDTH;
884
885 CG_DrawBigString( 635 - w, y + 2, s, 1.0F);
886
887 return y + BIGCHAR_HEIGHT + 4;
888 }
889
890 /*
891 CG_DrawDoubleDominationThings
892 *
893 *Sago: Might be relevant for debugging missionpack.
894 */
895
896 /*static float CG_DrawDoubleDominationThings( float y ) {
897 char *s;
898 int w;
899 int statusA, statusB;
900 statusA = cgs.redflag;
901 statusB = cgs.blueflag;
902
903 if(statusA == TEAM_NONE) {
904 s = va("Point A not spawned");
905 } else
906 if(statusA == TEAM_FREE) {
907 s = va("Point A is not controlled");
908 } else
909 if(statusA == TEAM_RED) {
910 s = va("Point A is controlled by RED");
911 } else
912 if(statusA == TEAM_BLUE) {
913 s = va("Point A is controlled by BLUE");
914 } else
915 s = va("Point A has an error");
916 w = CG_DrawStrlen( s ) * SMALLCHAR_WIDTH;
917 CG_DrawSmallString( 635 - w, y + 2, s, 1.0F);
918 y+=SMALLCHAR_HEIGHT+4;
919
920 if(statusB == TEAM_NONE) {
921 s = va("Point B not spawned");
922 } else
923 if(statusB == TEAM_FREE) {
924 s = va("Point B is not controlled");
925 } else
926 if(statusB == TEAM_RED) {
927 s = va("Point B is controlled by RED");
928 } else
929 if(statusB == TEAM_BLUE) {
930 s = va("Point B is controlled by BLUE");
931 } else
932 s = va("Point B has an error");
933 w = CG_DrawStrlen( s ) * SMALLCHAR_WIDTH;
934 CG_DrawSmallString( 635 - w, y + 2, s, 1.0F);
935
936 if( ( ( statusB == statusA ) && ( statusA == TEAM_RED ) ) ||
937 ( ( statusB == statusA ) && ( statusA == TEAM_BLUE ) ) ) {
938 s = va("Capture in: %i",(cgs.timetaken+10*1000-cg.time)/1000+1);
939 w = CG_DrawStrlen( s ) * SMALLCHAR_WIDTH;
940 y+=SMALLCHAR_HEIGHT+4;
941 CG_DrawSmallString( 635 - w, y + 2, s, 1.0F);
942 }
943
944 return y + SMALLCHAR_HEIGHT+4;
945 }*/
946
947 /*
948 =================
949 CG_DrawLMSmode
950 =================
951 */
952
953 static float CG_DrawLMSmode( float y ) {
954 char *s;
955 int w;
956
957 if(cgs.lms_mode == 0) {
958 s = va("LMS: Point/round + OT");
959 } else
960 if(cgs.lms_mode == 1) {
961 s = va("LMS: Point/round - OT");
962 } else
963 if(cgs.lms_mode == 2) {
964 s = va("LMS: Point/kill + OT");
965 } else
966 if(cgs.lms_mode == 3) {
967 s = va("LMS: Point/kill - OT");
968 } else
969 s = va("LMS: Unknown mode");
970
971 w = CG_DrawStrlen( s ) * SMALLCHAR_WIDTH;
972 CG_DrawSmallString( 635 - w, y + 2, s, 1.0F);
973
974 return y + SMALLCHAR_HEIGHT+4;
975 }
976
977 /*
978 =================
979 CG_DrawCTFoneway
980 =================
981 */
982
983 static float CG_DrawCTFoneway( float y ) {
984 char *s;
985 int w;
986 vec4_t color;
987
988 if(cgs.gametype != GT_CTF_ELIMINATION)
989 return y;
990
991 memcpy(color,g_color_table[ColorIndex(COLOR_WHITE)],sizeof(color));
992
993 if( (cgs.elimflags&EF_ONEWAY)==0) {
994 return y; //nothing to draw
995 } else
996 if(cgs.attackingTeam == TEAM_BLUE) {
997 memcpy(color,g_color_table[ColorIndex(COLOR_BLUE)],sizeof(color));
998 s = va("Blue team on offence");
999 } else
1000 if(cgs.attackingTeam == TEAM_RED) {
1001 memcpy(color,g_color_table[ColorIndex(COLOR_RED)],sizeof(color));
1002 s = va("Red team on offence");
1003 } else
1004 s = va("Unknown team on offence");
1005
1006 w = CG_DrawStrlen( s ) * SMALLCHAR_WIDTH;
1007 CG_DrawSmallStringColor( 635 - w, y + 2, s, color);
1008
1009 return y + SMALLCHAR_HEIGHT+4;
1010 }
1011
1012 /*
1013 =================
1014 CG_DrawEliminationDeathMessage
1015 =================
1016 */
1017
1018 /*static float CG_DrawEliminationDeathMessage( float y ) {
1019 char *s;
1020 int w;
1021
1022 s = va("You are waiting for a new round");
1023 w = CG_DrawStrlen( s ) * SMALLCHAR_WIDTH;
1024 CG_DrawSmallString( 635 - w, y + 2, s, 1.0F);
1025
1026 return y + SMALLCHAR_HEIGHT+4;
1027 }*/
1028
1029 /*
1030 =================
1031 CG_DrawDomStatus
1032 =================
1033 */
1034
1035 static float CG_DrawDomStatus( float y ) {
1036 int i,w;
1037 char *s;
1038 vec4_t color;
1039
1040 for(i = 0;i < cgs.domination_points_count;i++) {
1041 switch(cgs.domination_points_status[i]) {
1042 case TEAM_RED:
1043 memcpy(color,g_color_table[ColorIndex(COLOR_RED)],sizeof(color));
1044 break;
1045 case TEAM_BLUE:
1046 memcpy(color,g_color_table[ColorIndex(COLOR_BLUE)],sizeof(color));
1047 break;
1048 default:
1049 memcpy(color,g_color_table[ColorIndex(COLOR_WHITE)],sizeof(color));
1050 break;
1051 }
1052
1053 s = va("%s",cgs.domination_points_names[i]);
1054 w = CG_DrawStrlen( s ) * SMALLCHAR_WIDTH;
1055 CG_DrawSmallStringColor( 635 - w, y + 2, s, color);
1056 y += SMALLCHAR_HEIGHT+4;
1057
1058 }
1059
1060 return y;
1061 }
1062
1063
1064 /*
1065 =================
1066 CG_DrawEliminationTimer
1067 =================
1068 */
1069 static float CG_DrawEliminationTimer( float y ) {
1070 char *s;
1071 int w;
1072 int mins, seconds, tens, sec;
1073 int msec;
1074 vec4_t color;
1075 const char *st;
1076 float scale;
1077 int cw;
1078 int rst;
1079
1080
1081
1082 rst = cgs.roundStartTime;
1083
1084 if(cg.time>rst && !cgs.roundtime) {
1085 return y;
1086 }
1087
1088 //default color is white
1089 memcpy(color,g_color_table[ColorIndex(COLOR_WHITE)],sizeof(color));
1090
1091 //msec = cg.time - cgs.levelStartTime;
1092 if(cg.time>rst) //We are started
1093 {
1094 msec = cgs.roundtime*1000 - (cg.time -rst);
1095 if(msec<=30*1000-1) //<= 30 seconds
1096 memcpy(color,g_color_table[ColorIndex(COLOR_YELLOW)],sizeof(color));
1097 if(msec<=10*1000-1) //<= 10 seconds
1098 memcpy(color,g_color_table[ColorIndex(COLOR_RED)],sizeof(color));
1099 msec += 1000; //120-1 instead of 119-0
1100 }
1101 else
1102 {
1103 //Warmup
1104 msec = -cg.time +rst;
1105 memcpy(color,g_color_table[ColorIndex(COLOR_GREEN)],sizeof(color));
1106 sec = msec/1000;
1107 msec += 1000; //5-1 instead of 4-0
1108 /***
1109 Lots of stuff
1110 ****/
1111 if(cg.warmup == 0)
1112 {
1113 st = va( "Round in: %i", sec + 1 );
1114 if ( sec != cg.warmupCount ) {
1115 cg.warmupCount = sec;
1116 switch ( sec ) {
1117 case 0:
1118 trap_S_StartLocalSound( cgs.media.count1Sound, CHAN_ANNOUNCER );
1119 break;
1120 case 1:
1121 trap_S_StartLocalSound( cgs.media.count2Sound, CHAN_ANNOUNCER );
1122 break;
1123 case 2:
1124 trap_S_StartLocalSound( cgs.media.count3Sound, CHAN_ANNOUNCER );
1125 break;
1126 default:
1127 break;
1128 }
1129 }
1130 scale = 0.45f;
1131 switch ( cg.warmupCount ) {
1132 case 0:
1133 cw = 28;
1134 scale = 0.54f;
1135 break;
1136 case 1:
1137 cw = 24;
1138 scale = 0.51f;
1139 break;
1140 case 2:
1141 cw = 20;
1142 scale = 0.48f;
1143 break;
1144 default:
1145 cw = 16;
1146 scale = 0.45f;
1147 break;
1148 }
1149
1150 #ifdef MISSIONPACK
1151 //w = CG_Text_Width(s, scale, 0);
1152 //CG_Text_Paint(320 - w / 2, 125, scale, colorWhite, st, 0, 0, ITEM_TEXTSTYLE_SHADOWEDMORE);
1153 #else
1154
1155 w = CG_DrawStrlen( st );
1156 CG_DrawStringExt( 320 - w * cw/2, 70, st, colorWhite,
1157 qfalse, qtrue, cw, (int)(cw * 1.5), 0 );
1158 #endif
1159 }
1160 /*
1161 Lots of stuff
1162 */
1163 }
1164
1165 seconds = msec / 1000;
1166 mins = seconds / 60;
1167 seconds -= mins * 60;
1168 tens = seconds / 10;
1169 seconds -= tens * 10;
1170
1171 if(msec>=0)
1172 s = va( " %i:%i%i", mins, tens, seconds );
1173 else
1174 s = va( " Overtime");
1175 w = CG_DrawStrlen( s ) * BIGCHAR_WIDTH;
1176
1177 CG_DrawBigStringColor( 635 - w, y + 2, s, color);
1178
1179 return y + BIGCHAR_HEIGHT + 4;
1180 }
1181
1182
1183 /*
1184 =================
1185 CG_DrawTeamOverlay
1186 =================
1187 */
1188
1189 static float CG_DrawTeamOverlay( float y, qboolean right, qboolean upper ) {
1190 int x, w, h, xx;
1191 int i, j, len;
1192 const char *p;
1193 vec4_t hcolor;
1194 int pwidth, lwidth;
1195 int plyrs;
1196 char st[16];
1197 clientInfo_t *ci;
1198 gitem_t *item;
1199 int ret_y, count;
1200
1201 if ( !cg_drawTeamOverlay.integer ) {
1202 return y;
1203 }
1204
1205 if ( cg.snap->ps.persistant[PERS_TEAM] != TEAM_RED && cg.snap->ps.persistant[PERS_TEAM] != TEAM_BLUE ) {
1206 return y; // Not on any team
1207 }
1208
1209 plyrs = 0;
1210
1211 // max player name width
1212 pwidth = 0;
1213 count = (numSortedTeamPlayers > 8) ? 8 : numSortedTeamPlayers;
1214 for (i = 0; i < count; i++) {
1215 ci = cgs.clientinfo + sortedTeamPlayers[i];
1216 if ( ci->infoValid && ci->team == cg.snap->ps.persistant[PERS_TEAM]) {
1217 plyrs++;
1218 len = CG_DrawStrlen(ci->name);
1219 if (len > pwidth)
1220 pwidth = len;
1221 }
1222 }
1223
1224 if (!plyrs)
1225 return y;
1226
1227 if (pwidth > TEAM_OVERLAY_MAXNAME_WIDTH)
1228 pwidth = TEAM_OVERLAY_MAXNAME_WIDTH;
1229
1230 // max location name width
1231 lwidth = 0;
1232 for (i = 1; i < MAX_LOCATIONS; i++) {
1233 p = CG_ConfigString(CS_LOCATIONS + i);
1234 if (p && *p) {
1235 len = CG_DrawStrlen(p);
1236 if (len > lwidth)
1237 lwidth = len;
1238 }
1239 }
1240
1241 if (lwidth > TEAM_OVERLAY_MAXLOCATION_WIDTH)
1242 lwidth = TEAM_OVERLAY_MAXLOCATION_WIDTH;
1243
1244 w = (pwidth + lwidth + 4 + 7) * TINYCHAR_WIDTH;
1245
1246 if ( right )
1247 x = 640 - w;
1248 else
1249 x = 0;
1250
1251 h = plyrs * TINYCHAR_HEIGHT;
1252
1253 if ( upper ) {
1254 ret_y = y + h;
1255 } else {
1256 y -= h;
1257 ret_y = y;
1258 }
1259
1260 if ( cg.snap->ps.persistant[PERS_TEAM] == TEAM_RED ) {
1261 hcolor[0] = 1.0f;
1262 hcolor[1] = 0.0f;
1263 hcolor[2] = 0.0f;
1264 hcolor[3] = 0.33f;
1265 } else { // if ( cg.snap->ps.persistant[PERS_TEAM] == TEAM_BLUE )
1266 hcolor[0] = 0.0f;
1267 hcolor[1] = 0.0f;
1268 hcolor[2] = 1.0f;
1269 hcolor[3] = 0.33f;
1270 }
1271 trap_R_SetColor( hcolor );
1272 CG_DrawPic( x, y, w, h, cgs.media.teamStatusBar );
1273 trap_R_SetColor( NULL );
1274
1275 for (i = 0; i < count; i++) {
1276 ci = cgs.clientinfo + sortedTeamPlayers[i];
1277 if ( ci->infoValid && ci->team == cg.snap->ps.persistant[PERS_TEAM]) {
1278
1279 hcolor[0] = hcolor[1] = hcolor[2] = hcolor[3] = 1.0;
1280
1281 xx = x + TINYCHAR_WIDTH;
1282
1283 CG_DrawStringExt( xx, y,
1284 ci->name, hcolor, qfalse, qfalse,
1285 TINYCHAR_WIDTH, TINYCHAR_HEIGHT, TEAM_OVERLAY_MAXNAME_WIDTH);
1286
1287 if (lwidth) {
1288 p = CG_ConfigString(CS_LOCATIONS + ci->location);
1289 if (!p || !*p)
1290 p = "unknown";
1291 len = CG_DrawStrlen(p);
1292 if (len > lwidth)
1293 len = lwidth;
1294
1295 // xx = x + TINYCHAR_WIDTH * 2 + TINYCHAR_WIDTH * pwidth +
1296 // ((lwidth/2 - len/2) * TINYCHAR_WIDTH);
1297 xx = x + TINYCHAR_WIDTH * 2 + TINYCHAR_WIDTH * pwidth;
1298 CG_DrawStringExt( xx, y,
1299 p, hcolor, qfalse, qfalse, TINYCHAR_WIDTH, TINYCHAR_HEIGHT,
1300 TEAM_OVERLAY_MAXLOCATION_WIDTH);
1301 }
1302
1303 CG_GetColorForHealth( ci->health, ci->armor, hcolor );
1304
1305 Com_sprintf (st, sizeof(st), "%3i %3i", ci->health, ci->armor);
1306
1307 xx = x + TINYCHAR_WIDTH * 3 +
1308 TINYCHAR_WIDTH * pwidth + TINYCHAR_WIDTH * lwidth;
1309
1310 CG_DrawStringExt( xx, y,
1311 st, hcolor, qfalse, qfalse,
1312 TINYCHAR_WIDTH, TINYCHAR_HEIGHT, 0 );
1313
1314 // draw weapon icon
1315 xx += TINYCHAR_WIDTH * 3;
1316
1317 if ( cg_weapons[ci->curWeapon].weaponIcon ) {
1318 CG_DrawPic( xx, y, TINYCHAR_WIDTH, TINYCHAR_HEIGHT,
1319 cg_weapons[ci->curWeapon].weaponIcon );
1320 } else {
1321 CG_DrawPic( xx, y, TINYCHAR_WIDTH, TINYCHAR_HEIGHT,
1322 cgs.media.deferShader );
1323 }
1324
1325 // Draw powerup icons
1326 if (right) {
1327 xx = x;
1328 } else {
1329 xx = x + w - TINYCHAR_WIDTH;
1330 }
1331 for (j = 0; j <= PW_NUM_POWERUPS; j++) {
1332 if (ci->powerups & (1 << j)) {
1333
1334 item = BG_FindItemForPowerup( j );
1335
1336 if (item) {
1337 CG_DrawPic( xx, y, TINYCHAR_WIDTH, TINYCHAR_HEIGHT,
1338 trap_R_RegisterShader( item->icon ) );
1339 if (right) {
1340 xx -= TINYCHAR_WIDTH;
1341 } else {
1342 xx += TINYCHAR_WIDTH;
1343 }
1344 }
1345 }
1346 }
1347
1348 y += TINYCHAR_HEIGHT;
1349 }
1350 }
1351
1352 return ret_y;
1353 //#endif
1354 }
1355
1356 static float CG_DrawFollowMessage( float y ) {
1357 char *s;
1358 int w;
1359
1360 if ( !(cg.snap->ps.pm_flags & PMF_FOLLOW) || ( ( cgs.elimflags & EF_NO_FREESPEC ) && (cgs.gametype == GT_ELIMINATION || cgs.gametype == GT_CTF_ELIMINATION ) ) ) {
1361 return y;
1362 }
1363
1364 s = va("USE_ITEM to stop following");
1365 w = CG_DrawStrlen( s ) * SMALLCHAR_WIDTH;
1366 CG_DrawSmallString( 635 - w, y + 2, s, 1.0F);
1367
1368 return y + SMALLCHAR_HEIGHT+4;
1369 }
1370
1371
1372 /*
1373 =====================
1374 CG_DrawUpperRight
1375
1376 =====================
1377 */
1378 static void CG_DrawUpperRight(stereoFrame_t stereoFrame)
1379 {
1380 float y;
1381
1382 y = 0;
1383
1384 if ( cgs.gametype >= GT_TEAM && cgs.ffa_gt!=1 && cg_drawTeamOverlay.integer == 1 ) {
1385 y = CG_DrawTeamOverlay( y, qtrue, qtrue );
1386 }
1387 /*if ( cgs.gametype == GT_DOUBLE_D ) {
1388 y = CG_DrawDoubleDominationThings(y);
1389 }
1390 else*/
1391 if ( cgs.gametype == GT_LMS && cg.showScores ) {
1392 y = CG_DrawLMSmode(y);
1393 }
1394 else
1395 if ( cgs.gametype == GT_CTF_ELIMINATION ) {
1396 y = CG_DrawCTFoneway(y);
1397 }
1398 else
1399 if ( cgs.gametype == GT_DOMINATION ) {
1400 y = CG_DrawDomStatus(y);
1401 }
1402
1403 if ( cg_drawSnapshot.integer ) {
1404 y = CG_DrawSnapshot( y );
1405 }
1406 if (cg_drawFPS.integer && (stereoFrame == STEREO_CENTER || stereoFrame == STEREO_RIGHT)) {
1407 y = CG_DrawFPS( y );
1408 }
1409 if (cgs.gametype==GT_ELIMINATION || cgs.gametype == GT_CTF_ELIMINATION || cgs.gametype==GT_LMS) {
1410 y = CG_DrawEliminationTimer( y );
1411 /*if (cgs.clientinfo[ cg.clientNum ].isDead)
1412 y = CG_DrawEliminationDeathMessage( y);*/
1413 }
1414
1415 y = CG_DrawFollowMessage( y );
1416
1417 if ( cg_drawTimer.integer) {
1418 y = CG_DrawTimer( y );
1419 }
1420 if ( cg_drawAttacker.integer ) {
1421 y = CG_DrawAttacker( y );
1422 }
1423 if ( cg_drawSpeed.integer ) {
1424 y = CG_DrawSpeedMeter( y );
1425 }
1426
1427 }
1428
1429 /*
1430 ===========================================================================================
1431
1432 LOWER RIGHT CORNER
1433
1434 ===========================================================================================
1435 */
1436
1437 /*
1438 =================
1439 CG_DrawScores
1440
1441 Draw the small two score display
1442 =================
1443 */
1444 #ifndef MISSIONPACK
1445 static float CG_DrawScores( float y ) {
1446 const char *s;
1447 int s1, s2, score;
1448 int x, w;
1449 int v;
1450 vec4_t color;
1451 float y1;
1452 gitem_t *item;
1453 int statusA,statusB;
1454
1455 statusA = cgs.redflag;
1456 statusB = cgs.blueflag;
1457
1458 s1 = cgs.scores1;
1459 s2 = cgs.scores2;
1460
1461 y -= BIGCHAR_HEIGHT + 8;
1462
1463 y1 = y;
1464
1465 // draw from the right side to left
1466 if ( cgs.gametype >= GT_TEAM && cgs.ffa_gt!=1) {
1467 x = 640;
1468 color[0] = 0.0f;
1469 color[1] = 0.0f;
1470 color[2] = 1.0f;
1471 color[3] = 0.33f;
1472 s = va( "%2i", s2 );
1473 w = CG_DrawStrlen( s ) * BIGCHAR_WIDTH + 8;
1474 x -= w;
1475 CG_FillRect( x, y-4, w, BIGCHAR_HEIGHT+8, color );
1476 if ( cg.snap->ps.persistant[PERS_TEAM] == TEAM_BLUE ) {
1477 CG_DrawPic( x, y-4, w, BIGCHAR_HEIGHT+8, cgs.media.selectShader );
1478 }
1479 CG_DrawBigString( x + 4, y, s, 1.0F);
1480
1481 if ( cgs.gametype == GT_CTF || cgs.gametype == GT_CTF_ELIMINATION) {
1482 // Display flag status
1483 item = BG_FindItemForPowerup( PW_BLUEFLAG );
1484
1485 if (item) {
1486 y1 = y - BIGCHAR_HEIGHT - 8;
1487 if( cgs.blueflag >= 0 && cgs.blueflag <= 2 ) {
1488 CG_DrawPic( x, y1-4, w, BIGCHAR_HEIGHT+8, cgs.media.blueFlagShader[cgs.blueflag] );
1489 }
1490 }
1491 }
1492
1493 if ( cgs.gametype == GT_DOUBLE_D ) {
1494 // Display Domination point status
1495
1496 y1 = y - 32;//BIGCHAR_HEIGHT - 8;
1497 if( cgs.redflag >= 0 && cgs.redflag <= 3 ) {
1498 CG_DrawPic( x, y1-4, w, 32, cgs.media.ddPointSkinB[cgs.blueflag] );
1499 }
1500 }
1501
1502 color[0] = 1.0f;
1503 color[1] = 0.0f;
1504 color[2] = 0.0f;
1505 color[3] = 0.33f;
1506 s = va( "%2i", s1 );
1507 w = CG_DrawStrlen( s ) * BIGCHAR_WIDTH + 8;
1508 x -= w;
1509 CG_FillRect( x, y-4, w, BIGCHAR_HEIGHT+8, color );
1510 if ( cg.snap->ps.persistant[PERS_TEAM] == TEAM_RED ) {
1511 CG_DrawPic( x, y-4, w, BIGCHAR_HEIGHT+8, cgs.media.selectShader );
1512 }
1513 CG_DrawBigString( x + 4, y, s, 1.0F);
1514
1515 if ( cgs.gametype == GT_CTF || cgs.gametype == GT_CTF_ELIMINATION ) {
1516 // Display flag status
1517 item = BG_FindItemForPowerup( PW_REDFLAG );
1518
1519 if (item) {
1520 y1 = y - BIGCHAR_HEIGHT - 8;
1521 if( cgs.redflag >= 0 && cgs.redflag <= 2 ) {
1522 CG_DrawPic( x, y1-4, w, BIGCHAR_HEIGHT+8, cgs.media.redFlagShader[cgs.redflag] );
1523 }
1524 }
1525 }
1526
1527 if ( cgs.gametype == GT_DOUBLE_D ) {
1528 // Display Domination point status
1529
1530 y1 = y - 32;//BIGCHAR_HEIGHT - 8;
1531 if( cgs.redflag >= 0 && cgs.redflag <= 3 ) {
1532 CG_DrawPic( x, y1-4, w, 32, cgs.media.ddPointSkinA[cgs.redflag] );
1533 }
1534
1535
1536
1537 //Time till capture:
1538 if( ( ( statusB == statusA ) && ( statusA == TEAM_RED ) ) ||
1539 ( ( statusB == statusA ) && ( statusA == TEAM_BLUE ) ) ) {
1540 s = va("%i",(cgs.timetaken+10*1000-cg.time)/1000+1);
1541 w = CG_DrawStrlen( s ) * BIGCHAR_WIDTH;
1542 CG_DrawBigString( x + 32+8-w/2, y-28, s, 1.0F);
1543 }
1544 }
1545
1546 if ( cgs.gametype == GT_OBELISK ) {
1547 s = va("^1%3i%% ^4%3i%%",cg.redObeliskHealth,cg.blueObeliskHealth);
1548 CG_DrawSmallString( x, y-28, s, 1.0F);
1549 }
1550
1551
1552
1553 if ( cgs.gametype >= GT_CTF && cgs.ffa_gt==0) {
1554 v = cgs.capturelimit;
1555 } else {
1556 v = cgs.fraglimit;
1557 }
1558 if ( v ) {
1559 s = va( "%2i", v );
1560 w = CG_DrawStrlen( s ) * BIGCHAR_WIDTH + 8;
1561 x -= w;
1562 CG_DrawBigString( x + 4, y, s, 1.0F);
1563 }
1564
1565 } else {
1566 qboolean spectator;
1567
1568 x = 640;
1569 score = cg.snap->ps.persistant[PERS_SCORE];
1570 spectator = ( cg.snap->ps.persistant[PERS_TEAM] == TEAM_SPECTATOR );
1571
1572 // always show your score in the second box if not in first place
1573 if ( s1 != score ) {
1574 s2 = score;
1575 }
1576 if ( s2 != SCORE_NOT_PRESENT ) {
1577 s = va( "%2i", s2 );
1578 w = CG_DrawStrlen( s ) * BIGCHAR_WIDTH + 8;
1579 x -= w;
1580 if ( !spectator && score == s2 && score != s1 ) {
1581 color[0] = 1.0f;
1582 color[1] = 0.0f;
1583 color[2] = 0.0f;
1584 color[3] = 0.33f;
1585 CG_FillRect( x, y-4, w, BIGCHAR_HEIGHT+8, color );
1586 CG_DrawPic( x, y-4, w, BIGCHAR_HEIGHT+8, cgs.media.selectShader );
1587 } else {
1588 color[0] = 0.5f;
1589 color[1] = 0.5f;
1590 color[2] = 0.5f;
1591 color[3] = 0.33f;
1592 CG_FillRect( x, y-4, w, BIGCHAR_HEIGHT+8, color );
1593 }
1594 CG_DrawBigString( x + 4, y, s, 1.0F);
1595 }
1596
1597 // first place
1598 if ( s1 != SCORE_NOT_PRESENT ) {
1599 s = va( "%2i", s1 );
1600 w = CG_DrawStrlen( s ) * BIGCHAR_WIDTH + 8;
1601 x -= w;
1602 if ( !spectator && score == s1 ) {
1603 color[0] = 0.0f;
1604 color[1] = 0.0f;
1605 color[2] = 1.0f;
1606 color[3] = 0.33f;
1607 CG_FillRect( x, y-4, w, BIGCHAR_HEIGHT+8, color );
1608 CG_DrawPic( x, y-4, w, BIGCHAR_HEIGHT+8, cgs.media.selectShader );
1609 } else {
1610 color[0] = 0.5f;
1611 color[1] = 0.5f;
1612 color[2] = 0.5f;
1613 color[3] = 0.33f;
1614 CG_FillRect( x, y-4, w, BIGCHAR_HEIGHT+8, color );
1615 }
1616 CG_DrawBigString( x + 4, y, s, 1.0F);
1617 }
1618
1619 if ( cgs.fraglimit ) {
1620 s = va( "%2i", cgs.fraglimit );
1621 w = CG_DrawStrlen( s ) * BIGCHAR_WIDTH + 8;
1622 x -= w;
1623 CG_DrawBigString( x + 4, y, s, 1.0F);
1624 }
1625
1626 }
1627
1628 return y1 - 8;
1629 }
1630 #endif // MISSIONPACK
1631
1632 /*
1633 ================
1634 CG_DrawPowerups
1635 ================
1636 */
1637 #ifndef MISSIONPACK
1638 static float CG_DrawPowerups( float y ) {
1639 int sorted[MAX_POWERUPS];
1640 int sortedTime[MAX_POWERUPS];
1641 int i, j, k;
1642 int active;
1643 playerState_t *ps;
1644 int t;
1645 gitem_t *item;
1646 int x;
1647 int color;
1648 float size;
1649 float f;
1650 static float colors[2][4] = {
1651 { 0.2f, 1.0f, 0.2f, 1.0f } ,
1652 { 1.0f, 0.2f, 0.2f, 1.0f }
1653 };
1654
1655 ps = &cg.snap->ps;
1656
1657 if ( ps->stats[STAT_HEALTH] <= 0 ) {
1658 return y;
1659 }
1660
1661 // sort the list by time remaining
1662 active = 0;
1663 for ( i = 0 ; i < MAX_POWERUPS ; i++ ) {
1664 if ( !ps->powerups[ i ] ) {
1665 continue;
1666 }
1667 t = ps->powerups[ i ] - cg.time;
1668 // ZOID--don't draw if the power up has unlimited time (999 seconds)
1669 // This is true of the CTF flags
1670 if ( t < 0 || t > 999000) {
1671 continue;
1672 }
1673
1674 item = BG_FindItemForPowerup( i );
1675 if ( item && item->giType == IT_PERSISTANT_POWERUP)
1676 continue; //Don't draw persistant powerups here!
1677
1678 // insert into the list
1679 for ( j = 0 ; j < active ; j++ ) {
1680 if ( sortedTime[j] >= t ) {
1681 for ( k = active - 1 ; k >= j ; k-- ) {
1682 sorted[k+1] = sorted[k];
1683 sortedTime[k+1] = sortedTime[k];
1684 }
1685 break;
1686 }
1687 }
1688 sorted[j] = i;
1689 sortedTime[j] = t;
1690 active++;
1691 }
1692
1693 // draw the icons and timers
1694 x = 640 - ICON_SIZE - CHAR_WIDTH * 2;
1695 for ( i = 0 ; i < active ; i++ ) {
1696 item = BG_FindItemForPowerup( sorted[i] );
1697
1698 if (item) {
1699
1700 color = 1;
1701
1702 y -= ICON_SIZE;
1703
1704 trap_R_SetColor( colors[color] );
1705 CG_DrawField( x, y, 2, sortedTime[ i ] / 1000 );
1706
1707 t = ps->powerups[ sorted[i] ];
1708 if ( t - cg.time >= POWERUP_BLINKS * POWERUP_BLINK_TIME ) {
1709 trap_R_SetColor( NULL );
1710 } else {
1711 vec4_t modulate;
1712
1713 f = (float)( t - cg.time ) / POWERUP_BLINK_TIME;
1714 f -= (int)f;
1715 modulate[0] = modulate[1] = modulate[2] = modulate[3] = f;
1716 trap_R_SetColor( modulate );
1717 }
1718
1719 if ( cg.powerupActive == sorted[i] &&
1720 cg.time - cg.powerupTime < PULSE_TIME ) {
1721 f = 1.0 - ( ( (float)cg.time - cg.powerupTime ) / PULSE_TIME );
1722 size = ICON_SIZE * ( 1.0 + ( PULSE_SCALE - 1.0 ) * f );
1723 } else {
1724 size = ICON_SIZE;
1725 }
1726
1727 CG_DrawPic( 640 - size, y + ICON_SIZE / 2 - size / 2,
1728 size, size, trap_R_RegisterShader( item->icon ) );
1729 }
1730 }
1731 trap_R_SetColor( NULL );
1732
1733 return y;
1734 }
1735 #endif // MISSIONPACK
1736
1737 /*
1738 =====================
1739 CG_DrawLowerRight
1740
1741 =====================
1742 */
1743 #ifndef MISSIONPACK
1744 static void CG_DrawLowerRight( void ) {
1745 float y;
1746
1747 y = 480 - ICON_SIZE;
1748
1749 if ( cgs.gametype >= GT_TEAM && cgs.ffa_gt!=1 && cg_drawTeamOverlay.integer == 2 ) {
1750 y = CG_DrawTeamOverlay( y, qtrue, qfalse );
1751 }
1752
1753 y = CG_DrawScores( y );
1754 y = CG_DrawPowerups( y );
1755 }
1756 #endif // MISSIONPACK
1757
1758 /*
1759 ===================
1760 CG_DrawPickupItem
1761 ===================
1762 */
1763 #ifndef MISSIONPACK
1764 static int CG_DrawPickupItem( int y ) {
1765 int value;
1766 float *fadeColor;
1767
1768 if ( cg.snap->ps.stats[STAT_HEALTH] <= 0 ) {
1769 return y;
1770 }
1771
1772 y -= ICON_SIZE;
1773
1774 value = cg.itemPickup;
1775 if ( value ) {
1776 fadeColor = CG_FadeColor( cg.itemPickupTime, 3000 );
1777 if ( fadeColor ) {
1778 CG_RegisterItemVisuals( value );
1779 trap_R_SetColor( fadeColor );
1780 CG_DrawPic( 8, y, ICON_SIZE, ICON_SIZE, cg_items[ value ].icon );
1781 CG_DrawBigString( ICON_SIZE + 16, y + (ICON_SIZE/2 - BIGCHAR_HEIGHT/2), bg_itemlist[ value ].pickup_name, fadeColor[0] );
1782 trap_R_SetColor( NULL );
1783 }
1784 }
1785
1786 return y;
1787 }
1788 #endif // MISSIONPACK
1789
1790 /*
1791 =====================
1792 CG_DrawLowerLeft
1793
1794 =====================
1795 */
1796 #ifndef MISSIONPACK
1797 static void CG_DrawLowerLeft( void ) {
1798 float y;
1799
1800 y = 480 - ICON_SIZE;
1801
1802 if ( cgs.gametype >= GT_TEAM && cgs.ffa_gt!=1 && cg_drawTeamOverlay.integer == 3 ) {
1803 y = CG_DrawTeamOverlay( y, qfalse, qfalse );
1804 }
1805
1806
1807 y = CG_DrawPickupItem( y );
1808 }
1809 #endif // MISSIONPACK
1810
1811
1812 //===========================================================================================
1813
1814 /*
1815 =================
1816 CG_DrawTeamInfo
1817 =================
1818 */
1819 #ifndef MISSIONPACK
1820 static void CG_DrawTeamInfo( void ) {
1821 int w, h;
1822 int i, len;
1823 vec4_t hcolor;
1824 int chatHeight;
1825
1826 #define CHATLOC_Y 420 // bottom end
1827 #define CHATLOC_X 0
1828
1829 if (cg_teamChatHeight.integer < TEAMCHAT_HEIGHT)
1830 chatHeight = cg_teamChatHeight.integer;
1831 else
1832 chatHeight = TEAMCHAT_HEIGHT;
1833 if (chatHeight <= 0)
1834 return; // disabled
1835
1836 if (cgs.teamLastChatPos != cgs.teamChatPos) {
1837 if (cg.time - cgs.teamChatMsgTimes[cgs.teamLastChatPos % chatHeight] > cg_teamChatTime.integer) {
1838 cgs.teamLastChatPos++;
1839 }
1840
1841 h = (cgs.teamChatPos - cgs.teamLastChatPos) * TINYCHAR_HEIGHT;
1842
1843 w = 0;
1844
1845 for (i = cgs.teamLastChatPos; i < cgs.teamChatPos; i++) {
1846 len = CG_DrawStrlen(cgs.teamChatMsgs[i % chatHeight]);
1847 if (len > w)
1848 w = len;
1849 }
1850 w *= TINYCHAR_WIDTH;
1851 w += TINYCHAR_WIDTH * 2;
1852
1853 if ( cg.snap->ps.persistant[PERS_TEAM] == TEAM_RED ) {
1854 hcolor[0] = 1.0f;
1855 hcolor[1] = 0.0f;
1856 hcolor[2] = 0.0f;
1857 hcolor[3] = 0.33f;
1858 } else if ( cg.snap->ps.persistant[PERS_TEAM] == TEAM_BLUE ) {
1859 hcolor[0] = 0.0f;
1860 hcolor[1] = 0.0f;
1861 hcolor[2] = 1.0f;
1862 hcolor[3] = 0.33f;
1863 } else {
1864 hcolor[0] = 0.0f;
1865 hcolor[1] = 1.0f;
1866 hcolor[2] = 0.0f;
1867 hcolor[3] = 0.33f;
1868 }
1869
1870 trap_R_SetColor( hcolor );
1871 CG_DrawPic( CHATLOC_X, CHATLOC_Y - h, 640, h, cgs.media.teamStatusBar );
1872 trap_R_SetColor( NULL );
1873
1874 hcolor[0] = hcolor[1] = hcolor[2] = 1.0f;
1875 hcolor[3] = 1.0f;
1876
1877 for (i = cgs.teamChatPos - 1; i >= cgs.teamLastChatPos; i--) {
1878 CG_DrawStringExt( CHATLOC_X + TINYCHAR_WIDTH,
1879 CHATLOC_Y - (cgs.teamChatPos - i)*TINYCHAR_HEIGHT,
1880 cgs.teamChatMsgs[i % chatHeight], hcolor, qfalse, qfalse,
1881 TINYCHAR_WIDTH, TINYCHAR_HEIGHT, 0 );
1882 }
1883 }
1884 }
1885 #endif // MISSIONPACK
1886
1887 /*
1888 ===================
1889 CG_DrawHoldableItem
1890 ===================
1891 */
1892 #ifndef MISSIONPACK
1893 static void CG_DrawHoldableItem( void ) {
1894 int value;
1895
1896 value = cg.snap->ps.stats[STAT_HOLDABLE_ITEM];
1897 if ( value ) {
1898 CG_RegisterItemVisuals( value );
1899 CG_DrawPic( 640-ICON_SIZE, (SCREEN_HEIGHT-ICON_SIZE)/2, ICON_SIZE, ICON_SIZE, cg_items[ value ].icon );
1900 }
1901
1902 }
1903 #endif // MISSIONPACK
1904
1905 /*
1906 ===================
1907 CG_DrawPersistantPowerup
1908 ===================
1909 */
1910 #if 1 // sos001208 - DEAD // sago - ALIVE
1911 static void CG_DrawPersistantPowerup( void ) {
•1912 #ifdef HAVE_STAT_PERSISTANT_POWERUP
1913 int value;
1914
1915 value = cg.snap->ps.stats[STAT_PERSISTANT_POWERUP];
1916 if ( value ) {
1917 CG_RegisterItemVisuals( value );
1918 CG_DrawPic( 640-ICON_SIZE, (SCREEN_HEIGHT-ICON_SIZE)/2 - ICON_SIZE, ICON_SIZE, ICON_SIZE, cg_items[ value ].icon );
1919 }
•1920 #endif
1921 }
1922 #endif
1923
1924
1925 /*
1926 ===================
1927 CG_DrawReward
1928 ===================
1929 */
1930 static void CG_DrawReward( void ) {
1931 float *color;
1932 int i, count;
1933 float x, y;
1934 char buf[32];
1935
1936 if ( !cg_drawRewards.integer ) {
1937 return;
1938 }
1939
1940 color = CG_FadeColor( cg.rewardTime, REWARD_TIME );
1941 if ( !color ) {
1942 if (cg.rewardStack > 0) {
1943 for(i = 0; i < cg.rewardStack; i++) {
1944 cg.rewardSound[i] = cg.rewardSound[i+1];
1945
1946 cg.rewardShader[i] = cg.rewardShader[i+1];
1947 cg.rewardCount[i] = cg.rewardCount[i+1];
1948 }
1949 cg.rewardTime = cg.time;
1950 cg.rewardStack--;
1951 color = CG_FadeColor( cg.rewardTime, REWARD_TIME );
1952
1953 trap_S_StartLocalSound(cg.rewardSound[0], CHAN_ANNOUNCER);
1954
1955 } else {
1956 return;
1957 }
1958 }
1959
1960 trap_R_SetColor( color );
1961
1962 /*
1963 count = cg.rewardCount[0]/10; // number of big rewards to draw
1964
1965 if (count) {
1966 y = 4;
1967 x = 320 - count * ICON_SIZE;
1968 for ( i = 0 ; i < count ; i++ ) {
1969 CG_DrawPic( x, y, (ICON_SIZE*2)-4, (ICON_SIZE*2)-4, cg.rewardShader[0] );
1970 x += (ICON_SIZE*2);
1971 }
1972 }
1973
1974 count = cg.rewardCount[0] - count*10; // number of small rewards to draw
1975 */
1976
1977 if ( cg.rewardCount[0] >= 10 ) {
1978 y = 56;
1979 x = 320 - ICON_SIZE/2;
1980 CG_DrawPic( x, y, ICON_SIZE-4, ICON_SIZE-4, cg.rewardShader[0] );
1981 Com_sprintf(buf, sizeof(buf), "%d", cg.rewardCount[0]);
1982 x = ( SCREEN_WIDTH - SMALLCHAR_WIDTH * CG_DrawStrlen( buf ) ) / 2;
1983 CG_DrawStringExt( x, y+ICON_SIZE, buf, color, qfalse, qtrue,
1984 SMALLCHAR_WIDTH, SMALLCHAR_HEIGHT, 0 );
1985 }
1986 else {
1987
1988 count = cg.rewardCount[0];
1989
1990 y = 56;
1991 x = 320 - count * ICON_SIZE/2;
1992 for ( i = 0 ; i < count ; i++ ) {
1993 CG_DrawPic( x, y, ICON_SIZE-4, ICON_SIZE-4, cg.rewardShader[0] );
1994 x += ICON_SIZE;
1995 }
1996 }
1997 trap_R_SetColor( NULL );
1998 }
1999
2000
2001 /*
2002 ===============================================================================
2003
2004 LAGOMETER
2005
2006 ===============================================================================
2007 */
2008
2009 #define LAG_SAMPLES 128
2010
2011
2012 typedef struct {
2013 int frameSamples[LAG_SAMPLES];
2014 int frameCount;
2015 int snapshotFlags[LAG_SAMPLES];
2016 int snapshotSamples[LAG_SAMPLES];
2017 int snapshotCount;
2018 } lagometer_t;
2019
2020 lagometer_t lagometer;
2021
2022 /*
2023 ==============
2024 CG_AddLagometerFrameInfo
2025
2026 Adds the current interpolate / extrapolate bar for this frame
2027 ==============
2028 */
2029 void CG_AddLagometerFrameInfo( void ) {
2030 int offset;
2031
2032 offset = cg.time - cg.latestSnapshotTime;
2033 lagometer.frameSamples[ lagometer.frameCount & ( LAG_SAMPLES - 1) ] = offset;
2034 lagometer.frameCount++;
2035 }
2036
2037 /*
2038 ==============
2039 CG_AddLagometerSnapshotInfo
2040
2041 Each time a snapshot is received, log its ping time and
2042 the number of snapshots that were dropped before it.
2043
2044 Pass NULL for a dropped packet.
2045 ==============
2046 */
2047 void CG_AddLagometerSnapshotInfo( snapshot_t *snap ) {
2048 // dropped packet
2049 if ( !snap ) {
2050 lagometer.snapshotSamples[ lagometer.snapshotCount & ( LAG_SAMPLES - 1) ] = -1;
2051 lagometer.snapshotCount++;
2052 return;
2053 }
2054
2055 // add this snapshot's info
2056 lagometer.snapshotSamples[ lagometer.snapshotCount & ( LAG_SAMPLES - 1) ] = snap->ping;
2057 lagometer.snapshotFlags[ lagometer.snapshotCount & ( LAG_SAMPLES - 1) ] = snap->snapFlags;
2058 lagometer.snapshotCount++;
2059 }
2060
2061 /*
2062 ==============
2063 CG_DrawDisconnect
2064
2065 Should we draw something differnet for long lag vs no packets?
2066 ==============
2067 */
2068 static void CG_DrawDisconnect( void ) {
2069 float x, y;
2070 int cmdNum;
2071 usercmd_t cmd;
2072 const char *s;
2073 int w; // bk010215 - FIXME char message[1024];
2074
2075 // draw the phone jack if we are completely past our buffers
2076 cmdNum = trap_GetCurrentCmdNumber() - CMD_BACKUP + 1;
2077 trap_GetUserCmd( cmdNum, &cmd );
2078 if ( cmd.serverTime <= cg.snap->ps.commandTime
2079 || cmd.serverTime > cg.time ) { // special check for map_restart // bk 0102165 - FIXME
2080 return;
2081 }
2082
2083 // also add text in center of screen
2084 s = "Connection Interrupted"; // bk 010215 - FIXME
2085 w = CG_DrawStrlen( s ) * BIGCHAR_WIDTH;
2086 CG_DrawBigString( 320 - w/2, 100, s, 1.0F);
2087
2088 // blink the icon
2089 if ( ( cg.time >> 9 ) & 1 ) {
2090 return;
2091 }
2092
2093 x = 640 - 48;
2094 y = 480 - 48;
2095
2096 CG_DrawPic( x, y, 48, 48, trap_R_RegisterShader("gfx/2d/net.tga" ) );
2097 }
2098
2099
2100 #define MAX_LAGOMETER_PING 900
2101 #define MAX_LAGOMETER_RANGE 300
2102
2103 /*
2104 ==============
2105 CG_DrawLagometer
2106 ==============
2107 */
2108 static void CG_DrawLagometer( void ) {
2109 int a, x, y, i;
2110 float v;
2111 float ax, ay, aw, ah, mid, range;
2112 int color;
2113 float vscale;
2114
2115 if ( !cg_lagometer.integer || cgs.localServer ) {
2116 CG_DrawDisconnect();
2117 return;
2118 }
2119
2120 //
2121 // draw the graph
2122 //
2123 #ifdef MISSIONPACK
2124 x = 640 - 48;
2125 y = 480 - 144;
2126 #else
2127 x = 640 - 48;
2128 y = 480 - 48;
2129 #endif
2130
2131 trap_R_SetColor( NULL );
2132 CG_DrawPic( x, y, 48, 48, cgs.media.lagometerShader );
2133
2134 ax = x;
2135 ay = y;
2136 aw = 48;
2137 ah = 48;
2138 CG_AdjustFrom640( &ax, &ay, &aw, &ah );
2139
2140 color = -1;
2141 range = ah / 3;
2142 mid = ay + range;
2143
2144 vscale = range / MAX_LAGOMETER_RANGE;
2145
2146 // draw the frame interpoalte / extrapolate graph
2147 for ( a = 0 ; a < aw ; a++ ) {
2148 i = ( lagometer.frameCount - 1 - a ) & (LAG_SAMPLES - 1);
2149 v = lagometer.frameSamples[i];
2150 v *= vscale;
2151 if ( v > 0 ) {
2152 if ( color != 1 ) {
2153 color = 1;
2154 trap_R_SetColor( g_color_table[ColorIndex(COLOR_YELLOW)] );
2155 }
2156 if ( v > range ) {
2157 v = range;
2158 }
2159 trap_R_DrawStretchPic ( ax + aw - a, mid - v, 1, v, 0, 0, 0, 0, cgs.media.whiteShader );
2160 } else if ( v < 0 ) {
2161 if ( color != 2 ) {
2162 color = 2;
2163 trap_R_SetColor( g_color_table[ColorIndex(COLOR_BLUE)] );
2164 }
2165 v = -v;
2166 if ( v > range ) {
2167 v = range;
2168 }
2169 trap_R_DrawStretchPic( ax + aw - a, mid, 1, v, 0, 0, 0, 0, cgs.media.whiteShader );
2170 }
2171 }
2172
2173 // draw the snapshot latency / drop graph
2174 range = ah / 2;
2175 vscale = range / MAX_LAGOMETER_PING;
2176
2177 for ( a = 0 ; a < aw ; a++ ) {
2178 i = ( lagometer.snapshotCount - 1 - a ) & (LAG_SAMPLES - 1);
2179 v = lagometer.snapshotSamples[i];
2180 if ( v > 0 ) {
2181 if ( lagometer.snapshotFlags[i] & SNAPFLAG_RATE_DELAYED ) {
2182 if ( color != 5 ) {
2183 color = 5; // YELLOW for rate delay
2184 trap_R_SetColor( g_color_table[ColorIndex(COLOR_YELLOW)] );
2185 }
2186 } else {
2187 if ( color != 3 ) {
2188 color = 3;
2189 trap_R_SetColor( g_color_table[ColorIndex(COLOR_GREEN)] );
2190 }
2191 }
2192 v = v * vscale;
2193 if ( v > range ) {
2194 v = range;
2195 }
2196 trap_R_DrawStretchPic( ax + aw - a, ay + ah - v, 1, v, 0, 0, 0, 0, cgs.media.whiteShader );
2197 } else if ( v < 0 ) {
2198 if ( color != 4 ) {
2199 color = 4; // RED for dropped snapshots
2200 trap_R_SetColor( g_color_table[ColorIndex(COLOR_RED)] );
2201 }
2202 trap_R_DrawStretchPic( ax + aw - a, ay + ah - range, 1, range, 0, 0, 0, 0, cgs.media.whiteShader );
2203 }
2204 }
2205
2206 trap_R_SetColor( NULL );
2207
2208 if ( cg_nopredict.integer || cg_synchronousClients.integer ) {
2209 CG_DrawBigString( ax, ay, "snc", 1.0 );
2210 }
2211
2212 CG_DrawDisconnect();
2213 }
2214
2215
2216
2217 /*
2218 ===============================================================================
2219
2220 CENTER PRINTING
2221
2222 ===============================================================================
2223 */
2224
2225
2226 /*
2227 ==============
2228 CG_CenterPrint
2229
2230 Called for important messages that should stay in the center of the screen
2231 for a few moments
2232 ==============
2233 */
2234 void CG_CenterPrint( const char *str, int y, int charWidth ) {
2235 char *s;
2236
2237 Q_strncpyz( cg.centerPrint, str, sizeof(cg.centerPrint) );
2238
2239 cg.centerPrintTime = cg.time;
2240 cg.centerPrintY = y;
2241 cg.centerPrintCharWidth = charWidth;
2242
2243 // count the number of lines for centering
2244 cg.centerPrintLines = 1;
2245 s = cg.centerPrint;
2246 while( *s ) {
2247 if (*s == '\n')
2248 cg.centerPrintLines++;
2249 s++;
2250 }
2251 }
2252
2253
2254 /*
2255 ===================
2256 CG_DrawCenterString
2257 ===================
2258 */
2259 static void CG_DrawCenterString( void ) {
2260 char *start;
2261 int l;
2262 int x, y, w;
2263 #ifdef MISSIONPACK // bk010221 - unused else
2264 int h;
2265 #endif
2266 float *color;
2267
2268 if ( !cg.centerPrintTime ) {
2269 return;
2270 }
2271
2272 color = CG_FadeColor( cg.centerPrintTime, 1000 * cg_centertime.value );
2273 if ( !color ) {
2274 return;
2275 }
2276
2277 trap_R_SetColor( color );
2278
2279 start = cg.centerPrint;
2280
2281 y = cg.centerPrintY - cg.centerPrintLines * BIGCHAR_HEIGHT / 2;
2282
2283 while ( 1 ) {
2284 char linebuffer[1024];
2285
2286 for ( l = 0; l < 50; l++ ) {
2287 if ( !start[l] || start[l] == '\n' ) {
2288 break;
2289 }
2290 linebuffer[l] = start[l];
2291 }
2292 linebuffer[l] = 0;
2293
2294 #ifdef MISSIONPACK
2295 w = CG_Text_Width(linebuffer, 0.5, 0);
2296 h = CG_Text_Height(linebuffer, 0.5, 0);
2297 x = (SCREEN_WIDTH - w) / 2;
2298 CG_Text_Paint(x, y + h, 0.5, color, linebuffer, 0, 0, ITEM_TEXTSTYLE_SHADOWEDMORE);
2299 y += h + 6;
2300 #else
2301 w = cg.centerPrintCharWidth * CG_DrawStrlen( linebuffer );
2302
2303 x = ( SCREEN_WIDTH - w ) / 2;
2304
2305 CG_DrawStringExt( x, y, linebuffer, color, qfalse, qtrue,
2306 cg.centerPrintCharWidth, (int)(cg.centerPrintCharWidth * 1.5), 0 );
2307
2308 y += cg.centerPrintCharWidth * 1.5;
2309 #endif
2310 while ( *start && ( *start != '\n' ) ) {
2311 start++;
2312 }
2313 if ( !*start ) {
2314 break;
2315 }
2316 start++;
2317 }
2318
2319 trap_R_SetColor( NULL );
2320 }
2321
2322 /*
2323 =====================
2324 CG_DrawCenter1FctfString
2325 =====================
2326 */
2327 static void CG_DrawCenter1FctfString( void ) {
2328 #ifndef MISSIONPACK
2329 int x, y, w;
2330 float *color;
2331 char *line;
2332 int status;
2333
2334 if(cgs.gametype != GT_1FCTF)
2335 return;
2336
2337 status = cgs.flagStatus;
2338
2339 //Sago: TODO: Find the proper defines instead of hardcoded values.
2340 switch(status)
2341 {
2342 case 2:
2343 line = va("Red has the flag!");
2344 color = colorRed;
2345 break;
2346 case 3:
2347 line = va("Blue has the flag!");
2348 color = colorBlue;
2349 break;
2350 case 4:
2351 line = va("Flag dropped!");
2352 color = colorWhite;
2353 break;
2354 default:
2355 return;
2356
2357 };
2358 y = 100;
2359
2360
2361 w = cg.centerPrintCharWidth * CG_DrawStrlen( line );
2362
2363 x = ( SCREEN_WIDTH - w ) / 2;
2364
2365 CG_DrawStringExt( x, y, line, color, qfalse, qtrue,
2366 cg.centerPrintCharWidth, (int)(cg.centerPrintCharWidth * 1.5), 0 );
2367
2368
2369 #endif
2370 }
2371
2372
2373
2374 /*
2375 =====================
2376 CG_DrawCenterDDString
2377 =====================
2378 */
2379 static void CG_DrawCenterDDString( void ) {
2380 #ifndef MISSIONPACK
2381 int x, y, w;
2382 float *color;
2383 char *line;
2384 int statusA, statusB;
2385 int sec;
2386 static int lastDDSec = -100;
2387
2388
2389 if(cgs.gametype != GT_DOUBLE_D)
2390 return;
2391
2392 statusA = cgs.redflag;
2393 statusB = cgs.blueflag;
2394
2395 if( ( ( statusB == statusA ) && ( statusA == TEAM_RED ) ) ||
2396 ( ( statusB == statusA ) && ( statusA == TEAM_BLUE ) ) ) {
2397 }
2398 else
2399 return; //No team is dominating
2400
2401 if(statusA == TEAM_BLUE) {
2402 line = va("Blue scores in %i",(cgs.timetaken+10*1000-cg.time)/1000+1);
2403 color = colorBlue;
2404 } else if(statusA == TEAM_RED) {
2405 line = va("Red scores in %i",(cgs.timetaken+10*1000-cg.time)/1000+1);
2406 color = colorRed;
2407 } else {
2408 lastDDSec = -100;
2409 return;
2410 }
2411
2412 sec = (cgs.timetaken+10*1000-cg.time)/1000+1;
2413 if(sec!=lastDDSec) {
2414 //A new number is being displayed... play the sound!
2415 switch ( sec ) {
2416 case 1:
2417 trap_S_StartLocalSound( cgs.media.count1Sound, CHAN_ANNOUNCER );
2418 break;
2419 case 2:
2420 trap_S_StartLocalSound( cgs.media.count2Sound, CHAN_ANNOUNCER );
2421 break;
2422 case 3:
2423 trap_S_StartLocalSound( cgs.media.count3Sound, CHAN_ANNOUNCER );
2424 break;
2425 case 10:
2426 trap_S_StartLocalSound( cgs.media.doublerSound , CHAN_ANNOUNCER );
2427 break;
2428 default:
2429 break;
2430 }
2431 }
2432 lastDDSec = sec;
2433
2434 y = 100;
2435
2436
2437 w = cg.centerPrintCharWidth * CG_DrawStrlen( line );
2438
2439 x = ( SCREEN_WIDTH - w ) / 2;
2440
2441 CG_DrawStringExt( x, y, line, color, qfalse, qtrue,
2442 cg.centerPrintCharWidth, (int)(cg.centerPrintCharWidth * 1.5), 0 );
2443
2444 #endif
2445 }
2446
2447
2448 /*
2449 ================================================================================
2450
2451 CROSSHAIR
2452
2453 ================================================================================
2454 */
2455
2456
2457 /*
2458 =================
2459 CG_DrawCrosshair
2460 =================
2461 */
2462 static void CG_DrawCrosshair(void)
2463 {
2464 float w, h;
2465 qhandle_t hShader;
2466 float f;
2467 float x, y;
2468 int ca = 0; //only to get rid of the warning(not useful)
2469 int currentWeapon;
2470
2471 currentWeapon = cg.predictedPlayerState.weapon;
2472
2473 if ( !cg_drawCrosshair.integer ) {
2474 return;
2475 }
2476
2477 if ( cg.snap->ps.persistant[PERS_TEAM] == TEAM_SPECTATOR) {
2478 return;
2479 }
2480
2481 if ( cg.renderingThirdPerson ) {
2482 return;
2483 }
2484
2485 // set color based on health
2486 if ( cg_crosshairHealth.integer ) {
2487 vec4_t hcolor;
2488
2489 CG_ColorForHealth( hcolor );
2490 trap_R_SetColor( hcolor );
2491 } else {
2492 vec4_t color;
2493 color[0]=cg_crosshairColorRed.value;
2494 color[1]=cg_crosshairColorGreen.value;
2495 color[2]=cg_crosshairColorBlue.value;
2496 color[3]=1.0f;
2497 trap_R_SetColor( color );
2498 }
2499
2500 if( cg_differentCrosshairs.integer == 1 ){
2501 switch( currentWeapon ){
2502 case 1:
2503 w = h = cg_ch1size.value;
2504 ca = cg_ch1.integer;
2505 break;
2506 case 2:
2507 w = h = cg_ch2size.value;
2508 ca = cg_ch2.integer;
2509 break;
2510 case 3:
2511 w = h = cg_ch3size.value;
2512 ca = cg_ch3.integer;
2513 break;
2514 case 4:
2515 w = h = cg_ch4size.value;
2516 ca = cg_ch4.integer;
2517 break;
2518 case 5:
2519 w = h = cg_ch5size.value;
2520 ca = cg_ch5.integer;
2521 break;
2522 case 6:
2523 w = h = cg_ch6size.value;
2524 ca = cg_ch6.integer;
2525 break;
2526 case 7:
2527 w = h = cg_ch7size.value;
2528 ca = cg_ch7.integer;
2529 break;
2530 case 8:
2531 w = h = cg_ch8size.value;
2532 ca = cg_ch8.integer;
2533 break;
2534 case 9:
2535 w = h = cg_ch9size.value;
2536 ca = cg_ch9.integer;
2537 break;
2538 case 10:
2539 w = h = cg_ch10size.value;
2540 ca = cg_ch10.integer;
2541 break;
2542 case 11:
2543 w = h = cg_ch11size.value;
2544 ca = cg_ch11.integer;
2545 break;
2546 case 12:
2547 w = h = cg_ch12size.value;
2548 ca = cg_ch12.integer;
2549 break;
2550 case 13:
2551 w = h = cg_ch13size.value;
2552 ca = cg_ch13.integer;
2553 break;
2554 default:
2555 w = h = cg_crosshairSize.value;
2556 ca = cg_drawCrosshair.integer;
2557 break;
2558 }
2559 }
2560 else{
2561 w = h = cg_crosshairSize.value;
2562 ca = cg_drawCrosshair.integer;
2563 }
2564
2565 if( cg_crosshairPulse.integer ){
2566 // pulse the size of the crosshair when picking up items
2567 f = cg.time - cg.itemPickupBlendTime;
2568 if ( f > 0 && f < ITEM_BLOB_TIME ) {
2569 f /= ITEM_BLOB_TIME;
2570 w *= ( 1 + f );
2571 h *= ( 1 + f );
2572 }
2573 }
2574
2575 x = cg_crosshairX.integer;
2576 y = cg_crosshairY.integer;
2577 CG_AdjustFrom640( &x, &y, &w, &h );
2578
2579 if (ca < 0) {
2580 ca = 0;
2581 }
2582 hShader = cgs.media.crosshairShader[ ca % NUM_CROSSHAIRS ];
2583
2584 if(!hShader)
2585 hShader = cgs.media.crosshairShader[ ca % 10 ];
2586
2587 trap_R_DrawStretchPic( x + cg.refdef.x + 0.5 * (cg.refdef.width - w),
2588 y + cg.refdef.y + 0.5 * (cg.refdef.height - h),
2589 w, h, 0, 0, 1, 1, hShader );
2590 }
2591
2592 /*
2593 =================
2594 CG_DrawCrosshair3D
2595 =================
2596 */
2597 static void CG_DrawCrosshair3D(void)
2598 {
2599 float w, h;
2600 qhandle_t hShader;
2601 float f;
2602 int ca;
2603
2604 trace_t trace;
2605 vec3_t endpos;
2606 float stereoSep, zProj, maxdist, xmax;
2607 char rendererinfos[128];
2608 refEntity_t ent;
2609
2610 if ( !cg_drawCrosshair.integer ) {
2611 return;
2612 }
2613
2614 if ( cg.snap->ps.persistant[PERS_TEAM] == TEAM_SPECTATOR) {
2615 return;
2616 }
2617
2618 if ( cg.renderingThirdPerson ) {
2619 return;
2620 }
2621
2622 w = h = cg_crosshairSize.value;
2623
2624 // pulse the size of the crosshair when picking up items
2625 f = cg.time - cg.itemPickupBlendTime;
2626 if ( f > 0 && f < ITEM_BLOB_TIME ) {
2627 f /= ITEM_BLOB_TIME;
2628 w *= ( 1 + f );
2629 h *= ( 1 + f );
2630 }
2631
2632 ca = cg_drawCrosshair.integer;
2633 if (ca < 0) {
2634 ca = 0;
2635 }
2636 hShader = cgs.media.crosshairShader[ ca % NUM_CROSSHAIRS ];
2637
2638 if(!hShader)
2639 hShader = cgs.media.crosshairShader[ ca % 10 ];
2640
2641 // Use a different method rendering the crosshair so players don't see two of them when
2642 // focusing their eyes at distant objects with high stereo separation
2643 // We are going to trace to the next shootable object and place the crosshair in front of it.
2644
2645 // first get all the important renderer information
2646 trap_Cvar_VariableStringBuffer("r_zProj", rendererinfos, sizeof(rendererinfos));
2647 zProj = atof(rendererinfos);
2648 trap_Cvar_VariableStringBuffer("r_stereoSeparation", rendererinfos, sizeof(rendererinfos));
2649 stereoSep = zProj / atof(rendererinfos);
2650
2651 xmax = zProj * tan(cg.refdef.fov_x * M_PI / 360.0f);
2652
2653 // let the trace run through until a change in stereo separation of the crosshair becomes less than one pixel.
2654 maxdist = cgs.glconfig.vidWidth * stereoSep * zProj / (2 * xmax);
2655 VectorMA(cg.refdef.vieworg, maxdist, cg.refdef.viewaxis[0], endpos);
2656 CG_Trace(&trace, cg.refdef.vieworg, NULL, NULL, endpos, 0, MASK_SHOT);
2657
2658 memset(&ent, 0, sizeof(ent));
2659 ent.reType = RT_SPRITE;
2660 ent.renderfx = RF_DEPTHHACK | RF_CROSSHAIR;
2661
2662 VectorCopy(trace.endpos, ent.origin);
2663
2664 // scale the crosshair so it appears the same size for all distances
2665 ent.radius = w / 640 * xmax * trace.fraction * maxdist / zProj;
2666 ent.customShader = hShader;
2667
2668 trap_R_AddRefEntityToScene(&ent);
2669 }
2670
2671
2672
2673 /*
2674 =================
2675 CG_ScanForCrosshairEntity
2676 =================
2677 */
2678 static void CG_ScanForCrosshairEntity( void ) {
2679 trace_t trace;
2680 vec3_t start, end;
2681 int content;
2682
2683 VectorCopy( cg.refdef.vieworg, start );
2684 VectorMA( start, 131072, cg.refdef.viewaxis[0], end );
2685
2686 CG_Trace( &trace, start, vec3_origin, vec3_origin, end,
2687 cg.snap->ps.clientNum, CONTENTS_SOLID|CONTENTS_BODY );
2688 if ( trace.entityNum >= MAX_CLIENTS ) {
2689 return;
2690 }
2691
2692 // if the player is in fog, don't show it
2693 content = CG_PointContents( trace.endpos, 0 );
2694 if ( content & CONTENTS_FOG ) {
2695 return;
2696 }
2697
2698 // if the player is invisible, don't show it
2699 if ( cg_entities[ trace.entityNum ].currentState.powerups & ( 1 << PW_INVIS ) ) {
2700 return;
2701 }
2702
2703 // update the fade timer
2704 cg.crosshairClientNum = trace.entityNum;
2705 cg.crosshairClientTime = cg.time;
2706 }
2707
2708
2709 /*
2710 =====================
2711 CG_DrawCrosshairNames
2712 =====================
2713 */
2714 static void CG_DrawCrosshairNames( void ) {
2715 float *color;
2716 char *name;
2717 float w;
2718
2719 if ( !cg_drawCrosshair.integer ) {
2720 return;
2721 }
2722 if ( !cg_drawCrosshairNames.integer ) {
2723 return;
2724 }
2725 if ( cg.renderingThirdPerson ) {
2726 return;
2727 }
2728
2729 // scan the known entities to see if the crosshair is sighted on one
2730 CG_ScanForCrosshairEntity();
2731
2732 // draw the name of the player being looked at
2733 color = CG_FadeColor( cg.crosshairClientTime, 1000 );
2734 if ( !color ) {
2735 trap_R_SetColor( NULL );
2736 return;
2737 }
2738
2739 name = cgs.clientinfo[ cg.crosshairClientNum ].name;
2740 #ifdef MISSIONPACK
2741 color[3] *= 0.5f;
2742 w = CG_Text_Width(name, 0.3f, 0);
2743 CG_Text_Paint( 320 - w / 2, 190, 0.3f, color, name, 0, 0, ITEM_TEXTSTYLE_SHADOWED);
2744 #else
2745 w = CG_DrawStrlen( name ) * BIGCHAR_WIDTH;
2746 CG_DrawBigString( 320 - w / 2, 170, name, color[3] * 0.5f );
2747 #endif
2748 trap_R_SetColor( NULL );
2749 }
2750
2751
2752 //==============================================================================
2753
2754 /*
2755 =================
2756 CG_DrawSpectator
2757 =================
2758 */
2759 static void CG_DrawSpectator(void) {
2760 CG_DrawBigString(320 - 9 * 8, 440, "SPECTATOR", 1.0F);
2761 if ( cgs.gametype == GT_TOURNAMENT ) {
2762 CG_DrawBigString(320 - 15 * 8, 460, "waiting to play", 1.0F);
2763 }
2764 else if ( cgs.gametype >= GT_TEAM && cgs.ffa_gt!=1) {
2765 CG_DrawBigString(320 - 39 * 8, 460, "press ESC and use the JOIN menu to play", 1.0F);
2766 }
2767 }
2768
2769 /*
2770 =================
2771 CG_DrawVote
2772 =================
2773 */
2774 static void CG_DrawVote(void) {
2775 char *s;
2776 int sec;
2777
2778 if ( !cgs.voteTime ) {
2779 return;
2780 }
2781
2782 // play a talk beep whenever it is modified
2783 if ( cgs.voteModified ) {
2784 cgs.voteModified = qfalse;
2785 trap_S_StartLocalSound( cgs.media.talkSound, CHAN_LOCAL_SOUND );
2786 }
2787
2788 sec = ( VOTE_TIME - ( cg.time - cgs.voteTime ) ) / 1000;
2789 if ( sec < 0 ) {
2790 sec = 0;
2791 }
2792 #ifdef MISSIONPACK
2793 s = va("VOTE(%i):%s yes:%i no:%i", sec, cgs.voteString, cgs.voteYes, cgs.voteNo);
2794 CG_DrawSmallString( 0, 58, s, 1.0F );
2795 s = "or press ESC then click Vote";
2796 CG_DrawSmallString( 0, 58 + SMALLCHAR_HEIGHT + 2, s, 1.0F );
2797 #else
2798 s = va("VOTE(%i):%s yes:%i no:%i", sec, cgs.voteString, cgs.voteYes, cgs.voteNo );
2799 CG_DrawSmallString( 0, 58, s, 1.0F );
2800 #endif
2801 }
2802
2803 /*
2804 =================
2805 CG_DrawTeamVote
2806 =================
2807 */
2808 static void CG_DrawTeamVote(void) {
2809 char *s;
2810 int sec, cs_offset;
2811
2812 if ( cgs.clientinfo[cg.clientNum].team == TEAM_RED )
2813 cs_offset = 0;
2814 else if ( cgs.clientinfo[cg.clientNum].team == TEAM_BLUE )
2815 cs_offset = 1;
2816 else
2817 return;
2818
2819 if ( !cgs.teamVoteTime[cs_offset] ) {
2820 return;
2821 }
2822
2823 // play a talk beep whenever it is modified
2824 if ( cgs.teamVoteModified[cs_offset] ) {
2825 cgs.teamVoteModified[cs_offset] = qfalse;
2826 trap_S_StartLocalSound( cgs.media.talkSound, CHAN_LOCAL_SOUND );
2827 }
2828
2829 sec = ( VOTE_TIME - ( cg.time - cgs.teamVoteTime[cs_offset] ) ) / 1000;
2830 if ( sec < 0 ) {
2831 sec = 0;
2832 }
2833 s = va("TEAMVOTE(%i):%s yes:%i no:%i", sec, cgs.teamVoteString[cs_offset],
2834 cgs.teamVoteYes[cs_offset], cgs.teamVoteNo[cs_offset] );
2835 CG_DrawSmallString( 0, 90, s, 1.0F );
2836 }
2837
2838
2839 static qboolean CG_DrawScoreboard( void ) {
2840 #ifdef MISSIONPACK
2841 static qboolean firstTime = qtrue;
2842 float fade, *fadeColor;
2843
2844 if (menuScoreboard) {
2845 menuScoreboard->window.flags &= ~WINDOW_FORCED;
2846 }
2847 if (cg_paused.integer) {
2848 cg.deferredPlayerLoading = 0;
2849 firstTime = qtrue;
2850 return qfalse;
2851 }
2852
2853 // should never happen in Team Arena
2854 if (cgs.gametype == GT_SINGLE_PLAYER && cg.predictedPlayerState.pm_type == PM_INTERMISSION ) {
2855 cg.deferredPlayerLoading = 0;
2856 firstTime = qtrue;
2857 return qfalse;
2858 }
2859
2860 // don't draw scoreboard during death while warmup up
2861 if ( cg.warmup && !cg.showScores ) {
2862 return qfalse;
2863 }
2864
2865 if ( cg.showScores || cg.predictedPlayerState.pm_type == PM_DEAD || cg.predictedPlayerState.pm_type == PM_INTERMISSION ) {
2866 fade = 1.0;
2867 fadeColor = colorWhite;
2868 } else {
2869 fadeColor = CG_FadeColor( cg.scoreFadeTime, FADE_TIME );
2870 if ( !fadeColor ) {
2871 // next time scoreboard comes up, don't print killer
2872 cg.deferredPlayerLoading = 0;
2873 cg.killerName[0] = 0;
2874 firstTime = qtrue;
2875 return qfalse;
2876 }
2877 fade = *fadeColor;
2878 }
2879
2880
2881 if (menuScoreboard == NULL) {
2882 if ( cgs.gametype >= GT_TEAM && cgs.ffa_gt!=1) {
2883 menuScoreboard = Menus_FindByName("teamscore_menu");
2884 } else {
2885 menuScoreboard = Menus_FindByName("score_menu");
2886 }
2887 }
2888
2889 if (menuScoreboard) {
2890 if (firstTime) {
2891 CG_SetScoreSelection(menuScoreboard);
2892 firstTime = qfalse;
2893 }
2894 Menu_Paint(menuScoreboard, qtrue);
2895 }
2896
2897 // load any models that have been deferred
2898 if ( ++cg.deferredPlayerLoading > 10 ) {
2899 CG_LoadDeferredPlayers();
2900 }
2901
2902 return qtrue;
2903 #else
2904 char *s;
2905 int w;
2906 if(cg.respawnTime && cg.snap->ps.persistant[PERS_TEAM] != TEAM_SPECTATOR && (cgs.gametype < GT_ELIMINATION || cgs.gametype > GT_LMS) ) {
2907 if(cg.respawnTime>cg.time) {
2908 s = va("Respawn in: %2.2f",((double)cg.respawnTime-(double)cg.time)/1000.0);
2909 w = CG_DrawStrlen( s ) * SMALLCHAR_WIDTH;
2910 CG_DrawSmallStringColor(320-w/2,400, s, colorYellow);
2911 } else {
2912 s = va("Click FIRE to respawn");
2913 w = CG_DrawStrlen( s ) * SMALLCHAR_WIDTH;
2914 CG_DrawSmallStringColor(320-w/2,400, "Click FIRE to respawn", colorGreen);
2915 }
2916 }
2917 return CG_DrawOldScoreboard();
2918 #endif
2919 }
2920
2921 #define ACCBOARD_XPOS 500
2922 #define ACCBOARD_YPOS 150
2923 #define ACCBOARD_HEIGHT 20
2924 #define ACCBOARD_WIDTH 75
2925 #define ACCITEM_SIZE 16
2926
2927 qboolean CG_DrawAccboard( void ) {
2928 int counter, i;
2929
2930 i = 0;
2931
2932 if( !cg.showAcc ){
2933 return qfalse;
2934 }
2935 trap_R_SetColor( colorWhite );
2936
2937 for( counter = 0; counter < WP_NUM_WEAPONS ; counter++ ){
2938 if( cg_weapons[counter+2].weaponIcon && counter != WP_PROX_LAUNCHER && counter != WP_GRAPPLING_HOOK )
2939 i++;
2940 }
2941
2942 CG_DrawTeamBackground( ACCBOARD_XPOS, ACCBOARD_YPOS, ACCBOARD_WIDTH, ACCBOARD_HEIGHT*(i + 1), 0.33f, TEAM_BLUE );
2943
2944 i = 0;
2945
2946 for( counter = 0 ; counter < WP_NUM_WEAPONS ; counter++ ){
2947 if( cg_weapons[counter+2].weaponIcon && counter != WP_PROX_LAUNCHER && counter != WP_GRAPPLING_HOOK ){
2948 CG_DrawPic( ACCBOARD_XPOS + 10, ACCBOARD_YPOS + 10 +i*ACCBOARD_HEIGHT, ACCITEM_SIZE, ACCITEM_SIZE, cg_weapons[counter+2].weaponIcon );
2949 if( cg.accuracys[counter][0] > 0 )
2950 CG_DrawSmallStringColor(ACCBOARD_XPOS + 10 + ACCITEM_SIZE + 10, ACCBOARD_YPOS + 10 +i*ACCBOARD_HEIGHT + ACCITEM_SIZE/2 - SMALLCHAR_HEIGHT/2 ,
2951 va("%i%s",(int)(((float)cg.accuracys[counter][1]*100)/((float)(cg.accuracys[counter][0]))),"%"), colorWhite);
2952 else
2953 CG_DrawSmallStringColor(ACCBOARD_XPOS + 10 + ACCITEM_SIZE + 10, ACCBOARD_YPOS + 10 +i*ACCBOARD_HEIGHT + ACCITEM_SIZE/2 - SMALLCHAR_HEIGHT/2 , "-%", colorWhite);
2954 i++;
2955 }
2956 }
2957
2958 trap_R_SetColor(NULL);
2959 return qtrue;
2960 }
2961
2962
2963
2964 /*
2965 =================
2966 CG_DrawIntermission
2967 =================
2968 */
2969 static void CG_DrawIntermission( void ) {
2970 // int key;
2971 #ifdef MISSIONPACK
2972 //if (cg_singlePlayer.integer) {
2973 // CG_DrawCenterString();
2974 // return;
2975 //}
2976 #else
2977 if ( cgs.gametype == GT_SINGLE_PLAYER ) {
2978 CG_DrawCenterString();
2979 return;
2980 }
2981 #endif
2982 cg.scoreFadeTime = cg.time;
2983 cg.scoreBoardShowing = CG_DrawScoreboard();
2984 }
2985
2986 /*
2987 =================
2988 CG_DrawFollow
2989 =================
2990 */
2991 static qboolean CG_DrawFollow( void ) {
2992 float x;
2993 vec4_t color;
2994 const char *name;
2995
2996 if ( !(cg.snap->ps.pm_flags & PMF_FOLLOW) ) {
2997 return qfalse;
2998 }
2999 color[0] = 1;
3000 color[1] = 1;
3001 color[2] = 1;
3002 color[3] = 1;
3003
3004
3005 CG_DrawBigString( 320 - 9 * 8, 24, "following", 1.0F );
3006
3007 name = cgs.clientinfo[ cg.snap->ps.clientNum ].name;
3008
3009 x = 0.5 * ( 640 - GIANT_WIDTH * CG_DrawStrlen( name ) );
3010
3011 CG_DrawStringExt( x, 40, name, color, qtrue, qtrue, GIANT_WIDTH, GIANT_HEIGHT, 0 );
3012
3013 return qtrue;
3014 }
3015
3016
3017
3018 /*
3019 =================
3020 CG_DrawAmmoWarning
3021 =================
3022 */
3023 static void CG_DrawAmmoWarning( void ) {
3024 const char *s;
3025 int w;
3026
3027 //Don't report in instant gib same with RA
3028 if(cgs.nopickup)
3029 return;
3030
3031 if ( cg_drawAmmoWarning.integer == 0 ) {
3032 return;
3033 }
3034
3035 if ( !cg.lowAmmoWarning ) {
3036 return;
3037 }
3038
3039 if ( cg.lowAmmoWarning == 2 ) {
3040 s = "OUT OF AMMO";
3041 } else {
3042 s = "LOW AMMO WARNING";
3043 }
3044 w = CG_DrawStrlen( s ) * BIGCHAR_WIDTH;
3045 CG_DrawBigString(320 - w / 2, 64, s, 1.0F);
3046 }
3047
3048
3049 //#ifdef MISSIONPACK
3050 /*
3051 =================
3052 CG_DrawProxWarning
3053 =================
3054 */
3055 static void CG_DrawProxWarning( void ) {
3056 char s [32];
3057 int w;
3058 static int proxTime;
3059 static int proxCounter;
3060 static int proxTick;
3061
3062 if( !(cg.snap->ps.eFlags & EF_TICKING ) ) {
3063 proxTime = 0;
3064 return;
3065 }
3066
3067 if (proxTime == 0) {
3068 proxTime = cg.time + 5000;
3069 proxCounter = 5;
3070 proxTick = 0;
3071 }
3072
3073 if (cg.time > proxTime) {
3074 proxTick = proxCounter--;
3075 proxTime = cg.time + 1000;
3076 }
3077
3078 if (proxTick != 0) {
3079 Com_sprintf(s, sizeof(s), "INTERNAL COMBUSTION IN: %i", proxTick);
3080 } else {
3081 Com_sprintf(s, sizeof(s), "YOU HAVE BEEN MINED");
3082 }
3083
3084 w = CG_DrawStrlen( s ) * BIGCHAR_WIDTH;
3085 CG_DrawBigStringColor( 320 - w / 2, 64 + BIGCHAR_HEIGHT, s, g_color_table[ColorIndex(COLOR_RED)] );
3086 }
3087 //#endif
3088
3089
3090 /*
3091 =================
3092 CG_DrawWarmup
3093 =================
3094 */
3095 static void CG_DrawWarmup( void ) {
3096 int w;
3097 int sec;
3098 int i;
3099 float scale;
3100 clientInfo_t *ci1, *ci2;
3101 int cw;
3102 const char *s;
3103
3104 sec = cg.warmup;
3105 if ( !sec ) {
3106 return;
3107 }
3108
3109 if ( sec < 0 ) {
3110 s = "Waiting for players";
3111 w = CG_DrawStrlen( s ) * BIGCHAR_WIDTH;
3112 CG_DrawBigString(320 - w / 2, 24, s, 1.0F);
3113 cg.warmupCount = 0;
3114 return;
3115 }
3116
3117 if (cgs.gametype == GT_TOURNAMENT) {
3118 // find the two active players
3119 ci1 = NULL;
3120 ci2 = NULL;
3121 for ( i = 0 ; i < cgs.maxclients ; i++ ) {
3122 if ( cgs.clientinfo[i].infoValid && cgs.clientinfo[i].team == TEAM_FREE ) {
3123 if ( !ci1 ) {
3124 ci1 = &cgs.clientinfo[i];
3125 } else {
3126 ci2 = &cgs.clientinfo[i];
3127 }
3128 }
3129 }
3130
3131 if ( ci1 && ci2 ) {
3132 s = va( "%s vs %s", ci1->name, ci2->name );
3133 #ifdef MISSIONPACK
3134 w = CG_Text_Width(s, 0.6f, 0);
3135 CG_Text_Paint(320 - w / 2, 60, 0.6f, colorWhite, s, 0, 0, ITEM_TEXTSTYLE_SHADOWEDMORE);
3136 #else
3137 w = CG_DrawStrlen( s );
3138 if ( w > 640 / GIANT_WIDTH ) {
3139 cw = 640 / w;
3140 } else {
3141 cw = GIANT_WIDTH;
3142 }
3143 CG_DrawStringExt( 320 - w * cw/2, 20,s, colorWhite,
3144 qfalse, qtrue, cw, (int)(cw * 1.5f), 0 );
3145 #endif
3146 }
3147 } else {
3148 if ( cgs.gametype == GT_FFA ) {
3149 s = "Free For All";
3150 } else if ( cgs.gametype == GT_TEAM ) {
3151 s = "Team Deathmatch";
3152 } else if ( cgs.gametype == GT_CTF ) {
3153 s = "Capture the Flag";
3154 } else if ( cgs.gametype == GT_ELIMINATION ) {
3155 s = "Elimination";
3156 } else if ( cgs.gametype == GT_CTF_ELIMINATION ) {
3157 s = "CTF Elimination";
3158 } else if ( cgs.gametype == GT_LMS ) {
3159 s = "Last Man Standing";
3160 } else if ( cgs.gametype == GT_DOUBLE_D ) {
3161 s = "Double Domination";
3162 } else if ( cgs.gametype == GT_1FCTF ) {
3163 s = "One Flag CTF";
3164 } else if ( cgs.gametype == GT_OBELISK ) {
3165 s = "Overload";
3166 } else if ( cgs.gametype == GT_HARVESTER ) {
3167 s = "Harvester";
3168 } else if ( cgs.gametype == GT_DOMINATION ) {
3169 s = "Domination";
3170 } else {
3171 s = "";
3172 }
3173 #ifdef MISSIONPACK
3174 w = CG_Text_Width(s, 0.6f, 0);
3175 CG_Text_Paint(320 - w / 2, 90, 0.6f, colorWhite, s, 0, 0, ITEM_TEXTSTYLE_SHADOWEDMORE);
3176 #else
3177 w = CG_DrawStrlen( s );
3178 if ( w > 640 / GIANT_WIDTH ) {
3179 cw = 640 / w;
3180 } else {
3181 cw = GIANT_WIDTH;
3182 }
3183 CG_DrawStringExt( 320 - w * cw/2, 25,s, colorWhite,
3184 qfalse, qtrue, cw, (int)(cw * 1.1f), 0 );
3185 #endif
3186 }
3187
3188 sec = ( sec - cg.time ) / 1000;
3189 if ( sec < 0 ) {
3190 cg.warmup = 0;
3191 sec = 0;
3192 }
3193 s = va( "Starts in: %i", sec + 1 );
3194 if ( sec != cg.warmupCount ) {
3195 cg.warmupCount = sec;
3196 switch ( sec ) {
3197 case 0:
3198 trap_S_StartLocalSound( cgs.media.count1Sound, CHAN_ANNOUNCER );
3199 break;
3200 case 1:
3201 trap_S_StartLocalSound( cgs.media.count2Sound, CHAN_ANNOUNCER );
3202 break;
3203 case 2:
3204 trap_S_StartLocalSound( cgs.media.count3Sound, CHAN_ANNOUNCER );
3205 break;
3206 default:
3207 break;
3208 }
3209 }
3210 scale = 0.45f;
3211 switch ( cg.warmupCount ) {
3212 case 0:
3213 cw = 28;
3214 scale = 0.54f;
3215 break;
3216 case 1:
3217 cw = 24;
3218 scale = 0.51f;
3219 break;
3220 case 2:
3221 cw = 20;
3222 scale = 0.48f;
3223 break;
3224 default:
3225 cw = 16;
3226 scale = 0.45f;
3227 break;
3228 }
3229
3230 #ifdef MISSIONPACK
3231 w = CG_Text_Width(s, scale, 0);
3232 CG_Text_Paint(320 - w / 2, 125, scale, colorWhite, s, 0, 0, ITEM_TEXTSTYLE_SHADOWEDMORE);
3233 #else
3234 w = CG_DrawStrlen( s );
3235 CG_DrawStringExt( 320 - w * cw/2, 70, s, colorWhite,
3236 qfalse, qtrue, cw, (int)(cw * 1.5), 0 );
3237 #endif
3238 }
3239
3240 //==================================================================================
3241 #ifdef MISSIONPACK
3242 /*
3243 =================
3244 CG_DrawTimedMenus
3245 =================
3246 */
3247 void CG_DrawTimedMenus( void ) {
3248 if (cg.voiceTime) {
3249 int t = cg.time - cg.voiceTime;
3250 if ( t > 2500 ) {
3251 Menus_CloseByName("voiceMenu");
3252 trap_Cvar_Set("cl_conXOffset", "0");
3253 cg.voiceTime = 0;
3254 }
3255 }
3256 }
3257 #endif
3258 /*
3259 =================
3260 CG_Draw2D
3261 =================
3262 */
3263 static void CG_Draw2D(stereoFrame_t stereoFrame)
3264 {
3265 #ifdef MISSIONPACK
3266 if (cgs.orderPending && cg.time > cgs.orderTime) {
3267 CG_CheckOrderPending();
3268 }
3269 #endif
3270 // if we are taking a levelshot for the menu, don't draw anything
3271 if ( cg.levelShot ) {
3272 return;
3273 }
3274
3275 if ( cg_draw2D.integer == 0 ) {
3276 return;
3277 }
3278
3279 if ( cg.snap->ps.pm_type == PM_INTERMISSION ) {
3280 CG_DrawIntermission();
3281 return;
3282 }
3283
3284 /*
3285 if (cg.cameraMode) {
3286 return;
3287 }
3288 */
3289 if ( cg.snap->ps.persistant[PERS_TEAM] == TEAM_SPECTATOR /*|| cg.snap->ps.pm_type == PM_SPECTATOR*/ ) {
3290 CG_DrawSpectator();
3291
3292 if(stereoFrame == STEREO_CENTER)
3293 CG_DrawCrosshair();
3294
3295 CG_DrawCrosshairNames();
3296 } else {
3297 // don't draw any status if dead or the scoreboard is being explicitly shown
3298 if ( !cg.showScores && cg.snap->ps.stats[STAT_HEALTH] > 0 ) {
3299
3300 #ifdef MISSIONPACK
3301 if ( cg_drawStatus.integer ) {
3302 Menu_PaintAll();
3303 CG_DrawTimedMenus();
3304 }
3305 #else
3306 CG_DrawStatusBar();
3307 #endif
3308
3309 CG_DrawAmmoWarning();
3310
3311 CG_DrawProxWarning();
3312 if(stereoFrame == STEREO_CENTER)
3313 CG_DrawCrosshair();
3314 CG_DrawCrosshairNames();
3315 CG_DrawWeaponSelect();
3316
3317 #ifndef MISSIONPACK
3318 CG_DrawHoldableItem();
3319 #endif
•3320 CG_DrawPersistantPowerup();
3321
3322 CG_DrawReward();
3323 }
3324
3325 if ( cgs.gametype >= GT_TEAM && cgs.ffa_gt!=1) {
3326 #ifndef MISSIONPACK
3327 CG_DrawTeamInfo();
3328 #endif
3329 }
3330 }
3331
3332 CG_DrawVote();
3333 CG_DrawTeamVote();
3334
3335 CG_DrawLagometer();
3336
3337 #ifdef MISSIONPACK
3338 if (!cg_paused.integer) {
3339 CG_DrawUpperRight(stereoFrame);
3340 }
3341 #else
3342 CG_DrawUpperRight(stereoFrame);
3343 #endif
3344
3345 #ifndef MISSIONPACK
3346 CG_DrawLowerRight();
3347 CG_DrawLowerLeft();
3348 #endif
3349
3350 if ( !CG_DrawFollow() ) {
3351 CG_DrawWarmup();
3352 }
3353
3354 // don't draw center string if scoreboard is up
3355 cg.scoreBoardShowing = CG_DrawScoreboard();
3356 if ( !cg.scoreBoardShowing) {
3357 CG_DrawCenterDDString();
3358 CG_DrawCenter1FctfString();
3359 CG_DrawCenterString();
3360 }
3361
3362 cg.accBoardShowing = CG_DrawAccboard();
3363 }
3364
3365
3366 static void CG_DrawTourneyScoreboard( void ) {
3367 #ifdef MISSIONPACK
3368 #else
3369 CG_DrawOldTourneyScoreboard();
3370 #endif
3371 }
3372
3373 /*
3374 =====================
3375 CG_DrawActive
3376
3377 Perform all drawing needed to completely fill the screen
3378 =====================
3379 */
3380 void CG_DrawActive( stereoFrame_t stereoView ) {
3381 // optionally draw the info screen instead
3382 if ( !cg.snap ) {
3383 CG_DrawInformation();
3384 return;
3385 }
3386
3387 // optionally draw the tournement scoreboard instead
3388 if ( cg.snap->ps.persistant[PERS_TEAM] == TEAM_SPECTATOR &&
3389 ( cg.snap->ps.pm_flags & PMF_SCOREBOARD ) ) {
3390 CG_DrawTourneyScoreboard();
3391 return;
3392 }
3393
3394 // clear around the rendered view if sized down
3395 CG_TileClear();
3396
3397 if(stereoView != STEREO_CENTER)
3398 CG_DrawCrosshair3D();
3399
3400 // draw 3D view
3401 trap_R_RenderScene( &cg.refdef );
3402
3403 // draw status bar and other floating elements
3404 CG_Draw2D(stereoView);
3405 }
3406
3407
3408