-
Notifications
You must be signed in to change notification settings - Fork 1
/
Sbar.c
1824 lines (1543 loc) · 38.5 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
//**************************************************************************
//**
//** sbar.c
//**
//** $Header: /H2 Mission Pack/Sbar.c 17 3/20/98 12:55p Jmonroe $
//**
//**************************************************************************
// HEADER FILES ------------------------------------------------------------
#include "quakedef.h"
// MACROS ------------------------------------------------------------------
#define STAT_MINUS 10 // num frame for '-' stats digit
#define BAR_TOP_HEIGHT 46.0
#define BAR_BOTTOM_HEIGHT 98.0
#define BAR_TOTAL_HEIGHT (BAR_TOP_HEIGHT+BAR_BOTTOM_HEIGHT)
#define BAR_BUMP_HEIGHT 23.0
#define INVENTORY_DISPLAY_TIME 4
#define RING_FLIGHT 1
#define RING_WATER 2
#define RING_REGENERATION 4
#define RING_TURNING 8
#define INV_MAX_CNT 15
#define INV_MAX_ICON 6 // Max number of inventory icons to display at once
// TYPES -------------------------------------------------------------------
// EXTERNAL FUNCTION PROTOTYPES --------------------------------------------
void Sbar_DeathmatchOverlay(void);
void Sbar_NormalOverlay(void);
void Sbar_SmallDeathmatchOverlay(void);
void M_DrawPic(int x, int y, qpic_t *pic);
// PUBLIC FUNCTION PROTOTYPES ----------------------------------------------
// PRIVATE FUNCTION PROTOTYPES ---------------------------------------------
static void Sbar_DrawPic(int x, int y, qpic_t *pic);
static void Sbar_DrawTransPic(int x, int y, qpic_t *pic);
static int Sbar_itoa(int num, char *buf);
static void Sbar_DrawNum(int x, int y, int number, int digits);
static void Sbar_SortFrags(void);
static void Sbar_DrawCharacter(int x, int y, int num);
static void Sbar_DrawString(int x, int y, char *str);
static void Sbar_DrawSmallCharacter(int x, int y, int num);
static void Sbar_DrawSmallString(int x, int y, char *str);
static void DrawBarArtifactNumber(int x, int y, int number);
static void DrawFullScreenInfo(void);
static void DrawLowerBar(void);
static void DrawActiveRings(void);
static void DrawActiveArtifacts(void);
static int CalcAC(void);
static void DrawBarArtifactIcon(int x, int y, int artifact);
static qboolean SetChainPosition(float health, float maxHealth);
static void ShowInfoDown_f(void);
static void ShowInfoUp_f(void);
static void ShowDMDown_f(void);
static void ShowDMUp_f(void);
static void ToggleDM_f(void);
static void InvLeft_f(void);
static void InvRight_f(void);
static void InvUse_f(void);
static void InvOff_f(void);
static void DrawArtifactInventory(void);
extern qboolean intro_playing;
// EXTERNAL DATA DECLARATIONS ----------------------------------------------
extern int in_impulse;
// PUBLIC DATA DEFINITIONS -------------------------------------------------
int sb_lines; // scan lines to draw
// PRIVATE DATA DEFINITIONS ------------------------------------------------
static int sb_updates; // if >= vid.numpages, no update needed
static float BarHeight;
static float BarTargetHeight;
cvar_t BarSpeed = { "barspeed", "5" };
cvar_t sbtemp = { "sbtemp", "5" };
cvar_t DMMode = { "dm_mode", "1", true };
static qpic_t *sb_nums[11];
static qpic_t *sb_colon, *sb_slash;
static int fragsort[MAX_SCOREBOARD];
static char scoreboardtext[MAX_SCOREBOARD][20];
static int scoreboardtop[MAX_SCOREBOARD];
static int scoreboardbottom[MAX_SCOREBOARD];
static int scoreboardcount[MAX_SCOREBOARD];
static int scoreboardlines;
static float ChainPosition = 0;
static qboolean sb_ShowInfo;
static qboolean sb_ShowDM;
qboolean inv_flg; // true - show inventory interface
static float InventoryHideTime;
extern char *ClassNames[NUM_CLASSES]; //from menu.c
static int AmuletAC[NUM_CLASSES] =
{
8, // Paladin
4, // Crusader
2, // Necromancer
6, // Assassin
6 // Demoness
};
static int BracerAC[NUM_CLASSES] =
{
6, // Paladin
8, // Crusader
4, // Necromancer
2, // Assassin
2 // Demoness
};
static int BreastplateAC[NUM_CLASSES] =
{
2, // Paladin
6, // Crusader
8, // Necromancer
4, // Assassin
4 // Demoness
};
static int HelmetAC[NUM_CLASSES] =
{
4, // Paladin
2, // Crusader
6, // Necromancer
8, // Assassin
8 // Demoness
};
// CODE --------------------------------------------------------------------
//==========================================================================
//
// SB_Init
//
//==========================================================================
void SB_Init(void)
{
int i;
for(i = 0; i < 10; i++)
{
sb_nums[i] = Draw_PicFromWad(va("num_%i",i));
}
sb_nums[10] = Draw_PicFromWad("num_minus");
sb_colon = Draw_PicFromWad("num_colon");
sb_slash = Draw_PicFromWad("num_slash");
Cmd_AddCommand("+showinfo", ShowInfoDown_f);
Cmd_AddCommand("-showinfo", ShowInfoUp_f);
Cmd_AddCommand("+showdm", ShowDMDown_f);
Cmd_AddCommand("-showdm", ShowDMUp_f);
Cmd_AddCommand("invleft", InvLeft_f);
Cmd_AddCommand("invright", InvRight_f);
Cmd_AddCommand("invuse", InvUse_f);
Cmd_AddCommand("invoff", InvOff_f);
Cmd_AddCommand("toggle_dm", ToggleDM_f);
Cvar_RegisterVariable(&DMMode);
Cvar_RegisterVariable(&BarSpeed);
Cvar_RegisterVariable(&sbtemp);
BarHeight = BarTargetHeight = BAR_TOP_HEIGHT;
}
//==========================================================================
//
// SB_Draw
//
//==========================================================================
void SB_Draw(void)
{
float delta;
char tempStr[80];
int mana;
int maxMana;
int y;
if (intro_playing)
{
scr_fullupdate = 0;
scr_copyeverything = 1;
return;
}
if (scr_con_current == vid.height)
{ // console is full screen
return;
}
// Draw always until we fix things
//if (sb_updates >= vid.numpages)
// return;
/* if(BarHeight == BarTargetHeight)
{
return;
}
*/
if(BarHeight < BarTargetHeight)
{
delta = ((BarTargetHeight-BarHeight)*BarSpeed.value)
*host_frametime;
if(delta < 0.5)
{
delta = 0.5;
}
BarHeight += delta;
if(BarHeight > BarTargetHeight)
{
BarHeight = BarTargetHeight;
}
scr_fullupdate = 0;
}
else if(BarHeight > BarTargetHeight)
{
delta = ((BarHeight-BarTargetHeight)*BarSpeed.value)
*host_frametime;
if(delta < 0.5)
{
delta = 0.5;
}
BarHeight -= delta;
if(BarHeight < BarTargetHeight)
{
BarHeight = BarTargetHeight;
}
scr_fullupdate = 0;
}
scr_copyeverything = 1;
sb_updates++;
#if 1
if(BarHeight < 0)
DrawFullScreenInfo();
#endif
//Sbar_DrawPic(0, 0, Draw_CachePic("gfx/topbar.lmp"));
Sbar_DrawPic(0, 0, Draw_CachePic("gfx/topbar1.lmp"));
//return;
Sbar_DrawPic(160, 0, Draw_CachePic("gfx/topbar2.lmp"));
Sbar_DrawTransPic(0, -23, Draw_CachePic("gfx/topbumpl.lmp"));
Sbar_DrawTransPic(138, -8, Draw_CachePic("gfx/topbumpm.lmp"));
Sbar_DrawTransPic(269, -23, Draw_CachePic("gfx/topbumpr.lmp"));
maxMana = (int)cl.v.max_mana;
// Blue mana
mana = (int)cl.v.bluemana;
if(mana < 0)
{
mana = 0;
}
if(mana > maxMana)
{
mana = maxMana;
}
sprintf(tempStr, "%03d", mana);
Sbar_DrawSmallString(201, 22, tempStr);
if(mana)
{
Sbar_DrawPic(190, 26-(int)((mana*18.0)/(float)maxMana+0.5),
Draw_CachePic("gfx/bmana.lmp"));
Sbar_DrawPic(190, 27, Draw_CachePic("gfx/bmanacov.lmp"));
}
// Green mana
mana = (int)cl.v.greenmana;
if(mana < 0)
{
mana = 0;
}
if(mana > maxMana)
{
mana = maxMana;
}
sprintf(tempStr, "%03d", mana);
Sbar_DrawSmallString(243, 22, tempStr);
if(mana)
{
Sbar_DrawPic(232, 26-(int)((mana*18.0)/(float)maxMana+0.5),
Draw_CachePic("gfx/gmana.lmp"));
Sbar_DrawPic(232, 27, Draw_CachePic("gfx/gmanacov.lmp"));
}
// HP
if (cl.v.health < -99)
Sbar_DrawNum(58, 14, -99, 3);
else
Sbar_DrawNum(58, 14, cl.v.health, 3);
SetChainPosition(cl.v.health, cl.v.max_health);
Sbar_DrawTransPic(45+((int)ChainPosition&7), 38,
Draw_CachePic("gfx/hpchain.lmp"));
Sbar_DrawTransPic(45+(int)ChainPosition, 36,
Draw_CachePic("gfx/hpgem.lmp"));
Sbar_DrawPic(43, 36, Draw_CachePic("gfx/chnlcov.lmp"));
Sbar_DrawPic(267, 36, Draw_CachePic("gfx/chnrcov.lmp"));
// AC
Sbar_DrawNum(105, 14, CalcAC(), 2);
if(BarHeight > BAR_TOP_HEIGHT)
{
DrawLowerBar();
}
// Current inventory item
if(cl.inv_selected >= 0)
{
DrawBarArtifactIcon(144, 3, cl.inv_order[cl.inv_selected]);
//Sbar_DrawTransPic(144, 3, Draw_CachePic(va("gfx/arti%02d.lmp",
// cl.inv_order[cl.inv_selected])));
}
// FIXME: Check for deathmatch and draw frags
// if(cl.maxclients != 1) Sbar_Draw
DrawArtifactInventory();
DrawActiveRings();
DrawActiveArtifacts();
if (sb_ShowDM)
{
if (cl.gametype == GAME_DEATHMATCH)
Sbar_DeathmatchOverlay();
else
Sbar_NormalOverlay();
}
else if (cl.gametype == GAME_DEATHMATCH && DMMode.value)
Sbar_SmallDeathmatchOverlay();
}
//==========================================================================
//
// SetChainPosition
//
//==========================================================================
static qboolean SetChainPosition(float health, float maxHealth)
{
float delta;
float chainTargetPosition;
if(health < 0)
{
health = 0;
}
else if(health > maxHealth)
{
health = maxHealth;
}
chainTargetPosition = (health*195)/maxHealth;
if(fastfabs(ChainPosition-chainTargetPosition) < 0.1)
{
return false;
}
if(ChainPosition < chainTargetPosition)
{
delta = ((chainTargetPosition-ChainPosition)*5)*host_frametime;
if(delta < 0.5)
{
delta = 0.5;
}
ChainPosition += delta;
if(ChainPosition > chainTargetPosition)
{
ChainPosition = chainTargetPosition;
}
}
else if(ChainPosition > chainTargetPosition)
{
delta = ((ChainPosition-chainTargetPosition)*5)*host_frametime;
if(delta < 0.5)
{
delta = 0.5;
}
ChainPosition -= delta;
if(ChainPosition < chainTargetPosition)
{
ChainPosition = chainTargetPosition;
}
}
return true;
}
//==========================================================================
//
// DrawFullScreenInfo
//
//==========================================================================
static void DrawFullScreenInfo(void)
{
int y;
int mana;
int maxMana;
char tempStr[80];
y = BarHeight-37;
Sbar_DrawPic(3, y, Draw_CachePic("gfx/bmmana.lmp"));
Sbar_DrawPic(3, y+18, Draw_CachePic("gfx/gmmana.lmp"));
maxMana = (int)cl.v.max_mana;
// Blue mana
mana = (int)cl.v.bluemana;
if(mana < 0)
{
mana = 0;
}
if(mana > maxMana)
{
mana = maxMana;
}
sprintf(tempStr, "%03d", mana);
Sbar_DrawSmallString(10, y+6, tempStr);
// Green mana
mana = (int)cl.v.greenmana;
if(mana < 0)
{
mana = 0;
}
if(mana > maxMana)
{
mana = maxMana;
}
sprintf(tempStr, "%03d", mana);
Sbar_DrawSmallString(10, y+18+6, tempStr);
// HP
Sbar_DrawNum(38, y+18, cl.v.health, 3);
// Current inventory item
if(cl.inv_selected >= 0)
{
DrawBarArtifactIcon(288, y+7, cl.inv_order[cl.inv_selected]);
}
}
//==========================================================================
//
// DrawLowerBar
//
//==========================================================================
static void DrawLowerBar(void)
{
int i;
int minutes, seconds, tens, units;
char tempStr[80];
int playerClass;
int piece;
int ringhealth;
//playerClass = cl.v.playerclass;
playerClass = cl_playerclass.value;
if(playerClass < 1 || playerClass > NUM_CLASSES)
{ // Default to demoness
playerClass = NUM_CLASSES-1;
}
// Backdrop
//Sbar_DrawPic(0, 46, Draw_CachePic("gfx/btmbar.lmp"));
Sbar_DrawPic(0, 46, Draw_CachePic("gfx/btmbar1.lmp"));
Sbar_DrawPic(160, 46, Draw_CachePic("gfx/btmbar2.lmp"));
// Game time
//minutes = cl.time / 60;
//seconds = cl.time - 60*minutes;
//tens = seconds / 10;
//units = seconds - 10*tens;
//sprintf(tempStr, "Time :%3i:%i%i", minutes, tens, units);
//Sbar_DrawSmallString(116, 114, tempStr);
// Map name
//Sbar_DrawSmallString(10, 114, cl.levelname);
// Stats
Sbar_DrawSmallString(11, 48, ClassNames[playerClass-1]);
Sbar_DrawSmallString(11, 58, "int");
sprintf(tempStr, "%02d", (int)cl.v.intelligence);
Sbar_DrawSmallString(33, 58, tempStr);
Sbar_DrawSmallString(11, 64, "wis");
sprintf(tempStr, "%02d", (int)cl.v.wisdom);
Sbar_DrawSmallString(33, 64, tempStr);
Sbar_DrawSmallString(11, 70, "dex");
sprintf(tempStr, "%02d", (int)cl.v.dexterity);
Sbar_DrawSmallString(33, 70, tempStr);
Sbar_DrawSmallString(58, 58, "str");
sprintf(tempStr, "%02d", (int)cl.v.strength);
Sbar_DrawSmallString(80, 58, tempStr);
Sbar_DrawSmallString(58, 64, "lvl");
sprintf(tempStr, "%02d", (int)cl.v.level);
Sbar_DrawSmallString(80, 64, tempStr);
Sbar_DrawSmallString(58, 70, "exp");
sprintf(tempStr, "%06d", (int)cl.v.experience);
Sbar_DrawSmallString(80, 70, tempStr);
// Abilities
Sbar_DrawSmallString(11, 79, "abilities");
i = ABILITIES_STR_INDEX+(playerClass-1)*2;
if(i+1 < pr_string_count)
{
if(((int)cl.v.flags)&FL_SPECIAL_ABILITY1)
{
Sbar_DrawSmallString(8, 89,
&pr_global_strings[pr_string_index[i]]);
}
if(((int)cl.v.flags)&FL_SPECIAL_ABILITY2)
{
Sbar_DrawSmallString(8, 96,
&pr_global_strings[pr_string_index[i+1]]);
}
}
// Portrait
sprintf(tempStr, "gfx/cport%d.lmp", playerClass);
Sbar_DrawPic(134, 50, Draw_CachePic(tempStr));
// Armor
if(cl.v.armor_helmet > 0)
{
Sbar_DrawPic(164, 115, Draw_CachePic("gfx/armor1.lmp"));
sprintf(tempStr, "+%d", (int)cl.v.armor_helmet);
Sbar_DrawSmallString(168, 136, tempStr);
}
if(cl.v.armor_amulet > 0)
{
Sbar_DrawPic(205, 115, Draw_CachePic("gfx/armor2.lmp"));
sprintf(tempStr, "+%d", (int)cl.v.armor_amulet);
Sbar_DrawSmallString(208, 136, tempStr);
}
if(cl.v.armor_breastplate > 0)
{
Sbar_DrawPic(246, 115, Draw_CachePic("gfx/armor3.lmp"));
sprintf(tempStr, "+%d", (int)cl.v.armor_breastplate);
Sbar_DrawSmallString(249, 136, tempStr);
}
if(cl.v.armor_bracer > 0)
{
Sbar_DrawPic(285, 115, Draw_CachePic("gfx/armor4.lmp"));
sprintf(tempStr, "+%d", (int)cl.v.armor_bracer);
Sbar_DrawSmallString(288, 136, tempStr);
}
// Rings
if(cl.v.ring_flight > 0)
{
Sbar_DrawTransPic(6, 119, Draw_CachePic("gfx/ring_f.lmp"));
ringhealth = (int)cl.v.ring_flight;
if(ringhealth > 100)
ringhealth = 100;
Sbar_DrawPic( 35 - (int)(26 * (ringhealth/(float)100)),142,Draw_CachePic("gfx/ringhlth.lmp"));
Sbar_DrawPic( 35, 142, Draw_CachePic("gfx/rhlthcvr.lmp"));
}
if(cl.v.ring_water > 0)
{
Sbar_DrawTransPic(44, 119, Draw_CachePic("gfx/ring_w.lmp"));
ringhealth = (int)cl.v.ring_water;
if(ringhealth > 100)
ringhealth = 100;
Sbar_DrawPic( 73 - (int)(26 * (ringhealth/(float)100)),142,Draw_CachePic("gfx/ringhlth.lmp"));
Sbar_DrawPic( 73, 142, Draw_CachePic("gfx/rhlthcvr.lmp"));
}
if(cl.v.ring_turning > 0)
{
Sbar_DrawTransPic(81, 119, Draw_CachePic("gfx/ring_t.lmp"));
ringhealth = (int)cl.v.ring_turning;
if(ringhealth > 100)
ringhealth = 100;
Sbar_DrawPic( 110 - (int)(26 * (ringhealth/(float)100)),142,Draw_CachePic("gfx/ringhlth.lmp"));
Sbar_DrawPic( 110, 142, Draw_CachePic("gfx/rhlthcvr.lmp"));
}
if(cl.v.ring_regeneration > 0)
{
Sbar_DrawTransPic(119, 119, Draw_CachePic("gfx/ring_r.lmp"));
ringhealth = (int)cl.v.ring_regeneration;
if(ringhealth > 100)
ringhealth = 100;
Sbar_DrawPic( 148 -(int)(26 * (ringhealth/(float)100)),142,Draw_CachePic("gfx/ringhlth.lmp"));
Sbar_DrawPic( 148, 142, Draw_CachePic("gfx/rhlthcv2.lmp"));
}
// Puzzle pieces
piece = 0;
for(i = 0; i < 8; i++)
{
if(cl.puzzle_pieces[i][0] == 0)
{
continue;
}
Sbar_DrawPic(194+(piece%4)*31, piece < 4 ? 51 : 82,
Draw_CachePic(va("gfx/puzzle/%s.lmp", cl.puzzle_pieces[i])));
piece++;
}
}
//==========================================================================
//
// CalcAC
//
//==========================================================================
static int CalcAC(void)
{
int a;
int playerClass;
//playerClass = cl.v.playerclass;
playerClass = cl_playerclass.value -1 ;
if(playerClass < 0 || playerClass >= NUM_CLASSES)
{
playerClass = NUM_CLASSES-1;
}
a = 0;
if(cl.v.armor_amulet > 0)
{
a += AmuletAC[playerClass];
a += cl.v.armor_amulet/5;
}
if(cl.v.armor_bracer > 0)
{
a += BracerAC[playerClass];
a += cl.v.armor_bracer/5;
}
if(cl.v.armor_breastplate > 0)
{
a += BreastplateAC[playerClass];
a += cl.v.armor_breastplate/5;
}
if(cl.v.armor_helmet > 0)
{
a += HelmetAC[playerClass];
a += cl.v.armor_helmet/5;
}
return a;
}
//==========================================================================
//
// SB_Changed
//
//==========================================================================
void SB_Changed(void)
{
sb_updates = 0; // Update next frame
}
//==========================================================================
//
// Sbar_itoa
//
//==========================================================================
static 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
//
//==========================================================================
static void Sbar_DrawNum(int x, int y, int number, int digits)
{
char str[12];
char *ptr;
int l, frame;
l = Sbar_itoa(number, str);
ptr = str;
if(l > digits)
{
ptr += (l-digits);
}
if(l < digits)
{
x += ((digits-l)*13)/2;
}
while(*ptr)
{
if(*ptr == '-')
{
frame = STAT_MINUS;
}
else
{
frame = *ptr -'0';
}
Sbar_DrawTransPic(x, y, sb_nums[frame]);
x += 13;
ptr++;
}
}
//==========================================================================
//
// Sbar_SortFrags
//
//==========================================================================
static 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;
}
}
int Sbar_ColorForMap (int m)
{
return m < 128 ? m + 8 : m + 8;
}
//==========================================================================
//
// SoloScoreboard
//
//==========================================================================
static void SoloScoreboard(void)
{
char str[80];
int minutes, seconds, tens, units;
int l;
sprintf (str,"Monsters:%3i /%3i", cl.stats[STAT_MONSTERS], cl.stats[STAT_TOTALMONSTERS]);
Sbar_DrawString (8, 4, str);
sprintf (str,"Secrets :%3i /%3i", cl.stats[STAT_SECRETS], cl.stats[STAT_TOTALSECRETS]);
Sbar_DrawString (8, 12, str);
// draw time
minutes = cl.time / 60;
seconds = cl.time - 60*minutes;
tens = seconds / 10;
units = seconds - 10*tens;
sprintf (str,"Time :%3i:%i%i", minutes, tens, units);
Sbar_DrawString (184, 4, str);
// draw level name
l = strlen (cl.levelname);
Sbar_DrawString (232 - l*4, 12, cl.levelname);
}
//==========================================================================
//
// Sbar_DrawScoreboard
//
//==========================================================================
void Sbar_DrawScoreboard(void)
{
SoloScoreboard();
if(cl.gametype == GAME_DEATHMATCH)
{
Sbar_DeathmatchOverlay();
}
}
//==========================================================================
//
// Sbar_DrawFrags
//
//==========================================================================
/*
void Sbar_DrawFrags (void)
{
int i, k, l;
int top, bottom;
int x, y, f;
int xofs;
char num[12];
scoreboard_t *s;
Sbar_SortFrags ();
// draw the text
l = scoreboardlines <= 4 ? scoreboardlines : 4;
x = 23;
xofs = (vid.width - 320)>>1;
y = vid.height - BAR_TOP_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 (xofs + x*8 + 10, y, 28, 4, top);
Draw_Fill (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;
}
}
*/
//==========================================================================
//
// Sbar_IntermissionNumber
//
//==========================================================================
void Sbar_IntermissionNumber (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';
Draw_TransPic (x,y,sb_nums[frame]);
x += 24;
ptr++;
}
}
extern int color_offsets[NUM_CLASSES];
extern byte *playerTranslation;
void FindColor (int slot, int *color1, int *color2)
{
int j;
int top, bottom, done;
byte *sourceA, *sourceB, *colorA, *colorB;
if (slot > cl.maxclients)
Sys_Error ("CL_NewTranslation: slot > cl.maxclients");
if (!cl.scores[slot].playerclass)
{
*color1 = *color2 = 0;
return;
}
top = (cl.scores[slot].colors & 0xf0) >> 4;
bottom = (cl.scores[slot].colors & 15);
if (top > 10) top = 0;
if (bottom > 10) bottom = 0;
top -= 1;
bottom -= 1;
colorA = playerTranslation + 256 + color_offsets[(int)cl.scores[slot].playerclass-1];
colorB = colorA + 256;
sourceA = colorB + 256 + (top * 256);
sourceB = colorB + 256 + (bottom * 256);
done = 0;
for(j=0;j<256;j++,colorA++,colorB++,sourceA++,sourceB++)
{
if ((*colorA != 255) && !(done & 1))
{
if (top >= 0)
*color1 = *sourceA;
else
*color1 = *colorA;
// done |= 1;
}
if ((*colorB != 255) && !(done & 2))
{
if (bottom >= 0)
*color2 = *sourceB;
else
*color2 = *colorB;
// done |= 2;
}
}
}
//==========================================================================
//
// Sbar_DeathmatchOverlay
//
//==========================================================================
void Sbar_DeathmatchOverlay(void)