-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsbar.c
1495 lines (1280 loc) · 33.2 KB
/
sbar.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
Copyright (C) 1996-1997 Id Software, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// sbar.c -- status bar code
#include "quakedef.h"
int sb_updates; // if >= vid.numpages, no update needed
#define STAT_MINUS 10 // num frame for '-' stats digit
qpic_t *sb_nums[2][11];
qpic_t *sb_colon, *sb_slash;
qpic_t *sb_ibar;
qpic_t *sb_sbar;
qpic_t *sb_scorebar;
qpic_t *sb_weapons[7][8]; // 0 is active, 1 is owned, 2-5 are flashes
qpic_t *sb_ammo[4];
qpic_t *sb_sigil[4];
qpic_t *sb_armor[3];
qpic_t *sb_items[32];
qpic_t *sb_faces[7][2]; // 0 is gibbed, 1 is dead, 2-6 are alive
// 0 is static, 1 is temporary animation
qpic_t *sb_face_invis;
qpic_t *sb_face_quad;
qpic_t *sb_face_invuln;
qpic_t *sb_face_invis_invuln;
qboolean sb_showscores;
int sb_lines; // scan lines to draw
qpic_t *rsb_invbar[2];
qpic_t *rsb_weapons[5];
qpic_t *rsb_items[2];
qpic_t *rsb_ammo[3];
qpic_t *rsb_teambord; // PGM 01/19/97 - team color border
//MED 01/04/97 added two more weapons + 3 alternates for grenade launcher
qpic_t *hsb_weapons[7][5]; // 0 is active, 1 is owned, 2-5 are flashes
//MED 01/04/97 added array to simplify weapon parsing
int hipweapons[4] = {HIT_LASER_CANNON_BIT,HIT_MJOLNIR_BIT,4,HIT_PROXIMITY_GUN_BIT};
//MED 01/04/97 added hipnotic items array
qpic_t *hsb_items[2];
void Sbar_MiniDeathmatchOverlay (void);
void Sbar_IntermissionNumber (int x, int y, int num, int digits, int color);
void Sbar_DeathmatchOverlay (void);
int sbar_xofs;
cvar_t scr_sbar = {"scr_sbar", "0", CVAR_ARCHIVE};
cvar_t scr_centersbar = {"scr_centersbar", "1", CVAR_ARCHIVE};
cvar_t scr_overdrawsbar = {"scr_overdrawsbar", "1", CVAR_ARCHIVE};
cvar_t scr_sbaralpha = {"scr_sbaralpha", "1", CVAR_ARCHIVE};
/*
===============
Sbar_ShowScores
Tab key down
===============
*/
void Sbar_ShowScores (void)
{
if (sb_showscores)
return;
sb_showscores = true;
sb_updates = 0;
}
/*
===============
Sbar_DontShowScores
Tab key up
===============
*/
void Sbar_DontShowScores (void)
{
sb_showscores = false;
sb_updates = 0;
}
/*
===============
Sbar_Changed
===============
*/
void Sbar_Changed (void)
{
sb_updates = 0; // update next frame
}
/*
===============
Sbar_Init
===============
*/
void Sbar_Init (void)
{
int i;
for (i=0 ; i<10 ; i++)
{
sb_nums[0][i] = Draw_PicFromWad (va("num_%i",i));
sb_nums[1][i] = Draw_PicFromWad (va("anum_%i",i));
}
sb_nums[0][10] = Draw_PicFromWad ("num_minus");
sb_nums[1][10] = Draw_PicFromWad ("anum_minus");
sb_colon = Draw_PicFromWad ("num_colon");
sb_slash = Draw_PicFromWad ("num_slash");
sb_weapons[0][0] = Draw_PicFromWad ("inv_shotgun");
sb_weapons[0][1] = Draw_PicFromWad ("inv_sshotgun");
sb_weapons[0][2] = Draw_PicFromWad ("inv_nailgun");
sb_weapons[0][3] = Draw_PicFromWad ("inv_snailgun");
sb_weapons[0][4] = Draw_PicFromWad ("inv_rlaunch");
sb_weapons[0][5] = Draw_PicFromWad ("inv_srlaunch");
sb_weapons[0][6] = Draw_PicFromWad ("inv_lightng");
sb_weapons[1][0] = Draw_PicFromWad ("inv2_shotgun");
sb_weapons[1][1] = Draw_PicFromWad ("inv2_sshotgun");
sb_weapons[1][2] = Draw_PicFromWad ("inv2_nailgun");
sb_weapons[1][3] = Draw_PicFromWad ("inv2_snailgun");
sb_weapons[1][4] = Draw_PicFromWad ("inv2_rlaunch");
sb_weapons[1][5] = Draw_PicFromWad ("inv2_srlaunch");
sb_weapons[1][6] = Draw_PicFromWad ("inv2_lightng");
for (i=0 ; i<5 ; i++)
{
sb_weapons[2+i][0] = Draw_PicFromWad (va("inva%i_shotgun",i+1));
sb_weapons[2+i][1] = Draw_PicFromWad (va("inva%i_sshotgun",i+1));
sb_weapons[2+i][2] = Draw_PicFromWad (va("inva%i_nailgun",i+1));
sb_weapons[2+i][3] = Draw_PicFromWad (va("inva%i_snailgun",i+1));
sb_weapons[2+i][4] = Draw_PicFromWad (va("inva%i_rlaunch",i+1));
sb_weapons[2+i][5] = Draw_PicFromWad (va("inva%i_srlaunch",i+1));
sb_weapons[2+i][6] = Draw_PicFromWad (va("inva%i_lightng",i+1));
}
sb_ammo[0] = Draw_PicFromWad ("sb_shells");
sb_ammo[1] = Draw_PicFromWad ("sb_nails");
sb_ammo[2] = Draw_PicFromWad ("sb_rocket");
sb_ammo[3] = Draw_PicFromWad ("sb_cells");
sb_armor[0] = Draw_PicFromWad ("sb_armor1");
sb_armor[1] = Draw_PicFromWad ("sb_armor2");
sb_armor[2] = Draw_PicFromWad ("sb_armor3");
sb_items[0] = Draw_PicFromWad ("sb_key1");
sb_items[1] = Draw_PicFromWad ("sb_key2");
sb_items[2] = Draw_PicFromWad ("sb_invis");
sb_items[3] = Draw_PicFromWad ("sb_invuln");
sb_items[4] = Draw_PicFromWad ("sb_suit");
sb_items[5] = Draw_PicFromWad ("sb_quad");
sb_sigil[0] = Draw_PicFromWad ("sb_sigil1");
sb_sigil[1] = Draw_PicFromWad ("sb_sigil2");
sb_sigil[2] = Draw_PicFromWad ("sb_sigil3");
sb_sigil[3] = Draw_PicFromWad ("sb_sigil4");
sb_faces[4][0] = Draw_PicFromWad ("face1");
sb_faces[4][1] = Draw_PicFromWad ("face_p1");
sb_faces[3][0] = Draw_PicFromWad ("face2");
sb_faces[3][1] = Draw_PicFromWad ("face_p2");
sb_faces[2][0] = Draw_PicFromWad ("face3");
sb_faces[2][1] = Draw_PicFromWad ("face_p3");
sb_faces[1][0] = Draw_PicFromWad ("face4");
sb_faces[1][1] = Draw_PicFromWad ("face_p4");
sb_faces[0][0] = Draw_PicFromWad ("face5");
sb_faces[0][1] = Draw_PicFromWad ("face_p5");
sb_face_invis = Draw_PicFromWad ("face_invis");
sb_face_invuln = Draw_PicFromWad ("face_invul2");
sb_face_invis_invuln = Draw_PicFromWad ("face_inv2");
sb_face_quad = Draw_PicFromWad ("face_quad");
Cvar_RegisterVariable (&scr_sbar);
Cvar_RegisterVariable (&scr_centersbar);
Cvar_RegisterVariable (&scr_overdrawsbar);
Cvar_RegisterVariable (&scr_sbaralpha);
Cmd_AddCommand ("+showscores", Sbar_ShowScores);
Cmd_AddCommand ("-showscores", Sbar_DontShowScores);
sb_sbar = Draw_PicFromWad ("sbar");
sb_ibar = Draw_PicFromWad ("ibar");
sb_scorebar = Draw_PicFromWad ("scorebar");
//MED 01/04/97 added new hipnotic weapons
if (hipnotic)
{
hsb_weapons[0][0] = Draw_PicFromWad ("inv_laser");
hsb_weapons[0][1] = Draw_PicFromWad ("inv_mjolnir");
hsb_weapons[0][2] = Draw_PicFromWad ("inv_gren_prox");
hsb_weapons[0][3] = Draw_PicFromWad ("inv_prox_gren");
hsb_weapons[0][4] = Draw_PicFromWad ("inv_prox");
hsb_weapons[1][0] = Draw_PicFromWad ("inv2_laser");
hsb_weapons[1][1] = Draw_PicFromWad ("inv2_mjolnir");
hsb_weapons[1][2] = Draw_PicFromWad ("inv2_gren_prox");
hsb_weapons[1][3] = Draw_PicFromWad ("inv2_prox_gren");
hsb_weapons[1][4] = Draw_PicFromWad ("inv2_prox");
for (i=0 ; i<5 ; i++)
{
hsb_weapons[2+i][0] = Draw_PicFromWad (va("inva%i_laser",i+1));
hsb_weapons[2+i][1] = Draw_PicFromWad (va("inva%i_mjolnir",i+1));
hsb_weapons[2+i][2] = Draw_PicFromWad (va("inva%i_gren_prox",i+1));
hsb_weapons[2+i][3] = Draw_PicFromWad (va("inva%i_prox_gren",i+1));
hsb_weapons[2+i][4] = Draw_PicFromWad (va("inva%i_prox",i+1));
}
hsb_items[0] = Draw_PicFromWad ("sb_wsuit");
hsb_items[1] = Draw_PicFromWad ("sb_eshld");
}
if (rogue)
{
rsb_invbar[0] = Draw_PicFromWad ("r_invbar1");
rsb_invbar[1] = Draw_PicFromWad ("r_invbar2");
rsb_weapons[0] = Draw_PicFromWad ("r_lava");
rsb_weapons[1] = Draw_PicFromWad ("r_superlava");
rsb_weapons[2] = Draw_PicFromWad ("r_gren");
rsb_weapons[3] = Draw_PicFromWad ("r_multirock");
rsb_weapons[4] = Draw_PicFromWad ("r_plasma");
rsb_items[0] = Draw_PicFromWad ("r_shield1");
rsb_items[1] = Draw_PicFromWad ("r_agrav1");
// PGM 01/19/97 - team color border
rsb_teambord = Draw_PicFromWad ("r_teambord");
// PGM 01/19/97 - team color border
rsb_ammo[0] = Draw_PicFromWad ("r_ammolava");
rsb_ammo[1] = Draw_PicFromWad ("r_ammomulti");
rsb_ammo[2] = Draw_PicFromWad ("r_ammoplasma");
}
}
//=============================================================================
// drawing routines are relative to the status bar location
/*
=============
Sbar_DrawPic
=============
*/
void Sbar_DrawPic (int x, int y, qpic_t *pic)
{
Draw_Pic (x + sbar_xofs, y + (vid.height-SBAR_HEIGHT), pic);
}
/*
=============
Sbar_DrawPicAlpha
=============
*/
void Sbar_DrawPicAlpha (int x, int y, qpic_t *pic)
{
float alpha;
alpha = CLAMP(0.0, scr_sbaralpha.value, 1.0);
if (!scr_overdrawsbar.value)
Draw_Pic (x + sbar_xofs, y + (vid.height-SBAR_HEIGHT), pic);
else
Draw_AlphaPic (x + sbar_xofs, y + (vid.height-SBAR_HEIGHT), pic, alpha);
}
/*
=============
Sbar_DrawSubPic
=============
JACK: Draws a portion of the picture in the status bar.
*/
void Sbar_DrawSubPic (int x, int y, qpic_t *pic, int srcx, int srcy, int width, int height)
{
Draw_SubPic (x, y + (vid.height-SBAR_HEIGHT), pic, srcx, srcy, width, height);
}
/*
=============
Sbar_DrawTransPic
=============
*/
void Sbar_DrawTransPic (int x, int y, qpic_t *pic)
{
Draw_TransPic (x + sbar_xofs, y + (vid.height-SBAR_HEIGHT), pic);
}
/*
================
Sbar_DrawCharacter
Draws one solid graphics character
================
*/
void Sbar_DrawCharacter (int x, int y, int num)
{
Draw_Character (x + 4 + sbar_xofs, y + (vid.height-SBAR_HEIGHT), num);
}
/*
================
Sbar_DrawString
================
*/
void Sbar_DrawString (int x, int y, char *str)
{
Draw_String (x + sbar_xofs, y + (vid.height-SBAR_HEIGHT), str);
}
/*
=============
Sbar_itoa
=============
*/
int Sbar_itoa (int num, char *buf)
{
char *str;
int pow10;
int dig;
str = buf;
if (num < 0)
{
*str++ = '-';
num = -num;
}
for (pow10 = 10 ; num >= pow10 ; pow10 *= 10)
;
do
{
pow10 /= 10;
dig = num/pow10;
*str++ = '0'+dig;
num -= dig*pow10;
} while (pow10 != 1);
*str = 0;
return str-buf;
}
/*
=============
Sbar_DrawNum
=============
*/
void Sbar_DrawNum (int x, int y, int num, int digits, int color)
{
char str[12];
char *ptr;
int l, frame;
l = Sbar_itoa (num, str);
ptr = str;
if (l > digits)
ptr += (l-digits);
if (l < digits)
x += (digits-l)*24;
while (*ptr)
{
if (*ptr == '-')
frame = STAT_MINUS;
else
frame = *ptr -'0';
Sbar_DrawTransPic (x,y,sb_nums[color][frame]);
x += 24;
ptr++;
}
}
//=============================================================================
int fragsort[MAX_SCOREBOARD];
char scoreboardtext[MAX_SCOREBOARD][20];
int scoreboardtop[MAX_SCOREBOARD];
int scoreboardbottom[MAX_SCOREBOARD];
int scoreboardcount[MAX_SCOREBOARD];
int scoreboardlines;
/*
===============
Sbar_SortFrags
===============
*/
void Sbar_SortFrags (void)
{
int i, j, k;
// sort by frags
scoreboardlines = 0;
for (i=0 ; i<cl.maxclients ; i++)
{
if (cl.scores[i].name[0])
{
fragsort[scoreboardlines] = i;
scoreboardlines++;
}
}
for (i=0 ; i<scoreboardlines ; i++)
for (j=0 ; j<scoreboardlines-1-i ; j++)
if (cl.scores[fragsort[j]].frags < cl.scores[fragsort[j+1]].frags)
{
k = fragsort[j];
fragsort[j] = fragsort[j+1];
fragsort[j+1] = k;
}
}
/*
===============
Sbar_ColorForMap
===============
*/
int Sbar_ColorForMap (int m)
{
return m < 128 ? m + 8 : m + 8;
}
/*
===============
Sbar_DrawScrollString
scroll the string inside a glscissor region
===============
*/
void Sbar_DrawScrollString (int x, int y, int width, char *str)
{
int len, ofs, left;
left = x;
if (scr_centersbar.value)
left += (((float)vid.width - 320.0) / 2);
glEnable (GL_SCISSOR_TEST);
glScissor (left, 0, width, vid.height);
len = strlen(str)*8 + 40;
ofs = ((int)(realtime*30))%len;
Sbar_DrawString (x - ofs, y, str);
Sbar_DrawCharacter (x - ofs + len - 32, y, ' ');
Sbar_DrawCharacter (x - ofs + len - 24, y, ' ');
Sbar_DrawCharacter (x - ofs + len - 16, y, ' ');
Sbar_DrawCharacter (x - ofs + len - 8, y, ' ');
Sbar_DrawString (x - ofs + len, y, str);
glDisable (GL_SCISSOR_TEST);
}
/*
===============
Sbar_SoloScoreboard
new sbar layout from fitzquake
===============
*/
void Sbar_SoloScoreboard (void)
{
char str[256], s[32]="";
int minutes, seconds, tens, units;
int len;
// draw stat
sprintf (str,"Monsters: %i/%i", cl.stats[STAT_MONSTERS], cl.stats[STAT_TOTALMONSTERS]);
Sbar_DrawString (8, 12, str);
sprintf (str,"Secrets: %i/%i", cl.stats[STAT_SECRETS], cl.stats[STAT_TOTALSECRETS]);
Sbar_DrawString (312 - strlen(str)*8, 12, str);
// draw time
minutes = cl.time / 60;
seconds = cl.time - 60*minutes;
tens = seconds / 10;
units = seconds - 10*tens;
sprintf (str,"%i:%i%i", minutes, tens, units);
Sbar_DrawString (320 - strlen(str)*8, (scr_overdrawsbar.value ? -32 : scr_sbar.value ? -32 : -8), str); // alt.
// draw skill
if ((int)(skill.value + 0.5) == 0)
sprintf (s,"%s", "Easy");
else if ((int)(skill.value + 0.5) == 1)
sprintf (s,"%s", "Normal");
else if ((int)(skill.value + 0.5) == 2)
sprintf (s,"%s", "Hard");
else if ((int)(skill.value + 0.5) == 3)
sprintf (s,"%s", "Nightmare");
sprintf (str,"%s skill", s);
Sbar_DrawString (0, (scr_overdrawsbar.value ? -32 : scr_sbar.value ? -32 : -8), str); // alt.
// scroll long levelnames
sprintf (str,"%s (%s)", cl.levelname, cl.worldname);
len = strlen (str);
if (len > 40)
Sbar_DrawScrollString (0, 4, 320, str);
else
Sbar_DrawString (160 - len*4, 4, str);
}
/*
===============
Sbar_DrawScoreboard
===============
*/
void Sbar_DrawScoreboard (void)
{
Sbar_SoloScoreboard ();
if (cl.gametype == GAME_DEATHMATCH || cls.demoplayback)
Sbar_DeathmatchOverlay ();
}
//=============================================================================
/*
===============
Sbar_DrawInventory
===============
*/
void Sbar_DrawInventory (void)
{
int i, flashon, ystart;
char num[6];
float time;
qboolean headsup;
headsup = !(scr_sbar.value || scr_overdrawsbar.value || scr_viewsize.value < 100);
if (!headsup)
{
if (rogue)
{
if ( cl.stats[STAT_ACTIVEWEAPON] >= RIT_LAVA_NAILGUN )
Sbar_DrawPicAlpha (0, -24, rsb_invbar[0]); // was Sbar_DrawPic
else
Sbar_DrawPicAlpha (0, -24, rsb_invbar[1]); // was Sbar_DrawPic
}
else
{
Sbar_DrawPicAlpha (0, -24, sb_ibar); // was Sbar_DrawPic
}
}
// id weapons
ystart = hipnotic ? -100 : -68;
for (i=0 ; i<7 ; i++)
{
if (cl.items & (IT_SHOTGUN<<i) )
{
time = cl.item_gettime[i];
flashon = (int)((cl.time - time)*10);
if (flashon < 0)
flashon = 0; // Might happen if host_framerate is e.g. 1
if (flashon >= 10)
{
if ( cl.stats[STAT_ACTIVEWEAPON] == (IT_SHOTGUN<<i) )
flashon = 1;
else
flashon = 0;
}
else
flashon = (flashon%5) + 2;
if (headsup)
{
if (vid.height <= 240)
{
if (i == 6) // lightning gun
Sbar_DrawSubPic (0, ystart + 36 - (7-i)*16, sb_weapons[flashon][i], 0, 0, sb_weapons[flashon][i]->width, 16);
else
Sbar_DrawSubPic (0, ystart + 36 - (7-i)*16, sb_weapons[flashon][i], 0, 0, 24, 16);
}
else
if (i || vid.height > 240)
{
if (i == 6) // lightning gun
Sbar_DrawSubPic ((vid.width-sb_weapons[flashon][i]->width), ystart - (7-i)*16, sb_weapons[flashon][i], 0, 0, sb_weapons[flashon][i]->width, 16);
else
Sbar_DrawSubPic ((vid.width-24), ystart - (7-i)*16, sb_weapons[flashon][i], 0, 0, 24, 16);
}
}
else
{
Sbar_DrawPic (i*24, -16, sb_weapons[flashon][i]);
}
if (flashon > 1)
sb_updates = 0; // force update to remove flash
}
}
// MED 01/04/97
// hipnotic weapons
if (hipnotic)
{
int grenadeflashing=0;
for (i=0 ; i<4 ; i++)
{
if (cl.items & (1<<hipweapons[i]) )
{
time = cl.item_gettime[hipweapons[i]];
flashon = (int)((cl.time - time)*10);
if (flashon < 0)
flashon = 0; // Might happen if host_framerate is e.g. 1
if (flashon >= 10)
{
if ( cl.stats[STAT_ACTIVEWEAPON] == (1<<hipweapons[i]) )
flashon = 1;
else
flashon = 0;
}
else
flashon = (flashon%5) + 2;
// check grenade launcher
if (i==2)
{
if (cl.items & HIT_PROXIMITY_GUN)
{
if (flashon)
{
grenadeflashing = 1;
if (headsup)
{
if (vid.height <= 240)
{
Sbar_DrawSubPic (0, ystart + 36 - 48, hsb_weapons[flashon][2], 0, 0, 24, 16); // prox grenade launcher
}
else
if (i || vid.height > 240)
{
Sbar_DrawSubPic ((vid.width-24), ystart - 48, hsb_weapons[flashon][2], 0, 0, 24, 16);
}
}
else
{
Sbar_DrawPic (96, -16, hsb_weapons[flashon][2]);
}
}
}
}
else if (i==3)
{
if (cl.items & (IT_SHOTGUN<<4))
{
if (!grenadeflashing)
{
if (flashon)
{
if (headsup)
{
if (vid.height <= 240)
{
Sbar_DrawSubPic (0, ystart + 36 - 48, hsb_weapons[flashon][3], 0, 0, 24, 16); // prox grenade launcher
}
else
if (i || vid.height > 240)
{
Sbar_DrawSubPic ((vid.width-24), ystart - 48, hsb_weapons[flashon][3], 0, 0, 24, 16);
}
}
else
{
Sbar_DrawPic (96, -16, hsb_weapons[flashon][3]);
}
}
else
{
if (headsup)
{
if (vid.height <= 240)
{
Sbar_DrawSubPic (0, ystart + 36 - 48, hsb_weapons[0][3], 0, 0, 24, 16); // prox grenade launcher
}
else
if (i || vid.height > 240)
{
Sbar_DrawSubPic ((vid.width-24), ystart - 48, hsb_weapons[0][3], 0, 0, 24, 16);
}
}
else
{
Sbar_DrawPic (96, -16, hsb_weapons[0][3]);
}
}
}
}
else
{
if (headsup)
{
if (vid.height <= 240)
{
Sbar_DrawSubPic (0, ystart + 36 - 48, hsb_weapons[flashon][4], 0, 0, 24, 16);
}
else
if (i || vid.height > 240)
{
Sbar_DrawSubPic ((vid.width-24), ystart - 48, hsb_weapons[flashon][4], 0, 0, 24, 16);
}
}
else
{
Sbar_DrawPic (96, -16, hsb_weapons[flashon][4]);
}
}
}
else
{
if (headsup)
{
if (vid.height <= 240)
{
Sbar_DrawSubPic (0, ystart + 36 + i*16, hsb_weapons[flashon][i], 0, 0, hsb_weapons[flashon][i]->width, 16);
}
else
if (i || vid.height > 240)
{
Sbar_DrawSubPic ((vid.width-hsb_weapons[flashon][i]->width), ystart + i*16, hsb_weapons[flashon][i], 0, 0, hsb_weapons[flashon][i]->width, 16);
}
}
else
{
Sbar_DrawPic (176 + (i*24), -16, hsb_weapons[flashon][i]);
}
}
if (flashon > 1)
sb_updates = 0; // force update to remove flash
}
}
}
// rogue weapons
if (rogue)
{
// check for powered up weapon.
if ( cl.stats[STAT_ACTIVEWEAPON] >= RIT_LAVA_NAILGUN )
{
for (i=0;i<5;i++)
{
if (cl.stats[STAT_ACTIVEWEAPON] == (RIT_LAVA_NAILGUN << i))
{
if (headsup)
{
if (vid.height <= 240)
{
if (i == 4) // lightning / plasma gun
Sbar_DrawSubPic (0, ystart + 36 - (5-i)*16, rsb_weapons[i], 0, 0, 48, 16);
else
Sbar_DrawSubPic (0, ystart + 36 - (5-i)*16, rsb_weapons[i], 0, 0, 24, 16);
}
else
if (i || vid.height > 240)
{
if (i == 4) // lightning / plasma gun
Sbar_DrawSubPic ((vid.width-48), ystart - (5-i)*16, rsb_weapons[i], 0, 0, 48, 16);
else
Sbar_DrawSubPic ((vid.width-24), ystart - (5-i)*16, rsb_weapons[i], 0, 0, 24, 16);
}
}
else
{
Sbar_DrawPic ((i+2)*24, -16, rsb_weapons[i]);
}
}
}
}
}
// ammo counts
for (i=0 ; i<4 ; i++)
{
sprintf (num, "%3i",cl.stats[STAT_SHELLS+i] );
if (headsup)
{
if (rogue)
{
if ( cl.stats[STAT_ACTIVEWEAPON] >= RIT_LAVA_NAILGUN )
Sbar_DrawSubPic ((vid.width-42), -24 - (4-i)*11, rsb_invbar[0], 3+(i*48), 0, 42, 11);
else
Sbar_DrawSubPic ((vid.width-42), -24 - (4-i)*11, rsb_invbar[1], 3+(i*48), 0, 42, 11);
}
else
{
Sbar_DrawSubPic ((vid.width-42), -24 - (4-i)*11, sb_ibar, 3+(i*48), 0, 42, 11);
}
if (num[0] != ' ')
Draw_Character ((vid.width - 35), vid.height-SBAR_HEIGHT-24 - (4-i)*11, 18 + num[0] - '0');
if (num[1] != ' ')
Draw_Character ((vid.width - 27), vid.height-SBAR_HEIGHT-24 - (4-i)*11, 18 + num[1] - '0');
if (num[2] != ' ')
Draw_Character ((vid.width - 19), vid.height-SBAR_HEIGHT-24 - (4-i)*11, 18 + num[2] - '0');
}
else
{
if (num[0] != ' ')
Sbar_DrawCharacter ((6*i+1)*8 - 2, -24, 18 + num[0] - '0');
if (num[1] != ' ')
Sbar_DrawCharacter ((6*i+2)*8 - 2, -24, 18 + num[1] - '0');
if (num[2] != ' ')
Sbar_DrawCharacter ((6*i+3)*8 - 2, -24, 18 + num[2] - '0');
}
}
flashon = 0;
// id items
for (i=0 ; i<6 ; i++)
{
if (cl.items & (1<<(17+i)))
{
time = cl.item_gettime[17+i];
if (time && time > cl.time - 2 && flashon )
{ // flash frame
sb_updates = 0;
}
else
{ //MED 01/04/97 changed keys
if (!hipnotic || (i>1))
{
Sbar_DrawPic (192 + i*16, -16, sb_items[i]);
}
}
if (time && time > cl.time - 2)
sb_updates = 0;
}
}
//MED 01/04/97 added hipnotic items
// hipnotic items
if (hipnotic)
{
for (i=0 ; i<2 ; i++)
{
if (cl.items & (1<<(24+i)))
{
time = cl.item_gettime[24+i];
if (time && time > cl.time - 2 && flashon )
{ // flash frame
sb_updates = 0;
}
else
{
Sbar_DrawPic (288 + i*16, -16, hsb_items[i]);
}
if (time && time > cl.time - 2)
sb_updates = 0;
}
}
}
// rogue items
if (rogue)
{
// new rogue items
for (i=0 ; i<2 ; i++)
{
if (cl.items & (1<<(29+i)))
{
time = cl.item_gettime[29+i];
if (time && time > cl.time - 2 && flashon )
{ // flash frame
sb_updates = 0;
}
else
{
Sbar_DrawPic (288 + i*16, -16, rsb_items[i]);
}
if (time && time > cl.time - 2)
sb_updates = 0;
}
}
}
else
{
// sigils
for (i=0 ; i<4 ; i++)
{
if (cl.items & (1<<(28+i)))
{
time = cl.item_gettime[28+i];
if (time && time > cl.time - 2 && flashon )
{ // flash frame
sb_updates = 0;
}
else
{
Sbar_DrawPic (320-32 + i*8, -16, sb_sigil[i]);
}
if (time && time > cl.time - 2)
sb_updates = 0;
}
}
}
}
//=============================================================================
/*
===============
Sbar_DrawFrags
===============
*/
void Sbar_DrawFrags (void)
{
int i, k, l;
int top, bottom;
int x, y, f;
char num[12];
scoreboard_t *s;
if (cl.gametype != GAME_DEATHMATCH)
return;
Sbar_SortFrags ();
// draw the text
l = (scoreboardlines <= 4) ? scoreboardlines : 4;
x = 23;
y = vid.height - SBAR_HEIGHT - 23;
for (i=0 ; i<l ; i++)
{
k = fragsort[i];
s = &cl.scores[k];
if (!s->name[0])
continue;
// draw background
top = s->colors & 0xf0;
bottom = (s->colors & 15)<<4;
top = Sbar_ColorForMap (top);
bottom = Sbar_ColorForMap (bottom);
Draw_Fill (sbar_xofs + x*8 + 10, y, 28, 4, top);
Draw_Fill (sbar_xofs + x*8 + 10, y+4, 28, 3, bottom);
// draw number
f = s->frags;
sprintf (num, "%3i",f);
Sbar_DrawCharacter ( (x+1)*8 , -24, num[0]);
Sbar_DrawCharacter ( (x+2)*8 , -24, num[1]);
Sbar_DrawCharacter ( (x+3)*8 , -24, num[2]);
if (k == cl.viewentity - 1)
{
Sbar_DrawCharacter (x*8+2, -24, 16);
Sbar_DrawCharacter ( (x+4)*8-4, -24, 17);
}
x+=4;
}
}
//=============================================================================