fix a thinko in big endian support (forgot to use defined() in a #elif)
[divverent/darkplaces.git] / sbar.c
1 /*
2 Copyright (C) 1996-1997 Id Software, Inc.
3
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
13 See the GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18
19 */
20 // sbar.c -- status bar code
21
22 #include "quakedef.h"
23
24 typedef struct
25 {
26         char name[32];
27 }
28 sbarpic_t;
29
30 static sbarpic_t sbarpics[256];
31 static int numsbarpics;
32
33 static sbarpic_t *Sbar_NewPic(const char *name)
34 {
35         strcpy(sbarpics[numsbarpics].name, name);
36         // precache it
37         // FIXME: precache on every renderer restart (or move this to client)
38         Draw_CachePic(sbarpics[numsbarpics].name);
39         return sbarpics + (numsbarpics++);
40 }
41
42 sbarpic_t *sb_disc;
43
44 #define STAT_MINUS 10 // num frame for '-' stats digit
45 sbarpic_t *sb_nums[2][11];
46 sbarpic_t *sb_colon, *sb_slash;
47 sbarpic_t *sb_ibar;
48 sbarpic_t *sb_sbar;
49 sbarpic_t *sb_scorebar;
50 // AK only used by NEX
51 sbarpic_t *sb_sbar_minimal;
52 sbarpic_t *sb_sbar_overlay;
53
54 // AK changed the bound to 9
55 sbarpic_t *sb_weapons[7][9]; // 0 is active, 1 is owned, 2-5 are flashes
56 sbarpic_t *sb_ammo[4];
57 sbarpic_t *sb_sigil[4];
58 sbarpic_t *sb_armor[3];
59 sbarpic_t *sb_items[32];
60
61 // 0-4 are based on health (in 20 increments)
62 // 0 is static, 1 is temporary animation
63 sbarpic_t *sb_faces[5][2];
64
65 sbarpic_t *sb_face_invis;
66 sbarpic_t *sb_face_quad;
67 sbarpic_t *sb_face_invuln;
68 sbarpic_t *sb_face_invis_invuln;
69
70 qboolean sb_showscores;
71
72 int sb_lines;                   // scan lines to draw
73
74 sbarpic_t *rsb_invbar[2];
75 sbarpic_t *rsb_weapons[5];
76 sbarpic_t *rsb_items[2];
77 sbarpic_t *rsb_ammo[3];
78 sbarpic_t *rsb_teambord;                // PGM 01/19/97 - team color border
79
80 //MED 01/04/97 added two more weapons + 3 alternates for grenade launcher
81 sbarpic_t *hsb_weapons[7][5];   // 0 is active, 1 is owned, 2-5 are flashes
82 //MED 01/04/97 added array to simplify weapon parsing
83 int hipweapons[4] = {HIT_LASER_CANNON_BIT,HIT_MJOLNIR_BIT,4,HIT_PROXIMITY_GUN_BIT};
84 //MED 01/04/97 added hipnotic items array
85 sbarpic_t *hsb_items[2];
86
87 //GAME_SOM stuff:
88 sbarpic_t *somsb_health;
89 sbarpic_t *somsb_ammo[4];
90 sbarpic_t *somsb_armor[3];
91
92 cvar_t  showfps = {CVAR_SAVE, "showfps", "0"};
93 cvar_t  sbar_alpha = {CVAR_SAVE, "sbar_alpha", "1"};
94
95 void Sbar_MiniDeathmatchOverlay (int x, int y);
96 void Sbar_DeathmatchOverlay (void);
97 void Sbar_IntermissionOverlay (void);
98 void Sbar_FinaleOverlay (void);
99
100
101 /*
102 ===============
103 Sbar_ShowScores
104
105 Tab key down
106 ===============
107 */
108 void Sbar_ShowScores (void)
109 {
110         if (sb_showscores)
111                 return;
112         sb_showscores = true;
113 }
114
115 /*
116 ===============
117 Sbar_DontShowScores
118
119 Tab key up
120 ===============
121 */
122 void Sbar_DontShowScores (void)
123 {
124         sb_showscores = false;
125 }
126
127 void sbar_start(void)
128 {
129         int i;
130
131         numsbarpics = 0;
132
133         sb_disc = Sbar_NewPic("gfx/disc");
134
135         for (i = 0;i < 10;i++)
136         {
137                 sb_nums[0][i] = Sbar_NewPic (va("gfx/num_%i",i));
138                 sb_nums[1][i] = Sbar_NewPic (va("gfx/anum_%i",i));
139         }
140
141         sb_nums[0][10] = Sbar_NewPic ("gfx/num_minus");
142         sb_nums[1][10] = Sbar_NewPic ("gfx/anum_minus");
143
144         sb_colon = Sbar_NewPic ("gfx/num_colon");
145         sb_slash = Sbar_NewPic ("gfx/num_slash");
146
147         if (gamemode == GAME_SOM)
148         {
149                 somsb_health = Sbar_NewPic("gfx/hud_health");
150                 somsb_ammo[0] = Sbar_NewPic("gfx/sb_shells");
151                 somsb_ammo[1] = Sbar_NewPic("gfx/sb_nails");
152                 somsb_ammo[2] = Sbar_NewPic("gfx/sb_rocket");
153                 somsb_ammo[3] = Sbar_NewPic("gfx/sb_cells");
154                 somsb_armor[0] = Sbar_NewPic("gfx/sb_armor1");
155                 somsb_armor[1] = Sbar_NewPic("gfx/sb_armor2");
156                 somsb_armor[2] = Sbar_NewPic("gfx/sb_armor3");
157         }
158         else if (gamemode == GAME_NEXUIZ)
159         {
160                 sb_ammo[0] = Sbar_NewPic ("gfx/sb_shells");
161                 sb_ammo[1] = Sbar_NewPic ("gfx/sb_bullets");
162                 sb_ammo[2] = Sbar_NewPic ("gfx/sb_rocket");
163                 sb_ammo[3] = Sbar_NewPic ("gfx/sb_cells");
164
165                 sb_items[2] = Sbar_NewPic ("gfx/sb_slowmo");
166                 sb_items[3] = Sbar_NewPic ("gfx/sb_invinc");
167                 sb_items[4] = Sbar_NewPic ("gfx/sb_energy");
168                 sb_items[5] = Sbar_NewPic ("gfx/sb_str");
169
170                 sb_sbar = Sbar_NewPic("gfx/sbar");
171                 sb_sbar_minimal = Sbar_NewPic("gfx/sbar_minimal");
172                 sb_sbar_overlay = Sbar_NewPic("gfx/sbar_overlay");
173
174                 for(i = 0; i < 9;i++)
175                         sb_weapons[0][i] = Sbar_NewPic(va("gfx/inv_weapon%i",i));
176         }
177         else
178         {
179                 sb_weapons[0][0] = Sbar_NewPic ("gfx/inv_shotgun");
180                 sb_weapons[0][1] = Sbar_NewPic ("gfx/inv_sshotgun");
181                 sb_weapons[0][2] = Sbar_NewPic ("gfx/inv_nailgun");
182                 sb_weapons[0][3] = Sbar_NewPic ("gfx/inv_snailgun");
183                 sb_weapons[0][4] = Sbar_NewPic ("gfx/inv_rlaunch");
184                 sb_weapons[0][5] = Sbar_NewPic ("gfx/inv_srlaunch");
185                 sb_weapons[0][6] = Sbar_NewPic ("gfx/inv_lightng");
186         
187                 sb_weapons[1][0] = Sbar_NewPic ("gfx/inv2_shotgun");
188                 sb_weapons[1][1] = Sbar_NewPic ("gfx/inv2_sshotgun");
189                 sb_weapons[1][2] = Sbar_NewPic ("gfx/inv2_nailgun");
190                 sb_weapons[1][3] = Sbar_NewPic ("gfx/inv2_snailgun");
191                 sb_weapons[1][4] = Sbar_NewPic ("gfx/inv2_rlaunch");
192                 sb_weapons[1][5] = Sbar_NewPic ("gfx/inv2_srlaunch");
193                 sb_weapons[1][6] = Sbar_NewPic ("gfx/inv2_lightng");
194         
195                 for (i = 0;i < 5;i++)
196                 {
197                         sb_weapons[2+i][0] = Sbar_NewPic (va("gfx/inva%i_shotgun",i+1));
198                         sb_weapons[2+i][1] = Sbar_NewPic (va("gfx/inva%i_sshotgun",i+1));
199                         sb_weapons[2+i][2] = Sbar_NewPic (va("gfx/inva%i_nailgun",i+1));
200                         sb_weapons[2+i][3] = Sbar_NewPic (va("gfx/inva%i_snailgun",i+1));
201                         sb_weapons[2+i][4] = Sbar_NewPic (va("gfx/inva%i_rlaunch",i+1));
202                         sb_weapons[2+i][5] = Sbar_NewPic (va("gfx/inva%i_srlaunch",i+1));
203                         sb_weapons[2+i][6] = Sbar_NewPic (va("gfx/inva%i_lightng",i+1));
204                 }
205         
206                 sb_ammo[0] = Sbar_NewPic ("gfx/sb_shells");
207                 sb_ammo[1] = Sbar_NewPic ("gfx/sb_nails");
208                 sb_ammo[2] = Sbar_NewPic ("gfx/sb_rocket");
209                 sb_ammo[3] = Sbar_NewPic ("gfx/sb_cells");
210         
211                 sb_armor[0] = Sbar_NewPic ("gfx/sb_armor1");
212                 sb_armor[1] = Sbar_NewPic ("gfx/sb_armor2");
213                 sb_armor[2] = Sbar_NewPic ("gfx/sb_armor3");
214         
215                 sb_items[0] = Sbar_NewPic ("gfx/sb_key1");
216                 sb_items[1] = Sbar_NewPic ("gfx/sb_key2");
217                 sb_items[2] = Sbar_NewPic ("gfx/sb_invis");
218                 sb_items[3] = Sbar_NewPic ("gfx/sb_invuln");
219                 sb_items[4] = Sbar_NewPic ("gfx/sb_suit");
220                 sb_items[5] = Sbar_NewPic ("gfx/sb_quad");
221         
222                 sb_sigil[0] = Sbar_NewPic ("gfx/sb_sigil1");
223                 sb_sigil[1] = Sbar_NewPic ("gfx/sb_sigil2");
224                 sb_sigil[2] = Sbar_NewPic ("gfx/sb_sigil3");
225                 sb_sigil[3] = Sbar_NewPic ("gfx/sb_sigil4");
226         
227                 sb_faces[4][0] = Sbar_NewPic ("gfx/face1");
228                 sb_faces[4][1] = Sbar_NewPic ("gfx/face_p1");
229                 sb_faces[3][0] = Sbar_NewPic ("gfx/face2");
230                 sb_faces[3][1] = Sbar_NewPic ("gfx/face_p2");
231                 sb_faces[2][0] = Sbar_NewPic ("gfx/face3");
232                 sb_faces[2][1] = Sbar_NewPic ("gfx/face_p3");
233                 sb_faces[1][0] = Sbar_NewPic ("gfx/face4");
234                 sb_faces[1][1] = Sbar_NewPic ("gfx/face_p4");
235                 sb_faces[0][0] = Sbar_NewPic ("gfx/face5");
236                 sb_faces[0][1] = Sbar_NewPic ("gfx/face_p5");
237         
238                 sb_face_invis = Sbar_NewPic ("gfx/face_invis");
239                 sb_face_invuln = Sbar_NewPic ("gfx/face_invul2");
240                 sb_face_invis_invuln = Sbar_NewPic ("gfx/face_inv2");
241                 sb_face_quad = Sbar_NewPic ("gfx/face_quad");
242         
243                 sb_sbar = Sbar_NewPic ("gfx/sbar");
244                 sb_ibar = Sbar_NewPic ("gfx/ibar");
245                 sb_scorebar = Sbar_NewPic ("gfx/scorebar");
246         
247         //MED 01/04/97 added new hipnotic weapons
248                 if (gamemode == GAME_HIPNOTIC)
249                 {
250                         hsb_weapons[0][0] = Sbar_NewPic ("gfx/inv_laser");
251                         hsb_weapons[0][1] = Sbar_NewPic ("gfx/inv_mjolnir");
252                         hsb_weapons[0][2] = Sbar_NewPic ("gfx/inv_gren_prox");
253                         hsb_weapons[0][3] = Sbar_NewPic ("gfx/inv_prox_gren");
254                         hsb_weapons[0][4] = Sbar_NewPic ("gfx/inv_prox");
255         
256                         hsb_weapons[1][0] = Sbar_NewPic ("gfx/inv2_laser");
257                         hsb_weapons[1][1] = Sbar_NewPic ("gfx/inv2_mjolnir");
258                         hsb_weapons[1][2] = Sbar_NewPic ("gfx/inv2_gren_prox");
259                         hsb_weapons[1][3] = Sbar_NewPic ("gfx/inv2_prox_gren");
260                         hsb_weapons[1][4] = Sbar_NewPic ("gfx/inv2_prox");
261         
262                         for (i = 0;i < 5;i++)
263                         {
264                                 hsb_weapons[2+i][0] = Sbar_NewPic (va("gfx/inva%i_laser",i+1));
265                                 hsb_weapons[2+i][1] = Sbar_NewPic (va("gfx/inva%i_mjolnir",i+1));
266                                 hsb_weapons[2+i][2] = Sbar_NewPic (va("gfx/inva%i_gren_prox",i+1));
267                                 hsb_weapons[2+i][3] = Sbar_NewPic (va("gfx/inva%i_prox_gren",i+1));
268                                 hsb_weapons[2+i][4] = Sbar_NewPic (va("gfx/inva%i_prox",i+1));
269                         }
270         
271                         hsb_items[0] = Sbar_NewPic ("gfx/sb_wsuit");
272                         hsb_items[1] = Sbar_NewPic ("gfx/sb_eshld");
273                 }
274                 else if (gamemode == GAME_ROGUE)
275                 {
276                         rsb_invbar[0] = Sbar_NewPic ("gfx/r_invbar1");
277                         rsb_invbar[1] = Sbar_NewPic ("gfx/r_invbar2");
278         
279                         rsb_weapons[0] = Sbar_NewPic ("gfx/r_lava");
280                         rsb_weapons[1] = Sbar_NewPic ("gfx/r_superlava");
281                         rsb_weapons[2] = Sbar_NewPic ("gfx/r_gren");
282                         rsb_weapons[3] = Sbar_NewPic ("gfx/r_multirock");
283                         rsb_weapons[4] = Sbar_NewPic ("gfx/r_plasma");
284         
285                         rsb_items[0] = Sbar_NewPic ("gfx/r_shield1");
286                         rsb_items[1] = Sbar_NewPic ("gfx/r_agrav1");
287         
288         // PGM 01/19/97 - team color border
289                         rsb_teambord = Sbar_NewPic ("gfx/r_teambord");
290         // PGM 01/19/97 - team color border
291         
292                         rsb_ammo[0] = Sbar_NewPic ("gfx/r_ammolava");
293                         rsb_ammo[1] = Sbar_NewPic ("gfx/r_ammomulti");
294                         rsb_ammo[2] = Sbar_NewPic ("gfx/r_ammoplasma");
295                 }
296         }
297 }
298
299 void sbar_shutdown(void)
300 {
301 }
302
303 void sbar_newmap(void)
304 {
305 }
306
307 void Sbar_Init (void)
308 {
309         Cmd_AddCommand ("+showscores", Sbar_ShowScores);
310         Cmd_AddCommand ("-showscores", Sbar_DontShowScores);
311         Cvar_RegisterVariable (&showfps);
312         Cvar_RegisterVariable (&sbar_alpha);
313
314         R_RegisterModule("sbar", sbar_start, sbar_shutdown, sbar_newmap);
315 }
316
317
318 //=============================================================================
319
320 // drawing routines are relative to the status bar location
321
322 int sbar_x, sbar_y;
323
324 /*
325 =============
326 Sbar_DrawPic
327 =============
328 */
329 void Sbar_DrawPic (int x, int y, sbarpic_t *sbarpic)
330 {
331         DrawQ_Pic (sbar_x + x, sbar_y + y, sbarpic->name, 0, 0, 1, 1, 1, sbar_alpha.value, 0);
332 }
333
334 void Sbar_DrawAlphaPic (int x, int y, sbarpic_t *sbarpic, float alpha)
335 {
336         DrawQ_Pic (sbar_x + x, sbar_y + y, sbarpic->name, 0, 0, 1, 1, 1, alpha * sbar_alpha.value, 0);
337 }
338
339 /*
340 ================
341 Sbar_DrawCharacter
342
343 Draws one solid graphics character
344 ================
345 */
346 void Sbar_DrawCharacter (int x, int y, int num)
347 {
348         DrawQ_String (sbar_x + x + 4 , sbar_y + y, va("%c", num), 0, 8, 8, 1, 1, 1, sbar_alpha.value, 0);
349 }
350
351 /*
352 ================
353 Sbar_DrawString
354 ================
355 */
356 void Sbar_DrawString (int x, int y, char *str)
357 {
358         DrawQ_String (sbar_x + x, sbar_y + y, str, 0, 8, 8, 1, 1, 1, sbar_alpha.value, 0);
359 }
360
361 /*
362 =============
363 Sbar_DrawNum
364 =============
365 */
366 void Sbar_DrawNum (int x, int y, int num, int digits, int color)
367 {
368         char str[32], *ptr;
369         int l, frame;
370
371         l = sprintf(str, "%i", num);
372         ptr = str;
373         if (l > digits)
374                 ptr += (l-digits);
375         if (l < digits)
376                 x += (digits-l)*24;
377
378         while (*ptr)
379         {
380                 if (*ptr == '-')
381                         frame = STAT_MINUS;
382                 else
383                         frame = *ptr -'0';
384
385                 Sbar_DrawPic (x, y, sb_nums[color][frame]);
386                 x += 24;
387
388                 ptr++;
389         }
390 }
391
392 /*
393 =============
394 Sbar_DrawXNum
395 =============
396 */
397
398 void Sbar_DrawXNum (int x, int y, int num, int digits, int lettersize, float r, float g, float b, float a, int flags)
399 {
400         char str[32], *ptr;
401         int l, frame;
402
403         l = sprintf(str, "%i", num);
404         ptr = str;
405         if (l > digits)
406                 ptr += (l-digits);
407         if (l < digits)
408                 x += (digits-l) * lettersize;
409
410         while (*ptr)
411         {
412                 if (*ptr == '-')
413                         frame = STAT_MINUS;
414                 else
415                         frame = *ptr -'0';
416
417                 DrawQ_Pic (sbar_x + x, sbar_y + y, sb_nums[0][frame]->name,lettersize,lettersize,r,g,b,a * sbar_alpha.value,flags);
418                 x += lettersize;
419
420                 ptr++;
421         }
422 }
423
424 //=============================================================================
425
426
427 /*
428 ===============
429 Sbar_SortFrags
430 ===============
431 */
432 static int fragsort[MAX_SCOREBOARD];
433 static int scoreboardlines;
434 void Sbar_SortFrags (void)
435 {
436         int             i, j, k;
437
438 // sort by frags
439         scoreboardlines = 0;
440         for (i=0 ; i<cl.maxclients ; i++)
441         {
442                 if (cl.scores[i].name[0])
443                 {
444                         fragsort[scoreboardlines] = i;
445                         scoreboardlines++;
446                 }
447         }
448
449         for (i=0 ; i<scoreboardlines ; i++)
450                 for (j=0 ; j<scoreboardlines-1-i ; j++)
451                         if (cl.scores[fragsort[j]].frags < cl.scores[fragsort[j+1]].frags)
452                         {
453                                 k = fragsort[j];
454                                 fragsort[j] = fragsort[j+1];
455                                 fragsort[j+1] = k;
456                         }
457 }
458
459 /*
460 ===============
461 Sbar_SoloScoreboard
462 ===============
463 */
464 void Sbar_SoloScoreboard (void)
465 {
466         char    str[80];
467         int             minutes, seconds, tens, units;
468         int             l;
469
470         sprintf (str,"Monsters:%3i /%3i", cl.stats[STAT_MONSTERS], cl.stats[STAT_TOTALMONSTERS]);
471         Sbar_DrawString (8, 4, str);
472
473         sprintf (str,"Secrets :%3i /%3i", cl.stats[STAT_SECRETS], cl.stats[STAT_TOTALSECRETS]);
474         Sbar_DrawString (8, 12, str);
475
476 // time
477         minutes = cl.time / 60;
478         seconds = cl.time - 60*minutes;
479         tens = seconds / 10;
480         units = seconds - 10*tens;
481         sprintf (str,"Time :%3i:%i%i", minutes, tens, units);
482         Sbar_DrawString (184, 4, str);
483
484 // draw level name
485         l = strlen (cl.levelname);
486         Sbar_DrawString (232 - l*4, 12, cl.levelname);
487 }
488
489 /*
490 ===============
491 Sbar_DrawScoreboard
492 ===============
493 */
494 void Sbar_DrawScoreboard (void)
495 {
496         Sbar_SoloScoreboard ();
497         if (cl.gametype == GAME_DEATHMATCH)
498                 Sbar_DeathmatchOverlay ();
499 }
500
501 //=============================================================================
502
503 // AK to make DrawInventory smaller
504 static void Sbar_DrawWeapon(int nr, float fade, int active)
505 {
506         // width = 300, height = 100
507         const int w_width = 300, w_height = 100, w_space = 10, font_size = 10;
508         const float w_scale = 0.4;
509
510         DrawQ_Pic(vid.conwidth - (w_width + w_space) * w_scale, (w_height + w_space) * w_scale * nr + w_space, sb_weapons[0][nr]->name, w_width * w_scale, w_height * w_scale, (active) ? 1 : 0.6, active ? 1 : 0.6, active ? 1 : 1, fade * sbar_alpha.value, DRAWFLAG_ADDITIVE);
511         DrawQ_String(vid.conwidth - (w_space + font_size ), (w_height + w_space) * w_scale * nr + w_space, va("%i",nr+1), 0, font_size, font_size, 1, 0, 0, fade, 0);
512
513         if (active)
514                 DrawQ_Fill(vid.conwidth - (w_width + w_space) * w_scale, (w_height + w_space) * w_scale * nr + w_space, w_width * w_scale, w_height * w_scale, 0.3, 0.3, 0.3, fade * sbar_alpha.value, DRAWFLAG_ADDITIVE);
515 }
516
517 /*
518 ===============
519 Sbar_DrawInventory
520 ===============
521 */
522 void Sbar_DrawInventory (void)
523 {
524         int i;
525         char num[6];
526         float time;
527         int flashon;
528
529         if (gamemode == GAME_ROGUE)
530         {
531                 if ( cl.stats[STAT_ACTIVEWEAPON] >= RIT_LAVA_NAILGUN )
532                         Sbar_DrawAlphaPic (0, -24, rsb_invbar[0], 0.4);
533                 else
534                         Sbar_DrawAlphaPic (0, -24, rsb_invbar[1], 0.4);
535         }
536         else
537                 Sbar_DrawAlphaPic (0, -24, sb_ibar, 0.4);
538
539         // weapons
540         for (i=0 ; i<7 ; i++)
541         {
542                 if (cl.items & (IT_SHOTGUN<<i) )
543                 {
544                         time = cl.item_gettime[i];
545                         flashon = (int)((cl.time - time)*10);
546                         if (flashon >= 10)
547                         {
548                                 if ( cl.stats[STAT_ACTIVEWEAPON] == (IT_SHOTGUN<<i)  )
549                                         flashon = 1;
550                                 else
551                                         flashon = 0;
552                         }
553                         else
554                                 flashon = (flashon%5) + 2;
555
556                         Sbar_DrawAlphaPic (i*24, -16, sb_weapons[flashon][i], 0.4);
557                 }
558         }
559
560         // MED 01/04/97
561         // hipnotic weapons
562         if (gamemode == GAME_HIPNOTIC)
563         {
564                 int grenadeflashing=0;
565                 for (i=0 ; i<4 ; i++)
566                 {
567                         if (cl.items & (1<<hipweapons[i]) )
568                         {
569                                 time = cl.item_gettime[hipweapons[i]];
570                                 flashon = (int)((cl.time - time)*10);
571                                 if (flashon >= 10)
572                                 {
573                                         if ( cl.stats[STAT_ACTIVEWEAPON] == (1<<hipweapons[i])  )
574                                                 flashon = 1;
575                                         else
576                                                 flashon = 0;
577                                 }
578                                 else
579                                         flashon = (flashon%5) + 2;
580
581                                 // check grenade launcher
582                                 if (i==2)
583                                 {
584                                         if (cl.items & HIT_PROXIMITY_GUN)
585                                         {
586                                                 if (flashon)
587                                                 {
588                                                         grenadeflashing = 1;
589                                                         Sbar_DrawPic (96, -16, hsb_weapons[flashon][2]);
590                                                 }
591                                         }
592                                 }
593                                 else if (i==3)
594                                 {
595                                         if (cl.items & (IT_SHOTGUN<<4))
596                                         {
597                                                 if (!grenadeflashing)
598                                                         Sbar_DrawPic (96, -16, hsb_weapons[flashon][3]);
599                                         }
600                                         else
601                                                 Sbar_DrawPic (96, -16, hsb_weapons[flashon][4]);
602                                 }
603                                 else
604                                         Sbar_DrawPic (176 + (i*24), -16, hsb_weapons[flashon][i]);
605                         }
606                 }
607         }
608
609         if (gamemode == GAME_ROGUE)
610         {
611                 // check for powered up weapon.
612                 if ( cl.stats[STAT_ACTIVEWEAPON] >= RIT_LAVA_NAILGUN )
613                         for (i=0;i<5;i++)
614                                 if (cl.stats[STAT_ACTIVEWEAPON] == (RIT_LAVA_NAILGUN << i))
615                                         Sbar_DrawPic ((i+2)*24, -16, rsb_weapons[i]);
616         }
617
618         // ammo counts
619         for (i=0 ; i<4 ; i++)
620         {
621                 sprintf (num, "%3i",cl.stats[STAT_SHELLS+i] );
622                 if (num[0] != ' ')
623                         Sbar_DrawCharacter ( (6*i+1)*8 - 2, -24, 18 + num[0] - '0');
624                 if (num[1] != ' ')
625                         Sbar_DrawCharacter ( (6*i+2)*8 - 2, -24, 18 + num[1] - '0');
626                 if (num[2] != ' ')
627                         Sbar_DrawCharacter ( (6*i+3)*8 - 2, -24, 18 + num[2] - '0');
628         }
629
630         // items
631         for (i=0 ; i<6 ; i++)
632                 if (cl.items & (1<<(17+i)))
633                 {
634                         //MED 01/04/97 changed keys
635                         if (gamemode != GAME_HIPNOTIC || (i>1))
636                                 Sbar_DrawPic (192 + i*16, -16, sb_items[i]);
637                 }
638
639         //MED 01/04/97 added hipnotic items
640         // hipnotic items
641         if (gamemode == GAME_HIPNOTIC)
642         {
643                 for (i=0 ; i<2 ; i++)
644                         if (cl.items & (1<<(24+i)))
645                                 Sbar_DrawPic (288 + i*16, -16, hsb_items[i]);
646         }
647
648         if (gamemode == GAME_ROGUE)
649         {
650                 // new rogue items
651                 for (i=0 ; i<2 ; i++)
652                         if (cl.items & (1<<(29+i)))
653                                 Sbar_DrawPic (288 + i*16, -16, rsb_items[i]);
654         }
655         else
656         {
657                 // sigils
658                 for (i=0 ; i<4 ; i++)
659                         if (cl.items & (1<<(28+i)))
660                                 Sbar_DrawPic (320-32 + i*8, -16, sb_sigil[i]);
661         }
662 }
663
664 //=============================================================================
665
666 /*
667 ===============
668 Sbar_DrawFrags
669 ===============
670 */
671 void Sbar_DrawFrags (void)
672 {
673         int i, k, l, x, f;
674         char num[12];
675         scoreboard_t *s;
676         qbyte *c;
677
678         Sbar_SortFrags ();
679
680         // draw the text
681         l = scoreboardlines <= 4 ? scoreboardlines : 4;
682
683         x = 23 * 8;
684
685         for (i = 0;i < l;i++)
686         {
687                 k = fragsort[i];
688                 s = &cl.scores[k];
689                 if (!s->name[0])
690                         continue;
691
692                 // draw background
693                 c = (qbyte *)&palette_complete[(s->colors & 0xf0) + 8];
694                 DrawQ_Fill (sbar_x + x + 10, sbar_y     - 23, 28, 4, c[0] * (1.0f / 255.0f), c[1] * (1.0f / 255.0f), c[2] * (1.0f / 255.0f), c[3] * (1.0f / 255.0f) * sbar_alpha.value, 0);
695                 c = (qbyte *)&palette_complete[((s->colors & 15)<<4) + 8];
696                 DrawQ_Fill (sbar_x + x + 10, sbar_y + 4 - 23, 28, 3, c[0] * (1.0f / 255.0f), c[1] * (1.0f / 255.0f), c[2] * (1.0f / 255.0f), c[3] * (1.0f / 255.0f) * sbar_alpha.value, 0);
697
698                 // draw number
699                 f = s->frags;
700                 sprintf (num, "%3i",f);
701
702                 Sbar_DrawCharacter (x +  8, -24, num[0]);
703                 Sbar_DrawCharacter (x + 16, -24, num[1]);
704                 Sbar_DrawCharacter (x + 24, -24, num[2]);
705
706                 if (k == cl.viewentity - 1)
707                 {
708                         Sbar_DrawCharacter ( x      + 2, -24, 16);
709                         Sbar_DrawCharacter ( x + 32 - 4, -24, 17);
710                 }
711                 x += 32;
712         }
713 }
714
715 //=============================================================================
716
717
718 /*
719 ===============
720 Sbar_DrawFace
721 ===============
722 */
723 void Sbar_DrawFace (void)
724 {
725         int f;
726
727 // PGM 01/19/97 - team color drawing
728 // PGM 03/02/97 - fixed so color swatch only appears in CTF modes
729         if (gamemode == GAME_ROGUE && !cl.islocalgame && (teamplay.integer > 3) && (teamplay.integer < 7))
730         {
731                 char num[12];
732                 scoreboard_t *s;
733                 qbyte *c;
734
735                 s = &cl.scores[cl.viewentity - 1];
736                 // draw background
737                 Sbar_DrawPic (112, 0, rsb_teambord);
738                 c = (qbyte *)&palette_complete[(s->colors & 0xf0) + 8];
739                 DrawQ_Fill (sbar_x + 113, vid.conheight-SBAR_HEIGHT+3, 22, 9, c[0] * (1.0f / 255.0f), c[1] * (1.0f / 255.0f), c[2] * (1.0f / 255.0f), c[3] * (1.0f / 255.0f) * sbar_alpha.value, 0);
740                 c = (qbyte *)&palette_complete[((s->colors & 15)<<4) + 8];
741                 DrawQ_Fill (sbar_x + 113, vid.conheight-SBAR_HEIGHT+12, 22, 9, c[0] * (1.0f / 255.0f), c[1] * (1.0f / 255.0f), c[2] * (1.0f / 255.0f), c[3] * (1.0f / 255.0f) * sbar_alpha.value, 0);
742
743                 // draw number
744                 f = s->frags;
745                 sprintf (num, "%3i",f);
746
747                 if ((s->colors & 0xf0)==0)
748                 {
749                         if (num[0] != ' ')
750                                 Sbar_DrawCharacter(109, 3, 18 + num[0] - '0');
751                         if (num[1] != ' ')
752                                 Sbar_DrawCharacter(116, 3, 18 + num[1] - '0');
753                         if (num[2] != ' ')
754                                 Sbar_DrawCharacter(123, 3, 18 + num[2] - '0');
755                 }
756                 else
757                 {
758                         Sbar_DrawCharacter ( 109, 3, num[0]);
759                         Sbar_DrawCharacter ( 116, 3, num[1]);
760                         Sbar_DrawCharacter ( 123, 3, num[2]);
761                 }
762
763                 return;
764         }
765 // PGM 01/19/97 - team color drawing
766
767         if ( (cl.items & (IT_INVISIBILITY | IT_INVULNERABILITY) ) == (IT_INVISIBILITY | IT_INVULNERABILITY) )
768                 Sbar_DrawPic (112, 0, sb_face_invis_invuln);
769         else if (cl.items & IT_QUAD)
770                 Sbar_DrawPic (112, 0, sb_face_quad );
771         else if (cl.items & IT_INVISIBILITY)
772                 Sbar_DrawPic (112, 0, sb_face_invis );
773         else if (cl.items & IT_INVULNERABILITY)
774                 Sbar_DrawPic (112, 0, sb_face_invuln);
775         else
776         {
777                 f = cl.stats[STAT_HEALTH] / 20;
778                 f = bound(0, f, 4);
779                 Sbar_DrawPic (112, 0, sb_faces[f][cl.time <= cl.faceanimtime]);
780         }
781 }
782
783 void Sbar_ShowFPS(void)
784 {
785         if (showfps.integer)
786         {
787                 int calc;
788                 char temp[32];
789                 float fps_x, fps_y, fps_scalex, fps_scaley;
790                 if (showfps.integer > 1)
791                 {
792                         static double currtime, frametimes[32];
793                         double newtime, total;
794                         int count, i;
795                         static int framecycle = 0;
796
797                         newtime = Sys_DoubleTime();
798                         frametimes[framecycle] = newtime - currtime;
799                         total = 0;
800                         count = 0;
801                         while(total < 0.2 && count < 32 && frametimes[i = (framecycle - count) & 31])
802                         {
803                                 total += frametimes[i];
804                                 count++;
805                         }
806                         framecycle++;
807                         framecycle &= 31;
808                         if (showfps.integer == 2)
809                                 calc = (int) (((double) count / total) + 0.5);
810                         else // showfps 3, rapid update
811                                 calc = (int) ((1.0 / (newtime - currtime)) + 0.5);
812                         currtime = newtime;
813                 }
814                 else
815                 {
816                         static double nexttime = 0, lasttime = 0;
817                         static int framerate = 0, framecount = 0;
818                         double newtime;
819                         newtime = Sys_DoubleTime();
820                         if (newtime < nexttime)
821                                 framecount++;
822                         else
823                         {
824                                 framerate = (int) (framecount / (newtime - lasttime) + 0.5);
825                                 lasttime = newtime;
826                                 nexttime = lasttime + 0.2;
827                                 framecount = 1;
828                         }
829                         calc = framerate;
830                 }
831                 sprintf(temp, "%4i", calc);
832                 fps_scalex = 12;
833                 fps_scaley = 12;
834                 fps_x = vid.conwidth - (fps_scalex * strlen(temp));
835                 fps_y = vid.conheight - sb_lines/* - 8*/; // yes this might draw over the sbar
836                 if (fps_y > vid.conheight - fps_scaley)
837                         fps_y = vid.conheight - fps_scaley;
838                 DrawQ_Fill(fps_x, fps_y, fps_scalex * strlen(temp), fps_scaley, 0, 0, 0, 0.5 * sbar_alpha.value, 0);
839                 DrawQ_String(fps_x, fps_y, temp, 0, fps_scalex, fps_scaley, 1, 1, 1, 1 * sbar_alpha.value, 0);
840         }
841 }
842
843 /*
844 ===============
845 Sbar_Draw
846 ===============
847 */
848 void Sbar_Draw (void)
849 {
850         if (scr_con_current == vid.conheight)
851                 return;         // console is full screen
852
853         if (cl.intermission == 1)
854         {
855                 Sbar_IntermissionOverlay();
856                 return;
857         }
858         else if (cl.intermission == 2)
859         {
860                 Sbar_FinaleOverlay();
861                 return;
862         }
863
864         if (gamemode == GAME_SOM)
865         {
866                 if (sb_showscores || cl.stats[STAT_HEALTH] <= 0)
867                         Sbar_DrawScoreboard ();
868                 else if (sb_lines)
869                 {
870                         // this is the top left of the sbar area
871                         sbar_x = 0;
872                         sbar_y = vid.conheight - 24*3;
873
874                         // armor
875                         if (cl.stats[STAT_ARMOR])
876                         {
877                                 if (cl.items & IT_ARMOR3)
878                                         Sbar_DrawPic(0, 0, somsb_armor[2]);
879                                 else if (cl.items & IT_ARMOR2)
880                                         Sbar_DrawPic(0, 0, somsb_armor[1]);
881                                 else if (cl.items & IT_ARMOR1)
882                                         Sbar_DrawPic(0, 0, somsb_armor[0]);
883                                 Sbar_DrawNum(24, 0, cl.stats[STAT_ARMOR], 3, cl.stats[STAT_ARMOR] <= 25);
884                         }
885
886                         // health
887                         Sbar_DrawPic(0, 24, somsb_health);
888                         Sbar_DrawNum(24, 24, cl.stats[STAT_HEALTH], 3, cl.stats[STAT_HEALTH] <= 25);
889
890                         // ammo icon
891                         if (cl.items & IT_SHELLS)
892                                 Sbar_DrawPic(0, 48, somsb_ammo[0]);
893                         else if (cl.items & IT_NAILS)
894                                 Sbar_DrawPic(0, 48, somsb_ammo[1]);
895                         else if (cl.items & IT_ROCKETS)
896                                 Sbar_DrawPic(0, 48, somsb_ammo[2]);
897                         else if (cl.items & IT_CELLS)
898                                 Sbar_DrawPic(0, 48, somsb_ammo[3]);
899                         Sbar_DrawNum(24, 48, cl.stats[STAT_AMMO], 3, false);
900                         if (cl.stats[STAT_SHELLS])
901                                 Sbar_DrawNum(24 + 3*24, 48, cl.stats[STAT_SHELLS], 1, true);
902                 }
903         }
904         else if (gamemode == GAME_NEXUIZ)
905         {
906                 sbar_y = vid.conheight - 47;
907                 sbar_x = (vid.conwidth - 640)/2;
908
909                 if (sb_showscores || cl.stats[STAT_HEALTH] <= 0)
910                 {
911                         Sbar_DrawAlphaPic (0, 0, sb_scorebar, 0.4);
912                         Sbar_DrawScoreboard ();
913                 }
914                 else if (sb_lines)
915                 {
916                         int i;
917                         double time;
918                         float fade;
919
920                         // we have a max time 2s (min time = 0)
921                         if ((time = cl.time - cl.weapontime) < 2)
922                         {
923                                 fade = (1.0 - 0.5 * time);
924                                 fade *= fade;
925                                 for (i = 0; i < 8;i++)
926                                 {
927                                         if (!(cl.items & (1 << i)))
928                                                 continue;
929                                         Sbar_DrawWeapon(i + 1, fade, (i == cl.stats[STAT_ACTIVEWEAPON]));
930                                 }
931                         
932                                 if((cl.items & (1<<12)))
933                                         Sbar_DrawWeapon(0, fade, (cl.stats[STAT_ACTIVEWEAPON] == 12));
934                         }
935
936                         if (!cl.islocalgame)
937                                 Sbar_DrawFrags ();
938
939                         if (sb_lines > 24)
940                                 Sbar_DrawAlphaPic (0, 0, sb_sbar, sbar_alpha.value);
941                         else
942                                 Sbar_DrawAlphaPic (0, 0, sb_sbar_minimal, sbar_alpha.value);
943
944                         // special items
945                         if (cl.items & IT_INVULNERABILITY)
946                         {
947                                 Sbar_DrawNum (36, 0, 666, 3, 1);
948                                 Sbar_DrawPic (0, 0, sb_disc);
949                         }
950
951                         // armor
952                         Sbar_DrawXNum ((340-3*24), 12, cl.stats[STAT_ARMOR], 3, 24, 0.6,0.7,0.8,1,0);
953
954                         // health
955                         if(cl.stats[STAT_HEALTH] > 100)
956                                 Sbar_DrawXNum((154-3*24),12,cl.stats[STAT_HEALTH],3,24,1,1,1,1,0);
957                         else if(cl.stats[STAT_HEALTH] <= 25 && cl.time - (int)cl.time > 0.5)
958                                 Sbar_DrawXNum((154-3*24),12,cl.stats[STAT_HEALTH],3,24,0.7,0,0,1,0);
959                         else
960                                 Sbar_DrawXNum((154-3*24),12,cl.stats[STAT_HEALTH],3,24,0.6,0.7,0.8,1,0);
961
962                         // AK dont draw ammo for the laser
963                         if(cl.stats[STAT_ACTIVEWEAPON] != 12)
964                         {
965                                 if (cl.items & NEX_IT_SHELLS)
966                                         Sbar_DrawPic (519, 0, sb_ammo[0]);
967                                 else if (cl.items & NEX_IT_BULLETS)
968                                         Sbar_DrawPic (519, 0, sb_ammo[1]);
969                                 else if (cl.items & NEX_IT_ROCKETS)
970                                         Sbar_DrawPic (519, 0, sb_ammo[2]);
971                                 else if (cl.items & NEX_IT_CELLS)
972                                         Sbar_DrawPic (519, 0, sb_ammo[3]);
973
974                                 if(cl.stats[STAT_AMMO] <= 10)
975                                         Sbar_DrawXNum ((519-3*24), 12, cl.stats[STAT_AMMO], 3, 24, 0.7, 0,0,1,0);
976                                 else
977                                         Sbar_DrawXNum ((519-3*24), 12, cl.stats[STAT_AMMO], 3, 24, 0.6, 0.7,0.8,1,0);
978
979                         }
980
981                         if (sb_lines > 24)
982                                 DrawQ_Pic(sbar_x,sbar_y,sb_sbar_overlay->name,0,0,1,1,1,1,DRAWFLAG_MODULATE);
983                 }
984
985                 if (vid.conwidth > 320 && cl.gametype == GAME_DEATHMATCH)
986                         Sbar_MiniDeathmatchOverlay (0, 0);
987         }
988         else // Quake and others
989         {
990                 sbar_y = vid.conheight - SBAR_HEIGHT;
991                 if (cl.gametype == GAME_DEATHMATCH)
992                         sbar_x = 0;
993                 else
994                         sbar_x = (vid.conwidth - 320)/2;
995
996                 if (sb_lines > 24)
997                 {
998                         if (gamemode != GAME_GOODVSBAD2)
999                                 Sbar_DrawInventory ();
1000                         if (!cl.islocalgame)
1001                                 Sbar_DrawFrags ();
1002                 }
1003
1004                 if (sb_showscores || cl.stats[STAT_HEALTH] <= 0)
1005                 {
1006                         if (gamemode != GAME_GOODVSBAD2)
1007                                 Sbar_DrawAlphaPic (0, 0, sb_scorebar, 0.4);
1008                         Sbar_DrawScoreboard ();
1009                 }
1010                 else if (sb_lines)
1011                 {
1012                         Sbar_DrawAlphaPic (0, 0, sb_sbar, 0.4);
1013
1014                         // keys (hipnotic only)
1015                         //MED 01/04/97 moved keys here so they would not be overwritten
1016                         if (gamemode == GAME_HIPNOTIC)
1017                         {
1018                                 if (cl.items & IT_KEY1)
1019                                         Sbar_DrawPic (209, 3, sb_items[0]);
1020                                 if (cl.items & IT_KEY2)
1021                                         Sbar_DrawPic (209, 12, sb_items[1]);
1022                         }
1023                         // armor
1024                         if (gamemode != GAME_GOODVSBAD2)
1025                         {
1026                                 if (cl.items & IT_INVULNERABILITY)
1027                                 {
1028                                         Sbar_DrawNum (24, 0, 666, 3, 1);
1029                                         Sbar_DrawPic (0, 0, sb_disc);
1030                                 }
1031                                 else
1032                                 {
1033                                         if (gamemode == GAME_ROGUE)
1034                                         {
1035                                                 Sbar_DrawNum (24, 0, cl.stats[STAT_ARMOR], 3, cl.stats[STAT_ARMOR] <= 25);
1036                                                 if (cl.items & RIT_ARMOR3)
1037                                                         Sbar_DrawPic (0, 0, sb_armor[2]);
1038                                                 else if (cl.items & RIT_ARMOR2)
1039                                                         Sbar_DrawPic (0, 0, sb_armor[1]);
1040                                                 else if (cl.items & RIT_ARMOR1)
1041                                                         Sbar_DrawPic (0, 0, sb_armor[0]);
1042                                         }
1043                                         else
1044                                         {
1045                                                 Sbar_DrawNum (24, 0, cl.stats[STAT_ARMOR], 3, cl.stats[STAT_ARMOR] <= 25);
1046                                                 if (cl.items & IT_ARMOR3)
1047                                                         Sbar_DrawPic (0, 0, sb_armor[2]);
1048                                                 else if (cl.items & IT_ARMOR2)
1049                                                         Sbar_DrawPic (0, 0, sb_armor[1]);
1050                                                 else if (cl.items & IT_ARMOR1)
1051                                                         Sbar_DrawPic (0, 0, sb_armor[0]);
1052                                         }
1053                                 }
1054                         }
1055
1056                         // face
1057                         Sbar_DrawFace ();
1058
1059                         // health
1060                         Sbar_DrawNum (154, 0, cl.stats[STAT_HEALTH], 3, cl.stats[STAT_HEALTH] <= 25);
1061
1062                         // ammo icon
1063                         if (gamemode == GAME_ROGUE)
1064                         {
1065                                 if (cl.items & RIT_SHELLS)
1066                                         Sbar_DrawPic (224, 0, sb_ammo[0]);
1067                                 else if (cl.items & RIT_NAILS)
1068                                         Sbar_DrawPic (224, 0, sb_ammo[1]);
1069                                 else if (cl.items & RIT_ROCKETS)
1070                                         Sbar_DrawPic (224, 0, sb_ammo[2]);
1071                                 else if (cl.items & RIT_CELLS)
1072                                         Sbar_DrawPic (224, 0, sb_ammo[3]);
1073                                 else if (cl.items & RIT_LAVA_NAILS)
1074                                         Sbar_DrawPic (224, 0, rsb_ammo[0]);
1075                                 else if (cl.items & RIT_PLASMA_AMMO)
1076                                         Sbar_DrawPic (224, 0, rsb_ammo[1]);
1077                                 else if (cl.items & RIT_MULTI_ROCKETS)
1078                                         Sbar_DrawPic (224, 0, rsb_ammo[2]);
1079                         }
1080                         else
1081                         {
1082                                 if (cl.items & IT_SHELLS)
1083                                         Sbar_DrawPic (224, 0, sb_ammo[0]);
1084                                 else if (cl.items & IT_NAILS)
1085                                         Sbar_DrawPic (224, 0, sb_ammo[1]);
1086                                 else if (cl.items & IT_ROCKETS)
1087                                         Sbar_DrawPic (224, 0, sb_ammo[2]);
1088                                 else if (cl.items & IT_CELLS)
1089                                         Sbar_DrawPic (224, 0, sb_ammo[3]);
1090                         }
1091
1092                         Sbar_DrawNum (248, 0, cl.stats[STAT_AMMO], 3, cl.stats[STAT_AMMO] <= 10);
1093
1094                 }
1095
1096                 if (vid.conwidth > 320 && cl.gametype == GAME_DEATHMATCH)
1097                         Sbar_MiniDeathmatchOverlay (324, vid.conheight - sb_lines);
1098         }
1099
1100         Sbar_ShowFPS();
1101
1102         R_Draw2DCrosshair();
1103 }
1104
1105 //=============================================================================
1106
1107 /*
1108 ==================
1109 Sbar_DeathmatchOverlay
1110
1111 ==================
1112 */
1113 float Sbar_PrintScoreboardItem(scoreboard_t *s, float x, float y)
1114 {
1115         qbyte *c;
1116         if (s->name[0] || s->frags || s->colors || (s - cl.scores) == cl.playerentity - 1)
1117         {
1118                 // draw colors behind score
1119                 c = (qbyte *)&palette_complete[(s->colors & 0xf0) + 8];
1120                 DrawQ_Fill(x + 8, y+1, 32, 3, c[0] * (1.0f / 255.0f), c[1] * (1.0f / 255.0f), c[2] * (1.0f / 255.0f), c[3] * (1.0f / 255.0f) * sbar_alpha.value, 0);
1121                 c = (qbyte *)&palette_complete[((s->colors & 15)<<4) + 8];
1122                 DrawQ_Fill(x + 8, y+4, 32, 3, c[0] * (1.0f / 255.0f), c[1] * (1.0f / 255.0f), c[2] * (1.0f / 255.0f), c[3] * (1.0f / 255.0f) * sbar_alpha.value, 0);
1123                 // print the text
1124                 DrawQ_String(x, y, va("%c%4i %s", (s - cl.scores) == cl.playerentity - 1 ? 13 : ' ', (int) s->frags, s->name), 0, 8, 8, 1, 1, 1, 1 * sbar_alpha.value, 0);
1125                 return 8;
1126         }
1127         else
1128                 return 0;
1129 }
1130
1131 void Sbar_DeathmatchOverlay (void)
1132 {
1133         int i, x, y;
1134         cachepic_t *pic;
1135
1136         pic = Draw_CachePic ("gfx/ranking.lmp");
1137         DrawQ_Pic ((vid.conwidth - pic->width)/2, 8, "gfx/ranking.lmp", 0, 0, 1, 1, 1, 1 * sbar_alpha.value, 0);
1138
1139         // scores
1140         Sbar_SortFrags ();
1141         // draw the text
1142         x = (vid.conwidth - (6 + 15) * 8) / 2;
1143         y = 40;
1144         for (i = 0;i < scoreboardlines && y < vid.conheight;i++)
1145                 y += Sbar_PrintScoreboardItem(cl.scores + fragsort[i], x, y);
1146 }
1147
1148 /*
1149 ==================
1150 Sbar_DeathmatchOverlay
1151
1152 ==================
1153 */
1154 void Sbar_MiniDeathmatchOverlay (int x, int y)
1155 {
1156         int i, numlines;
1157
1158         // decide where to print
1159
1160         numlines = (vid.conheight - y) / 8;
1161         // give up if there isn't room
1162         if (x + (6 + 15) * 8 > vid.conwidth || numlines < 1)
1163                 return;
1164
1165         // scores
1166         Sbar_SortFrags ();
1167
1168         //find us
1169         for (i = 0; i < scoreboardlines; i++)
1170                 if (fragsort[i] == cl.playerentity - 1)
1171                         break;
1172
1173         if (i == scoreboardlines) // we're not there
1174                 i = 0;
1175         else // figure out start
1176         {
1177                 i -= numlines/2;
1178                 i = bound(0, i, scoreboardlines - numlines);
1179         }
1180
1181         for (;i < scoreboardlines && y < vid.conheight;i++)
1182                 y += Sbar_PrintScoreboardItem(cl.scores + fragsort[i], x, y);
1183 }
1184
1185 /*
1186 ==================
1187 Sbar_IntermissionOverlay
1188
1189 ==================
1190 */
1191 void Sbar_IntermissionOverlay (void)
1192 {
1193         int             dig;
1194         int             num;
1195
1196         if (cl.gametype == GAME_DEATHMATCH)
1197         {
1198                 Sbar_DeathmatchOverlay ();
1199                 return;
1200         }
1201
1202         sbar_x = (vid.conwidth - 320) >> 1;
1203         sbar_y = (vid.conheight - 200) >> 1;
1204
1205         DrawQ_Pic (sbar_x + 64, sbar_y + 24, "gfx/complete.lmp", 0, 0, 1, 1, 1, 1 * sbar_alpha.value, 0);
1206         DrawQ_Pic (sbar_x + 0, sbar_y + 56, "gfx/inter.lmp", 0, 0, 1, 1, 1, 1 * sbar_alpha.value, 0);
1207
1208 // time
1209         dig = cl.completed_time/60;
1210         Sbar_DrawNum (160, 64, dig, 3, 0);
1211         num = cl.completed_time - dig*60;
1212         Sbar_DrawPic (234,64,sb_colon);
1213         Sbar_DrawPic (246,64,sb_nums[0][num/10]);
1214         Sbar_DrawPic (266,64,sb_nums[0][num%10]);
1215
1216         Sbar_DrawNum (160, 104, cl.stats[STAT_SECRETS], 3, 0);
1217         Sbar_DrawPic (232, 104, sb_slash);
1218         Sbar_DrawNum (240, 104, cl.stats[STAT_TOTALSECRETS], 3, 0);
1219
1220         Sbar_DrawNum (160, 144, cl.stats[STAT_MONSTERS], 3, 0);
1221         Sbar_DrawPic (232, 144, sb_slash);
1222         Sbar_DrawNum (240, 144, cl.stats[STAT_TOTALMONSTERS], 3, 0);
1223
1224 }
1225
1226
1227 /*
1228 ==================
1229 Sbar_FinaleOverlay
1230
1231 ==================
1232 */
1233 void Sbar_FinaleOverlay (void)
1234 {
1235         cachepic_t      *pic;
1236
1237         pic = Draw_CachePic ("gfx/finale.lmp");
1238         DrawQ_Pic((vid.conwidth - pic->width)/2, 16, "gfx/finale.lmp", 0, 0, 1, 1, 1, 1 * sbar_alpha.value, 0);
1239 }
1240