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