forked from Panguins/OneTap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sdk.h
5313 lines (4387 loc) · 147 KB
/
sdk.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 <cmath>
#include <algorithm>
#include "memory.h"
#pragma warning( push, 0 )
typedef unsigned long ulong;
#define Assert( _exp ) ((void)0)
#define DEFAULT_TICK_INTERVAL (0.015) // 15 msec is the default
#define MINIMUM_TICK_INTERVAL (0.001)
#define MAXIMUM_TICK_INTERVAL (0.1)
#define HITGROUP_GENERIC 0
#define HITGROUP_HEAD 1
#define HITGROUP_CHEST 2
#define HITGROUP_STOMACH 3
#define HITGROUP_LEFTARM 4
#define HITGROUP_RIGHTARM 5
#define HITGROUP_LEFTLEG 6
#define HITGROUP_RIGHTLEG 7
#define HITGROUP_GEAR 10
// This is the max # of players the engine can handle
#define ABSOLUTE_PLAYER_LIMIT 255 // not 256, so we can send the limit as a byte
#define ABSOLUTE_PLAYER_LIMIT_DW ( (ABSOLUTE_PLAYER_LIMIT/32) + 1 )
// a player name may have 31 chars + 0 on the PC.
// the 360 only allows 15 char + 0, but stick with the larger PC size for cross-platform communication
#define MAX_PLAYER_NAME_LENGTH 32
#define MAX_PLAYERS_PER_CLIENT 1 // One player per PC
// Max decorated map name, with things like workshop/cp_foo.ugc123456
#define MAX_MAP_NAME 96
// Max name used in save files. Needs to be left at 32 for SourceSDK compatibility.
#define MAX_MAP_NAME_SAVE 32
// Max non-decorated map name for e.g. server browser (just cp_foo)
#define MAX_DISPLAY_MAP_NAME 32
#define MAX_NETWORKID_LENGTH 64 // num chars for a network (i.e steam) ID
// BUGBUG: Reconcile with or derive this from the engine's internal definition!
// FIXME: I added an extra bit because I needed to make it signed
#define SP_MODEL_INDEX_BITS 13
// How many bits to use to encode an edict.
#define MAX_EDICT_BITS 11 // # of bits needed to represent max edicts
// Max # of edicts in a level
#define MAX_EDICTS (1<<MAX_EDICT_BITS)
// How many bits to use to encode an server class index
#define MAX_SERVER_CLASS_BITS 9
// Max # of networkable server classes
#define MAX_SERVER_CLASSES (1<<MAX_SERVER_CLASS_BITS)
#define SIGNED_GUID_LEN 32 // Hashed CD Key (32 hex alphabetic chars + 0 terminator )
// Used for networking ehandles.
#define NUM_ENT_ENTRY_BITS (MAX_EDICT_BITS + 1)
#define NUM_ENT_ENTRIES (1 << NUM_ENT_ENTRY_BITS)
#define ENT_ENTRY_MASK (NUM_ENT_ENTRIES - 1)
#define INVALID_EHANDLE_INDEX 0xFFFFFFFF
#define NUM_SERIAL_NUM_BITS (32 - NUM_ENT_ENTRY_BITS)
// Networked ehandles use less bits to encode the serial number.
#define NUM_NETWORKED_EHANDLE_SERIAL_NUMBER_BITS 10
#define NUM_NETWORKED_EHANDLE_BITS (MAX_EDICT_BITS + NUM_NETWORKED_EHANDLE_SERIAL_NUMBER_BITS)
#define INVALID_NETWORKED_EHANDLE_VALUE ((1 << NUM_NETWORKED_EHANDLE_BITS) - 1)
// This is the maximum amount of data a PackedEntity can have. Having a limit allows us
// to use static arrays sometimes instead of allocating memory all over the place.
#define MAX_PACKEDENTITY_DATA (16384)
// This is the maximum number of properties that can be delta'd. Must be evenly divisible by 8.
#define MAX_PACKEDENTITY_PROPS (4096)
// a client can have up to 4 customization files (logo, sounds, models, txt).
#define MAX_CUSTOM_FILES 4 // max 4 files
#define MAX_CUSTOM_FILE_SIZE 524288 // Half a megabyte
#define BONE_CALCULATE_MASK 0x1F
#define BONE_PHYSICALLY_SIMULATED 0x01 // bone is physically simulated when physics are active
#define BONE_PHYSICS_PROCEDURAL 0x02 // procedural when physics is active
#define BONE_ALWAYS_PROCEDURAL 0x04 // bone is always procedurally animated
#define BONE_SCREEN_ALIGN_SPHERE 0x08 // bone aligns to the screen, not constrained in motion.
#define BONE_SCREEN_ALIGN_CYLINDER 0x10 // bone aligns to the screen, constrained by it's own axis.
#define BONE_USED_MASK 0x0007FF00
#define BONE_USED_BY_ANYTHING 0x0007FF00
#define BONE_USED_BY_HITBOX 0x00000100 // bone (or child) is used by a hit box
#define BONE_USED_BY_ATTACHMENT 0x00000200 // bone (or child) is used by an attachment point
#define BONE_USED_BY_VERTEX_MASK 0x0003FC00
#define BONE_USED_BY_VERTEX_LOD0 0x00000400 // bone (or child) is used by the toplevel model via skinned vertex
#define BONE_USED_BY_VERTEX_LOD1 0x00000800
#define BONE_USED_BY_VERTEX_LOD2 0x00001000
#define BONE_USED_BY_VERTEX_LOD3 0x00002000
#define BONE_USED_BY_VERTEX_LOD4 0x00004000
#define BONE_USED_BY_VERTEX_LOD5 0x00008000
#define BONE_USED_BY_VERTEX_LOD6 0x00010000
#define BONE_USED_BY_VERTEX_LOD7 0x00020000
#define BONE_USED_BY_BONE_MERGE 0x00040000 // bone is available for bone merge to occur against it
#define BONE_USED_BY_VERTEX_AT_LOD(lod) ( BONE_USED_BY_VERTEX_LOD0 << (lod) )
#define BONE_USED_BY_ANYTHING_AT_LOD(lod) ( ( BONE_USED_BY_ANYTHING & ~BONE_USED_BY_VERTEX_MASK ) | BONE_USED_BY_VERTEX_AT_LOD(lod) )
#define MAX_NUM_LODS 8
#define BONE_TYPE_MASK 0x00F00000
#define BONE_FIXED_ALIGNMENT 0x00100000 // bone can't spin 360 degrees, all interpolation is normalized around a fixed orientation
#define BONE_HAS_SAVEFRAME_POS 0x00200000 // Vector48
#define BONE_HAS_SAVEFRAME_ROT 0x00400000 // Quaternion64
#define IN_ATTACK (1 << 0)
#define IN_JUMP (1 << 1)
#define IN_DUCK (1 << 2)
#define IN_FORWARD (1 << 3)
#define IN_BACK (1 << 4)
#define IN_USE (1 << 5)
#define IN_CANCEL (1 << 6)
#define IN_LEFT (1 << 7)
#define IN_RIGHT (1 << 8)
#define IN_MOVELEFT (1 << 9)
#define IN_MOVERIGHT (1 << 10)
#define IN_ATTACK2 (1 << 11)
#define IN_RUN (1 << 12)
#define IN_RELOAD (1 << 13)
#define IN_ALT1 (1 << 14)
#define IN_ALT2 (1 << 15)
#define IN_SCORE (1 << 16)
#define IN_SPEED (1 << 17)
#define IN_WALK (1 << 18)
#define IN_ZOOM (1 << 19)
#define IN_WEAPON1 (1 << 20)
#define IN_WEAPON2 (1 << 21)
#define IN_BULLRUSH (1 << 22)
#define FL_ONGROUND (1 << 0)
#define FL_DUCKING (1 << 1)
#define FL_WATERJUMP (1 << 3)
#define FL_ONTRAIN (1 << 4)
#define FL_INRAIN (1 << 5)
#define FL_FROZEN (1 << 6)
#define FL_ATCONTROLS (1 << 7)
#define FL_CLIENT (1 << 8)
#define FL_FAKECLIENT (1 << 9)
#define FL_INWATER (1 << 10)
#define TEXTURE_GROUP_LIGHTMAP xors( "Lightmaps" )
#define TEXTURE_GROUP_WORLD xors( "World textures" )
#define TEXTURE_GROUP_MODEL xors( "Model textures" )
#define TEXTURE_GROUP_VGUI xors( "VGUI textures" )
#define TEXTURE_GROUP_PARTICLE xors( "Particle textures")
#define TEXTURE_GROUP_DECAL xors( "Decal textures")
#define TEXTURE_GROUP_SKYBOX xors( "SkyBox textures")
#define TEXTURE_GROUP_CLIENT_EFFECTS xors( "ClientEffect textures")
#define TEXTURE_GROUP_OTHER xors( "Other textures")
#define TEXTURE_GROUP_PRECACHED xors( "Precached" ) // TODO: assign texture groups to the precached materials
#define TEXTURE_GROUP_CUBE_MAP xors( "CubeMap textures")
#define TEXTURE_GROUP_RENDER_TARGET xors( "RenderTargets")
#define TEXTURE_GROUP_UNACCOUNTED xors( "Unaccounted textures" )// Textures that weren't assigned a texture group.
#define TEXTURE_GROUP_STATIC_VERTEX_BUFFER xors( "Static Vertex")
#define TEXTURE_GROUP_STATICPROPS xors( "StaticProp Textures")
#define TEXTURE_GROUP_STATIC_INDEX_BUFFER xors( "Static Indices")
#define TEXTURE_GROUP_STATIC_VERTEX_BUFFER_DISP xors( "Displacement Verts")
#define TEXTURE_GROUP_STATIC_VERTEX_BUFFER_COLOR xors( "Lighting Verts")
#define TEXTURE_GROUP_STATIC_VERTEX_BUFFER_WORLD xors( "World Verts")
#define TEXTURE_GROUP_STATIC_VERTEX_BUFFER_MODELS xors( "Model Verts")
#define TEXTURE_GROUP_STATIC_VERTEX_BUFFER_OTHER xors( "Other Verts")
#define TEXTURE_GROUP_DYNAMIC_INDEX_BUFFER xors( "Dynamic Indices")
#define TEXTURE_GROUP_DYNAMIC_VERTEX_BUFFER xors( "Dynamic Verts")
#define TEXTURE_GROUP_DEPTH_BUFFER xors( "DepthBuffer")
#define TEXTURE_GROUP_VIEW_MODEL xors( "ViewModel")
#define TEXTURE_GROUP_PIXEL_SHADERS xors( "Pixel Shaders")
#define TEXTURE_GROUP_VERTEX_SHADERS xors( "Vertex Shaders")
#define TEXTURE_GROUP_RENDER_TARGET_SURFACE xors( "RenderTarget Surfaces" )
#define TEXTURE_GROUP_MORPH_TARGETS xors( "Morph Targets" )
#define CONTENTS_EMPTY 0 // No contents
#define CONTENTS_SOLID 0x1 // an eye is never valid in a solid
#define CONTENTS_WINDOW 0x2 // translucent, but not watery (glass)
#define CONTENTS_AUX 0x4
#define CONTENTS_GRATE 0x8 // alpha-tested "grate" textures. Bullets/sight pass through, but solids don't
#define CONTENTS_SLIME 0x10
#define CONTENTS_WATER 0x20
#define CONTENTS_BLOCKLOS 0x40 // block AI line of sight
#define CONTENTS_OPAQUE 0x80 // things that cannot be seen through (may be non-solid though)
#define LAST_VISIBLE_CONTENTS CONTENTS_OPAQUE
#define ALL_VISIBLE_CONTENTS (LAST_VISIBLE_CONTENTS | (LAST_VISIBLE_CONTENTS-1))
#define CONTENTS_TESTFOGVOLUME 0x100
#define CONTENTS_UNUSED 0x200
// unused
// NOTE: If it's visible, grab from the top + update LAST_VISIBLE_CONTENTS
// if not visible, then grab from the bottom.
// CONTENTS_OPAQUE + SURF_NODRAW count as CONTENTS_OPAQUE (shadow-casting toolsblocklight textures)
#define CONTENTS_BLOCKLIGHT 0x400
#define CONTENTS_TEAM1 0x800 // per team contents used to differentiate collisions
#define CONTENTS_TEAM2 0x1000 // between players and objects on different teams
// ignore CONTENTS_OPAQUE on surfaces that have SURF_NODRAW
#define CONTENTS_IGNORE_NODRAW_OPAQUE 0x2000
// hits entities which are MOVETYPE_PUSH (doors, plats, etc.)
#define CONTENTS_MOVEABLE 0x4000
// remaining contents are non-visible, and don't eat brushes
#define CONTENTS_AREAPORTAL 0x8000
#define CONTENTS_PLAYERCLIP 0x10000
#define CONTENTS_MONSTERCLIP 0x20000
// currents can be added to any other contents, and may be mixed
#define CONTENTS_CURRENT_0 0x40000
#define CONTENTS_CURRENT_90 0x80000
#define CONTENTS_CURRENT_180 0x100000
#define CONTENTS_CURRENT_270 0x200000
#define CONTENTS_CURRENT_UP 0x400000
#define CONTENTS_CURRENT_DOWN 0x800000
#define CONTENTS_ORIGIN 0x1000000 // removed before bsping an entity
#define CONTENTS_MONSTER 0x2000000 // should never be on a brush, only in game
#define CONTENTS_DEBRIS 0x4000000
#define CONTENTS_DETAIL 0x8000000 // brushes to be added after vis leafs
#define CONTENTS_TRANSLUCENT 0x10000000 // auto set if any surface has trans
#define CONTENTS_LADDER 0x20000000
#define CONTENTS_HITBOX 0x40000000 // use accurate hitboxes on trace
#define MASK_SHOT (CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_MONSTER|CONTENTS_WINDOW|CONTENTS_DEBRIS|CONTENTS_HITBOX)
// NOTE: These are stored in a short in the engine now. Don't use more than 16 bits
#define SURF_LIGHT 0x0001 // value will hold the light strength
#define SURF_SKY2D 0x0002 // don't draw, indicates we should skylight + draw 2d sky but not draw the 3D skybox
#define SURF_SKY 0x0004 // don't draw, but add to skybox
#define SURF_WARP 0x0008 // turbulent water warp
#define SURF_TRANS 0x0010
#define SURF_NOPORTAL 0x0020 // the surface can not have a portal placed on it
#define SURF_TRIGGER 0x0040 // FIXME: This is an xbox hack to work around elimination of trigger surfaces, which breaks occluders
#define SURF_NODRAW 0x0080 // don't bother referencing the texture
#define SURF_HINT 0x0100 // make a primary bsp splitter
#define SURF_SKIP 0x0200 // completely ignore, allowing non-closed brushes
#define SURF_NOLIGHT 0x0400 // Don't calculate light
#define SURF_BUMPLIGHT 0x0800 // calculate three lightmaps for the surface for bumpmapping
#define SURF_NOSHADOWS 0x1000 // Don't receive shadows
#define SURF_NODECALS 0x2000 // Don't receive decals
#define SURF_NOPAINT SURF_NODECALS // the surface can not have paint placed on it
#define SURF_NOCHOP 0x4000 // Don't subdivide patches on this surface
#define SURF_HITBOX 0x8000 // surface is part of a hitbox
#define MASK_ALL (0xFFFFFFFF)
// everything that is normally solid
#define MASK_SOLID (CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_WINDOW|CONTENTS_MONSTER|CONTENTS_GRATE)
// everything that blocks player movement
#define MASK_PLAYERSOLID (CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_PLAYERCLIP|CONTENTS_WINDOW|CONTENTS_MONSTER|CONTENTS_GRATE)
// blocks npc movement
#define MASK_NPCSOLID (CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_MONSTERCLIP|CONTENTS_WINDOW|CONTENTS_MONSTER|CONTENTS_GRATE)
// blocks fluid movement
#define MASK_NPCFLUID (CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_MONSTERCLIP|CONTENTS_WINDOW|CONTENTS_MONSTER)
// water physics in these contents
#define MASK_WATER (CONTENTS_WATER|CONTENTS_MOVEABLE|CONTENTS_SLIME)
// everything that blocks lighting
#define MASK_OPAQUE (CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_OPAQUE)
// everything that blocks lighting, but with monsters added.
#define MASK_OPAQUE_AND_NPCS (MASK_OPAQUE|CONTENTS_MONSTER)
// everything that blocks line of sight for AI
#define MASK_BLOCKLOS (CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_BLOCKLOS)
// everything that blocks line of sight for AI plus NPCs
#define MASK_BLOCKLOS_AND_NPCS (MASK_BLOCKLOS|CONTENTS_MONSTER)
// everything that blocks line of sight for players
#define MASK_VISIBLE (MASK_OPAQUE|CONTENTS_IGNORE_NODRAW_OPAQUE)
// everything that blocks line of sight for players, but with monsters added.
#define MASK_VISIBLE_AND_NPCS (MASK_OPAQUE_AND_NPCS|CONTENTS_IGNORE_NODRAW_OPAQUE)
// bullets see these as solid
#define MASK_SHOT (CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_MONSTER|CONTENTS_WINDOW|CONTENTS_DEBRIS|CONTENTS_HITBOX)
// bullets see these as solid, except monsters (world+brush only)
#define MASK_SHOT_BRUSHONLY (CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_WINDOW|CONTENTS_DEBRIS)
// non-raycasted weapons see this as solid (includes grates)
#define MASK_SHOT_HULL (CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_MONSTER|CONTENTS_WINDOW|CONTENTS_DEBRIS|CONTENTS_GRATE)
// hits solids (not grates) and passes through everything else
#define MASK_SHOT_PORTAL (CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_WINDOW|CONTENTS_MONSTER)
// everything normally solid, except monsters (world+brush only)
#define MASK_SOLID_BRUSHONLY (CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_WINDOW|CONTENTS_GRATE)
// everything normally solid for player movement, except monsters (world+brush only)
#define MASK_PLAYERSOLID_BRUSHONLY (CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_WINDOW|CONTENTS_PLAYERCLIP|CONTENTS_GRATE)
// everything normally solid for npc movement, except monsters (world+brush only)
#define MASK_NPCSOLID_BRUSHONLY (CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_WINDOW|CONTENTS_MONSTERCLIP|CONTENTS_GRATE)
// just the world, used for route rebuilding
#define MASK_NPCWORLDSTATIC (CONTENTS_SOLID|CONTENTS_WINDOW|CONTENTS_MONSTERCLIP|CONTENTS_GRATE)
// just the world, used for route rebuilding
#define MASK_NPCWORLDSTATIC_FLUID (CONTENTS_SOLID|CONTENTS_WINDOW|CONTENTS_MONSTERCLIP)
// These are things that can split areaportals
#define MASK_SPLITAREAPORTAL (CONTENTS_WATER|CONTENTS_SLIME)
// UNDONE: This is untested, any moving water
#define MASK_CURRENT (CONTENTS_CURRENT_0|CONTENTS_CURRENT_90|CONTENTS_CURRENT_180|CONTENTS_CURRENT_270|CONTENTS_CURRENT_UP|CONTENTS_CURRENT_DOWN)
// everything that blocks corpse movement
// UNDONE: Not used yet / may be deleted
#define MASK_DEADSOLID (CONTENTS_SOLID|CONTENTS_PLAYERCLIP|CONTENTS_WINDOW|CONTENTS_GRATE)
#define CHAR_TEX_ANTLION 'A'
#define CHAR_TEX_BLOODYFLESH 'B'
#define CHAR_TEX_CONCRETE 'C'
#define CHAR_TEX_DIRT 'D'
#define CHAR_TEX_EGGSHELL 'E' ///< the egg sacs in the tunnels in ep2.
#define CHAR_TEX_FLESH 'F'
#define CHAR_TEX_GRATE 'G'
#define CHAR_TEX_ALIENFLESH 'H'
#define CHAR_TEX_CLIP 'I'
#define CHAR_TEX_GRASS 'J' // L4D addition
#define CHAR_TEX_SNOW 'K'
#define CHAR_TEX_PLASTIC 'L'
#define CHAR_TEX_METAL 'M'
#define CHAR_TEX_SAND 'N'
#define CHAR_TEX_FOLIAGE 'O'
#define CHAR_TEX_COMPUTER 'P'
#define CHAR_TEX_ASPHALT 'Q' // L4D addition
#define CHAR_TEX_BRICK 'R' // L4D addition
#define CHAR_TEX_SLOSH 'S'
#define CHAR_TEX_TILE 'T'
#define CHAR_TEX_CARDBOARD 'U' // L4D addition
#define CHAR_TEX_VENT 'V'
#define CHAR_TEX_WOOD 'W'
//// CHAR_TEX_UNUSED 'X' ///< do not use - "fake" materials use this (ladders, wading, clips, etc)
#define CHAR_TEX_GLASS 'Y'
#define CHAR_TEX_WARPSHIELD 'Z' ///< wierd-looking jello effect for advisor shield.
#define CHAR_TEX_CLAY 1 // L4D addition
#define CHAR_TEX_PLASTER 2 // L4D addition
#define CHAR_TEX_ROCK 3 // L4D addition
#define CHAR_TEX_RUBBER 4 // L4D addition
#define CHAR_TEX_SHEETROCK 5 // L4D addition
#define CHAR_TEX_CLOTH 6 // L4D addition
#define CHAR_TEX_CARPET 7 // L4D addition
#define CHAR_TEX_PAPER 8 // L4D addition
#define CHAR_TEX_UPHOLSTERY 9 // L4D addition
#define CHAR_TEX_PUDDLE 10 // L4D addition
#define CHAR_TEX_MUD 11 // L4D addition
#define CHAR_TEX_SANDBARREL 12 // CSGO addition (no penetration)
struct RecvProp;
class vec2
{
public:
vec2( )
{
x = y = 0.0f;
}
template <typename T>
vec2( T X, T Y )
{
x = static_cast< float >( X ); y = static_cast< float >( Y );
}
vec2( float* v )
{
x = v[0]; y = v[1];
}
vec2( const float* v )
{
x = v[0]; y = v[1];
}
vec2( const vec2& v )
{
x = v.x; y = v.y;
}
vec2& operator=( const vec2& v )
{
x = v.x; y = v.y; return *this;
}
float& operator[]( int i )
{
return ( ( float* ) this )[i];
}
float operator[]( int i ) const
{
return ( ( float* ) this )[i];
}
vec2& operator+=( const vec2& v )
{
x += v.x; y += v.y; return *this;
}
vec2& operator-=( const vec2& v )
{
x -= v.x; y -= v.y; return *this;
}
vec2& operator*=( const vec2& v )
{
x *= v.x; y *= v.y; return *this;
}
vec2& operator/=( const vec2& v )
{
x /= v.x; y /= v.y; return *this;
}
vec2& operator+=( float v )
{
x += v; y += v; return *this;
}
vec2& operator-=( float v )
{
x -= v; y -= v; return *this;
}
vec2& operator*=( float v )
{
x *= v; y *= v; return *this;
}
vec2& operator/=( float v )
{
x /= v; y /= v; return *this;
}
vec2 operator+( const vec2& v ) const
{
return vec2( x + v.x, y + v.y );
}
vec2 operator-( const vec2& v ) const
{
return vec2( x - v.x, y - v.y );
}
vec2 operator*( const vec2& v ) const
{
return vec2( x * v.x, y * v.y );
}
vec2 operator/( const vec2& v ) const
{
return vec2( x / v.x, y / v.y );
}
vec2 operator+( float v ) const
{
return vec2( x + v, y + v );
}
vec2 operator-( float v ) const
{
return vec2( x - v, y - v );
}
vec2 operator*( float v ) const
{
return vec2( x * v, y * v );
}
vec2 operator/( float v ) const
{
return vec2( x / v, y / v );
}
void set( float X = 0.0f, float Y = 0.0f )
{
x = X; y = Y;
}
float length( void ) const
{
return sqrtf( x * x + y * y );
}
float lengthsqr( void ) const
{
return ( x * x + y * y );
}
float dist_to( const vec2& v ) const
{
return ( *this - v ).length( );
}
float dist_to_sqr( const vec2& v ) const
{
return ( *this - v ).lengthsqr( );
}
float dot( const vec2& v ) const
{
return ( x * v.x + y * v.y );
}
bool is_zero( void ) const
{
return ( x > -FLT_EPSILON && x < FLT_EPSILON &&
y > -FLT_EPSILON && y < FLT_EPSILON );
}
operator bool( ) const noexcept
{
return !is_zero( );
}
public:
float x, y;
};
class vec3
{
public:
vec3( )
{
x = y = z = 0.0f;
}
vec3( float X, float Y, float Z )
{
x = X;
y = Y;
z = Z;
}
vec3( float* v )
{
x = v[0];
y = v[1];
z = v[2];
}
vec3( const float* v )
{
x = v[0];
y = v[1];
z = v[2];
}
vec3( const vec3& v )
{
x = v.x;
y = v.y;
z = v.z;
}
vec3( const vec2& v )
{
x = v.x;
y = v.y;
z = 0.0f;
}
vec3& operator=( const vec3& v )
{
x = v.x;
y = v.y;
z = v.z;
return *this;
}
vec3& operator=( const vec2& v )
{
x = v.x;
y = v.y;
z = 0.0f;
return *this;
}
float& operator[]( int i )
{
return ( ( float* ) this )[i];
}
float operator[]( int i ) const
{
return ( ( float* ) this )[i];
}
vec3& operator+=( const vec3& v )
{
x += v.x;
y += v.y;
z += v.z;
return *this;
}
vec3& operator-=( const vec3& v )
{
x -= v.x;
y -= v.y;
z -= v.z;
return *this;
}
vec3& operator*=( const vec3& v )
{
x *= v.x;
y *= v.y;
z *= v.z;
return *this;
}
vec3& operator/=( const vec3& v )
{
x /= v.x;
y /= v.y;
z /= v.z;
return *this;
}
vec3& operator+=( float v )
{
x += v;
y += v;
z += v;
return *this;
}
vec3& operator-=( float v )
{
x -= v;
y -= v;
z -= v;
return *this;
}
vec3& operator*=( float v )
{
x *= v;
y *= v;
z *= v;
return *this;
}
vec3& operator/=( float v )
{
x /= v;
y /= v;
z /= v;
return *this;
}
vec3 operator+( const vec3& v ) const
{
return vec3( x + v.x, y + v.y, z + v.z );
}
vec3 operator-( const vec3& v ) const
{
return vec3( x - v.x, y - v.y, z - v.z );
}
vec3 operator*( const vec3& v ) const
{
return vec3( x * v.x, y * v.y, z * v.z );
}
vec3 operator/( const vec3& v ) const
{
return vec3( x / v.x, y / v.y, z / v.z );
}
vec3 operator+( float v ) const
{
return vec3( x + v, y + v, z + v );
}
vec3 operator-( float v ) const
{
return vec3( x - v, y - v, z - v );
}
vec3 operator*( float v ) const
{
return vec3( x * v, y * v, z * v );
}
vec3 operator/( float v ) const
{
return vec3( x / v, y / v, z / v );
}
bool operator== ( const vec3& other ) const
{
return x == other.x && y == other.y && other.z == other.z;
}
bool operator!= ( const vec3& other ) const
{
return !( *this == other );
}
bool operator!( ) const
{
return this->is_zero( );
}
void set( float X = 0.0f, float Y = 0.0f, float Z = 0.0f )
{
x = X;
y = Y;
z = Z;
}
vec3 center( ) const
{
return *this * 0.5f;
}
float length( ) const
{
return std::sqrt( x * x + y * y + z * z );
}
float length_sqr( ) const
{
return ( x * x + y * y + z * z );
}
float length2d( ) const
{
return std::sqrt( x * x + y * y );
}
float length2d_sqr( ) const
{
return ( x * x + y * y );
}
float dist( const vec3& v ) const
{
return ( *this - v ).length( );
}
float dist_sqr( const vec3& v ) const
{
return ( *this - v ).length_sqr( );
}
float dot( const vec3& v ) const
{
return ( x * v.x + y * v.y + z * v.z );
}
float dot_2d( const vec3& v ) const
{
return ( x * v.x + y * v.y );
}
vec3 cross_product( const vec3& v ) const
{
return vec3( y * v.z - z * v.y, z * v.x - x * v.z, x * v.y - y * v.x );
}
bool is_zero( ) const
{
return ( x > -0.01f && x < 0.01f &&
y > -0.01f && y < 0.01f &&
z > -0.01f && z < 0.01f );
}
bool is_nan( ) const
{
return isnan( x ) || isnan( y ) || isnan( z );
}
void normalize( )
{
auto& vec = *this;
// Proper large epenis normalization, none of that gay while loop shit
for ( auto i = 0; i <= 2; i++ )
if ( vec[i] > 180.f || vec[i] < -180.f )
vec[i] = ( vec[i] < 0.f ) ? vec[i] + 360.f * round( abs( vec[i] / 360.f ) ) : vec[i] - 360.f * round( abs( vec[i] / 360.f ) );
}
vec3 normalized( ) const
{
auto vec = *this;
vec.normalize( );
return vec;
}
void clamp( )
{
x = std::clamp<float>( x, -89.f, 89.f );
y = std::clamp<float>( y, -180.0f, 180.0f );
z = 0.0f;
}
vec3 clamped( )
{
return vec3(
std::clamp<float>( x, -89.f, 89.f ),
std::clamp<float>( y, -180.0f, 180.0f ),
0.0f
);
}
void sanitize( )
{
//safety
if ( !isfinite( x ) || isnan( x ) || isinf( x ) )
x = 0.0f;
if ( !isfinite( y ) || isnan( y ) || isinf( y ) )
y = 0.0f;
//normalize
normalize( );
//clamp
clamp( );
}
void normalize_in_place( )
{
vec3& v = *this;
float iradius = 1.f / ( this->length( ) + FLT_EPSILON );
v.x *= iradius;
v.y *= iradius;
v.z *= iradius;
}
bool is_zero( )
{
return x == 0.0f && y == 0.0f && z == 0.0f;
}
public:
float x, y, z;
};
struct VMatrix
{
float m[4][4];
inline float* operator[]( int i )
{
return m[i];
}
inline const float* operator[]( int i ) const
{
return m[i];
}
};
class CRecvProxyData
{
public:
const RecvProp* m_prop;
unsigned char pad[0x18];
int m_element;
int m_spawn_id;
};
typedef void( *RecvVarProxyFn )( const CRecvProxyData *pData, void *pStruct, void *pOut );
struct RecvTable
{
RecvProp *m_pProps;
int m_nProps;
void *m_pDecoder;
char *m_pNetTableName;
bool m_bInitialized;
bool m_bInMainList;
};
struct RecvProp
{
char *m_pVarName;
int m_RecvType;
int m_Flags;
int m_StringBufferSize;
bool m_bInsideArray;
const void *m_pExtraData;
RecvProp *m_pArrayProp;
void* m_ArrayLengthProxy;
void* m_ProxyFn;
void* m_DataTableProxyFn;
RecvTable *m_pDataTable;
int m_Offset;
int m_ElementStride;
int m_nElements;
const char *m_pParentArrayPropName;
};
class c_client
{
public:
void* m_create_function;
void* m_create_event;
char* m_name;
RecvTable* m_table;
c_client* m_next;
int m_class_id;
};
class c_base_client
{
public:
c_client* get_all_classes( )
{
return memory::get_vfunc< c_client*( __thiscall* )( void* ) >( this, 8 )( this );
}
};
using matrix3x3_t = float[3][3];
struct matrix3x4_t
{
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;
}
//-----------------------------------------------------------------------------
// Creates a matrix where the X axis = forward
// the Y axis = left, and the Z axis = up
//-----------------------------------------------------------------------------
void Init( const vec3& xAxis, const vec3& yAxis, const vec3& zAxis, const vec3&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;
}
//-----------------------------------------------------------------------------
// Creates a matrix where the X axis = forward
// the Y axis = left, and the Z axis = up
//-----------------------------------------------------------------------------
matrix3x4_t( const vec3& xAxis, const vec3& yAxis, const vec3& zAxis, const vec3 &vecOrigin )
{
Init( xAxis, yAxis, zAxis, vecOrigin );
}
inline void SetOrigin( vec3 const & p )
{
m_flMatVal[0][3] = p.x;
m_flMatVal[1][3] = p.y;
m_flMatVal[2][3] = p.z;
}
inline void Invalidate( void )
{
for ( int i = 0; i < 3; i++ )
{
for ( int j = 0; j < 4; j++ )
{
m_flMatVal[i][j] = NAN;
}
}
}
float *operator[]( int i ) { Assert( ( i >= 0 ) && ( i < 3 ) ); return m_flMatVal[i]; }
const float *operator[]( int i ) const { Assert( ( i >= 0 ) && ( i < 3 ) ); 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 ICollideable
{
public:
virtual void pad( );
virtual const vec3& OBBMins( ) const;
virtual const vec3& OBBMaxs( ) const;
const vec3& collision_origin( )
{
return *reinterpret_cast< vec3* >( reinterpret_cast< uintptr_t >( this ) + 0x90 );
}
const vec3& collision_angles( )
{
return *reinterpret_cast< vec3* >( reinterpret_cast< uintptr_t >( this ) + 0x9C );
}