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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
|
/*
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
Copyright (C) 2000-2009 Darklegion Development
This file is part of Tremulous.
Tremulous 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.
Tremulous 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 Tremulous; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
// cg_main.c -- initialization and primary entry point for cgame
#include "cg_local.h"
#include "../ui/ui_shared.h"
// display context for new ui stuff
displayContextDef_t cgDC;
void CG_Init( int serverMessageNum, int serverCommandSequence, int clientNum );
void CG_Shutdown( void );
static char *CG_VoIPString( void );
/*
================
vmMain
This is the only way control passes into the module.
This must be the very first function compiled into the .q3vm file
================
*/
Q_EXPORT intptr_t vmMain( int command, int arg0, int arg1, int arg2, int arg3,
int arg4, int arg5, int arg6, int arg7,
int arg8, int arg9, int arg10, int arg11 )
{
switch( command )
{
case CG_INIT:
CG_Init( arg0, arg1, arg2 );
return 0;
case CG_SHUTDOWN:
CG_Shutdown( );
return 0;
case CG_CONSOLE_COMMAND:
return CG_ConsoleCommand( );
case CG_CONSOLE_TEXT:
CG_AddNotifyText( );
return 0;
case CG_DRAW_ACTIVE_FRAME:
CG_DrawActiveFrame( arg0, arg1, arg2 );
return 0;
case CG_CROSSHAIR_PLAYER:
return CG_CrosshairPlayer( );
case CG_LAST_ATTACKER:
return CG_LastAttacker( );
case CG_KEY_EVENT:
CG_KeyEvent( arg0, arg1 );
return 0;
case CG_MOUSE_EVENT:
// cgame doesn't care where the cursor is
return 0;
case CG_EVENT_HANDLING:
CG_EventHandling( arg0 );
return 0;
case CG_VOIP_STRING:
return (intptr_t)CG_VoIPString( );
default:
CG_Error( "vmMain: unknown command %i", command );
break;
}
return -1;
}
cg_t cg;
cgs_t cgs;
centity_t cg_entities[ MAX_GENTITIES ];
weaponInfo_t cg_weapons[ 32 ];
upgradeInfo_t cg_upgrades[ 32 ];
buildableInfo_t cg_buildables[ CUBOID_FIRST ];
cuboidInfo_t cg_cuboids[ CUBOID_TYPES ];
vmCvar_t cg_teslaTrailTime;
vmCvar_t cg_centertime;
vmCvar_t cg_runpitch;
vmCvar_t cg_runroll;
vmCvar_t cg_swingSpeed;
vmCvar_t cg_shadows;
vmCvar_t cg_drawTimer;
vmCvar_t cg_drawClock;
vmCvar_t cg_drawFPS;
vmCvar_t cg_drawDemoState;
vmCvar_t cg_drawSnapshot;
vmCvar_t cg_drawChargeBar;
vmCvar_t cg_drawCrosshair;
vmCvar_t cg_drawCrosshairNames;
vmCvar_t cg_crosshairSize;
vmCvar_t cg_draw2D;
vmCvar_t cg_animSpeed;
vmCvar_t cg_debugAnim;
vmCvar_t cg_debugPosition;
vmCvar_t cg_debugEvents;
vmCvar_t cg_errorDecay;
vmCvar_t cg_nopredict;
vmCvar_t cg_debugMove;
vmCvar_t cg_noPlayerAnims;
vmCvar_t cg_showmiss;
vmCvar_t cg_footsteps;
vmCvar_t cg_addMarks;
vmCvar_t cg_viewsize;
vmCvar_t cg_drawGun;
vmCvar_t cg_gun_frame;
vmCvar_t cg_gun_x;
vmCvar_t cg_gun_y;
vmCvar_t cg_gun_z;
vmCvar_t cg_tracerChance;
vmCvar_t cg_tracerWidth;
vmCvar_t cg_tracerLength;
vmCvar_t cg_thirdPerson;
vmCvar_t cg_thirdPersonAngle;
vmCvar_t cg_thirdPersonShoulderViewMode;
vmCvar_t cg_staticDeathCam;
vmCvar_t cg_thirdPersonPitchFollow;
vmCvar_t cg_thirdPersonRange;
vmCvar_t cg_stereoSeparation;
vmCvar_t cg_lagometer;
vmCvar_t cg_drawSpeed;
vmCvar_t cg_synchronousClients;
vmCvar_t cg_stats;
vmCvar_t cg_paused;
vmCvar_t cg_blood;
vmCvar_t cg_teamChatsOnly;
vmCvar_t cg_drawTeamOverlay;
vmCvar_t cg_teamOverlaySortMode;
vmCvar_t cg_teamOverlayMaxPlayers;
vmCvar_t cg_teamOverlayUserinfo;
vmCvar_t cg_noPrintDuplicate;
vmCvar_t cg_noVoiceChats;
vmCvar_t cg_noVoiceText;
vmCvar_t cg_hudFiles;
vmCvar_t cg_hudFilesEnable;
vmCvar_t cg_smoothClients;
vmCvar_t pmove_fixed;
vmCvar_t pmove_msec;
vmCvar_t cg_cameraMode;
vmCvar_t cg_timescaleFadeEnd;
vmCvar_t cg_timescaleFadeSpeed;
vmCvar_t cg_timescale;
vmCvar_t cg_noTaunt;
vmCvar_t cg_drawSurfNormal;
vmCvar_t cg_drawBBOX;
vmCvar_t cg_wwSmoothTime;
vmCvar_t cg_disableBlueprintErrors;
vmCvar_t cg_depthSortParticles;
vmCvar_t cg_bounceParticles;
vmCvar_t cg_consoleLatency;
vmCvar_t cg_lightFlare;
vmCvar_t cg_debugParticles;
vmCvar_t cg_debugTrails;
vmCvar_t cg_debugPVS;
vmCvar_t cg_disableWarningDialogs;
vmCvar_t cg_disableUpgradeDialogs;
vmCvar_t cg_disableBuildDialogs;
vmCvar_t cg_disableCommandDialogs;
vmCvar_t cg_disableScannerPlane;
vmCvar_t cg_tutorial;
vmCvar_t cg_painBlendUpRate;
vmCvar_t cg_painBlendDownRate;
vmCvar_t cg_painBlendMax;
vmCvar_t cg_painBlendScale;
vmCvar_t cg_painBlendZoom;
vmCvar_t cg_stickySpec;
vmCvar_t cg_sprintToggle;
vmCvar_t cg_unlagged;
vmCvar_t cg_debugVoices;
vmCvar_t ui_currentClass;
vmCvar_t ui_carriage;
vmCvar_t ui_stages;
vmCvar_t ui_dialog;
vmCvar_t ui_voteActive;
vmCvar_t ui_alienTeamVoteActive;
vmCvar_t ui_humanTeamVoteActive;
vmCvar_t cg_debugRandom;
vmCvar_t cg_optimizePrediction;
vmCvar_t cg_projectileNudge;
vmCvar_t cg_voice;
vmCvar_t cg_emoticons;
vmCvar_t cg_chatTeamPrefix;
vmCvar_t cg_cuboidResizeAxis;
vmCvar_t cg_cuboidResizeRate;
vmCvar_t cg_cuboidPSQuality;
vmCvar_t cg_cuboidInfoX;
vmCvar_t cg_cuboidInfoY;
vmCvar_t cg_drawCuboidInfo;
vmCvar_t cg_fuelInfoX;
vmCvar_t cg_fuelInfoY;
vmCvar_t cg_fuelInfoScale;
vmCvar_t cg_announcer;
vmCvar_t cg_cameraShakeMagnitude;
vmCvar_t cg_debug1;
vmCvar_t cg_debug2;
vmCvar_t cg_debug3;
vmCvar_t cg_debug4;
typedef struct
{
vmCvar_t *vmCvar;
char *cvarName;
char *defaultString;
int cvarFlags;
} cvarTable_t;
static cvarTable_t cvarTable[ ] =
{
{ &cg_drawGun, "cg_drawGun", "1", CVAR_ARCHIVE },
{ &cg_viewsize, "cg_viewsize", "100", CVAR_ARCHIVE },
{ &cg_stereoSeparation, "cg_stereoSeparation", "0.4", CVAR_ARCHIVE },
{ &cg_shadows, "cg_shadows", "1", CVAR_ARCHIVE },
{ &cg_draw2D, "cg_draw2D", "1", CVAR_ARCHIVE },
{ &cg_drawTimer, "cg_drawTimer", "1", CVAR_ARCHIVE },
{ &cg_drawClock, "cg_drawClock", "0", CVAR_ARCHIVE },
{ &cg_drawFPS, "cg_drawFPS", "1", CVAR_ARCHIVE },
{ &cg_drawDemoState, "cg_drawDemoState", "1", CVAR_ARCHIVE },
{ &cg_drawSnapshot, "cg_drawSnapshot", "0", CVAR_ARCHIVE },
{ &cg_drawChargeBar, "cg_drawChargeBar", "1", CVAR_ARCHIVE },
{ &cg_drawCrosshair, "cg_drawCrosshair", "2", CVAR_ARCHIVE },
{ &cg_drawCrosshairNames, "cg_drawCrosshairNames", "1", CVAR_ARCHIVE },
{ &cg_crosshairSize, "cg_crosshairSize", "1", CVAR_ARCHIVE },
{ &cg_addMarks, "cg_marks", "1", CVAR_ARCHIVE },
{ &cg_lagometer, "cg_lagometer", "0", CVAR_ARCHIVE },
{ &cg_drawSpeed, "cg_drawSpeed", "0", CVAR_ARCHIVE },
{ &cg_teslaTrailTime, "cg_teslaTrailTime", "250", CVAR_ARCHIVE },
{ &cg_gun_x, "cg_gunX", "0", CVAR_CHEAT },
{ &cg_gun_y, "cg_gunY", "0", CVAR_CHEAT },
{ &cg_gun_z, "cg_gunZ", "0", CVAR_CHEAT },
{ &cg_centertime, "cg_centertime", "3", CVAR_CHEAT },
{ &cg_runpitch, "cg_runpitch", "0.002", CVAR_ARCHIVE},
{ &cg_runroll, "cg_runroll", "0.005", CVAR_ARCHIVE },
{ &cg_swingSpeed, "cg_swingSpeed", "0.3", CVAR_CHEAT },
{ &cg_animSpeed, "cg_animspeed", "1", CVAR_CHEAT },
{ &cg_debugAnim, "cg_debuganim", "0", CVAR_CHEAT },
{ &cg_debugPosition, "cg_debugposition", "0", CVAR_CHEAT },
{ &cg_debugEvents, "cg_debugevents", "0", CVAR_CHEAT },
{ &cg_errorDecay, "cg_errordecay", "100", 0 },
{ &cg_nopredict, "cg_nopredict", "0", 0 },
{ &cg_debugMove, "cg_debugMove", "0", 0 },
{ &cg_noPlayerAnims, "cg_noplayeranims", "0", CVAR_CHEAT },
{ &cg_showmiss, "cg_showmiss", "0", 0 },
{ &cg_footsteps, "cg_footsteps", "1", CVAR_CHEAT },
{ &cg_tracerChance, "cg_tracerchance", "0.4", CVAR_CHEAT },
{ &cg_tracerWidth, "cg_tracerwidth", "1", CVAR_CHEAT },
{ &cg_tracerLength, "cg_tracerlength", "100", CVAR_CHEAT },
{ &cg_thirdPersonRange, "cg_thirdPersonRange", "75", CVAR_ARCHIVE },
{ &cg_thirdPerson, "cg_thirdPerson", "0", CVAR_CHEAT },
{ &cg_thirdPersonAngle, "cg_thirdPersonAngle", "0", CVAR_CHEAT },
{ &cg_thirdPersonPitchFollow, "cg_thirdPersonPitchFollow", "0", 0 },
{ &cg_thirdPersonShoulderViewMode, "cg_thirdPersonShoulderViewMode", "1", CVAR_ARCHIVE },
{ &cg_staticDeathCam, "cg_staticDeathCam", "0", CVAR_ARCHIVE },
{ &cg_stats, "cg_stats", "0", 0 },
{ &cg_drawTeamOverlay, "cg_drawTeamOverlay", "1", CVAR_ARCHIVE },
{ &cg_teamOverlaySortMode, "cg_teamOverlaySortMode", "1", CVAR_ARCHIVE },
{ &cg_teamOverlayMaxPlayers, "cg_teamOverlayMaxPlayers", "8", CVAR_ARCHIVE },
{ &cg_teamOverlayUserinfo, "teamoverlay", "1", CVAR_ARCHIVE|CVAR_USERINFO },
{ &cg_teamChatsOnly, "cg_teamChatsOnly", "0", CVAR_ARCHIVE },
{ &cg_noPrintDuplicate, "cg_noPrintDuplicate", "0", CVAR_ARCHIVE },
{ &cg_noVoiceChats, "cg_noVoiceChats", "0", CVAR_ARCHIVE },
{ &cg_noVoiceText, "cg_noVoiceText", "0", CVAR_ARCHIVE },
{ &cg_drawSurfNormal, "cg_drawSurfNormal", "0", CVAR_CHEAT },
{ &cg_drawBBOX, "cg_drawBBOX", "0", CVAR_CHEAT },
{ &cg_wwSmoothTime, "cg_wwSmoothTime", "300", CVAR_ARCHIVE },
{ NULL, "cg_wwFollow", "1", CVAR_ARCHIVE|CVAR_USERINFO },
{ NULL, "cg_wwToggle", "1", CVAR_ARCHIVE|CVAR_USERINFO },
{ NULL, "cg_disableBlueprintErrors", "0", CVAR_ARCHIVE|CVAR_USERINFO },
{ &cg_stickySpec, "cg_stickySpec", "1", CVAR_ARCHIVE|CVAR_USERINFO },
{ &cg_sprintToggle, "cg_sprintToggle", "0", CVAR_ARCHIVE|CVAR_USERINFO },
{ &cg_unlagged, "cg_unlagged", "1", CVAR_ARCHIVE|CVAR_USERINFO },
{ NULL, "cg_flySpeed", "600", CVAR_ARCHIVE|CVAR_USERINFO },
{ &cg_depthSortParticles, "cg_depthSortParticles", "1", CVAR_ARCHIVE },
{ &cg_bounceParticles, "cg_bounceParticles", "0", CVAR_ARCHIVE },
{ &cg_consoleLatency, "cg_consoleLatency", "3000", CVAR_ARCHIVE },
{ &cg_lightFlare, "cg_lightFlare", "3", CVAR_ARCHIVE },
{ &cg_debugParticles, "cg_debugParticles", "0", CVAR_CHEAT },
{ &cg_debugTrails, "cg_debugTrails", "0", CVAR_CHEAT },
{ &cg_debugPVS, "cg_debugPVS", "0", CVAR_CHEAT },
{ &cg_disableWarningDialogs, "cg_disableWarningDialogs", "0", CVAR_ARCHIVE },
{ &cg_disableUpgradeDialogs, "cg_disableUpgradeDialogs", "0", CVAR_ARCHIVE },
{ &cg_disableBuildDialogs, "cg_disableBuildDialogs", "0", CVAR_ARCHIVE },
{ &cg_disableCommandDialogs, "cg_disableCommandDialogs", "0", CVAR_ARCHIVE },
{ &cg_disableScannerPlane, "cg_disableScannerPlane", "0", CVAR_ARCHIVE },
{ &cg_tutorial, "cg_tutorial", "1", CVAR_ARCHIVE },
{ &cg_hudFiles, "cg_hudFiles", "ui/hud.txt", CVAR_ARCHIVE},
{ &cg_hudFilesEnable, "cg_hudFilesEnable", "0", CVAR_ARCHIVE},
{ NULL, "cg_alienConfig", "", CVAR_ARCHIVE },
{ NULL, "cg_humanConfig", "", CVAR_ARCHIVE },
{ NULL, "cg_spectatorConfig", "", CVAR_ARCHIVE },
{ &cg_painBlendUpRate, "cg_painBlendUpRate", "10.0", 0 },
{ &cg_painBlendDownRate, "cg_painBlendDownRate", "0.5", 0 },
{ &cg_painBlendMax, "cg_painBlendMax", "0.7", 0 },
{ &cg_painBlendScale, "cg_painBlendScale", "7.0", 0 },
{ &cg_painBlendZoom, "cg_painBlendZoom", "0.65", 0 },
{ &cg_debugVoices, "cg_debugVoices", "0", 0 },
// communication cvars set by the cgame to be read by ui
{ &ui_currentClass, "ui_currentClass", "0", CVAR_ROM },
{ &ui_carriage, "ui_carriage", "", CVAR_ROM },
{ &ui_stages, "ui_stages", "0 0", CVAR_ROM },
{ &ui_dialog, "ui_dialog", "Text not set", CVAR_ROM },
{ &ui_voteActive, "ui_voteActive", "0", CVAR_ROM },
{ &ui_humanTeamVoteActive, "ui_humanTeamVoteActive", "0", CVAR_ROM },
{ &ui_alienTeamVoteActive, "ui_alienTeamVoteActive", "0", CVAR_ROM },
{ &cg_debugRandom, "cg_debugRandom", "0", 0 },
{ &cg_optimizePrediction, "cg_optimizePrediction", "1", CVAR_ARCHIVE },
{ &cg_projectileNudge, "cg_projectileNudge", "1", CVAR_ARCHIVE },
// the following variables are created in other parts of the system,
// but we also reference them here
{ &cg_paused, "cl_paused", "0", CVAR_ROM },
{ &cg_blood, "com_blood", "1", CVAR_ARCHIVE },
{ &cg_synchronousClients, "g_synchronousClients", "0", 0 }, // communicated by systeminfo
{ &cg_timescaleFadeEnd, "cg_timescaleFadeEnd", "1", CVAR_CHEAT },
{ &cg_timescaleFadeSpeed, "cg_timescaleFadeSpeed", "0", CVAR_CHEAT },
{ &cg_timescale, "timescale", "1", 0},
{ &cg_smoothClients, "cg_smoothClients", "0", CVAR_USERINFO | CVAR_ARCHIVE},
{ &cg_cameraMode, "com_cameraMode", "0", CVAR_CHEAT},
{ &pmove_fixed, "pmove_fixed", "0", 0},
{ &pmove_msec, "pmove_msec", "8", 0},
{ &cg_noTaunt, "cg_noTaunt", "0", CVAR_ARCHIVE},
{ &cg_voice, "voice", "default", CVAR_USERINFO|CVAR_ARCHIVE},
{ &cg_emoticons, "cg_emoticons", "1", CVAR_LATCH|CVAR_ARCHIVE},
{ &cg_chatTeamPrefix, "cg_chatTeamPrefix", "1", CVAR_ARCHIVE },
{ &cg_cuboidResizeAxis, "cg_cuboidResizeAxis", "2", 0 },
{ &cg_cuboidResizeRate, "cg_cuboidResizeRate", "5", CVAR_ARCHIVE },
{ &cg_cuboidPSQuality, "cg_cuboidPSQuality", "3", CVAR_ARCHIVE },
{ &cg_cuboidInfoX, "cg_cuboidInfoX" ,"0", CVAR_ARCHIVE },
{ &cg_cuboidInfoY, "cg_cuboidInfoY" ,"150", CVAR_ARCHIVE },
{ &cg_drawCuboidInfo, "cg_drawCuboidInfo" ,"0", CVAR_ARCHIVE },
{ &cg_fuelInfoX, "cg_fuelInfoX" ,"0", CVAR_ARCHIVE },
{ &cg_fuelInfoY, "cg_fuelInfoY" ,"150", CVAR_ARCHIVE },
{ &cg_fuelInfoScale, "cg_fuelInfoScale" ,"0.5", CVAR_ARCHIVE },
{ &cg_announcer, "cg_announcer", "1", CVAR_ARCHIVE },
{ &cg_cameraShakeMagnitude, "cg_cameraShakeMagnitude", "1", CVAR_ARCHIVE },
{ &cg_debug1, "cg_debug1", "", CVAR_CHEAT },
{ &cg_debug2, "cg_debug2", "", CVAR_CHEAT },
{ &cg_debug3, "cg_debug3", "", CVAR_CHEAT },
{ &cg_debug4, "cg_debug4", "", CVAR_CHEAT }
};
static int cvarTableSize = sizeof( cvarTable ) / sizeof( cvarTable[0] );
/*
=================
CG_RegisterCvars
=================
*/
void CG_RegisterCvars( void )
{
int i;
cvarTable_t *cv;
char var[ MAX_TOKEN_CHARS ];
for( i = 0, cv = cvarTable; i < cvarTableSize; i++, cv++ )
{
trap_Cvar_Register( cv->vmCvar, cv->cvarName,
cv->defaultString, cv->cvarFlags );
}
// see if we are also running the server on this machine
trap_Cvar_VariableStringBuffer( "sv_running", var, sizeof( var ) );
cgs.localServer = atoi( var );
}
/*
===============
CG_SetUIVars
Set some cvars used by the UI
===============
*/
static void CG_SetUIVars( void )
{
int i;
char carriageCvar[ MAX_TOKEN_CHARS ];
if( !cg.snap )
return;
*carriageCvar = 0;
//determine what the player is carrying
for( i = WP_NONE + 1; i < WP_NUM_WEAPONS; i++ )
{
if( BG_InventoryContainsWeapon( i, cg.snap->ps.stats ) &&
BG_Weapon( i )->purchasable )
strcat( carriageCvar, va( "W%d ", i ) );
}
for( i = UP_NONE + 1; i < UP_NUM_UPGRADES; i++ )
{
if( BG_InventoryContainsUpgrade( i, cg.snap->ps.stats ) &&
BG_Upgrade( i )->purchasable )
strcat( carriageCvar, va( "U%d ", i ) );
}
strcat( carriageCvar, "$" );
trap_Cvar_Set( "ui_carriage", carriageCvar );
trap_Cvar_Set( "ui_stages", va( "%d %d", cgs.alienStage, cgs.humanStage ) );
}
/*
=================
CG_UpdateCvars
=================
*/
void CG_UpdateCvars( void )
{
int i;
cvarTable_t *cv;
for( i = 0, cv = cvarTable; i < cvarTableSize; i++, cv++ )
if( cv->vmCvar )
trap_Cvar_Update( cv->vmCvar );
// check for modications here
CG_SetUIVars( );
}
int CG_CrosshairPlayer( void )
{
if( cg.time > ( cg.crosshairClientTime + 1000 ) )
return -1;
return cg.crosshairClientNum;
}
int CG_LastAttacker( void )
{
if( !cg.attackerTime )
return -1;
return cg.snap->ps.persistant[ PERS_ATTACKER ];
}
/*
=================
CG_RemoveNotifyLine
=================
*/
void CG_RemoveNotifyLine( void )
{
int i, offset, totalLength;
if( cg.numConsoleLines == 0 )
return;
offset = cg.consoleLines[ 0 ].length;
totalLength = strlen( cg.consoleText ) - offset;
//slide up consoleText
for( i = 0; i <= totalLength; i++ )
cg.consoleText[ i ] = cg.consoleText[ i + offset ];
//pop up the first consoleLine
for( i = 0; i < cg.numConsoleLines; i++ )
cg.consoleLines[ i ] = cg.consoleLines[ i + 1 ];
cg.numConsoleLines--;
}
/*
=================
CG_AddNotifyText
=================
*/
void CG_AddNotifyText( void )
{
char buffer[ BIG_INFO_STRING ];
int bufferLen, textLen;
trap_LiteralArgs( buffer, BIG_INFO_STRING );
if( !buffer[ 0 ] )
{
cg.consoleText[ 0 ] = '\0';
cg.numConsoleLines = 0;
return;
}
bufferLen = strlen( buffer );
textLen = strlen( cg.consoleText );
// Ignore console messages that were just printed
if( cg_noPrintDuplicate.integer && textLen >= bufferLen &&
!strcmp( cg.consoleText + textLen - bufferLen, buffer ) )
return;
if( cg.numConsoleLines == MAX_CONSOLE_LINES )
CG_RemoveNotifyLine( );
Q_strcat( cg.consoleText, MAX_CONSOLE_TEXT, buffer );
cg.consoleLines[ cg.numConsoleLines ].time = cg.time;
cg.consoleLines[ cg.numConsoleLines ].length = bufferLen;
cg.numConsoleLines++;
}
void QDECL CG_Printf( const char *msg, ... )
{
va_list argptr;
char text[ 1024 ];
va_start( argptr, msg );
Q_vsnprintf( text, sizeof( text ), msg, argptr );
va_end( argptr );
trap_Print( text );
}
void QDECL CG_Error( const char *msg, ... )
{
va_list argptr;
char text[ 1024 ];
va_start( argptr, msg );
Q_vsnprintf( text, sizeof( text ), msg, argptr );
va_end( argptr );
trap_Error( text );
}
void QDECL Com_Error( int level, const char *error, ... )
{
va_list argptr;
char text[1024];
va_start( argptr, error );
Q_vsnprintf( text, sizeof( text ), error, argptr );
va_end( argptr );
CG_Error( "%s", text );
}
void QDECL Com_Printf( const char *msg, ... ) {
va_list argptr;
char text[1024];
va_start( argptr, msg );
Q_vsnprintf( text, sizeof( text ), msg, argptr );
va_end( argptr );
CG_Printf ("%s", text);
}
/*
================
CG_Argv
================
*/
const char *CG_Argv( int arg )
{
static char buffer[ MAX_STRING_CHARS ];
trap_Argv( arg, buffer, sizeof( buffer ) );
return buffer;
}
//========================================================================
/*
=================
CG_FileExists
Test if a specific file exists or not
=================
*/
qboolean CG_FileExists( char *filename )
{
return trap_FS_FOpenFile( filename, NULL, FS_READ );
}
/*
=================
CG_RegisterSounds
called during a precache command
=================
*/
static void CG_RegisterSounds( void )
{
int i;
char name[ MAX_QPATH ];
const char *soundName;
cgs.media.alienStageTransition = trap_S_RegisterSound( "sound/announcements/overmindevolved.wav", qtrue );
cgs.media.humanStageTransition = trap_S_RegisterSound( "sound/announcements/reinforcement.wav", qtrue );
cgs.media.alienOvermindAttack = trap_S_RegisterSound( "sound/announcements/overmindattack.wav", qtrue );
cgs.media.alienOvermindDying = trap_S_RegisterSound( "sound/announcements/overminddying.wav", qtrue );
cgs.media.alienOvermindSpawns = trap_S_RegisterSound( "sound/announcements/overmindspawns.wav", qtrue );
cgs.media.alienL1Grab = trap_S_RegisterSound( "sound/player/level1/grab.wav", qtrue );
cgs.media.alienL4ChargePrepare = trap_S_RegisterSound( "sound/player/level4/charge_prepare.wav", qtrue );
cgs.media.alienL4ChargeStart = trap_S_RegisterSound( "sound/player/level4/charge_start.wav", qtrue );
cgs.media.tracerSound = trap_S_RegisterSound( "sound/weapons/tracer.wav", qfalse );
cgs.media.selectSound = trap_S_RegisterSound( "sound/weapons/change.wav", qfalse );
cgs.media.turretSpinupSoundA = trap_S_RegisterSound( "sound/buildables/mgturret/spinup_a.wav", qfalse );
cgs.media.turretSpinupSoundB = trap_S_RegisterSound( "sound/buildables/mgturret/spinup_b.wav", qfalse );
cgs.media.turretKillSound = trap_S_RegisterSound( "sound/buildables/mgturret/turretkill_a.wav", qfalse );
cgs.media.weaponEmptyClick = trap_S_RegisterSound( "sound/weapons/click.wav", qfalse );
cgs.media.talkSound = trap_S_RegisterSound( "sound/misc/talk.wav", qfalse );
cgs.media.alienTalkSound = trap_S_RegisterSound( "sound/misc/alien_talk.wav", qfalse );
cgs.media.humanTalkSound = trap_S_RegisterSound( "sound/misc/human_talk.wav", qfalse );
cgs.media.landSound = trap_S_RegisterSound( "sound/player/land1.wav", qfalse );
cgs.media.watrInSound = trap_S_RegisterSound( "sound/player/watr_in.wav", qfalse );
cgs.media.watrOutSound = trap_S_RegisterSound( "sound/player/watr_out.wav", qfalse );
cgs.media.watrUnSound = trap_S_RegisterSound( "sound/player/watr_un.wav", qfalse );
cgs.media.disconnectSound = trap_S_RegisterSound( "sound/misc/disconnect.wav", qfalse );
for( i = 0; i < 4; i++ )
{
Com_sprintf( name, sizeof( name ), "sound/player/footsteps/step%i.wav", i + 1 );
cgs.media.footsteps[ FOOTSTEP_NORMAL ][ i ] = trap_S_RegisterSound( name, qfalse );
Com_sprintf( name, sizeof( name ), "sound/player/footsteps/flesh%i.wav", i + 1 );
cgs.media.footsteps[ FOOTSTEP_FLESH ][ i ] = trap_S_RegisterSound( name, qfalse );
Com_sprintf( name, sizeof( name ), "sound/player/footsteps/splash%i.wav", i + 1 );
cgs.media.footsteps[ FOOTSTEP_SPLASH ][ i ] = trap_S_RegisterSound( name, qfalse );
Com_sprintf( name, sizeof( name ), "sound/player/footsteps/clank%i.wav", i + 1 );
cgs.media.footsteps[ FOOTSTEP_METAL ][ i ] = trap_S_RegisterSound( name, qfalse );
}
for( i = 1 ; i < MAX_SOUNDS ; i++ )
{
soundName = CG_ConfigString( CS_SOUNDS + i );
if( !soundName[ 0 ] )
break;
if( soundName[ 0 ] == '*' )
continue; // custom sound
cgs.gameSounds[ i ] = trap_S_RegisterSound( soundName, qfalse );
}
cgs.media.jetpackDescendSound = trap_S_RegisterSound( "sound/upgrades/jetpack/low.wav", qfalse );
cgs.media.jetpackIdleSound = trap_S_RegisterSound( "sound/upgrades/jetpack/idle.wav", qfalse );
cgs.media.jetpackAscendSound = trap_S_RegisterSound( "sound/upgrades/jetpack/hi.wav", qfalse );
cgs.media.jetpackDescendDeactivateSound = trap_S_RegisterSound( "sound/upgrades/jetpack/low_off.wav", qfalse );
cgs.media.jetpackIdleDeactivateSound = trap_S_RegisterSound( "sound/upgrades/jetpack/idle_off.wav", qfalse );
cgs.media.jetpackAscendDeactivateSound = trap_S_RegisterSound( "sound/upgrades/jetpack/hi_off.wav", qfalse );
cgs.media.jetpackJumpSound = trap_S_RegisterSound( "sound/upgrades/jetpack/jump.wav", qfalse );
cgs.media.jetpackLowFuelSound = trap_S_RegisterSound( "sound/upgrades/jetpack/lowfuel.wav", qfalse );
cgs.media.jetpackNoJumpFuelSound = trap_S_RegisterSound( "sound/upgrades/jetpack/nojumpfuel.wav", qfalse );
cgs.media.jetpackRefuelSound = trap_S_RegisterSound( "sound/upgrades/jetpack/refuel.wav", qfalse );
cgs.media.medkitUseSound = trap_S_RegisterSound( "sound/upgrades/medkit/medkit.wav", qfalse );
cgs.media.alienEvolveSound = trap_S_RegisterSound( "sound/player/alienevolve.wav", qfalse );
cgs.media.alienHatchSound = trap_S_RegisterSound( "sound/player/alienhatch.wav", qfalse );
cgs.media.alienFailedHatchSound = trap_S_RegisterSound( "sound/player/alienfailedhatch.wav", qfalse );
cgs.media.alienBuildableExplosion = trap_S_RegisterSound( "sound/buildables/alien/explosion.wav", qfalse );
cgs.media.alienBuildableDamage = trap_S_RegisterSound( "sound/buildables/alien/damage.wav", qfalse );
cgs.media.alienBuildablePrebuild = trap_S_RegisterSound( "sound/buildables/alien/prebuild.wav", qfalse );
cgs.media.humanBuildableExplosion = trap_S_RegisterSound( "sound/buildables/human/explosion.wav", qfalse );
cgs.media.humanBuildablePrebuild = trap_S_RegisterSound( "sound/buildables/human/prebuild.wav", qfalse );
for( i = 0; i < 4; i++ )
cgs.media.humanBuildableDamage[ i ] = trap_S_RegisterSound(
va( "sound/buildables/human/damage%d.wav", i ), qfalse );
cgs.media.hardBounceSound1 = trap_S_RegisterSound( "sound/misc/hard_bounce1.wav", qfalse );
cgs.media.hardBounceSound2 = trap_S_RegisterSound( "sound/misc/hard_bounce2.wav", qfalse );
cgs.media.repeaterUseSound = trap_S_RegisterSound( "sound/buildables/repeater/use.wav", qfalse );
cgs.media.buildableRepairSound = trap_S_RegisterSound( "sound/buildables/human/repair.wav", qfalse );
cgs.media.buildableRepairedSound = trap_S_RegisterSound( "sound/buildables/human/repaired.wav", qfalse );
cgs.media.lCannonWarningSound = trap_S_RegisterSound( "models/weapons/lcannon/warning.wav", qfalse );
cgs.media.lCannonWarningSound2 = trap_S_RegisterSound( "models/weapons/lcannon/warning2.wav", qfalse );
cgs.media.cuboidErrorSound = trap_S_RegisterSound( "sound/cuboid/error.wav", qfalse );
cg.lastCuboidError = cg.time;
cgs.media.cuboidResizeSoundA = trap_S_RegisterSound( "sound/cuboid/resizea.wav", qfalse );
cgs.media.cuboidResizeSoundB = trap_S_RegisterSound( "sound/cuboid/resizeb.wav", qfalse );
cgs.media.cuboidRotateSound = trap_S_RegisterSound( "sound/cuboid/rotate.wav", qfalse );
cgs.media.cuboidAxisChangeSound = trap_S_RegisterSound( "sound/cuboid/axischange.wav", qfalse );
cgs.media.unpoweredSurgeLoop = trap_S_RegisterSound( "sound/buildables/human/unpowered_surge.wav", qfalse );
cgs.media.powerSwitchSound = trap_S_RegisterSound( "sound/buildables/human/switch.wav", qfalse );
for( i = 0; i < 4; i++ )
cgs.media.powerZap[ i ] = trap_S_RegisterSound( va( "sound/buildables/human/powerzap%i.wav", i + 1 ), qfalse );
cgs.media.hitSound = trap_S_RegisterSound( "sound/feedback/_hit.wav", qfalse );
}
//===================================================================================
/*
=================
CG_RegisterGraphics
This function may execute for a couple of minutes with a slow disk.
=================
*/
static void CG_RegisterGraphics( void )
{
int i;
static char *sb_nums[ 11 ] =
{
"gfx/2d/numbers/zero_32b",
"gfx/2d/numbers/one_32b",
"gfx/2d/numbers/two_32b",
"gfx/2d/numbers/three_32b",
"gfx/2d/numbers/four_32b",
"gfx/2d/numbers/five_32b",
"gfx/2d/numbers/six_32b",
"gfx/2d/numbers/seven_32b",
"gfx/2d/numbers/eight_32b",
"gfx/2d/numbers/nine_32b",
"gfx/2d/numbers/minus_32b",
};
static char *sb_digital[ 12 ] =
{
"gfx/2d/digital/0",
"gfx/2d/digital/1",
"gfx/2d/digital/2",
"gfx/2d/digital/3",
"gfx/2d/digital/4",
"gfx/2d/digital/5",
"gfx/2d/digital/6",
"gfx/2d/digital/7",
"gfx/2d/digital/8",
"gfx/2d/digital/9",
"gfx/2d/digital/minus",
"gfx/2d/digital/comma"
};
static char *buildWeaponTimerPieShaders[ 8 ] =
{
"ui/assets/neutral/1_5pie",
"ui/assets/neutral/3_0pie",
"ui/assets/neutral/4_5pie",
"ui/assets/neutral/6_0pie",
"ui/assets/neutral/7_5pie",
"ui/assets/neutral/9_0pie",
"ui/assets/neutral/10_5pie",
"ui/assets/neutral/12_0pie",
};
// clear any references to old media
memset( &cg.refdef, 0, sizeof( cg.refdef ) );
trap_R_ClearScene( );
trap_R_LoadWorldMap( cgs.mapname );
CG_UpdateMediaFraction( 0.66f );
for( i = 0; i < 11; i++ )
cgs.media.numberShaders[ i ] = trap_R_RegisterShader( sb_nums[ i ] );
for( i = 0; i < 12; i++ )
cgs.media.digitalNumberShaders[ i ] = trap_R_RegisterShader( sb_digital[ i ] );
cgs.media.viewBloodShader = trap_R_RegisterShader( "gfx/damage/fullscreen_painblend" );
cgs.media.connectionShader = trap_R_RegisterShader( "gfx/2d/net" );
cgs.media.creepShader = trap_R_RegisterShader( "creep" );
cgs.media.scannerBlipShader = trap_R_RegisterShader( "gfx/2d/blip" );
cgs.media.scannerLineShader = trap_R_RegisterShader( "gfx/2d/stalk" );
cgs.media.teamOverlayShader = trap_R_RegisterShader( "gfx/2d/teamoverlay" );
cgs.media.tracerShader = trap_R_RegisterShader( "gfx/misc/tracer" );
cgs.media.backTileShader = trap_R_RegisterShader( "console" );
// building shaders
cgs.media.greenBuildShader = trap_R_RegisterShader("gfx/misc/greenbuild" );
cgs.media.redBuildShader = trap_R_RegisterShader("gfx/misc/redbuild" );
cgs.media.humanSpawningShader = trap_R_RegisterShader("models/buildables/telenode/rep_cyl" );
cgs.media.humanUnpoweredSpawningShader = trap_R_RegisterShader("gfx/misc/unpowered_prebuild" );
cgs.media.cuboidCracks = trap_R_RegisterShader( "models/cuboid/cracks" );
cgs.media.cuboidModel = trap_R_RegisterModel( "models/cuboid/cuboid.md3" );
cgs.media.cuboidRedBuildShader = trap_R_RegisterShader( "gfx/cuboid/build_red" );
cgs.media.cuboidYellowBuildShader = trap_R_RegisterShader( "gfx/cuboid/build_yellow" );
cgs.media.cuboidGreenBuildShader = trap_R_RegisterShader( "gfx/cuboid/build_green" );
cgs.media.cuboidAxis = trap_R_RegisterShader( "gfx/cuboid/build_axis" );
cgs.media.cuboidAlienPrebuild = trap_R_RegisterShader( "gfx/cuboid/prebuild_alien" );
cg.waitForCB = qfalse;
cg.cuboidValid = qfalse;
cg.latestCBNumber = 0;
VectorSet( cg.cuboidSelection, 30, 30, 30 );
// ckit...
cgs.media.ckitBackgroundShader = trap_R_RegisterShader( "gfx/ckit/background" );
cgs.media.ckitOverlayShader = trap_R_RegisterShader( "gfx/ckit/overlay" );
cgs.media.ckit_icon_bp = trap_R_RegisterShader( "gfx/ckit/icon_bp" );
cgs.media.ckit_icon_current = trap_R_RegisterShader( "gfx/ckit/icon_current" );
cgs.media.ckit_icon_depth = trap_R_RegisterShader( "gfx/ckit/icon_depth" );
cgs.media.ckit_icon_health = trap_R_RegisterShader( "gfx/ckit/icon_health" );
cgs.media.ckit_icon_height = trap_R_RegisterShader( "gfx/ckit/icon_height" );
cgs.media.ckit_icon_network = trap_R_RegisterShader( "gfx/ckit/icon_network" );
cgs.media.ckit_icon_nopower = trap_R_RegisterShader( "gfx/ckit/icon_nopower" );
cgs.media.ckit_icon_nosurge = trap_R_RegisterShader( "gfx/ckit/icon_nosurge" );
cgs.media.ckit_icon_off = trap_R_RegisterShader( "gfx/ckit/icon_off" );
cgs.media.ckit_icon_power = trap_R_RegisterShader( "gfx/ckit/icon_power" );
cgs.media.ckit_icon_storedbp = trap_R_RegisterShader( "gfx/ckit/icon_storedbp" );
cgs.media.ckit_icon_surge = trap_R_RegisterShader( "gfx/ckit/icon_surge" );
cgs.media.ckit_icon_time = trap_R_RegisterShader( "gfx/ckit/icon_time" );
cgs.media.ckit_icon_voltage = trap_R_RegisterShader( "gfx/ckit/icon_voltage" );
cgs.media.ckit_icon_width = trap_R_RegisterShader( "gfx/ckit/icon_width" );
for( i = 0; i < 15; i++ )
cgs.media.splashLogo[ i ] = trap_R_RegisterShader( va( "cuboid/logo_%i.tga", i ) );
cgs.media.splashLeft = trap_R_RegisterShader( "cuboid/logo_left.tga" );
cgs.media.splashRight = trap_R_RegisterShader( "cuboid/logo_right.tga" );
cgs.media.basivisionShader = trap_R_RegisterShader( "gfx/2d/basivision" );
cgs.media.basivisionBlipShader = trap_R_RegisterShader( "gfx/2d/basivisionBlip" );
cgs.media.basivisionFlareShader = trap_R_RegisterShader( "gfx/2d/basivisionFlare" );
for( i = 0; i < 8; i++ )
cgs.media.buildWeaponTimerPie[ i ] = trap_R_RegisterShader( buildWeaponTimerPieShaders[ i ] );
cgs.media.friendlyCrosshair = trap_R_RegisterShader( "gfx/2d/crosshair_friendly.tga" );
cgs.media.hitCrosshair = trap_R_RegisterShader( "gfx/2d/crosshair_hit.tga" );
cgs.media.ch_dot = trap_R_RegisterShader( "gfx/2d/ch_dot.tga" );
cgs.media.ch_dothit = trap_R_RegisterShader( "gfx/2d/ch_dothit.tga" );
cgs.media.ch_circle = trap_R_RegisterShader( "gfx/2d/ch_circle.tga" );
cgs.media.ch_circlehit = trap_R_RegisterShader( "gfx/2d/ch_circlehit.tga" );
cgs.media.ch_friendly = trap_R_RegisterShader( "gfx/2d/ch_friendly.tga" );
cgs.media.ch_adot = trap_R_RegisterShader( "gfx/2d/ch_adot.tga" );
cgs.media.ch_acircle = trap_R_RegisterShader( "gfx/2d/ch_acircle.tga" );
cgs.media.ch_afriendly = trap_R_RegisterShader( "gfx/2d/ch_afriendly.tga" );
cgs.media.ch_aheadshot = trap_R_RegisterShader( "gfx/2d/ch_aheadshot.tga" );
// player health cross shaders
cgs.media.healthCross = trap_R_RegisterShader( "ui/assets/neutral/cross.tga" );
cgs.media.healthCross2X = trap_R_RegisterShader( "ui/assets/neutral/cross2.tga" );
cgs.media.healthCross3X = trap_R_RegisterShader( "ui/assets/neutral/cross3.tga" );
cgs.media.healthCrossMedkit = trap_R_RegisterShader( "ui/assets/neutral/cross_medkit.tga" );
cgs.media.healthCrossPoisoned = trap_R_RegisterShader( "ui/assets/neutral/cross_poison.tga" );
cgs.media.healthCrossImplanted = trap_R_RegisterShader( "ui/assets/neutral/cross_implanted.tga" );
cgs.media.upgradeClassIconShader = trap_R_RegisterShader( "icons/icona_upgrade.tga" );
cgs.media.balloonShader = trap_R_RegisterShader( "gfx/sprites/chatballoon" );
cgs.media.disconnectPS = CG_RegisterParticleSystem( "disconnectPS" );
CG_UpdateMediaFraction( 0.7f );
memset( cg_weapons, 0, sizeof( cg_weapons ) );
memset( cg_upgrades, 0, sizeof( cg_upgrades ) );
cgs.media.shadowMarkShader = trap_R_RegisterShader( "gfx/marks/shadow" );
cgs.media.wakeMarkShader = trap_R_RegisterShader( "gfx/marks/wake" );
cgs.media.poisonCloudPS = CG_RegisterParticleSystem( "firstPersonPoisonCloudPS" );
cgs.media.poisonCloudedPS = CG_RegisterParticleSystem( "poisonCloudedPS" );
cgs.media.alienEvolvePS = CG_RegisterParticleSystem( "alienEvolvePS" );
cgs.media.alienAcidTubePS = CG_RegisterParticleSystem( "alienAcidTubePS" );
cgs.media.alienHatchPS = CG_RegisterParticleSystem( "alienHatchPS" );
cgs.media.jetPackDescendPS = CG_RegisterParticleSystem( "jetPackDescendPS" );
cgs.media.jetPackHoverPS = CG_RegisterParticleSystem( "jetPackHoverPS" );
cgs.media.jetPackAscendPS = CG_RegisterParticleSystem( "jetPackAscendPS" );
cgs.media.humanBuildableDamagedPS = CG_RegisterParticleSystem( "humanBuildableDamagedPS" );
cgs.media.alienBuildableDamagedPS = CG_RegisterParticleSystem( "alienBuildableDamagedPS" );
cgs.media.humanBuildableDestroyedPS = CG_RegisterParticleSystem( "humanBuildableDestroyedPS" );
cgs.media.alienBuildableDestroyedPS = CG_RegisterParticleSystem( "alienBuildableDestroyedPS" );
cgs.media.humanBuildableBleedPS = CG_RegisterParticleSystem( "humanBuildableBleedPS");
cgs.media.alienBuildableBleedPS = CG_RegisterParticleSystem( "alienBuildableBleedPS" );
cgs.media.humanPowerZapPS = CG_RegisterParticleSystem( "humanPowerZapPS" );
cgs.media.alienBleedPS = CG_RegisterParticleSystem( "alienBleedPS" );
cgs.media.humanBleedPS = CG_RegisterParticleSystem( "humanBleedPS" );
CG_BuildableStatusParse( "ui/assets/human/buildstat.cfg", &cgs.humanBuildStat );
CG_BuildableStatusParse( "ui/assets/alien/buildstat.cfg", &cgs.alienBuildStat );
// register the inline models
cgs.numInlineModels = trap_CM_NumInlineModels( );
for( i = 1; i < cgs.numInlineModels; i++ )
{
char name[ 10 ];
vec3_t mins, maxs;
int j;
Com_sprintf( name, sizeof( name ), "*%i", i );
cgs.inlineDrawModel[ i ] = trap_R_RegisterModel( name );
trap_R_ModelBounds( cgs.inlineDrawModel[ i ], mins, maxs );
for( j = 0 ; j < 3 ; j++ )
cgs.inlineModelMidpoints[ i ][ j ] = mins[ j ] + 0.5 * ( maxs[ j ] - mins[ j ] );
}
// register all the server specified models
for( i = 1; i < MAX_MODELS; i++ )
{
const char *modelName;
modelName = CG_ConfigString( CS_MODELS + i );
if( !modelName[ 0 ] )
break;
cgs.gameModels[ i ] = trap_R_RegisterModel( modelName );
}
CG_UpdateMediaFraction( 0.8f );
// register all the server specified shaders
for( i = 1; i < MAX_GAME_SHADERS; i++ )
{
const char *shaderName;
shaderName = CG_ConfigString( CS_SHADERS + i );
if( !shaderName[ 0 ] )
break;
cgs.gameShaders[ i ] = trap_R_RegisterShader( shaderName );
}
CG_UpdateMediaFraction( 0.9f );
// register all the server specified particle systems
for( i = 1; i < MAX_GAME_PARTICLE_SYSTEMS; i++ )
{
const char *psName;
psName = CG_ConfigString( CS_PARTICLE_SYSTEMS + i );
if( !psName[ 0 ] )
break;
cgs.gameParticleSystems[ i ] = CG_RegisterParticleSystem( (char *)psName );
}
}
/*
=======================
CG_BuildSpectatorString
=======================
*/
void CG_BuildSpectatorString( void )
{
int i;
cg.spectatorList[ 0 ] = 0;
for( i = 0; i < MAX_CLIENTS; i++ )
{
if( cgs.clientinfo[ i ].infoValid && cgs.clientinfo[ i ].team == TEAM_NONE )
{
Q_strcat( cg.spectatorList, sizeof( cg.spectatorList ),
va( S_COLOR_WHITE "%s ", cgs.clientinfo[ i ].name ) );
}
}
}
/*
===================
CG_RegisterClients
===================
*/
static void CG_RegisterClients( void )
{
int i;
cg.charModelFraction = 0.0f;
//precache all the models/sounds/etc
for( i = PCL_NONE + 1; i < PCL_NUM_CLASSES; i++ )
{
CG_PrecacheClientInfo( i, BG_ClassConfig( i )->modelName,
BG_ClassConfig( i )->skinName );
cg.charModelFraction = (float)i / (float)PCL_NUM_CLASSES;
trap_UpdateScreen( );
}
cgs.media.larmourHeadSkin = trap_R_RegisterSkin( "models/players/human_base/head_light.skin" );
cgs.media.larmourMk2HeadSkin = trap_R_RegisterSkin( "models/players/human_base/head_light_mk2.skin" );
cgs.media.larmourLegsSkin = trap_R_RegisterSkin( "models/players/human_base/lower_light.skin" );
cgs.media.larmourTorsoSkin = trap_R_RegisterSkin( "models/players/human_base/upper_light.skin" );
cgs.media.headMk2Model = trap_R_RegisterModel( "models/players/human_base/head_mk2.md3" );
cgs.media.jetpackModel = trap_R_RegisterModel( "models/players/human_base/jetpack.md3" );
cgs.media.jetpackFlashModel = trap_R_RegisterModel( "models/players/human_base/jetpack_flash.md3" );
cgs.media.battpackModel = trap_R_RegisterModel( "models/players/human_base/battpack.md3" );
cgs.media.ckit_background = trap_R_RegisterModel( "models/weapons/ckit/ckit_background.md3" );
cgs.media.ckit_overlay = trap_R_RegisterModel( "models/weapons/ckit/ckit_overlay.md3" );
cgs.media.ckit_bigicona = trap_R_RegisterModel( "models/weapons/ckit/ckit_bigicona.md3" );
cgs.media.ckit_bigiconb = trap_R_RegisterModel( "models/weapons/ckit/ckit_bigiconb.md3" );
cgs.media.ckit_icon = trap_R_RegisterModel( "models/weapons/ckit/ckit_icon.md3" );
cgs.media.ckit_digit = trap_R_RegisterModel( "models/weapons/ckit/ckit_digit.md3" );
cg.charModelFraction = 1.0f;
trap_UpdateScreen( );
//load all the clientinfos of clients already connected to the server
for( i = 0; i < MAX_CLIENTS; i++ )
{
const char *clientInfo;
clientInfo = CG_ConfigString( CS_PLAYERS + i );
if( !clientInfo[ 0 ] )
continue;
CG_NewClientInfo( i );
}
CG_BuildSpectatorString( );
}
//===========================================================================
/*
=================
CG_ConfigString
=================
*/
const char *CG_ConfigString( int index )
{
if( index < 0 || index >= MAX_CONFIGSTRINGS )
CG_Error( "CG_ConfigString: bad index: %i", index );
return cgs.gameState.stringData + cgs.gameState.stringOffsets[ index ];
}
//==================================================================
/*
======================
CG_StartMusic
======================
*/
void CG_StartMusic( void )
{
char *s;
char parm1[ MAX_QPATH ], parm2[ MAX_QPATH ];
// start the background music
s = (char *)CG_ConfigString( CS_MUSIC );
Q_strncpyz( parm1, COM_Parse( &s ), sizeof( parm1 ) );
Q_strncpyz( parm2, COM_Parse( &s ), sizeof( parm2 ) );
trap_S_StartBackgroundTrack( parm1, parm2 );
}
/*
======================
CG_PlayerCount
======================
*/
int CG_PlayerCount( void )
{
int i, count = 0;
CG_RequestScores( );
for( i = 0; i < cg.numScores; i++ )
{
if( cg.scores[ i ].team == TEAM_ALIENS ||
cg.scores[ i ].team == TEAM_HUMANS )
count++;
}
return count;
}
//
// ==============================
// new hud stuff ( mission pack )
// ==============================
//
char *CG_GetMenuBuffer( const char *filename )
{
int len;
fileHandle_t f;
static char buf[ MAX_MENUFILE ];
len = trap_FS_FOpenFile( filename, &f, FS_READ );
if( !f )
{
trap_Print( va( S_COLOR_RED "menu file not found: %s, using default\n", filename ) );
return NULL;
}
if( len >= MAX_MENUFILE )
{
trap_Print( va( S_COLOR_RED "menu file too large: %s is %i, max allowed is %i",
filename, len, MAX_MENUFILE ) );
trap_FS_FCloseFile( f );
return NULL;
}
trap_FS_Read( buf, len, f );
buf[len] = 0;
trap_FS_FCloseFile( f );
return buf;
}
qboolean CG_Asset_Parse( int handle )
{
pc_token_t token;
const char *tempStr;
if( !trap_Parse_ReadToken( handle, &token ) )
return qfalse;
if( Q_stricmp( token.string, "{" ) != 0 )
return qfalse;
while( 1 )
{
if( !trap_Parse_ReadToken( handle, &token ) )
return qfalse;
if( Q_stricmp( token.string, "}" ) == 0 )
return qtrue;
// font
if( Q_stricmp( token.string, "font" ) == 0 )
{
int pointSize;
if( !PC_String_Parse( handle, &tempStr ) || !PC_Int_Parse( handle, &pointSize ) )
return qfalse;
cgDC.registerFont( tempStr, pointSize, &cgDC.Assets.textFont );
continue;
}
// smallFont
if( Q_stricmp( token.string, "smallFont" ) == 0 )
{
int pointSize;
if( !PC_String_Parse( handle, &tempStr ) || !PC_Int_Parse( handle, &pointSize ) )
return qfalse;
cgDC.registerFont( tempStr, pointSize, &cgDC.Assets.smallFont );
continue;
}
// font
if( Q_stricmp( token.string, "bigfont" ) == 0 )
{
int pointSize;
if( !PC_String_Parse( handle, &tempStr ) || !PC_Int_Parse( handle, &pointSize ) )
return qfalse;
cgDC.registerFont( tempStr, pointSize, &cgDC.Assets.bigFont );
continue;
}
// gradientbar
if( Q_stricmp( token.string, "gradientbar" ) == 0 )
{
if( !PC_String_Parse( handle, &tempStr ) )
return qfalse;
cgDC.Assets.gradientBar = trap_R_RegisterShaderNoMip( tempStr );
continue;
}
// enterMenuSound
if( Q_stricmp( token.string, "menuEnterSound" ) == 0 )
{
if( !PC_String_Parse( handle, &tempStr ) )
return qfalse;
cgDC.Assets.menuEnterSound = trap_S_RegisterSound( tempStr, qfalse );
continue;
}
// exitMenuSound
if( Q_stricmp( token.string, "menuExitSound" ) == 0 )
{
if( !PC_String_Parse( handle, &tempStr ) )
return qfalse;
cgDC.Assets.menuExitSound = trap_S_RegisterSound( tempStr, qfalse );
continue;
}
// itemFocusSound
if( Q_stricmp( token.string, "itemFocusSound" ) == 0 )
{
if( !PC_String_Parse( handle, &tempStr ) )
return qfalse;
cgDC.Assets.itemFocusSound = trap_S_RegisterSound( tempStr, qfalse );
continue;
}
// menuBuzzSound
if( Q_stricmp( token.string, "menuBuzzSound" ) == 0 )
{
if( !PC_String_Parse( handle, &tempStr ) )
return qfalse;
cgDC.Assets.menuBuzzSound = trap_S_RegisterSound( tempStr, qfalse );
continue;
}
if( Q_stricmp( token.string, "cursor" ) == 0 )
{
if( !PC_String_Parse( handle, &cgDC.Assets.cursorStr ) )
return qfalse;
cgDC.Assets.cursor = trap_R_RegisterShaderNoMip( cgDC.Assets.cursorStr );
continue;
}
if( Q_stricmp( token.string, "fadeClamp" ) == 0 )
{
if( !PC_Float_Parse( handle, &cgDC.Assets.fadeClamp ) )
return qfalse;
continue;
}
if( Q_stricmp( token.string, "fadeCycle" ) == 0 )
{
if( !PC_Int_Parse( handle, &cgDC.Assets.fadeCycle ) )
return qfalse;
continue;
}
if( Q_stricmp( token.string, "fadeAmount" ) == 0 )
{
if( !PC_Float_Parse( handle, &cgDC.Assets.fadeAmount ) )
return qfalse;
continue;
}
if( Q_stricmp( token.string, "shadowX" ) == 0 )
{
if( !PC_Float_Parse( handle, &cgDC.Assets.shadowX ) )
return qfalse;
continue;
}
if( Q_stricmp( token.string, "shadowY" ) == 0 )
{
if( !PC_Float_Parse( handle, &cgDC.Assets.shadowY ) )
return qfalse;
continue;
}
if( Q_stricmp( token.string, "shadowColor" ) == 0 )
{
if( !PC_Color_Parse( handle, &cgDC.Assets.shadowColor ) )
return qfalse;
cgDC.Assets.shadowFadeClamp = cgDC.Assets.shadowColor[ 3 ];
continue;
}
}
return qfalse;
}
void CG_ParseMenu( const char *menuFile )
{
pc_token_t token;
int handle;
handle = trap_Parse_LoadSource( menuFile );
if( !handle )
handle = trap_Parse_LoadSource( "ui/testhud.menu" );
if( !handle )
return;
while( 1 )
{
if( !trap_Parse_ReadToken( handle, &token ) )
break;
//if ( Q_stricmp( token, "{" ) ) {
// Com_Printf( "Missing { in menu file\n" );
// break;
//}
//if ( menuCount == MAX_MENUS ) {
// Com_Printf( "Too many menus!\n" );
// break;
//}
if( token.string[ 0 ] == '}' )
break;
if( Q_stricmp( token.string, "assetGlobalDef" ) == 0 )
{
if( CG_Asset_Parse( handle ) )
continue;
else
break;
}
if( Q_stricmp( token.string, "menudef" ) == 0 )
{
// start a new menu
Menu_New( handle );
}
}
trap_Parse_FreeSource( handle );
}
qboolean CG_Load_Menu( char **p )
{
char *token;
token = COM_ParseExt( p, qtrue );
if( token[ 0 ] != '{' )
return qfalse;
while( 1 )
{
token = COM_ParseExt( p, qtrue );
if( Q_stricmp( token, "}" ) == 0 )
return qtrue;
if( !token || token[ 0 ] == 0 )
return qfalse;
CG_ParseMenu( token );
}
return qfalse;
}
void CG_LoadMenus( const char *menuFile )
{
char *token;
char *p;
int len, start;
fileHandle_t f;
static char buf[ MAX_MENUDEFFILE ];
start = trap_Milliseconds( );
len = trap_FS_FOpenFile( menuFile, &f, FS_READ );
if( !f )
{
trap_Error( va( S_COLOR_YELLOW "menu file not found: %s, using default\n", menuFile ) );
len = trap_FS_FOpenFile( "ui/hud.txt", &f, FS_READ );
if( !f )
trap_Error( va( S_COLOR_RED "default menu file not found: ui/hud.txt, unable to continue!\n" ) );
}
if( len >= MAX_MENUDEFFILE )
{
trap_Error( va( S_COLOR_RED "menu file too large: %s is %i, max allowed is %i",
menuFile, len, MAX_MENUDEFFILE ) );
trap_FS_FCloseFile( f );
return;
}
trap_FS_Read( buf, len, f );
buf[ len ] = 0;
trap_FS_FCloseFile( f );
COM_Compress( buf );
Menu_Reset( );
p = buf;
while( 1 )
{
token = COM_ParseExt( &p, qtrue );
if( !token || token[ 0 ] == 0 || token[ 0 ] == '}' )
break;
if( Q_stricmp( token, "}" ) == 0 )
break;
if( Q_stricmp( token, "loadmenu" ) == 0 )
{
if( CG_Load_Menu( &p ) )
continue;
else
break;
}
}
Com_Printf( "UI menu load time = %d milli seconds\n", trap_Milliseconds( ) - start );
}
static qboolean CG_OwnerDrawHandleKey( int ownerDraw, int key )
{
return qfalse;
}
static int CG_FeederCount( int feederID )
{
int i, count = 0;
if( feederID == FEEDER_ALIENTEAM_LIST )
{
for( i = 0; i < cg.numScores; i++ )
{
if( cg.scores[ i ].team == TEAM_ALIENS )
count++;
}
}
else if( feederID == FEEDER_HUMANTEAM_LIST )
{
for( i = 0; i < cg.numScores; i++ )
{
if( cg.scores[ i ].team == TEAM_HUMANS )
count++;
}
}
return count;
}
void CG_SetScoreSelection( void *p )
{
menuDef_t *menu = (menuDef_t*)p;
playerState_t *ps = &cg.snap->ps;
int i, alien, human;
int feeder;
alien = human = 0;
for( i = 0; i < cg.numScores; i++ )
{
if( cg.scores[ i ].team == TEAM_ALIENS )
alien++;
else if( cg.scores[ i ].team == TEAM_HUMANS )
human++;
if( ps->clientNum == cg.scores[ i ].client )
cg.selectedScore = i;
}
if( menu == NULL )
// just interested in setting the selected score
return;
feeder = FEEDER_ALIENTEAM_LIST;
i = alien;
if( cg.scores[ cg.selectedScore ].team == TEAM_HUMANS )
{
feeder = FEEDER_HUMANTEAM_LIST;
i = human;
}
Menu_SetFeederSelection(menu, feeder, i, NULL);
}
// FIXME: might need to cache this info
static clientInfo_t * CG_InfoFromScoreIndex( int index, int team, int *scoreIndex )
{
int i, count;
count = 0;
for( i = 0; i < cg.numScores; i++ )
{
if( cg.scores[ i ].team == team )
{
if( count == index )
{
*scoreIndex = i;
return &cgs.clientinfo[ cg.scores[ i ].client ];
}
count++;
}
}
*scoreIndex = index;
return &cgs.clientinfo[ cg.scores[ index ].client ];
}
qboolean CG_ClientIsReady( int clientNum )
{
clientList_t ready;
Com_ClientListParse( &ready, CG_ConfigString( CS_CLIENTS_READY ) );
return Com_ClientListContains( &ready, clientNum );
}
static const char *CG_FeederItemText( int feederID, int index, int column, qhandle_t *handle )
{
int scoreIndex = 0;
clientInfo_t *info = NULL;
int team = -1;
score_t *sp = NULL;
qboolean showIcons = qfalse;
*handle = -1;
if( feederID == FEEDER_ALIENTEAM_LIST )
team = TEAM_ALIENS;
else if( feederID == FEEDER_HUMANTEAM_LIST )
team = TEAM_HUMANS;
info = CG_InfoFromScoreIndex( index, team, &scoreIndex );
sp = &cg.scores[ scoreIndex ];
if( cg.intermissionStarted && CG_ClientIsReady( sp->client ) )
showIcons = qfalse;
else if( cg.snap->ps.pm_type == PM_SPECTATOR ||
cg.snap->ps.pm_type == PM_NOCLIP ||
cg.snap->ps.pm_flags & PMF_FOLLOW ||
team == cg.snap->ps.stats[ STAT_TEAM ] ||
cg.intermissionStarted )
{
showIcons = qtrue;
}
if( info && info->infoValid )
{
switch( column )
{
case 0:
if( showIcons )
{
if( sp->weapon != WP_NONE )
*handle = cg_weapons[ sp->weapon ].weaponIcon;
}
break;
case 1:
if( showIcons )
{
if( sp->team == TEAM_HUMANS && sp->upgrade != UP_NONE )
*handle = cg_upgrades[ sp->upgrade ].upgradeIcon;
else if( sp->team == TEAM_ALIENS )
{
switch( sp->weapon )
{
case WP_ABUILD2:
case WP_ALEVEL1_UPG:
case WP_ALEVEL2_UPG:
case WP_ALEVEL3_UPG:
*handle = cgs.media.upgradeClassIconShader;
break;
default:
break;
}
}
}
break;
case 2:
if( cg.intermissionStarted && CG_ClientIsReady( sp->client ) )
return "Ready";
break;
case 3:
return va( S_COLOR_WHITE "%s", info->name );
break;
case 4:
return va( "%d", sp->score );
break;
case 5:
return va( "%4d", sp->time );
break;
case 6:
if( sp->ping == -1 )
return "";
return va( "%4d", sp->ping );
break;
}
}
return "";
}
static qhandle_t CG_FeederItemImage( int feederID, int index )
{
return 0;
}
static void CG_FeederSelection( int feederID, int index )
{
int i, count;
int team = ( feederID == FEEDER_ALIENTEAM_LIST ) ? TEAM_ALIENS : TEAM_HUMANS;
count = 0;
for( i = 0; i < cg.numScores; i++ )
{
if( cg.scores[ i ].team == team )
{
if( index == count )
cg.selectedScore = i;
count++;
}
}
}
static float CG_Cvar_Get( const char *cvar )
{
char buff[ 128 ];
memset( buff, 0, sizeof( buff ) );
trap_Cvar_VariableStringBuffer( cvar, buff, sizeof( buff ) );
return atof( buff );
}
void CG_Text_PaintWithCursor( float x, float y, float scale, vec4_t color, const char *text,
int cursorPos, char cursor, int limit, int style )
{
UI_Text_Paint( x, y, scale, color, text, 0, limit, style );
}
static int CG_OwnerDrawWidth( int ownerDraw, float scale )
{
switch( ownerDraw )
{
case CG_KILLER:
return UI_Text_Width( CG_GetKillerText( ), scale );
break;
}
return 0;
}
static int CG_PlayCinematic( const char *name, float x, float y, float w, float h )
{
return trap_CIN_PlayCinematic( name, x, y, w, h, CIN_loop );
}
static void CG_StopCinematic( int handle )
{
trap_CIN_StopCinematic( handle );
}
static void CG_DrawCinematic( int handle, float x, float y, float w, float h )
{
trap_CIN_SetExtents( handle, x, y, w, h );
trap_CIN_DrawCinematic( handle );
}
static void CG_RunCinematicFrame( int handle )
{
trap_CIN_RunCinematic( handle );
}
// hack to prevent warning
static qboolean CG_OwnerDrawVisible( int parameter )
{
return qfalse;
}
/*
=================
CG_LoadHudMenu
=================
*/
void CG_LoadHudMenu( void )
{
char buff[ 1024 ];
const char *hudSet;
cgDC.aspectScale = ( ( 640.0f * cgs.glconfig.vidHeight ) /
( 480.0f * cgs.glconfig.vidWidth ) );
cgDC.xscale = cgs.glconfig.vidWidth / 640.0f;
cgDC.yscale = cgs.glconfig.vidHeight / 480.0f;
cgDC.smallFontScale = CG_Cvar_Get( "ui_smallFont" );
cgDC.bigFontScale = CG_Cvar_Get( "ui_bigFont" );
cgDC.registerShaderNoMip = &trap_R_RegisterShaderNoMip;
cgDC.setColor = &trap_R_SetColor;
cgDC.drawHandlePic = &CG_DrawPic;
cgDC.drawStretchPic = &trap_R_DrawStretchPic;
cgDC.registerModel = &trap_R_RegisterModel;
cgDC.modelBounds = &trap_R_ModelBounds;
cgDC.fillRect = &CG_FillRect;
cgDC.drawRect = &CG_DrawRect;
cgDC.drawSides = &CG_DrawSides;
cgDC.drawTopBottom = &CG_DrawTopBottom;
cgDC.clearScene = &trap_R_ClearScene;
cgDC.addRefEntityToScene = &trap_R_AddRefEntityToScene;
cgDC.renderScene = &trap_R_RenderScene;
cgDC.registerFont = &trap_R_RegisterFont;
cgDC.ownerDrawItem = &CG_OwnerDraw;
cgDC.getValue = &CG_GetValue;
cgDC.ownerDrawVisible = &CG_OwnerDrawVisible;
cgDC.runScript = &CG_RunMenuScript;
cgDC.setCVar = trap_Cvar_Set;
cgDC.getCVarString = trap_Cvar_VariableStringBuffer;
cgDC.getCVarValue = CG_Cvar_Get;
cgDC.setOverstrikeMode = &trap_Key_SetOverstrikeMode;
cgDC.getOverstrikeMode = &trap_Key_GetOverstrikeMode;
cgDC.startLocalSound = &trap_S_StartLocalSound;
cgDC.ownerDrawHandleKey = &CG_OwnerDrawHandleKey;
cgDC.feederCount = &CG_FeederCount;
cgDC.feederItemImage = &CG_FeederItemImage;
cgDC.feederItemText = &CG_FeederItemText;
cgDC.feederSelection = &CG_FeederSelection;
//cgDC.setBinding = &trap_Key_SetBinding;
//cgDC.getBindingBuf = &trap_Key_GetBindingBuf;
//cgDC.keynumToStringBuf = &trap_Key_KeynumToStringBuf;
//cgDC.executeText = &trap_Cmd_ExecuteText;
cgDC.Error = &Com_Error;
cgDC.Print = &Com_Printf;
cgDC.ownerDrawWidth = &CG_OwnerDrawWidth;
//cgDC.ownerDrawText = &CG_OwnerDrawText;
//cgDC.Pause = &CG_Pause;
cgDC.registerSound = &trap_S_RegisterSound;
cgDC.startBackgroundTrack = &trap_S_StartBackgroundTrack;
cgDC.stopBackgroundTrack = &trap_S_StopBackgroundTrack;
cgDC.playCinematic = &CG_PlayCinematic;
cgDC.stopCinematic = &CG_StopCinematic;
cgDC.drawCinematic = &CG_DrawCinematic;
cgDC.runCinematicFrame = &CG_RunCinematicFrame;
Init_Display( &cgDC );
Menu_Reset( );
trap_Cvar_VariableStringBuffer( "cg_hudFiles", buff, sizeof( buff ) );
hudSet = buff;
if( !cg_hudFilesEnable.integer || hudSet[ 0 ] == '\0' )
hudSet = "ui/hud.txt";
CG_LoadMenus( hudSet );
}
void CG_AssetCache( void )
{
int i;
cgDC.Assets.gradientBar = trap_R_RegisterShaderNoMip( ASSET_GRADIENTBAR );
cgDC.Assets.scrollBar = trap_R_RegisterShaderNoMip( ASSET_SCROLLBAR );
cgDC.Assets.scrollBarArrowDown = trap_R_RegisterShaderNoMip( ASSET_SCROLLBAR_ARROWDOWN );
cgDC.Assets.scrollBarArrowUp = trap_R_RegisterShaderNoMip( ASSET_SCROLLBAR_ARROWUP );
cgDC.Assets.scrollBarArrowLeft = trap_R_RegisterShaderNoMip( ASSET_SCROLLBAR_ARROWLEFT );
cgDC.Assets.scrollBarArrowRight = trap_R_RegisterShaderNoMip( ASSET_SCROLLBAR_ARROWRIGHT );
cgDC.Assets.scrollBarThumb = trap_R_RegisterShaderNoMip( ASSET_SCROLL_THUMB );
cgDC.Assets.sliderBar = trap_R_RegisterShaderNoMip( ASSET_SLIDER_BAR );
cgDC.Assets.sliderThumb = trap_R_RegisterShaderNoMip( ASSET_SLIDER_THUMB );
if( cg_emoticons.integer )
{
cgDC.Assets.emoticonCount = BG_LoadEmoticons( cgDC.Assets.emoticons,
MAX_EMOTICONS );
}
else
cgDC.Assets.emoticonCount = 0;
for( i = 0; i < cgDC.Assets.emoticonCount; i++ )
{
cgDC.Assets.emoticons[ i ].shader = trap_R_RegisterShaderNoMip(
va( "emoticons/%s_%dx1.tga", cgDC.Assets.emoticons[ i ].name,
cgDC.Assets.emoticons[ i ].width ) );
}
}
/*
=================
CG_Init
Called after every level change or subsystem restart
Will perform callbacks to make the loading info screen update.
=================
*/
void CG_Init( int serverMessageNum, int serverCommandSequence, int clientNum )
{
const char *s;
// clear everything
memset( &cgs, 0, sizeof( cgs ) );
memset( &cg, 0, sizeof( cg ) );
memset( &cg.pmext, 0, sizeof( cg.pmext ) );
memset( cg_entities, 0, sizeof( cg_entities ) );
cg.clientNum = clientNum;
cgs.processedSnapshotNum = serverMessageNum;
cgs.serverCommandSequence = serverCommandSequence;
// get the rendering configuration from the client system
trap_GetGlconfig( &cgs.glconfig );
cgs.screenXScale = cgs.glconfig.vidWidth / 640.0f;
cgs.screenYScale = cgs.glconfig.vidHeight / 480.0f;
// load a few needed things before we do any screen updates
cgs.media.whiteShader = trap_R_RegisterShader( "white" );
cgs.media.charsetShader = trap_R_RegisterShader( "gfx/2d/bigchars" );
cgs.media.outlineShader = trap_R_RegisterShader( "outline" );
// load overrides
BG_InitClassConfigs( );
BG_InitBuildableConfigs( );
BG_InitAllowedGameElements( );
// Dynamic memory
BG_InitMemory( );
CG_RegisterCvars( );
CG_InitConsoleCommands( );
String_Init( );
CG_AssetCache( );
CG_LoadHudMenu( );
cg.weaponSelect = WP_NONE;
// old servers
// get the gamestate from the client system
trap_GetGameState( &cgs.gameState );
// copy vote display strings so they don't show up blank if we see
// the same one directly after connecting
Q_strncpyz( cgs.voteString[ TEAM_NONE ],
CG_ConfigString( CS_VOTE_STRING + TEAM_NONE ),
sizeof( cgs.voteString ) );
Q_strncpyz( cgs.voteString[ TEAM_ALIENS ],
CG_ConfigString( CS_VOTE_STRING + TEAM_ALIENS ),
sizeof( cgs.voteString[ TEAM_ALIENS ] ) );
Q_strncpyz( cgs.voteString[ TEAM_HUMANS ],
CG_ConfigString( CS_VOTE_STRING + TEAM_ALIENS ),
sizeof( cgs.voteString[ TEAM_HUMANS ] ) );
// check version
s = CG_ConfigString( CS_GAME_VERSION );
if( strcmp( s, GAME_VERSION ) )
CG_Error( "Client/Server game mismatch: %s/%s", GAME_VERSION, s );
s = CG_ConfigString( CS_LEVEL_START_TIME );
cgs.levelStartTime = atoi( s );
CG_ParseServerinfo( );
// load the new map
trap_CM_LoadMap( cgs.mapname );
cg.loading = qtrue; // force players to load instead of defer
CG_LoadTrailSystems( );
CG_UpdateMediaFraction( 0.05f );
CG_LoadParticleSystems( );
CG_UpdateMediaFraction( 0.05f );
CG_RegisterSounds( );
CG_UpdateMediaFraction( 0.60f );
CG_RegisterGraphics( );
CG_UpdateMediaFraction( 0.90f );
CG_InitWeapons( );
CG_UpdateMediaFraction( 0.95f );
CG_InitUpgrades( );
CG_UpdateMediaFraction( 1.0f );
CG_InitBuildables( );
cgs.voices = BG_VoiceInit( );
BG_PrintVoices( cgs.voices, cg_debugVoices.integer );
CG_RegisterClients( ); // if low on memory, some clients will be deferred
cg.loading = qfalse; // future players will be deferred
CG_InitMarkPolys( );
// remove the last loading update
cg.infoScreenText[ 0 ] = 0;
// Make sure we have update values (scores)
CG_SetConfigValues( );
CG_StartMusic( );
CG_ShaderStateChanged( );
trap_S_ClearLoopingSounds( qtrue );
cg.announcerStackLatest = -1;
cg.announcerStackPos = -1;
}
/*
=================
CG_Shutdown
Called before every level change or subsystem restart
=================
*/
void CG_Shutdown( void )
{
// some mods may need to do cleanup work here,
// like closing files or archiving session data
}
/*
================
CG_VoIPString
================
*/
static char *CG_VoIPString( void )
{
// a generous overestimate of the space needed for 0,1,2...61,62,63
static char voipString[ MAX_CLIENTS * 4 ];
char voipSendTarget[ MAX_CVAR_VALUE_STRING ];
trap_Cvar_VariableStringBuffer( "cl_voipSendTarget", voipSendTarget,
sizeof( voipSendTarget ) );
if( Q_stricmp( voipSendTarget, "team" ) == 0 )
{
int i, slen, nlen;
for( slen = i = 0; i < cgs.maxclients; i++ )
{
if( !cgs.clientinfo[ i ].infoValid || i == cg.clientNum )
continue;
if( cgs.clientinfo[ i ].team != cgs.clientinfo[ cg.clientNum ].team )
continue;
nlen = Q_snprintf( &voipString[ slen ], sizeof( voipString ) - slen,
"%s%d", ( slen > 0 ) ? "," : "", i );
if( slen + nlen + 1 >= sizeof( voipString ) )
{
CG_Printf( S_COLOR_YELLOW "WARNING: voipString overflowed\n" );
break;
}
slen += nlen;
}
// Notice that if the snprintf was truncated, slen was not updated
// so this will remove any trailing commas or partially-completed numbers
voipString[ slen ] = '\0';
}
else if( Q_stricmp( voipSendTarget, "crosshair" ) == 0 )
Com_sprintf( voipString, sizeof( voipString ), "%d",
CG_CrosshairPlayer( ) );
else if( Q_stricmp( voipSendTarget, "attacker" ) == 0 )
Com_sprintf( voipString, sizeof( voipString ), "%d",
CG_LastAttacker( ) );
else
return NULL;
return voipString;
}
|