-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHU_STUFF.C
1038 lines (853 loc) · 25.3 KB
/
HU_STUFF.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
// hu_stuff.c : heads up displays, cleaned up (hasta la vista hu_lib)
// because a lot of code was unnecessary now
#include "doomdef.h"
#include "hu_stuff.h"
#include "d_netcmd.h"
#include "d_clisrv.h"
#include "g_game.h"
#include "g_input.h"
#include "i_video.h"
// Data.
#include "dstrings.h"
#include "st_stuff.h" //added:05-02-98: ST_HEIGHT
#include "r_local.h"
#include "wi_stuff.h" // for drawranckings
#include "keys.h"
#include "v_video.h"
#include "w_wad.h"
#include "z_zone.h"
#ifdef __WIN32__
#include "win32/hwr_main.h"
#endif
// coords are scaled
#define HU_INPUTX 0
#define HU_INPUTY 0
// DOOM shareware/registered/retail (Ultimate) names.
#define HU_TITLE (text[HUSTR_E1M1_NUM+(gameepisode-1)*9+gamemap-1])
// DOOM 2 map names.
#define HU_TITLE2 (text[HUSTR_1_NUM+gamemap-1])
// Plutonia WAD map names.
#define HU_TITLEP (text[PHUSTR_1_NUM+gamemap-1])
// TNT WAD map names.
#define HU_TITLET (text[THUSTR_1_NUM+gamemap-1])
#define HU_TITLEX 0
#define HU_TITLEY ((BASEVIDHEIGHT-ST_HEIGHT-1) - SHORT(hu_font[0]->height))
//-------------------------------------------
// heads up font
//-------------------------------------------
patch_t* hu_font[HU_FONTSIZE];
static player_t* plr;
boolean chat_on;
static char w_title[80]; //mapname
static char w_inputbuffer[MAXPLAYERS][80];
static char w_chat[HU_MAXMSGLEN];
static boolean headsupactive = false;
boolean hu_showscores; // draw deathmatch rankings
static char hu_tick;
//-------------------------------------------
// misc vars
//-------------------------------------------
consvar_t* chat_macros[10];
extern byte* whitemap; // color translation table for red->white font
extern boolean automapactive;
//added:16-02-98: crosshair 0=off, 1=cross, 2=angle, 3=point, see m_menu.c
patch_t* crosshair[3]; //3 precached crosshair graphics
// -------
// protos.
// -------
void HU_drawDeathmatchRankings (void);
void HU_drawCrosshair (void);
//======================================================================
// KEYBOARD LAYOUTS FOR ENTERING TEXT
//======================================================================
char* shiftxform;
char french_shiftxform[] =
{
0,
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,
' ', '!', '"', '#', '$', '%', '&',
'"', // shift-'
'(', ')', '*', '+',
'?', // shift-,
'_', // shift--
'>', // shift-.
'?', // shift-/
'0', // shift-0
'1', // shift-1
'2', // shift-2
'3', // shift-3
'4', // shift-4
'5', // shift-5
'6', // shift-6
'7', // shift-7
'8', // shift-8
'9', // shift-9
'/',
'.', // shift-;
'<',
'+', // shift-=
'>', '?', '@',
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',
'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
'[', // shift-[
'!', // shift-backslash - OH MY GOD DOES WATCOM SUCK
']', // shift-]
'"', '_',
'\'', // shift-`
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',
'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
'{', '|', '}', '~', 127
};
char english_shiftxform[] =
{
0,
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,
' ', '!', '"', '#', '$', '%', '&',
'"', // shift-'
'(', ')', '*', '+',
'<', // shift-,
'_', // shift--
'>', // shift-.
'?', // shift-/
')', // shift-0
'!', // shift-1
'@', // shift-2
'#', // shift-3
'$', // shift-4
'%', // shift-5
'^', // shift-6
'&', // shift-7
'*', // shift-8
'(', // shift-9
':',
':', // shift-;
'<',
'+', // shift-=
'>', '?', '@',
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',
'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
'[', // shift-[
'!', // shift-backslash - OH MY GOD DOES WATCOM SUCK
']', // shift-]
'"', '_',
'\'', // shift-`
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',
'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
'{', '|', '}', '~', 127
};
char frenchKeyMap[128]=
{
0,
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,
' ','!','"','#','$','%','&','%','(',')','*','+',';','-',':','!',
'0','1','2','3','4','5','6','7','8','9',':','M','<','=','>','?',
'@','Q','B','C','D','E','F','G','H','I','J','K','L',',','N','O',
'P','A','R','S','T','U','V','Z','X','Y','W','^','\\','$','^','_',
'@','Q','B','C','D','E','F','G','H','I','J','K','L',',','N','O',
'P','A','R','S','T','U','V','Z','X','Y','W','^','\\','$','^',127
};
char ForeignTranslation(unsigned char ch)
{
return ch < 128 ? frenchKeyMap[ch] : ch;
}
//======================================================================
// HEADS UP INIT
//======================================================================
// just after
void Command_Say_f (void);
void Command_Sayto_f (void);
void Command_Sayteam_f (void);
void Got_Saycmd(char **p,int playernum);
// Initialise Heads up
// once at game startup.
//
void HU_Init(void)
{
int i;
int j;
char buffer[9];
COM_AddCommand ("say" , Command_Say_f);
COM_AddCommand ("sayto" , Command_Sayto_f);
COM_AddCommand ("sayteam", Command_Sayteam_f);
RegisterNetXCmd(XD_SAY,Got_Saycmd);
// set shift translation table
if (language==french)
shiftxform = french_shiftxform;
else
shiftxform = english_shiftxform;
// cache the heads-up font for entire game execution
j = HU_FONTSTART;
for (i=0;i<HU_FONTSIZE;i++)
{
sprintf(buffer, "STCFN%.3d", j++);
hu_font[i] = (patch_t *) W_CachePatchName(buffer, PU_STATIC);
}
//hu_showscores = false; //added:05-02-98:deathmatch rankings overlay off
// cache the crosshairs, dont bother to know which one is being used,
// just cache them 3 all, they're so small anyway.
for(i=0;i<HU_CROSSHAIRS;i++)
{
sprintf(buffer, "CROSHAI%c", '1'+i);
crosshair[i] = (patch_t *) W_CachePatchName(buffer, PU_STATIC);
}
}
void HU_Stop(void)
{
headsupactive = false;
}
// Reset Heads up when consoleplayer spawns
//
//
void HU_Start(void)
{
int i;
char* s;
if (headsupactive)
HU_Stop();
plr = &players[consoleplayer];
chat_on = false;
switch ( gamemode )
{
case shareware:
case registered:
case retail:
s = HU_TITLE;
break;
// FIXME
// case pack_plut:
// s = HU_TITLEP;
// break;
// case pack_tnt:
// s = HU_TITLET;
// break;
case commercial:
default:
s = HU_TITLE2;
break;
}
strcpy(w_title,s);
// empty the inputbuffers
for (i=0 ; i<MAXPLAYERS ; i++)
w_inputbuffer[i][0] = '\0';
headsupactive = true;
}
//======================================================================
// EXECUTION
//======================================================================
void TeamPlay_OnChange(void)
{
int i;
char s[50];
// Change the name of the teams
if(cv_teamplay.value==1)
{
// color
for(i=0;i<MAXSKINCOLORS;i++)
{
sprintf(s,"%s team",Color_Names[i]);
strcpy(team_names[i],s);
}
}
else
if(cv_teamplay.value==2)
{
// skins
for(i=0;i<numskins;i++)
{
sprintf(s,"%s team",skins[i].name);
strcpy(team_names[i],s);
}
}
}
void Command_Say_f (void)
{
char buf[255];
int i,j;
if((j=COM_Argc())<2)
{
CONS_Printf ("say <message> : send a message\n");
return;
}
buf[0]=0;
strcpy(&buf[1],COM_Argv(1));
for(i=2;i<j;i++)
{
strcat(&buf[1]," ");
strcat(&buf[1],COM_Argv(i));
}
SendNetXCmd(XD_SAY,buf,strlen(buf+1)+2); // +2 because 1 for buf[0] and the other for null terminated string
}
void Command_Sayto_f (void)
{
char buf[255];
int i,j;
if((j=COM_Argc())<3)
{
CONS_Printf ("sayto <playername|playernum> <message> : send a message to a player\n");
return;
}
buf[0]=nametonum(COM_Argv(1));
if(buf[0]==-1)
return;
strcpy(&buf[1],COM_Argv(2));
for(i=3;i<j;i++)
{
strcat(&buf[1]," ");
strcat(&buf[1],COM_Argv(i));
}
SendNetXCmd(XD_SAY,buf,strlen(buf+1)+2);
}
void Command_Sayteam_f (void)
{
char buf[255];
int i,j;
if((j=COM_Argc())<2)
{
CONS_Printf ("sayteam <message> : send a message to your team\n");
return;
}
buf[0]=-consoleplayer;
strcpy(&buf[1],COM_Argv(1));
for(i=2;i<j;i++)
{
strcat(&buf[1]," ");
strcat(&buf[1],COM_Argv(i));
}
SendNetXCmd(XD_SAY,buf,strlen(buf+1)+2); // +2 because 1 for buf[0] and the other for null terminated string
}
// netsyntax : to : byte 1->32 player 1 to 32
// 0 all
// -1->-32 say team -numplayer of the sender
void Got_Saycmd(char **p,int playernum)
{
char to;
to=*(*p)++;
if(to==0 || to==consoleplayer || consoleplayer==playernum
|| (to<0 && ST_SameTeam(&players[consoleplayer],&players[-to])) )
CONS_Printf("\3%s: %s\n", player_names[playernum], *p);
*p+=strlen(*p)+1;
}
// Handles key input and string input
//
boolean HU_keyInChatString (char *s, char ch)
{
int l;
if (ch >= ' ' && ch <= '_')
{
l = strlen(s);
if (l<HU_MAXMSGLEN-1)
{
s[l++]=ch;
s[l]=0;
return true;
}
return false;
}
else
if (ch == KEY_BACKSPACE)
{
l = strlen(s);
if (l)
s[--l]=0;
else
return false;
}
else
if (ch != KEY_ENTER)
return false; // did not eat key
return true; // ate the key
}
//
//
extern boolean playerdeadview; //hack from P_DeathThink()
void HU_Ticker(void)
{
player_t *pl;
hu_tick++;
hu_tick &= 7; //currently only to blink chat input cursor
// display message if necessary
// (display the viewplayer's messages)
pl = &players[displayplayer];
if (cv_showmessages.value && pl->message)
{
CONS_Printf ("%s\n",pl->message);
pl->message = 0;
}
//deathmatch rankings overlay if press key or while in death view
if (cv_deathmatch.value)
{
if (gamekeydown[gamecontrol[gc_scores][0]] ||
gamekeydown[gamecontrol[gc_scores][1]] )
hu_showscores = !chat_on;
else
hu_showscores = playerdeadview; //hack from P_DeathThink()
}
}
#define QUEUESIZE 128
static char chatchars[QUEUESIZE];
static int head = 0;
static int tail = 0;
//
//
char HU_dequeueChatChar(void)
{
char c;
if (head != tail)
{
c = chatchars[tail];
tail = (tail + 1) & (QUEUESIZE-1);
}
else
{
c = 0;
}
return c;
}
//
//
void HU_queueChatChar(char c)
{
if (((head + 1) & (QUEUESIZE-1)) == tail)
{
plr->message = HUSTR_MSGU; //message not send
}
else
{
if (c == KEY_BACKSPACE)
{
if(tail!=head)
head = (head - 1) & (QUEUESIZE-1);
}
else
{
chatchars[head] = c;
head = (head + 1) & (QUEUESIZE-1);
}
}
// send automaticly the message (no more chat char)
if(c==KEY_ENTER)
{
char buf[255],c;
int i=0;
do {
c=HU_dequeueChatChar();
buf[i++]=c;
} while(c);
if(i>3)
COM_BufInsertText (va("say %s",buf));
}
}
extern int con_keymap;
//
// Returns true if key eaten
//
boolean HU_Responder (event_t *ev)
{
static boolean shiftdown = false;
static boolean altdown = false;
boolean eatkey = false;
char* macromessage;
unsigned char c;
if (ev->data1 == KEY_SHIFT)
{
shiftdown = (ev->type == ev_keydown);
return false;
}
else if (ev->data1 == KEY_ALT)
{
altdown = (ev->type == ev_keydown);
return false;
}
if (ev->type != ev_keydown)
return false;
// only KeyDown events now...
if (!chat_on)
{
// enter chat mode
if (ev->data1==gamecontrol[gc_talkkey][0]
|| ev->data1==gamecontrol[gc_talkkey][1])
{
eatkey = chat_on = true;
w_chat[0] = 0;
HU_queueChatChar(HU_BROADCAST);
}
}
else
{
c = ev->data1;
// use console translations
if (con_keymap==french)
c = ForeignTranslation(c);
if (shiftdown)
c = shiftxform[c];
// send a macro
if (altdown)
{
c = c - '0';
if (c > 9)
return false;
macromessage = chat_macros[c]->string;
// kill last message with a '\n'
HU_queueChatChar(KEY_ENTER); // DEBUG!!!
// send the macro message
while (*macromessage)
HU_queueChatChar(*macromessage++);
HU_queueChatChar(KEY_ENTER);
// leave chat mode and notify that it was sent
chat_on = false;
eatkey = true;
}
else
{
if (language==french)
c = ForeignTranslation(c);
if (shiftdown || (c >= 'a' && c <= 'z'))
c = shiftxform[c];
eatkey = HU_keyInChatString(w_chat,c);
if (eatkey)
{
// static unsigned char buf[20]; // DEBUG
HU_queueChatChar(c);
// sprintf(buf, "KEY: %d => %d", ev->data1, c);
// plr->message = buf;
}
if (c == KEY_ENTER)
{
chat_on = false;
}
else if (c == KEY_ESCAPE)
chat_on = false;
}
}
return eatkey;
}
//======================================================================
// HEADS UP DRAWING
//======================================================================
// Draw chat input
//
static void HU_DrawChat (void)
{
int i,c,y;
c=0;
i=0;
y=HU_INPUTY;
while (w_chat[i])
{
V_DrawCharacter( HU_INPUTX + (c<<3), y, w_chat[i++]);
c++;
if (c>=(vid.width>>3))
{
c = 0;
y+=8;
}
}
if (hu_tick<4)
V_DrawMappedPatch (HU_INPUTX + (c<<3),
y,0,
hu_font['_'-HU_FONTSTART],
whitemap);
}
// Heads up displays drawer, call each frame
//
void HU_Drawer(void)
{
// draw chat string plus cursor
if (chat_on)
HU_DrawChat ();
// mapname
if (automapactive)
V_DrawString(HU_TITLEX,HU_TITLEY,w_title);
// draw deathmatch rankings
if (hu_showscores)
HU_drawDeathmatchRankings ();
// draw the crosshair, not when viewing demos
if (viewactive && cv_crosshair.value && !demoplayback)
HU_drawCrosshair ();
}
//======================================================================
// HUD MESSAGES CLEARING FROM SCREEN
//======================================================================
// Clear old messages from the borders around the view window
// (only for reduced view, refresh the borders when needed)
//
// startline : y coord to start clear,
// clearlines : how many lines to clear.
//
extern int con_clearlines; // lines of top of screen to refresh
extern boolean con_hudupdate; // hud messages have changed, need refresh
static int oldclearlines;
void HU_Erase (void)
{
int topline;
int bottomline;
int y,yoffset;
//faB: clear hud msgs on double buffer (Glide mode)
boolean secondframe;
static int secondframelines;
// int x; //DEBUG
//static int col;
if (con_clearlines==oldclearlines && !con_hudupdate)
return;
// clear the other frame in double-buffer modes
secondframe = (con_clearlines!=oldclearlines);
if (secondframe)
secondframelines = oldclearlines;
// clear the message lines that go away, so use _oldclearlines_
bottomline = oldclearlines;
oldclearlines = con_clearlines;
if (automapactive || viewwindowx==0) // hud msgs don't need to be cleared
return;
// software mode copies view border pattern & beveled edges from the backbuffer
if (rendermode==render_soft)
{
topline = 0;
for (y=topline,yoffset=y*vid.width; y<bottomline ; y++,yoffset+=vid.width)
{
if (y < viewwindowy || y >= viewwindowy + viewheight)
R_VideoErase(yoffset, vid.width); // erase entire line
else
{
R_VideoErase(yoffset, viewwindowx); // erase left border
// erase right border
R_VideoErase(yoffset + viewwindowx + viewwidth, viewwindowx);
}
}
con_hudupdate = false; // if it was set..
}
#ifdef __WIN32__
else {
// refresh just what is needed from the view borders
HWR_DrawViewBorder (secondframelines);
con_hudupdate = secondframe;
}
#endif
//DEBUG
// for (x=0;x<vid.width;x++)
// {
// screens[0][yoffset+x] = col;
// screens[0][vid.height*vid.width-vid.width+x] = col;
// }
// col++;
}
//======================================================================
// IN-LEVEL DEATHMATCH RANKINGS
//======================================================================
// count frags for each team
int HU_CreateTeamFragTbl(fragsort_t *fragtab,int dmtotals[],int fragtbl[MAXPLAYERS][MAXPLAYERS])
{
int i,j,k,scorelines,team;
scorelines = 0;
for (i=0; i<MAXPLAYERS; i++)
{
if (playeringame[i])
{
if(cv_teamplay.value==1)
team=players[i].skincolor;
else
team=players[i].skin;
for(j=0;j<scorelines;j++)
if (fragtab[j].num == team)
{ // found there team
if(fragtbl)
{
for(k=0;k<MAXPLAYERS;k++)
if(playeringame[k])
if(cv_teamplay.value==1)
fragtbl[team][players[k].skincolor] +=
players[i].frags[k];
else
fragtbl[team][players[k].skin] +=
players[i].frags[k];
}
fragtab[j].count += ST_PlayerFrags(i);
if(dmtotals)
dmtotals[team]=fragtab[j].count;
break;
}
if (j==scorelines)
{ // team not found add it
if(fragtbl)
for(k=0;k<MAXPLAYERS;k++)
fragtbl[team][k] = 0;
fragtab[scorelines].count = ST_PlayerFrags(i);
fragtab[scorelines].num = team;
fragtab[scorelines].color = players[i].skincolor;
fragtab[scorelines].name = team_names[team];
if(fragtbl)
{
for(k=0;k<MAXPLAYERS;k++)
if(playeringame[k])
if(cv_teamplay.value==1)
fragtbl[team][players[k].skincolor] +=
players[i].frags[k];
else
fragtbl[team][players[k].skin] +=
players[i].frags[k];
}
if(dmtotals)
dmtotals[team]=fragtab[scorelines].count;
scorelines++;
}
}
}
return scorelines;
}
//
// draw Deathmatch Rankings
//
void HU_drawDeathmatchRankings (void)
{
patch_t* p;
fragsort_t fragtab[MAXPLAYERS];
int i;
int scorelines;
int whiteplayer;
// draw the ranking title panel
p = W_CachePatchName("RANKINGS",PU_CACHE);
V_DrawScaledPatch ((BASEVIDWIDTH-p->width)/2,5,0,p);
// count frags for each present player
scorelines = 0;
for (i=0; i<MAXPLAYERS; i++)
{
if (playeringame[i])
{
fragtab[scorelines].count = ST_PlayerFrags(i);
fragtab[scorelines].num = i;
fragtab[scorelines].color = players[i].skincolor;
fragtab[scorelines].name = player_names[i];
scorelines++;
}
}
//Fab:25-04-98: when you play, you quickly see your frags because your
// name is displayed white, when playback demo, you quicly see who's the
// view.
whiteplayer = demoplayback ? displayplayer : consoleplayer;
if (scorelines>9)
scorelines = 9; //dont draw past bottom of screen, show the best only
if(cv_teamplay.value==0)
WI_drawRancking(NULL,80,70,fragtab,scorelines,true,whiteplayer);
else
{
// draw the frag to the right
// WI_drawRancking("Individual",170,70,fragtab,scorelines,true,whiteplayer);
scorelines = HU_CreateTeamFragTbl(fragtab,NULL,NULL);
// and the team frag to the left
WI_drawRancking("Teams",80,70,fragtab,scorelines,true,players[whiteplayer].skincolor);
}
}
// draw the Crosshair, at the exact center of the view.
//
// Crosshairs are pre-cached at HU_Init
#ifdef __WIN32__
extern float gr_basewindowcentery;
extern float gr_viewheight;
#endif
void HU_drawCrosshair (void)
{
int i;
int y;
i = cv_crosshair.value & 3;
if (!i)
return;
if ( rendermode != render_soft ) {
#ifdef __WIN32__
HWR_ScalePatch ( FALSE );
// #endif
y = gr_basewindowcentery;
}
else
y = viewwindowy+(viewheight>>1);
V_DrawTranslucentPatch (vid.width>>1, y, 0, crosshair[i-1]);
if( cv_splitscreen.value )
{
if ( rendermode == render_soft )
y += viewheight;
#endif
#ifdef __WIN32__
else
y += gr_viewheight;
#endif
V_DrawTranslucentPatch (vid.width>>1, y, 0, crosshair[i-1]);
}
#ifdef __WIN32__
if ( rendermode != render_soft )
HWR_ScalePatch ( TRUE );
#endif
}
//======================================================================
// CHAT MACROS COMMAND & VARS
//======================================================================
// better do HackChatmacros() because the strings are NULL !!
consvar_t cv_chatmacro1 = {"_chatmacro1", NULL, CV_SAVE,NULL};
consvar_t cv_chatmacro2 = {"_chatmacro2", NULL, CV_SAVE,NULL};
consvar_t cv_chatmacro3 = {"_chatmacro3", NULL, CV_SAVE,NULL};
consvar_t cv_chatmacro4 = {"_chatmacro4", NULL, CV_SAVE,NULL};
consvar_t cv_chatmacro5 = {"_chatmacro5", NULL, CV_SAVE,NULL};
consvar_t cv_chatmacro6 = {"_chatmacro6", NULL, CV_SAVE,NULL};
consvar_t cv_chatmacro7 = {"_chatmacro7", NULL, CV_SAVE,NULL};
consvar_t cv_chatmacro8 = {"_chatmacro8", NULL, CV_SAVE,NULL};
consvar_t cv_chatmacro9 = {"_chatmacro9", NULL, CV_SAVE,NULL};
consvar_t cv_chatmacro0 = {"_chatmacro0", NULL, CV_SAVE,NULL};
// set the chatmacros original text, before config is executed
// if a dehacked patch was loaded, it will set the hacked texts,
// but the config.cfg will override it.
//
void HU_HackChatmacros (void)
{
int i;
// this is either the original text, or dehacked ones
cv_chatmacro0.string = HUSTR_CHATMACRO0;
cv_chatmacro1.string = HUSTR_CHATMACRO1;
cv_chatmacro2.string = HUSTR_CHATMACRO2;
cv_chatmacro3.string = HUSTR_CHATMACRO3;
cv_chatmacro4.string = HUSTR_CHATMACRO4;
cv_chatmacro5.string = HUSTR_CHATMACRO5;
cv_chatmacro6.string = HUSTR_CHATMACRO6;
cv_chatmacro7.string = HUSTR_CHATMACRO7;
cv_chatmacro8.string = HUSTR_CHATMACRO8;
cv_chatmacro9.string = HUSTR_CHATMACRO9;
// link chatmacros to cvars
chat_macros[0] = &cv_chatmacro0;
chat_macros[1] = &cv_chatmacro1;
chat_macros[2] = &cv_chatmacro2;