-
Notifications
You must be signed in to change notification settings - Fork 1
/
MiscClasses.h
1489 lines (1256 loc) · 42.8 KB
/
MiscClasses.h
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 "MiscDefinitions.h"
#include "ClientRecvProps.h"
#include "offsets.h"
#include "Vector.h"
#include "bspflags.h"
#include "winwindef.h"
// Entity List
class IClientModeShared
{
public:
};
class IClientEntityList
{
public:
virtual void Function0();
virtual void Function1();
virtual void Function2();
virtual IClientEntity * GetClientEntity(int entnum);
virtual IClientEntity * GetClientEntityFromHandle(HANDLE hEnt) = 0;
virtual int NumberOfEntities(bool bIncludeNonNetworkable) = 0;
virtual int GetHighestEntityIndex(void);
virtual void SetMaxEntities(int maxents);
virtual int GetMaxEntities();
void* GetClientEntityFromHandle(uintptr_t handle) {
using original_fn = void*(__thiscall*)(void*, uintptr_t);
return (*(original_fn**)this)[4](this, handle);
}
};
class INetChannel
{
public:
char pad_0000[20]; //0x0000
bool m_bProcessingMessages; //0x0014
bool m_bShouldDelete; //0x0015
char pad_0016[2]; //0x0016
int32_t m_nOutSequenceNr; //0x0018 last send outgoing sequence number
int32_t m_nInSequenceNr; //0x001C last received incoming sequnec number
int32_t m_nOutSequenceNrAck; //0x0020 last received acknowledge outgoing sequnce number
int32_t m_nOutReliableState; //0x0024 state of outgoing reliable data (0/1) flip flop used for loss detection
int32_t m_nInReliableState; //0x0028 state of incoming reliable data
int32_t m_nChokedPackets; //0x002C number of choked packets
char pad_0030[1044]; //0x0030
};
class CClockDriftMgr
{
public:
float m_ClockOffsets[16]; //0x0000
uint32_t m_iCurClockOffset; //0x0040
int32_t m_nServerTick; //0x0044
int32_t m_nClientTick; //0x0048
}; //Size: 0x004C
class CClientState
{
public:
char pad_0000[156]; //0x0000
INetChannel* m_NetChannel; //0x009C
uint32_t m_nChallengeNr; //0x00A0
char pad_00A4[100]; //0x00A4
uint32_t m_nSignonState; //0x0108
char pad_010C[8]; //0x010C
float m_flNextCmdTime; //0x0114
uint32_t m_nServerCount; //0x0118
uint32_t m_nCurrentSequence; //0x011C
char pad_0120[8]; //0x0120
CClockDriftMgr m_ClockDriftMgr; //0x0128
uint32_t m_nDeltaTick; //0x0178
bool m_bPaused; //0x017C
char pad_017D[3]; //0x017D
uint32_t m_nViewEntity; //0x0180
uint32_t m_nPlayerSlot; //0x0184
char m_szLevelName[260]; //0x0188
char m_szLevelNameShort[40]; //0x028C
char m_szGroupName[40]; //0x02B4
char pad_02DC[56]; //0x02DC
uint32_t m_nMaxClients; //0x0310
char pad_0314[18940]; //0x0314
Vector viewangles; //0x4D10
}; //Size: 0x4D18
struct CViewSetup
{
char _0x0000[16];
__int32 x;
__int32 x_old;
__int32 y;
__int32 y_old;
__int32 width;
__int32 width_old;
__int32 height;
__int32 height_old;
char _0x0030[128];
float fov;
float fovViewmodel;
Vector origin;
Vector angles;
float zNear;
float zFar;
float zNearViewmodel;
float zFarViewmodel;
float m_flAspectRatio;
float m_flNearBlurDepth;
float m_flNearFocusDepth;
float m_flFarFocusDepth;
float m_flFarBlurDepth;
float m_flNearBlurRadius;
float m_flFarBlurRadius;
float m_nDoFQuality;
__int32 m_nMotionBlurMode;
char _0x0104[68];
__int32 m_EdgeBlur;
};
// Panels
class IPanel
{
public:
const char *GetName(unsigned int vguiPanel)
{
typedef const char* (__thiscall* OriginalFn)(PVOID, unsigned int);
return call_vfunc<OriginalFn>(this, Offsets::VMT::Panel_GetName)(this, vguiPanel);
}
};
#define EVENT_DEBUG_ID_INIT 42
class IGameEvent {
public:
virtual ~IGameEvent() {};
virtual const char *GetName() const = 0; // get event name
virtual bool IsReliable() const = 0; // if event handled reliable
virtual bool IsLocal() const = 0; // if event is never networked
virtual bool IsEmpty(const char *keyName = NULL) = 0; // check if data field exists
// Data access
virtual bool GetBool(const char *keyName = NULL, bool defaultValue = false) = 0;
virtual int GetInt(const char *keyName = NULL, int defaultValue = 0) = 0;
virtual unsigned __int64 GetUint64(const char *keyName = NULL, unsigned __int64 defaultValue = 0) = 0;
virtual float GetFloat(const char *keyName = NULL, float defaultValue = 0.0f) = 0;
virtual const char *GetString(const char *keyName = NULL, const char *defaultValue = "") = 0;
virtual const wchar_t * GetWString(char const *keyName = NULL, const wchar_t *defaultValue = L"") = 0;
virtual void SetBool(const char *keyName, bool value) = 0;
virtual void SetInt(const char *keyName, int value) = 0;
virtual void SetUint64(const char *keyName, unsigned __int64 value) = 0;
virtual void SetFloat(const char *keyName, float value) = 0;
virtual void SetString(const char *keyName, const char *value) = 0;
virtual void SetWString(const char *keyName, const wchar_t *value) = 0;
};
class IGameEventListener2 {
public:
virtual ~IGameEventListener2(void) {};
virtual void FireGameEvent(IGameEvent *event) = 0;
virtual int GetEventDebugID(void) = 0;
};
class bf_read;
class bf_write;
class IGameEventManager2 {
public:
virtual ~IGameEventManager2(void) {};
virtual int LoadEventsFromFile(const char *filename) = 0;
virtual void Reset() = 0;
virtual bool AddListener(IGameEventListener2 *listener, const char *name, bool bServerSide) = 0;
virtual bool FindListener(IGameEventListener2 *listener, const char *name) = 0;
virtual void RemoveListener(IGameEventListener2 *listener) = 0;
virtual IGameEvent *CreateEvent(const char *name, bool bForce = false, int *pCookie = NULL) = 0;
virtual bool FireEvent(IGameEvent *event, bool bDontBroadcast = false) = 0;
virtual bool FireEventClientSide(IGameEvent *event) = 0;
virtual IGameEvent *DuplicateEvent(IGameEvent *event) = 0;
virtual void FreeEvent(IGameEvent *event) = 0;
virtual bool SerializeEvent(IGameEvent *event, bf_write *buf) = 0;
virtual IGameEvent *UnserializeEvent(bf_read *buf) = 0;
};
// Colors
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);
}
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]; }
inline float rBase() const { return _color[0] / 255.0f; }
inline float gBase() const { return _color[1] / 255.0f; }
inline float bBase() const { return _color[2] / 255.0f; }
inline float aBase() const { return _color[3] / 255.0f; }
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 * 4.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 * 1),
(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); }
//Menu
static Color Background() { return Color(55, 55, 55); }
static Color FrameBorder() { return Color(80, 80, 80); }
static Color MainText() { return Color(230, 230, 230); }
static Color HeaderText() { return Color(49, 124, 230); }
static Color CurrentTab() { return Color(55, 55, 55); }
static Color Tabs() { return Color(23, 23, 23); }
static Color Highlight() { return Color(49, 124, 230); }
static Color ElementBorder() { return Color(0, 0, 0); }
static Color SliderScroll() { return Color(78, 143, 230); }
private:
unsigned char _color[4];
};
class IVDebugOverlay
{
public:
virtual void AddEntityTextOverlay(int ent_index, int line_offset, float duration, int r, int g, int b, int a, const char *format, ...) = 0;
virtual void AddBoxOverlay(const Vector& origin, const Vector& mins, const Vector& max, Vector const& orientation, int r, int g, int b, int a, float duration) = 0;
virtual void AddSphereOverlay(const Vector& vOrigin, float flRadius, int nTheta, int nPhi, int r, int g, int b, int a, float flDuration) = 0;
virtual void AddTriangleOverlay(const Vector& p1, const Vector& p2, const Vector& p3, int r, int g, int b, int a, bool noDepthTest, float duration) = 0;
virtual void AddLineOverlay(const Vector& origin, const Vector& dest, int r, int g, int b, bool noDepthTest, float duration) = 0;
virtual void AddTextOverlay(const Vector& origin, float duration, const char *format, ...) = 0;
virtual void AddTextOverlay(const Vector& origin, int line_offset, float duration, const char *format, ...) = 0;
virtual void AddScreenTextOverlay(float flXPos, float flYPos, float flDuration, int r, int g, int b, int a, const char *text) = 0;
virtual void AddSweptBoxOverlay(const Vector& start, const Vector& end, const Vector& mins, const Vector& max, const Vector & angles, int r, int g, int b, int a, float flDuration) = 0;
virtual void AddGridOverlay(const Vector& origin) = 0;
virtual void AddCoordFrameOverlay(const matrix3x4& frame, float flScale, int vColorTable[3][3] = NULL) = 0;
virtual int ScreenPosition(const Vector& point, Vector& screen) = 0;
virtual int ScreenPosition(float flXPos, float flYPos, Vector& screen) = 0;
virtual void *GetFirst(void) = 0;
virtual void *GetNext(void *current) = 0;
virtual void ClearDeadOverlays(void) = 0;
virtual void ClearAllOverlays() = 0;
virtual void AddTextOverlayRGB(const Vector& origin, int line_offset, float duration, float r, float g, float b, float alpha, const char *format, ...) = 0;
virtual void AddTextOverlayRGB(const Vector& origin, int line_offset, float duration, int r, int g, int b, int a, const char *format, ...) = 0;
virtual void AddLineOverlayAlpha(const Vector& origin, const Vector& dest, int r, int g, int b, int a, bool noDepthTest, float duration) = 0;
virtual void AddBoxOverlay2(const Vector& origin, const Vector& mins, const Vector& max, Vector const& orientation, const Color& faceColor, const Color& edgeColor, float duration) = 0;
virtual void PurgeTextOverlays() = 0;
};
// User Cmd's
class CUserCmd
{
public:
virtual ~CUserCmd() {}; //Destructor 0
CUserCmd()
{
Reset();
}
void Reset()
{
command_number = 0;
tick_count = 0;
viewangles.Init();
forwardmove = 0.0f;
sidemove = 0.0f;
upmove = 0.0f;
buttons = 0;
impulse = 0;
weaponselect = 0;
weaponsubtype = 0;
random_seed = 0;
mousedx = 0;
mousedy = 0;
headangles.Init();
headoffset.Init();
hasbeenpredicted = false;
}
CUserCmd& operator =(const CUserCmd& src)
{
if (this == &src)
return *this;
command_number = src.command_number;
tick_count = src.tick_count;
viewangles = src.viewangles;
forwardmove = src.forwardmove;
sidemove = src.sidemove;
upmove = src.upmove;
buttons = src.buttons;
impulse = src.impulse;
weaponselect = src.weaponselect;
weaponsubtype = src.weaponsubtype;
random_seed = src.random_seed;
mousedx = src.mousedx;
mousedy = src.mousedy;
hasbeenpredicted = src.hasbeenpredicted;
headangles = src.headangles;
headoffset = src.headoffset;
return *this;
}
CUserCmd(const CUserCmd& src)
{
*this = src;
}
int command_number;
int tick_count;
Vector viewangles;
Vector aimdirection;
float forwardmove;
float sidemove;
float upmove;
int buttons;
BYTE impulse;
int weaponselect;
int weaponsubtype;
int random_seed;
short mousedx;
short mousedy;
bool hasbeenpredicted;
Vector headangles;
Vector headoffset;
};
class CVerifiedUserCmd
{
public:
CUserCmd m_cmd;
unsigned long m_crc;
};
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose: Generic CRC functions
//
// $NoKeywords: $
//=============================================================================//
#ifndef CHECKSUM_CRC_H
#define CHECKSUM_CRC_H
#ifdef _WIN32
#pragma once
#endif
typedef unsigned long CRC32_t;
void CRC32_Init(CRC32_t *pulCRC);
void CRC32_ProcessBuffer(CRC32_t *pulCRC, const void *p, int len);
void CRC32_Final(CRC32_t *pulCRC);
CRC32_t CRC32_GetTableEntry(unsigned int slot);
inline CRC32_t CRC32_ProcessSingleBuffer(const void *p, int len)
{
CRC32_t crc;
CRC32_Init(&crc);
CRC32_ProcessBuffer(&crc, p, len);
CRC32_Final(&crc);
return crc;
}
#endif // CHECKSUM_CRC_H
class CInput
{
public:
void* pvftable; //0x00
bool m_fTrackIRAvailable; //0x04
bool m_fMouseInitialized; //0x05
bool m_fMouseActive; //0x06
bool m_fJoystickAdvancedInit; //0x07
char pad_0x08[0x2C]; //0x08
void* m_pKeys; //0x34
char pad_0x38[0x64]; //0x38
int pad_0x41;
int pad_0x42;
bool m_fCameraInterceptingMouse; //0x9C
bool m_fCameraInThirdPerson; //0x9D
bool m_fCameraMovingWithMouse; //0x9E
Vector m_vecCameraOffset; //0xA0
bool m_fCameraDistanceMove; //0xAC
int m_nCameraOldX; //0xB0
int m_nCameraOldY; //0xB4
int m_nCameraX; //0xB8
int m_nCameraY; //0xBC
bool m_CameraIsOrthographic; //0xC0
Vector m_angPreviousViewAngles; //0xC4
Vector m_angPreviousViewAnglesTilt; //0xD0
float m_flLastForwardMove; //0xDC
int m_nClearInputState; //0xE0
char pad_0xE4[0x8]; //0xE4
CUserCmd* m_pCommands; //0xEC
//CVerifiedUserCmd* m_pVerifiedCommands; //0xF0
class CUserCmd
{
public:
CRC32_t GetChecksum(void) const
{
CRC32_t crc;
CRC32_Init(&crc);
CRC32_ProcessBuffer(&crc, &command_number, sizeof(command_number));
CRC32_ProcessBuffer(&crc, &tick_count, sizeof(tick_count));
CRC32_ProcessBuffer(&crc, &viewangles, sizeof(viewangles));
CRC32_ProcessBuffer(&crc, &aimdirection, sizeof(aimdirection));
CRC32_ProcessBuffer(&crc, &forwardmove, sizeof(forwardmove));
CRC32_ProcessBuffer(&crc, &sidemove, sizeof(sidemove));
CRC32_ProcessBuffer(&crc, &upmove, sizeof(upmove));
CRC32_ProcessBuffer(&crc, &buttons, sizeof(buttons));
CRC32_ProcessBuffer(&crc, &impulse, sizeof(impulse));
CRC32_ProcessBuffer(&crc, &weaponselect, sizeof(weaponselect));
CRC32_ProcessBuffer(&crc, &weaponsubtype, sizeof(weaponsubtype));
CRC32_ProcessBuffer(&crc, &random_seed, sizeof(random_seed));
CRC32_ProcessBuffer(&crc, &mousedx, sizeof(mousedx));
CRC32_ProcessBuffer(&crc, &mousedy, sizeof(mousedy));
CRC32_Final(&crc);
return crc;
}
BYTE u1[4];
int command_number;
int tick_count;
Vector viewangles;
Vector aimdirection;
float forwardmove;
float sidemove;
float upmove;
int buttons;
BYTE impulse;
int weaponselect;
int weaponsubtype;
int random_seed;
short mousedx;
short mousedy;
bool hasbeenpredicted;
Vector headangles;
Vector headoffset;
};
class CVerifiedUserCmd
{
public:
CUserCmd m_cmd;
unsigned long m_crc;
};
CUserCmd* GetUserCmd(int slot, int seq)
{
typedef CUserCmd* (__thiscall* OriginalFn)(PVOID, int, int);
return call_vfunc<OriginalFn>(this, 9)(this, slot, seq);
}
};
class CGlobalVarsBase
{
public:
float realtime;
int framecount;
float absoluteframetime;
float absoluteframestarttimestddev;
float curtime;
float frametime;
int maxClients;
int tickcount;
float interval_per_tick;
float interpolation_amount;
int simTicksThisFrame;
int network_protocol;
void* pSaveData;
bool m_bClient;
int nTimestampNetworkingBase;
int nTimestampRandomizeWindow;
};
struct Ray_t
{
__declspec(align(16)) Vector m_Start;
__declspec(align(16)) Vector m_Delta;
__declspec(align(16)) Vector m_StartOffset;
__declspec(align(16)) Vector m_Extents;
//without your matrix3x4
bool m_IsRay;
bool m_IsSwept;
void Init(Vector& vecStart, Vector& vecEnd)
{
m_Delta = vecEnd - vecStart;
m_IsSwept = (m_Delta.LengthSqr() != 0);
m_Extents.x = m_Extents.y = m_Extents.z = 0.0f;
m_IsRay = true;
m_StartOffset.x = m_StartOffset.y = m_StartOffset.z = 0.0f;
m_Start = vecStart;
}
};
struct cplane_t
{
Vector normal;
float dist;
BYTE type;
BYTE signbits;
BYTE pad[2];
};
class CBaseTrace
{
public:
Vector startpos;
Vector endpos;
cplane_t plane;
float fraction;
int contents;
unsigned short dispFlags;
bool allsolid;
bool startsolid;
};
struct csurface_t
{
const char* name;
short surfaceProps;
unsigned short flags;
};
class CGameTrace : public CBaseTrace
{
public:
bool DidHitWorld() const;
bool DidHitNonWorldEntity() const;
int GetEntityIndex() const;
bool DidHit() const;
public:
float fractionleftsolid;
csurface_t surface;
int hitgroup;
short physicsbone;
unsigned short worldSurfaceIndex;
IClientEntity* m_pEnt;
int hitbox;
char shit[0x24];
};
inline bool CGameTrace::DidHit() const
{
return fraction < 1.0f || allsolid || startsolid;
}
typedef CGameTrace trace_t;
enum TraceType_t
{
TRACE_EVERYTHING = 0,
TRACE_WORLD_ONLY,
TRACE_ENTITIES_ONLY,
TRACE_EVERYTHING_FILTER_PROPS,
};
class ITraceFilter
{
public:
virtual bool ShouldHitEntity(IClientEntity* pEntity, int contentsMask) = 0;
virtual TraceType_t GetTraceType() const = 0;
};
class CTraceFilter : public ITraceFilter
{
public:
bool ShouldHitEntity(IClientEntity* pEntityHandle, int contentsMask)
{
return !(pEntityHandle == pSkip);
}
TraceType_t GetTraceType() const
{
return TRACE_EVERYTHING;
}
void* pSkip;
};
class IEngineTrace
{
public:
int GetPointContents(const Vector &vecAbsPosition, int contentsMask = MASK_ALL, IClientEntity** ppEntity = NULL)
{
typedef int(__thiscall* fnGetPointContents)(void*, const Vector&, int, IClientEntity**);
return call_vfunc<fnGetPointContents>(this, 0)(this, vecAbsPosition, contentsMask, ppEntity);
}
void TraceRay(const Ray_t &ray, unsigned int fMask, ITraceFilter* pTraceFilter, trace_t* pTrace)
{
typedef void(__thiscall* fnTraceRay)(void*, const Ray_t&, unsigned int, ITraceFilter*, trace_t*);
call_vfunc<fnTraceRay>(this, 5)(this, ray, fMask, pTraceFilter, pTrace);
}
void EdgeTraceRay(Ray_t &ray, CTraceFilter &filt, CGameTrace &trace, bool wall = false)
{
typedef void(__thiscall *OrigFn)(void *, Ray_t &, unsigned int, CTraceFilter &, CGameTrace &);
call_vfunc<OrigFn>(this, 5)(this, ray, wall ? 0x200400B : 0x46004003, filt, trace); // 0x46004003 0x4600400B
}
};
struct mstudiobbox_t
{
int bone;
int group;
Vector bbmin;
Vector bbmax;
int szhitboxnameindex;
int unused[8];
//float radius;
char* GetHitboxName(void)
{
if (szhitboxnameindex == 0)
return "";
return ((char*)this) + szhitboxnameindex;
}
};
struct mstudiohitboxset_t
{
int sznameindex;
inline char* const GetName(void) const { return ((char*)this) + sznameindex; }
int numhitboxes;
int hitboxindex;
inline mstudiobbox_t* GetHitbox(int i) const { return (mstudiobbox_t*)(((byte*)this) + hitboxindex) + i; };
};
struct mstudiobone_t
{
int sznameindex;
inline char * const GetName(void) const { return ((char *)this) + sznameindex; }
int parent;
int bonecontroller[6];
Vector pos;
float quat[4];
Vector rot;
Vector posscale;
Vector rotscale;
matrix3x4 poseToBone;
float qAlignment[4];
int flags;
int proctype;
int procindex; // procedural rule
mutable int physicsbone; // index into physically simulated bone
inline void * GetProcedure() const { if (procindex == 0) return NULL; else return (void *)(((byte *)this) + procindex); };
int surfacepropidx; // index into string tablefor property name
inline char * const GetSurfaceProps(void) const { return ((char *)this) + surfacepropidx; }
int contents; // See BSPFlags.h for the contents flags
int unused[8]; // remove as appropriate
};
struct studiohdr_t
{
int id;
int version;
int checksum;
char name[64];
int length;
Vector eyeposition;
Vector illumposition;
Vector hull_min;
Vector hull_max;
Vector view_bbmin;
Vector view_bbmax;
int flags;
int numbones;
int boneindex;
inline mstudiobone_t *GetBone(int i) const { return (mstudiobone_t *)(((byte *)this) + boneindex) + i; };
// inline mstudiobone_t *pBone(int i) const { Assert(i >= 0 && i < numbones); return (mstudiobone_t *)(((byte *)this) + boneindex) + i; };
int numbonecontrollers;
int bonecontrollerindex;
int numhitboxsets;
int hitboxsetindex;
mstudiohitboxset_t* GetHitboxSet(int i) const
{
return (mstudiohitboxset_t*)(((byte*)this) + hitboxsetindex) + i;
}
inline mstudiobbox_t* GetHitbox(int i, int set) const
{
mstudiohitboxset_t const* s = GetHitboxSet(set);
if (!s)
return NULL;
return s->GetHitbox(i);
}
inline int GetHitboxCount(int set) const
{
mstudiohitboxset_t const* s = GetHitboxSet(set);
if (!s)
return 0;
return s->numhitboxes;
}
int numlocalanim;
int localanimindex;
int numlocalseq;
int localseqindex;
mutable int activitylistversion;
mutable int eventsindexed;
int numtextures;
int textureindex;
int numcdtextures;
int cdtextureindex;
int numskinref;
int numskinfamilies;
int skinindex;
int numbodyparts;
int bodypartindex;
int numlocalattachments;
int localattachmentindex;
int numlocalnodes;
int localnodeindex;
int localnodenameindex;
int numflexdesc;
int flexdescindex;
int numflexcontrollers;
int flexcontrollerindex;
int numflexrules;
int flexruleindex;
int numikchains;
int ikchainindex;