forked from faggotman69/Prometheus
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMiscDefinitions.h
More file actions
1003 lines (859 loc) · 34.7 KB
/
MiscDefinitions.h
File metadata and controls
1003 lines (859 loc) · 34.7 KB
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
#pragma once
#include "CommonIncludes.h"
#include "Vector.h"
#include "UtlVector.hpp"
template< typename Function > Function call_vfunc(PVOID Base, DWORD Index)
{
PDWORD* VTablePointer = (PDWORD*)Base;
PDWORD VTableFunctionBase = *VTablePointer;
DWORD dwAddress = VTableFunctionBase[Index];
return (Function)(dwAddress);
}
template <typename T> __forceinline T GetVirtualFunction(PVOID Base, DWORD Index)
{
return (T)((uint32_t *) *(uint32_t **)Base)[Index];
}
#define dwThis (DWORD)this
// Lifestates
enum source_lifestates
{
LIFE_ALIVE,
LIFE_DYING,
LIFE_DEAD,
LIFE_RESPAWNABLE,
LIFE_DISCARDBODY,
};
enum itemdefinitionindex
{
deagle_itemdefinitionindex = 1,
dualies_itemdefinitionindex,
fiveseven_itemdefinitionindex,
glock18_itemdefinitionindex,
ak47_itemdefinitionindex = 7,
aug_itemdefinitionindex,
awp_itemdefinitionindex,
famas_itemdefinitionindex,
g3sg1_itemdefinitionindex,
galilar_itemdefinitionindex = 13,
m249_itemdefinitionindex,
m4a4_itemdefinitionindex = 16,
mac10_itemdefinitionindex,
p90_itemdefinitionindex = 19,
ump45_itemdefinitionindex = 24,
xm1014_itemdefinitionindex,
bizon_itemdefinitionindex,
mag7_itemdefinitionindex,
negev_itemdefinitionindex,
sawedoff_itemdefinitionindex,
tec9_itemdefinitionindex,
zeus_itemdefinitionindex,
p2000_itemdefinitionindex,
mp7_itemdefinitionindex,
mp9_itemdefinitionindex,
nova_itemdefinitionindex,
p250_itemdefinitionindex,
scar20_itemdefinitionindex = 38,
sg553_itemdefinitionindex,
ssg08_itemdefinitionindex,
CTKnife_itemdefinitionindex = 42,
flashbang_itemdefinitionindex,
hegrenade_itemdefinitionindex,
smoke_itemdefinitionindex,
molotov_itemdefinitionindex,
decoy_itemdefinitionindex,
incendiary_itemdefinitionindex,
c4_itemdefinitionindex,
TKnife_itemdefinitionindex = 59,
m4a1s_itemdefinitionindex,
usps_itemdefinitionindex,
cz75auto_itemdefinitionindex = 63,
r8revoler_itemdefinitionindex,
bayonet_itemdefinitionindex = 500,
flip_itemdefinitionindex = 505,
gut_itemdefinitionindex,
karambit_itemdefinitionindex,
m9_itemdefinitionindex,
huntsman_itemdefinitionindex,
falchion_itemdefinitionindex = 512,
bowie_itemdefinitionindex = 514,
butterfly_itemdefinitionindex,
shadowdaggers_itemdefinitionindex
};
class matrix3x4_t
{
public:
matrix3x4_t() {}
matrix3x4_t(
float m00, float m01, float m02, float m03,
float m10, float m11, float m12, float m13,
float m20, float m21, float m22, float m23)
{
m_flMatVal[0][0] = m00; m_flMatVal[0][1] = m01; m_flMatVal[0][2] = m02; m_flMatVal[0][3] = m03;
m_flMatVal[1][0] = m10; m_flMatVal[1][1] = m11; m_flMatVal[1][2] = m12; m_flMatVal[1][3] = m13;
m_flMatVal[2][0] = m20; m_flMatVal[2][1] = m21; m_flMatVal[2][2] = m22; m_flMatVal[2][3] = m23;
}
void Init(Vector xAxis, Vector yAxis, Vector zAxis, Vector vecOrigin)
{
m_flMatVal[0][0] = xAxis.x; m_flMatVal[0][1] = yAxis.x; m_flMatVal[0][2] = zAxis.x; m_flMatVal[0][3] = vecOrigin.x;
m_flMatVal[1][0] = xAxis.y; m_flMatVal[1][1] = yAxis.y; m_flMatVal[1][2] = zAxis.y; m_flMatVal[1][3] = vecOrigin.y;
m_flMatVal[2][0] = xAxis.z; m_flMatVal[2][1] = yAxis.z; m_flMatVal[2][2] = zAxis.z; m_flMatVal[2][3] = vecOrigin.z;
}
matrix3x4_t(Vector xAxis, Vector yAxis, Vector zAxis, Vector vecOrigin)
{
m_flMatVal[0][0] = xAxis.x; m_flMatVal[0][1] = yAxis.x; m_flMatVal[0][2] = zAxis.x; m_flMatVal[0][3] = vecOrigin.x;
m_flMatVal[1][0] = xAxis.y; m_flMatVal[1][1] = yAxis.y; m_flMatVal[1][2] = zAxis.y; m_flMatVal[1][3] = vecOrigin.y;
m_flMatVal[2][0] = xAxis.z; m_flMatVal[2][1] = yAxis.z; m_flMatVal[2][2] = zAxis.z; m_flMatVal[2][3] = vecOrigin.z;
}
inline void SetOrigin(Vector const & p)
{
m_flMatVal[0][3] = p.x;
m_flMatVal[1][3] = p.y;
m_flMatVal[2][3] = p.z;
}
float *operator[](int i) { return m_flMatVal[i]; }
const float *operator[](int i) const { return m_flMatVal[i]; }
float *Base() { return &m_flMatVal[0][0]; }
const float *Base() const { return &m_flMatVal[0][0]; }
float m_flMatVal[3][4];
};
class __declspec(align(16)) matrix3x4a_t : public matrix3x4_t
{
public:
matrix3x4a_t& operator=(const matrix3x4_t& src) { memcpy(Base(), src.Base(), sizeof(float) * 3 * 4); return *this; };
};
enum FontRenderFlag_t
{
FONT_LEFT = 0,
FONT_RIGHT = 1,
FONT_CENTER = 2
};
enum SIGNONSTATE
{
SIGNONSTATE_NONE = 0,
SIGNONSTATE_CHALLENGE = 1,
SIGNONSTATE_CONNECTED = 2,
SIGNONSTATE_NEW = 3,
SIGNONSTATE_PRESPAWN = 4,
SIGNONSTATE_SPAWN = 5,
SIGNONSTATE_FULL = 6,
SIGNONSTATE_CHANGELEVEL = 7
};
class Color
{
public:
Color()
{
*((int *)this) = 0;
}
Color(int color32)
{
*((int *)this) = color32;
}
Color(int _r, int _g, int _b)
{
SetColor(_r, _g, _b, 255);
}
Color(int _r, int _g, int _b, int _a)
{
SetColor(_r, _g, _b, _a);
}
Color(float _rgb[3])
{
SetColor((int)(_rgb[0] * 255.0f), (int)(_rgb[1] * 255.0f), (int)(_rgb[2] * 255.0f), 255);
}
Color(float _rgb[3], float _alpha)
{
SetColor((int)(_rgb[0] * 255.0f), (int)(_rgb[1] * 255.0f), (int)(_rgb[2] * 255.0f), _alpha);
}
void SetColor(int _r, int _g, int _b, int _a = 255)
{
_color[0] = (unsigned char)_r;
_color[1] = (unsigned char)_g;
_color[2] = (unsigned char)_b;
_color[3] = (unsigned char)_a;
}
void GetColor(int &_r, int &_g, int &_b, int &_a) const
{
_r = _color[0];
_g = _color[1];
_b = _color[2];
_a = _color[3];
}
void SetRawColor(int color32)
{
*((int*)this) = color32;
}
int GetRawColor() const
{
return *((int*)this);
}
int GetD3DColor() const
{
return ((int)((((_color[3]) & 0xff) << 24) | (((_color[0]) & 0xff) << 16) | (((_color[1]) & 0xff) << 8) | ((_color[2]) & 0xff)));
}
inline int r() const { return _color[0]; }
inline int g() const { return _color[1]; }
inline int b() const { return _color[2]; }
inline int a() const { return _color[3]; }
unsigned char &operator[](int index)
{
return _color[index];
}
const unsigned char &operator[](int index) const
{
return _color[index];
}
bool operator == (const Color &rhs) const
{
return (*((int *)this) == *((int *)&rhs));
}
bool operator != (const Color &rhs) const
{
return !(operator==(rhs));
}
Color &operator=(const Color &rhs)
{
SetRawColor(rhs.GetRawColor());
return *this;
}
float* Base()
{
float clr[3];
clr[0] = _color[0] / 255.0f;
clr[1] = _color[1] / 255.0f;
clr[2] = _color[2] / 255.0f;
return &clr[0];
}
float* BaseAlpha()
{
float clr[4];
clr[0] = _color[0] / 255.0f;
clr[1] = _color[1] / 255.0f;
clr[2] = _color[2] / 255.0f;
clr[3] = _color[3] / 255.0f;
return &clr[0];
}
float Hue() const
{
if (_color[0] == _color[1] && _color[1] == _color[2])
{
return 0.0f;
}
float r = _color[0] / 255.0f;
float g = _color[1] / 255.0f;
float b = _color[2] / 255.0f;
float max = r > g ? r : g > b ? g : b,
min = r < g ? r : g < b ? g : b;
float delta = max - min;
float hue = 0.0f;
if (r == max)
{
hue = (g - b) / delta;
}
else if (g == max)
{
hue = 2 + (b - r) / delta;
}
else if (b == max)
{
hue = 4 + (r - g) / delta;
}
hue *= 60;
if (hue < 0.0f)
{
hue += 360.0f;
}
return hue;
}
float Saturation() const
{
float r = _color[0] / 255.0f;
float g = _color[1] / 255.0f;
float b = _color[2] / 255.0f;
float max = r > g ? r : g > b ? g : b,
min = r < g ? r : g < b ? g : b;
float l, s = 0;
if (max != min)
{
l = (max + min) / 2;
if (l <= 0.5f)
s = (max - min) / (max + min);
else
s = (max - min) / (2 - max - min);
}
return s;
}
float Brightness() const
{
float r = _color[0] / 255.0f;
float g = _color[1] / 255.0f;
float b = _color[2] / 255.0f;
float max = r > g ? r : g > b ? g : b,
min = r < g ? r : g < b ? g : b;
return (max + min) / 2;
}
static Color FromHSB(float hue, float saturation, float brightness)
{
float h = hue == 1.0f ? 0 : hue * 6.0f;
float f = h - (int)h;
float p = brightness * (1.0f - saturation);
float q = brightness * (1.0f - saturation * f);
float t = brightness * (1.0f - (saturation * (1.0f - f)));
if (h < 1)
{
return Color(
(unsigned char)(brightness * 255),
(unsigned char)(t * 255),
(unsigned char)(p * 255)
);
}
else if (h < 2)
{
return Color(
(unsigned char)(q * 255),
(unsigned char)(brightness * 255),
(unsigned char)(p * 255)
);
}
else if (h < 3)
{
return Color(
(unsigned char)(p * 255),
(unsigned char)(brightness * 255),
(unsigned char)(t * 255)
);
}
else if (h < 4)
{
return Color(
(unsigned char)(p * 255),
(unsigned char)(q * 255),
(unsigned char)(brightness * 255)
);
}
else if (h < 5)
{
return Color(
(unsigned char)(t * 255),
(unsigned char)(p * 255),
(unsigned char)(brightness * 255)
);
}
else
{
return Color(
(unsigned char)(brightness * 255),
(unsigned char)(p * 255),
(unsigned char)(q * 255)
);
}
}
static Color Red() { return Color(255, 0, 0); }
static Color Green() { return Color(0, 255, 0); }
static Color Blue() { return Color(0, 0, 255); }
static Color LightBlue() { return Color(100, 100, 255); }
static Color Grey() { return Color(128, 128, 128); }
static Color DarkGrey() { return Color(45, 45, 45); }
static Color Black() { return Color(0, 0, 0); }
static Color White() { return Color(255, 255, 255); }
static Color Purple() { return Color(220, 0, 220); }
private:
unsigned char _color[4];
};
// Player Controls for CS:GO
enum playercontrols
{
IN_ATTACK = (1 << 0),
IN_JUMP = (1 << 1),
IN_DUCK = (1 << 2),
IN_FORWARD = (1 << 3),
IN_BACK = (1 << 4),
IN_USE = (1 << 5),
IN_CANCEL = (1 << 6),
IN_LEFT = (1 << 7),
IN_RIGHT = (1 << 8),
IN_MOVELEFT = (1 << 9),
IN_MOVERIGHT = (1 << 10),
IN_ATTACK2 = (1 << 11),
IN_RUN = (1 << 12),
IN_RELOAD = (1 << 13),
IN_ALT1 = (1 << 14),
IN_ALT2 = (1 << 15),
IN_SCORE = (1 << 16), // Used by client.dll for when scoreboard is held down
IN_SPEED = (1 << 17), // Player is holding the speed key
IN_WALK = (1 << 18), // Player holding walk key
IN_ZOOM = (1 << 19), // Zoom key for HUD zoom
IN_WEAPON1 = (1 << 20), // weapon defines these bits
IN_WEAPON2 = (1 << 21), // weapon defines these bits
IN_BULLRUSH = (1 << 22),
};
typedef float matrix3x4[3][4];
/*class player_info_t
{
public:
DWORD __pad0[2];
int xuidlow;
int xuidhigh;
char name[128];//32
int userid;
char steamid[33];//32
UINT steam3id;
char friendsname[128];
bool isfakeplayer;
bool ishltv;
DWORD customfiles[4];
BYTE filesdownloaded;
int __pad1;
};*/
typedef struct player_info_s
{
int64_t __pad0;
union {
int64_t xuid;
struct {
int xuidlow;
int xuidhigh;
};
};
char name[128];
int userid;
char guid[33];
unsigned int friendsid;
char friendsname[128];
bool fakeplayer;
bool ishltv;
unsigned int customfiles[4];
unsigned char filesdownloaded;
} player_info_t;
enum SolidType_t
{
SOLID_NONE = 0, // no solid model
SOLID_BSP = 1, // a BSP tree
SOLID_BBOX = 2, // an AABB
SOLID_OBB = 3, // an OBB (not implemented yet)
SOLID_OBB_YAW = 4, // an OBB, constrained so that it can only yaw
SOLID_CUSTOM = 5, // Always call into the entity for tests
SOLID_VPHYSICS = 6, // solid vphysics object, get vcollide from the model and collide with that
SOLID_LAST,
};
enum SolidFlags_t
{
FSOLID_CUSTOMRAYTEST = 0x0001, // Ignore solid type + always call into the entity for ray tests
FSOLID_CUSTOMBOXTEST = 0x0002, // Ignore solid type + always call into the entity for swept box tests
FSOLID_NOT_SOLID = 0x0004, // Are we currently not solid00
FSOLID_TRIGGER = 0x0008, // This is something may be collideable but fires touch functions
// even when it's not collideable (when the FSOLID_NOT_SOLID flag is set)
FSOLID_NOT_STANDABLE = 0x0010, // You can't stand on this
FSOLID_VOLUME_CONTENTS = 0x0020, // Contains volumetric contents (like water)
FSOLID_FORCE_WORLD_ALIGNED = 0x0040, // Forces the collision rep to be world-aligned even if it's SOLID_BSP or SOLID_VPHYSICS
FSOLID_USE_TRIGGER_BOUNDS = 0x0080, // Uses a special trigger bounds separate from the normal OBB
FSOLID_ROOT_PARENT_ALIGNED = 0x0100, // Collisions are defined in root parent's local coordinate space
FSOLID_TRIGGER_TOUCH_DEBRIS = 0x0200, // This trigger will touch debris objects
FSOLID_MAX_BITS = 10
};
// KeyValues
/*class KeyValues
{
public:
char _pad[0x20];//csgo, for css its a diff size
};*/
#define FCVAR_MATERIAL_THREAD_MASK ( FCVAR_RELOAD_MATERIALS | FCVAR_RELOAD_TEXTURES | FCVAR_MATERIAL_SYSTEM_THREAD )
struct FileHandle_t;
class KeyValues
{
public:
// By default, the KeyValues class uses a string table for the key names that is
// limited to 4MB. The game will exit in error if this space is exhausted. In
// general this is preferable for game code for performance and memory fragmentation
// reasons.
//
// If this is not acceptable, you can use this call to switch to a table that can grow
// arbitrarily. This call must be made before any KeyValues objects are allocated or it
// will result in undefined behavior. If you use the growable string table, you cannot
// share KeyValues pointers directly with any other module. You can serialize them across
// module boundaries. These limitations are acceptable in the Steam backend code
// this option was written for, but may not be in other situations. Make sure to
// understand the implications before using this.
static void SetUseGrowableStringTable(bool bUseGrowableTable);
KeyValues(const char *setName) {}
//
// AutoDelete class to automatically free the keyvalues.
// Simply construct it with the keyvalues you allocated and it will free them when falls out of scope.
// When you decide that keyvalues shouldn't be deleted call Assign(NULL) on it.
// If you constructed AutoDelete(NULL) you can later assign the keyvalues to be deleted with Assign(pKeyValues).
// You can also pass temporary KeyValues object as an argument to a function by wrapping it into KeyValues::AutoDelete
// instance: call_my_function( KeyValues::AutoDelete( new KeyValues( "test" ) ) )
//
class AutoDelete
{
public:
explicit inline AutoDelete(KeyValues *pKeyValues) : m_pKeyValues(pKeyValues) {}
explicit inline AutoDelete(const char *pchKVName) : m_pKeyValues(new KeyValues(pchKVName)) {}
inline ~AutoDelete(void) { if (m_pKeyValues) m_pKeyValues->deleteThis(); }
inline void Assign(KeyValues *pKeyValues) { m_pKeyValues = pKeyValues; }
KeyValues *operator->() { return m_pKeyValues; }
operator KeyValues *() { return m_pKeyValues; }
private:
AutoDelete(AutoDelete const &x); // forbid
AutoDelete & operator= (AutoDelete const &x); // forbid
KeyValues *m_pKeyValues;
};
// Quick setup constructors
KeyValues(const char *setName, const char *firstKey, const char *firstValue);
KeyValues(const char *setName, const char *firstKey, const wchar_t *firstValue);
KeyValues(const char *setName, const char *firstKey, int firstValue);
KeyValues(const char *setName, const char *firstKey, const char *firstValue, const char *secondKey, const char *secondValue);
KeyValues(const char *setName, const char *firstKey, int firstValue, const char *secondKey, int secondValue);
// Section name
const char *GetName() const;
void SetName(const char *setName);
// gets the name as a unique int
int GetNameSymbol() const { return m_iKeyName; }
// File access. Set UsesEscapeSequences true, if resource file/buffer uses Escape Sequences (eg \n, \t)
void UsesEscapeSequences(bool state); // default false
void UsesConditionals(bool state); // default true
bool LoadFromFile(void *filesystem, const char *resourceName, const char *pathID = NULL);
bool SaveToFile(void *filesystem, const char *resourceName, const char *pathID = NULL, bool sortKeys = false, bool bAllowEmptyString = false);
// Read from a buffer... Note that the buffer must be null terminated
bool LoadFromBuffer(char const *resourceName, const char *pBuffer, void* pFileSystem = NULL, const char *pPathID = NULL);
// Read from a utlbuffer...
bool LoadFromBuffer(char const *resourceName, void*buf, void* pFileSystem = NULL, const char *pPathID = NULL);
// Find a keyValue, create it if it is not found.
// Set bCreate to true to create the key if it doesn't already exist (which ensures a valid pointer will be returned)
KeyValues *FindKey(const char *keyName, bool bCreate = false);
KeyValues *FindKey(int keySymbol) const;
KeyValues *CreateNewKey(); // creates a new key, with an autogenerated name. name is guaranteed to be an integer, of value 1 higher than the highest other integer key name
void AddSubKey(KeyValues *pSubkey); // Adds a subkey. Make sure the subkey isn't a child of some other keyvalues
void RemoveSubKey(KeyValues *subKey); // removes a subkey from the list, DOES NOT DELETE IT
// Key iteration.
//
// NOTE: GetFirstSubKey/GetNextKey will iterate keys AND values. Use the functions
// below if you want to iterate over just the keys or just the values.
//
KeyValues *GetFirstSubKey() { return m_pSub; } // returns the first subkey in the list
KeyValues *GetNextKey() { return m_pPeer; } // returns the next subkey
void SetNextKey(KeyValues * pDat);
KeyValues *FindLastSubKey(); // returns the LAST subkey in the list. This requires a linked list iteration to find the key. Returns NULL if we don't have any children
//
// These functions can be used to treat it like a true key/values tree instead of
// confusing values with keys.
//
// So if you wanted to iterate all subkeys, then all values, it would look like this:
// for ( KeyValues *pKey = pRoot->GetFirstTrueSubKey(); pKey; pKey = pKey->GetNextTrueSubKey() )
// {
// Msg( "Key name: %s\n", pKey->GetName() );
// }
// for ( KeyValues *pValue = pRoot->GetFirstValue(); pKey; pKey = pKey->GetNextValue() )
// {
// Msg( "Int value: %d\n", pValue->GetInt() ); // Assuming pValue->GetDataType() == TYPE_INT...
// }
KeyValues* GetFirstTrueSubKey();
KeyValues* GetNextTrueSubKey();
KeyValues* GetFirstValue(); // When you get a value back, you can use GetX and pass in NULL to get the value.
KeyValues* GetNextValue();
// Data access
int GetInt(const char *keyName = NULL, int defaultValue = 0);
UINT64 GetUint64(const char *keyName = NULL, UINT64 defaultValue = 0);
float GetFloat(const char *keyName = NULL, float defaultValue = 0.0f);
const char *GetString(const char *keyName = NULL, const char *defaultValue = "");
const wchar_t *GetWString(const char *keyName = NULL, const wchar_t *defaultValue = L"");
void *GetPtr(const char *keyName = NULL, void *defaultValue = (void*)0);
bool GetBool(const char *keyName = NULL, bool defaultValue = false);
Color GetColor(const char *keyName = NULL /* default value is all black */);
bool IsEmpty(const char *keyName = NULL);
// Data access
int GetInt(int keySymbol, int defaultValue = 0);
float GetFloat(int keySymbol, float defaultValue = 0.0f);
const char *GetString(int keySymbol, const char *defaultValue = "");
const wchar_t *GetWString(int keySymbol, const wchar_t *defaultValue = L"");
void *GetPtr(int keySymbol, void *defaultValue = (void*)0);
Color GetColor(int keySymbol /* default value is all black */);
bool IsEmpty(int keySymbol);
// Key writing
void SetWString(const char *keyName, const wchar_t *value);
void SetString(const char *keyName, const char *value);
void SetInt(const char *keyName, int value);
void SetUint64(const char *keyName, UINT64 value);
void SetFloat(const char *keyName, float value);
void SetPtr(const char *keyName, void *value);
void SetColor(const char *keyName, Color value);
void SetBool(const char *keyName, bool value) { SetInt(keyName, value ? 1 : 0); }
// Adds a chain... if we don't find stuff in this keyvalue, we'll look
// in the one we're chained to.
void ChainKeyValue(KeyValues* pChain);
void RecursiveSaveToFile(void* buf, int indentLevel, bool sortKeys = false, bool bAllowEmptyString = false);
bool WriteAsBinary(void*buffer);
bool ReadAsBinary(void*buffer, int nStackDepth = 0);
// Allocate & create a new copy of the keys
KeyValues *MakeCopy(void) const;
// Make a new copy of all subkeys, add them all to the passed-in keyvalues
void CopySubkeys(KeyValues *pParent) const;
// Clear out all subkeys, and the current value
void Clear(void);
// Data type
enum types_t
{
TYPE_NONE = 0,
TYPE_STRING,
TYPE_INT,
TYPE_FLOAT,
TYPE_PTR,
TYPE_WSTRING,
TYPE_COLOR,
TYPE_UINT64,
TYPE_NUMTYPES,
};
types_t GetDataType(const char *keyName = NULL);
// Virtual deletion function - ensures that KeyValues object is deleted from correct heap
void deleteThis();
void SetStringValue(char const *strValue);
// unpack a key values list into a structure
void UnpackIntoStructure(struct KeyValuesUnpackStructure const *pUnpackTable, void *pDest, size_t DestSizeInBytes);
// Process conditional keys for widescreen support.
bool ProcessResolutionKeys(const char *pResString);
// Dump keyvalues recursively into a dump context
bool Dump(class IKeyValuesDumpContext *pDump, int nIndentLevel = 0);
// Merge in another KeyValues, keeping "our" settings
void RecursiveMergeKeyValues(KeyValues *baseKV);
private:
KeyValues(KeyValues&); // prevent copy constructor being used
// prevent delete being called except through deleteThis()
~KeyValues();
KeyValues* CreateKey(const char *keyName);
/// Create a child key, given that we know which child is currently the last child.
/// This avoids the O(N^2) behaviour when adding children in sequence to KV,
/// when CreateKey() wil have to re-locate the end of the list each time. This happens,
/// for example, every time we load any KV file whatsoever.
KeyValues* CreateKeyUsingKnownLastChild(const char *keyName, KeyValues *pLastChild);
void AddSubkeyUsingKnownLastChild(KeyValues *pSubKey, KeyValues *pLastChild);
void RecursiveCopyKeyValues(KeyValues& src);
void RemoveEverything();
// void RecursiveSaveToFile( IBaseFileSystem *filesystem, void*buffer, int indentLevel );
// void WriteConvertedString( void*buffer, const char *pszString );
// NOTE: If both filesystem and pBuf are non-null, it'll save to both of them.
// If filesystem is null, it'll ignore f.
void RecursiveSaveToFile(void *filesystem, FileHandle_t f, void *pBuf, int indentLevel, bool sortKeys, bool bAllowEmptyString);
void SaveKeyToFile(KeyValues *dat, void *filesystem, FileHandle_t f, void *pBuf, int indentLevel, bool sortKeys, bool bAllowEmptyString);
void WriteConvertedString(void *filesystem, FileHandle_t f, void *pBuf, const char *pszString);
void RecursiveLoadFromBuffer(char const *resourceName, void*buf);
// For handling #include "filename"
void AppendIncludedKeys(void* includedKeys);
void ParseIncludedKeys(char const *resourceName, const char *filetoinclude,
void* pFileSystem, const char *pPathID, void* includedKeys);
// For handling #base "filename"
void MergeBaseKeys(void* baseKeys);
// NOTE: If both filesystem and pBuf are non-null, it'll save to both of them.
// If filesystem is null, it'll ignore f.
void InternalWrite(void *filesystem, FileHandle_t f, void *pBuf, const void *pData, int len);
void Init();
const char * ReadToken(void*buf, bool &wasQuoted, bool &wasConditional);
void WriteIndents(void *filesystem, FileHandle_t f, void *pBuf, int indentLevel);
void FreeAllocatedValue();
void AllocateValueBlock(int size);
int m_iKeyName; // keyname is a symbol defined in KeyValuesSystem
// These are needed out of the union because the API returns string pointers
char *m_sValue;
wchar_t *m_wsValue;
// we don't delete these
union
{
int m_iValue;
float m_flValue;
void *m_pValue;
unsigned char m_Color[4];
};
char m_iDataType;
char m_bHasEscapeSequences; // true, if while parsing this KeyValue, Escape Sequences are used (default false)
char m_bEvaluateConditionals; // true, if while parsing this KeyValue, conditionals blocks are evaluated (default true)
char unused[1];
KeyValues *m_pPeer; // pointer to next key in list
KeyValues *m_pSub; // pointer to Start of a new sub key list
KeyValues *m_pChain;// Search here if it's not in our list
public:
void *operator new(size_t iAllocSize);
void operator delete(void *pMem);
void *operator new(size_t iAllocSize, int nBlockUse, const char *pFileName, int nLine);
void operator delete(void *pMem, int nBlockUse, const char *pFileName, int nLine);
private:
// Statics to implement the optional growable string table
// Function pointers that will determine which mode we are in
static int(*s_pfGetSymbolForString)(const char *name, bool bCreate);
static const char *(*s_pfGetStringForSymbol)(int symbol);
static void *s_pGrowableStringTable;
public:
// Functions that invoke the default behavior
static int GetSymbolForStringClassic(const char *name, bool bCreate = true);
static const char *GetStringForSymbolClassic(int symbol);
// Functions that use the growable string table
static int GetSymbolForStringGrowable(const char *name, bool bCreate = true);
static const char *GetStringForSymbolGrowable(int symbol);
// Functions to get external access to whichever of the above functions we're going to call.
static int CallGetSymbolForString(const char *name, bool bCreate = true) { return s_pfGetSymbolForString(name, bCreate); }
static const char *CallGetStringForSymbol(int symbol) { return s_pfGetStringForSymbol(symbol); }
};
// Memes
struct ModelRenderInfo_t
{
Vector origin;
Vector angles;
char pad[0x4];
void *pRenderable;
const void *pModel;
const matrix3x4 *pModelToWorld;
const matrix3x4 *pLightingOffset;
const Vector *pLightingOrigin;
int flags;
int entity_index;
int skin;
int body;
int hitboxset;
unsigned short instance;
ModelRenderInfo_t()
{
pModelToWorld = NULL;
pLightingOffset = NULL;
pLightingOrigin = NULL;
}
};
typedef float vec_t;
inline unsigned long& FloatBits(vec_t& f)
{
return *reinterpret_cast<unsigned long*>(&f);
}
inline bool IsFinite(vec_t f)
{
return ((FloatBits(f) & 0x7F8000) != 0x7F8000);
}
struct model_t;
enum OverrideType_t
{
OVERRIDE_NORMAL = 0,
OVERRIDE_BUILD_SHADOWS,
OVERRIDE_DEPTH_WRITE,
};
enum MaterialVarFlags_t
{
MATERIAL_VAR_DEBUG = (1 << 0),
MATERIAL_VAR_NO_DEBUG_OVERRIDE = (1 << 1),
MATERIAL_VAR_NO_DRAW = (1 << 2),
MATERIAL_VAR_USE_IN_FILLRATE_MODE = (1 << 3),
MATERIAL_VAR_VERTEXCOLOR = (1 << 4),
MATERIAL_VAR_VERTEXALPHA = (1 << 5),
MATERIAL_VAR_SELFILLUM = (1 << 6),
MATERIAL_VAR_ADDITIVE = (1 << 7),
MATERIAL_VAR_ALPHATEST = (1 << 8),
MATERIAL_VAR_MULTIPASS = (1 << 9),
MATERIAL_VAR_ZNEARER = (1 << 10),
MATERIAL_VAR_MODEL = (1 << 11),
MATERIAL_VAR_FLAT = (1 << 12),
MATERIAL_VAR_NOCULL = (1 << 13),
MATERIAL_VAR_NOFOG = (1 << 14),
MATERIAL_VAR_IGNOREZ = (1 << 15),
MATERIAL_VAR_DECAL = (1 << 16),
MATERIAL_VAR_ENVMAPSPHERE = (1 << 17),
MATERIAL_VAR_NOALPHAMOD = (1 << 18),
MATERIAL_VAR_ENVMAPCAMERASPACE = (1 << 19),
MATERIAL_VAR_BASEALPHAENVMAPMASK = (1 << 20),
MATERIAL_VAR_TRANSLUCENT = (1 << 21),
MATERIAL_VAR_NORMALMAPALPHAENVMAPMASK = (1 << 22),
MATERIAL_VAR_NEEDS_SOFTWARE_SKINNING = (1 << 23),
MATERIAL_VAR_OPAQUETEXTURE = (1 << 24),
MATERIAL_VAR_ENVMAPMODE = (1 << 25),
MATERIAL_VAR_SUPPRESS_DECALS = (1 << 26),
MATERIAL_VAR_HALFLAMBERT = (1 << 27),
MATERIAL_VAR_WIREFRAME = (1 << 28),
// NOTE: Only add flags here that either should be read from
// .vmts or can be set directly from client code. Other, internal
// flags should to into the flag enum in IMaterialInternal.h
};
#define FL_ONGROUND (1<<0) // At rest / on the ground
#define FL_DUCKING (1<<1) // Player flag -- Player is fully crouched
#define FL_WATERJUMP (1<<2) // player jumping out of water
#define FL_ONTRAIN (1<<3) // Player is _controlling_ a train, so movement commands should be ignored on client during prediction.
#define FL_INRAIN (1<<4) // Indicates the entity is standing in rain
#define FL_FROZEN (1<<5) // Player is frozen for 3rd person camera
#define FL_ATCONTROLS (1<<6) // Player can't move, but keeps key inputs for controlling another entity
#define FL_CLIENT (1<<7) // Is a player
#define FL_FAKECLIENT (1<<8) // Fake client, simulated server side; don't send network messages to them
// NON-PLAYER SPECIFIC (i.e., not used by GameMovement or the client .dll ) -- Can still be applied to players, though
#define FL_INWATER (1<<9) // In water
// NOTE if you move things up, make sure to change this value
#define PLAYER_FLAG_BITS 10
#define FL_FLY (1<<10) // Changes the SV_Movestep() behavior to not need to be on ground
#define FL_SWIM (1<<11) // Changes the SV_Movestep() behavior to not need to be on ground (but stay in water)
#define FL_CONVEYOR (1<<12)
#define FL_NPC (1<<13)
#define FL_GODMODE (1<<14)
#define FL_NOTARGET (1<<15)
#define FL_AIMTARGET (1<<16) // set if the crosshair needs to aim onto the entity
#define FL_PARTIALGROUND (1<<17) // not all corners are valid
#define FL_STATICPROP (1<<18) // Eetsa static prop!
#define FL_GRAPHED (1<<19) // worldgraph has this ent listed as something that blocks a connection
#define FL_GRENADE (1<<20)
#define FL_STEPMOVEMENT (1<<21) // Changes the SV_Movestep() behavior to not do any processing
#define FL_DONTTOUCH (1<<22) // Doesn't generate touch functions, generates Untouch() for anything it was touching when this flag was set
#define FL_BASEVELOCITY (1<<23) // Base velocity has been applied this frame (used to convert base velocity into momentum)
#define FL_WORLDBRUSH (1<<24) // Not moveable/removeable brush entity (really part of the world, but represented as an entity for transparency or something)
#define FL_OBJECT (1<<25) // Terrible name. This is an object that NPCs should see. Missiles, for example.
#define FL_KILLME (1<<26) // This entity is marked for death -- will be freed by game DLL
#define FL_ONFIRE (1<<27) // You know...
#define FL_DISSOLVING (1<<28) // We're dissolving!
#define FL_TRANSRAGDOLL (1<<29) // In the process of turning into a client side ragdoll.
#define FL_UNBLOCKABLE_BY_PLAYER (1<<30) // pusher that can't be blocked by the player
enum ClientFrameStage_t
{
FRAME_UNDEFINED = -1, // (haven't run any frames yet)
FRAME_START,
// A network packet is being recieved
FRAME_NET_UPDATE_START,
// Data has been received and we're going to start calling PostDataUpdate
FRAME_NET_UPDATE_POSTDATAUPDATE_START,
// Data has been received and we've called PostDataUpdate on all data recipients
FRAME_NET_UPDATE_POSTDATAUPDATE_END,
// We've received all packets, we can now do interpolation, prediction, etc..
FRAME_NET_UPDATE_END,
// We're about to start rendering the scene
FRAME_RENDER_START,
// We've finished rendering the scene.
FRAME_RENDER_END
};
// ConVar flags
#define FCVAR_NONE 0
// Command to ConVars and ConCommands
// ConVar Systems
#define FCVAR_UNREGISTERED (1<<0) // If this is set, don't add to linked list, etc.
#define FCVAR_DEVELOPMENTONLY (1<<1) // Hidden in released products. Flag is removed automatically if ALLOW_DEVELOPMENT_CVARS is defined.
#define FCVAR_GAMEDLL (1<<2) // defined by the game DLL
#define FCVAR_CLIENTDLL (1<<3) // defined by the client DLL
#define FCVAR_HIDDEN (1<<4) // Hidden. Doesn't appear in find or auto complete. Like DEVELOPMENTONLY, but can't be compiled out.
// ConVar only
#define FCVAR_PROTECTED (1<<5) // It's a server cvar, but we don't send the data since it's a password, etc. Sends 1 if it's not bland/zero, 0 otherwise as value
#define FCVAR_SPONLY (1<<6) // This cvar cannot be changed by clients connected to a multiplayer server.
#define FCVAR_ARCHIVE (1<<7) // set to cause it to be saved to vars.rc
#define FCVAR_NOTIFY (1<<8) // notifies players when changed
#define FCVAR_USERINFO (1<<9) // changes the client's info string
#define FCVAR_PRINTABLEONLY (1<<10) // This cvar's string cannot contain unprintable characters ( e.g., used for player name etc ).
#define FCVAR_UNLOGGED (1<<11) // If this is a FCVAR_SERVER, don't log changes to the log file / console if we are creating a log
#define FCVAR_NEVER_AS_STRING (1<<12) // never try to print that cvar
// It's a ConVar that's shared between the client and the server.
// At signon, the values of all such ConVars are sent from the server to the client (skipped for local
// client, of course )
// If a change is requested it must come from the console (i.e., no remote client changes)
// If a value is changed while a server is active, it's replicated to all connected clients
#define FCVAR_REPLICATED (1<<13) // server setting enforced on clients, TODO rename to FCAR_SERVER at some time
#define FCVAR_CHEAT (1<<14) // Only useable in singleplayer / debug / multiplayer & sv_cheats
#define FCVAR_SS (1<<15) // causes varnameN where N == 2 through max splitscreen slots for mod to be autogenerated
#define FCVAR_DEMO (1<<16) // record this cvar when starting a demo file
#define FCVAR_DONTRECORD (1<<17) // don't record these command in demofiles
#define FCVAR_SS_ADDED (1<<18) // This is one of the "added" FCVAR_SS variables for the splitscreen players
#define FCVAR_RELEASE (1<<19) // Cvars tagged with this are the only cvars avaliable to customers
#define FCVAR_RELOAD_MATERIALS (1<<20) // If this cvar changes, it forces a material reload
#define FCVAR_RELOAD_TEXTURES (1<<21) // If this cvar changes, if forces a texture reload
#define FCVAR_NOT_CONNECTED (1<<22) // cvar cannot be changed by a client that is connected to a server
#define FCVAR_MATERIAL_SYSTEM_THREAD (1<<23) // Indicates this cvar is read from the material system thread
#define FCVAR_ARCHIVE_XBOX (1<<24) // cvar written to config.cfg on the Xbox
#define FCVAR_SERVER_CAN_EXECUTE (1<<28)// the server is allowed to execute this command on clients via ClientCommand/NET_StringCmd/CBaseClientState::ProcessStringCmd.
#define FCVAR_SERVER_CANNOT_QUERY (1<<29)// If this is set, then the server is not allowed to query this cvar's value (via IServerPluginHelpers::StartQueryCvarValue).
#define FCVAR_CLIENTCMD_CAN_EXECUTE (1<<30) // IVEngineClient::ClientCmd is allowed to execute this command.