keybode

css steam sdk

Mar 17th, 2014
686
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 26.41 KB | None | 0 0
  1. #ifndef SDK_H
  2. #define SDK_H
  3.  
  4. #include "Math.h"
  5. #include "WinCustom.h"
  6. #include "CRC32.h"
  7.  
  8. #include "dt_recv.h"
  9. #include "checksum_crc.h"
  10. #include "checksum_md5.h"
  11.  
  12. typedef void* (*CreateInterfaceFn)( const char*, int* );
  13.  
  14. #undef CreateFont
  15.  
  16. #define clamp(val, min, max)    (((val) > (max)) ? (max) : (((val) < (min)) ? (min) : (val)))
  17.  
  18. #define CHAR_TEX_CONCRETE       'C'
  19. #define CHAR_TEX_METAL          'M'
  20. #define CHAR_TEX_DIRT           'D'
  21. #define CHAR_TEX_VENT           'V'
  22. #define CHAR_TEX_GRATE          'G'
  23. #define CHAR_TEX_TILE           'T'
  24. #define CHAR_TEX_SLOSH          'S'
  25. #define CHAR_TEX_WOOD           'W'
  26. #define CHAR_TEX_COMPUTER       'P'
  27. #define CHAR_TEX_GLASS          'Y'
  28. #define CHAR_TEX_FLESH          'F'
  29. #define CHAR_TEX_BLOODYFLESH    'B'
  30. #define CHAR_TEX_CLIP           'I'
  31. #define CHAR_TEX_ANTLION        'A'
  32. #define CHAR_TEX_ALIENFLESH     'H'
  33. #define CHAR_TEX_FOLIAGE        'O'
  34. #define CHAR_TEX_SAND           'N'
  35. #define CHAR_TEX_PLASTIC        'L'
  36.  
  37. #define IN_ATTACK               ( 1 << 0 )
  38. #define IN_JUMP                 ( 1 << 1 )
  39. #define IN_DUCK                 ( 1 << 2 )
  40.  
  41. #define FL_ONGROUND             ( 1 << 0 )
  42. #define FL_DUCKING              ( 1 << 1 )
  43.  
  44. enum WeaponId_t
  45. {
  46.     WEAPON_CSBASE = 0,
  47.     WEAPON_P228,
  48.     WEAPON_GLOCK,
  49.     WEAPON_SCOUT,
  50.     WEAPON_HEGRENADE,
  51.     WEAPON_XM1014,
  52.     WEAPON_C4,
  53.     WEAPON_MAC10,
  54.     WEAPON_AUG,
  55.     WEAPON_SMOKEGRENADE,
  56.     WEAPON_ELITE,
  57.     WEAPON_FIVESEVEN,
  58.     WEAPON_UMP45,
  59.     WEAPON_SG550,
  60.     WEAPON_GALIL,
  61.     WEAPON_FAMAS,
  62.     WEAPON_USP,
  63.     WEAPON_AWP,
  64.     WEAPON_MP5,
  65.     WEAPON_M249,
  66.     WEAPON_M3,
  67.     WEAPON_M4A1,
  68.     WEAPON_TMP,
  69.     WEAPON_G3SG1,
  70.     WEAPON_FLASHBANG,
  71.     WEAPON_DEAGLE,
  72.     WEAPON_SG552,
  73.     WEAPON_AK47,
  74.     WEAPON_KNIFE,
  75.     WEAPON_P90,
  76.     WEAPON_SHIELD,
  77.     WEAPON_KEVLAR,
  78.     WEAPON_ASSAULTSUIT,
  79.     WEAPON_NIGHTVISION
  80. };
  81.  
  82. class CSPlayer;
  83. class CSWeapon;
  84. class model_t;
  85.  
  86. struct player_info_t
  87. {
  88.     char            name[32];
  89.     int             userID;
  90.     char            guid[32 + 1];
  91.     unsigned int    friendsID;
  92.     char            friendsName[32];
  93.     bool            fakeplayer;
  94.     bool            ishltv;
  95.     unsigned long   customFiles[4];
  96.     unsigned char   filesDownloaded;
  97. };
  98.  
  99. struct surfacephysicsparams_t
  100. {
  101.     float           friction;
  102.     float           elasticity;
  103.     float           density;
  104.     float           thickness;
  105.     float           dampening;
  106. };
  107.  
  108. struct surfaceaudioparams_t
  109. {
  110.     float           reflectivity;
  111.     float           hardnessFactor;
  112.     float           roughnessFactor;
  113.     float           roughThreshold;
  114.     float           hardThreshold;
  115.     float           hardVelocityThreshold;
  116. };
  117.  
  118. struct surfacesoundnames_t
  119. {
  120.     unsigned short  stepleft;
  121.     unsigned short  stepright;
  122.  
  123.     unsigned short  impactSoft;
  124.     unsigned short  impactHard;
  125.  
  126.     unsigned short  scrapeSmooth;
  127.     unsigned short  scrapeRough;
  128.  
  129.     unsigned short  bulletImpact;
  130.     unsigned short  rolling;
  131.  
  132.     unsigned short  breakSound;
  133.     unsigned short  strainSound;
  134. };
  135.  
  136. struct surfacesoundhandles_t
  137. {
  138.     short   stepleft;
  139.     short   stepright;
  140.  
  141.     short   impactSoft;
  142.     short   impactHard;
  143.  
  144.     short   scrapeSmooth;
  145.     short   scrapeRough;
  146.  
  147.     short   bulletImpact;
  148.     short   rolling;
  149.  
  150.     short   breakSound;
  151.     short   strainSound;
  152. };
  153.  
  154. struct surfacegameprops_t
  155. {
  156.     float           maxSpeedFactor;
  157.     float           jumpFactor;
  158.     unsigned short  material;
  159.     unsigned char   climbable;
  160.     unsigned char   pad;
  161. };
  162.  
  163. struct surfacedata_t
  164. {
  165.     surfacephysicsparams_t  physics;
  166.     surfaceaudioparams_t    audio;
  167.     surfacesoundnames_t     sounds;
  168.     surfacegameprops_t      game;
  169.     surfacesoundhandles_t   soundhandles;
  170. };
  171.  
  172. struct mstudiobbox_t
  173. {
  174.     int                 bone;
  175.     int                 group;
  176.     Vector              bbmin;
  177.     Vector              bbmax; 
  178.     int                 szhitboxnameindex;
  179.     int                 unused[8];
  180.  
  181.     char* pszHitboxName( )
  182.     {
  183.         if( szhitboxnameindex == 0 )
  184.             return "";
  185.  
  186.         return ( ( char* )this ) + szhitboxnameindex;
  187.     }
  188. };
  189.  
  190. struct mstudiohitboxset_t
  191. {
  192.     int                     sznameindex;
  193.     inline char* const      pszName( void ) const { return ( ( char* )this ) + sznameindex; }
  194.     int                     numhitboxes;
  195.     int                     hitboxindex;
  196.     inline mstudiobbox_t*   pHitbox( int i ) const { return ( mstudiobbox_t* )( ( ( byte* )this ) + hitboxindex ) + i; };
  197. };
  198.  
  199. struct studiohdr_t
  200. {
  201.     unsigned char       pad[0xAC];
  202.     int                 numhitboxsets;
  203.     int                 hitboxsetindex;
  204.  
  205.     mstudiohitboxset_t* pHitboxSet( int i ) const
  206.     {
  207.         return ( mstudiohitboxset_t* )( ( ( byte* )this ) + hitboxsetindex ) + i;
  208.     };
  209.  
  210.     inline mstudiobbox_t* pHitbox( int i, int set ) const
  211.     {
  212.         mstudiohitboxset_t const* s = pHitboxSet( set );
  213.  
  214.         if( !s )
  215.             return NULL;
  216.  
  217.         return s->pHitbox( i );
  218.     };
  219.  
  220.     inline int iHitboxCount( int set ) const
  221.     {
  222.         mstudiohitboxset_t const* s = pHitboxSet( set );
  223.  
  224.         if( !s )
  225.             return 0;
  226.  
  227.         return s->numhitboxes;
  228.     };
  229. };
  230.  
  231. class CUserCmd
  232. {
  233. public:
  234.     virtual ~CUserCmd () {};
  235.  
  236.     int     command_number;
  237.     int     tick_count;
  238.     Vector  viewangles;
  239.     float   forwardmove;
  240.     float   sidemove;
  241.     float   upmove;
  242.     int     buttons;
  243.     BYTE    impulse;
  244.     int     weaponselect;
  245.     int     weaponsubtype;
  246.     int     random_seed;
  247.     short   mousedx;
  248.     short   mousedy;
  249.     bool    hasbeenpredicted;
  250.  
  251.     CRC32_t GetChecksum ()
  252.     {
  253.         return CRC32_ProcessSingleBuffer ( &*this, sizeof(CUserCmd) );
  254.     }
  255. };
  256.  
  257. class CGlobalVarsBase
  258. {
  259. public:
  260.     float           realtime;
  261.     int             framecount;
  262.     float           absoluteframetime;
  263.     float           curtime;
  264.     float           frametime;
  265.     int             maxClients;
  266.     int             tickcount;
  267.     float           interval_per_tick;
  268.     float           interpolation_amount;
  269.     int             simTicksThisFrame;
  270.     int             network_protocol;
  271. };
  272.  
  273. class ClientClass
  274. {
  275. public:
  276.     const char              __pad0[ 0x8 ];
  277.  
  278.     const char              *m_pNetworkName;
  279.     RecvTable               *m_pRecvTable;
  280.     ClientClass             *m_pNext;
  281.     int                     m_ClassID;
  282. };
  283.  
  284. class IBaseClientDLL
  285. {
  286. public:
  287.     ClientClass* GetAllClasses( )
  288.     {
  289.         typedef ClientClass* ( __thiscall* GetAllClassesFn )( PVOID );
  290.         return GetMethod< GetAllClassesFn >( this, 8 )( this );
  291.     }
  292. };
  293.  
  294. class IClientEntityList
  295. {
  296. public:
  297.     CSPlayer* GetClientEntity( int nIndex )
  298.     {
  299.         typedef CSPlayer* ( __thiscall* GetClientEntityFn )( PVOID, int );
  300.         return GetMethod< GetClientEntityFn >( this, 3 )( this, nIndex );
  301.     }
  302.  
  303.     CSWeapon* GetClientEntityFromHandle( int nHandle )
  304.     {
  305.         typedef CSWeapon* ( __thiscall* GetClientEntityFromHandleFn )( PVOID, int );
  306.         return GetMethod< GetClientEntityFromHandleFn >( this, 4 )( this, nHandle );
  307.     }
  308.  
  309.     int GetHighestEntityIndex( )
  310.     {
  311.         typedef int ( __thiscall* GetHighestEntityIndexFn )( PVOID );
  312.         return GetMethod< GetHighestEntityIndexFn >( this, 6 )( this );
  313.     }
  314. };
  315.  
  316. class CVerifiedUserCmd
  317. {
  318. public:
  319.     CUserCmd    m_cmd;
  320.     DWORD_PTR   m_crc;
  321. };
  322.  
  323. class CInput
  324. {
  325. public:
  326.     CUserCmd* GetUserCmd( int sequence_number )
  327.     {
  328.         typedef CUserCmd* ( __thiscall* GetUserCmdFn )( PVOID, int );
  329.         return GetMethod< GetUserCmdFn >( this, 8 )( this, sequence_number );
  330.     }
  331.  
  332.     CVerifiedUserCmd* GetVerifiedCmd ( int sequence_number )
  333.     {
  334.         return &m_pVerified[ sequence_number % 90 ];
  335.     }
  336.  
  337.     char                __pad0[ 0xC4 ];
  338.     CUserCmd*           m_pCmd;
  339.     CVerifiedUserCmd*   m_pVerified;
  340. };
  341.  
  342. class IVModelInfoClient
  343. {
  344. public:
  345.     const char* GetModelName( const model_t* model )
  346.     {
  347.         typedef const char* ( __thiscall* GetModelNameFn )( PVOID, const model_t* );
  348.         return GetMethod< GetModelNameFn >( this, 3 )( this, model );
  349.     }
  350.  
  351.     studiohdr_t* GetStudiomodel( const model_t* mod )
  352.     {
  353.         typedef studiohdr_t* ( __thiscall* GetStudiomodelFn )( PVOID, const model_t* );
  354.         return GetMethod< GetStudiomodelFn >( this, 28 )( this, mod );
  355.     }
  356. };
  357.  
  358. class IVEngineClient
  359. {
  360. public:
  361.     void GetScreenSize( int& width, int& height )
  362.     {
  363.         typedef void ( __thiscall* GetScreenSizeFn )( PVOID, int&, int& );
  364.         GetMethod< GetScreenSizeFn >( this, 5 )( this, width, height );
  365.     }
  366.  
  367.     bool GetPlayerInfo( int ent_num, player_info_t *pinfo )
  368.     {
  369.         typedef bool ( __thiscall* GetPlayerInfoFn )( PVOID, int, player_info_t* );
  370.         return GetMethod< GetPlayerInfoFn >( this, 8 )( this, ent_num, pinfo );
  371.     }
  372.  
  373.     int GetLocalPlayer( )
  374.     {
  375.         typedef int ( __thiscall* GetLocalPlayerFn )( PVOID );
  376.         return GetMethod< GetLocalPlayerFn >( this, 12 )( this );
  377.     }
  378.  
  379.     void GetViewAngles( Vector& va )
  380.     {
  381.         typedef void ( __thiscall* GetViewAnglesFn )( PVOID, Vector& );
  382.         GetMethod< GetViewAnglesFn >( this, 19 )( this, va );
  383.     }
  384.  
  385.     void SetViewAngles( Vector& va )
  386.     {
  387.         typedef void ( __thiscall* SetViewAnglesFn )( PVOID, Vector& );
  388.         GetMethod< SetViewAnglesFn >( this, 20 )( this, va );
  389.     }
  390.  
  391.     int GetMaxClients( void )
  392.     {
  393.         typedef int ( __thiscall* GetMaxClientsFn )( PVOID );
  394.         return GetMethod< GetMaxClientsFn >( this, 21 )( this );
  395.     }
  396.  
  397.     const VMatrix& WorldToScreenMatrix( )
  398.     {
  399.         typedef const VMatrix& ( __thiscall* WorldToScreenMatrixFn )( PVOID );
  400.         return GetMethod< WorldToScreenMatrixFn >( this, 36 )( this );
  401.     }
  402. };
  403.  
  404. struct Ray_t
  405. {
  406.     VectorAligned   m_Start;
  407.     VectorAligned   m_Delta;
  408.     VectorAligned   m_StartOffset;
  409.     VectorAligned   m_Extents;
  410.  
  411.     bool            m_IsRay;
  412.     bool            m_IsSwept;
  413.  
  414.     void Init( Vector& vecStart, Vector& vecEnd )
  415.     {
  416.         m_Delta = vecEnd - vecStart;
  417.  
  418.         m_IsSwept = ( m_Delta.LengthSqr( ) != 0 );
  419.  
  420.         m_Extents.x = m_Extents.y = m_Extents.z = 0.0f;
  421.  
  422.         m_IsRay = true;
  423.  
  424.         m_StartOffset.x = m_StartOffset.y = m_StartOffset.z = 0.0f;
  425.  
  426.         m_Start = vecStart;
  427.     }
  428. };
  429.  
  430. struct cplane_t
  431. {
  432.     Vector  normal;
  433.     float   dist;
  434.     BYTE    type;
  435.     BYTE    signbits;
  436.     BYTE    pad[2];
  437. };
  438.  
  439. class CBaseTrace
  440. {
  441. public:
  442.     Vector          startpos;
  443.     Vector          endpos;
  444.     cplane_t        plane;
  445.     float           fraction;
  446.     int             contents;
  447.     unsigned short  dispFlags;
  448.     bool            allsolid;
  449.     bool            startsolid;
  450. };
  451.  
  452. struct csurface_t
  453. {
  454.     const char*     name;
  455.     short           surfaceProps;
  456.     unsigned short  flags;
  457. };
  458.  
  459. class CGameTrace : public CBaseTrace
  460. {
  461. public:
  462.     bool            DidHitWorld( ) const;
  463.     bool            DidHitNonWorldEntity( ) const;
  464.     int             GetEntityIndex( ) const;
  465.     bool            DidHit( ) const;
  466. public:
  467.     float           fractionleftsolid;
  468.     csurface_t      surface;
  469.     int             hitgroup;
  470.     short           physicsbone;
  471.     CSPlayer*       m_pEnt;
  472.     int             hitbox;
  473. };
  474.  
  475. inline bool CGameTrace::DidHit( ) const
  476. {
  477.     return fraction < 1.0f || allsolid || startsolid;
  478. }
  479.  
  480. typedef CGameTrace trace_t;
  481.  
  482. enum TraceType_t
  483. {
  484.     TRACE_EVERYTHING = 0,
  485.     TRACE_WORLD_ONLY,
  486.     TRACE_ENTITIES_ONLY,
  487.     TRACE_EVERYTHING_FILTER_PROPS,
  488. };
  489.  
  490. class ITraceFilter
  491. {
  492. public:
  493.     virtual bool        ShouldHitEntity( PVOID pEntity, int contentsMask ) = 0;
  494.     virtual TraceType_t GetTraceType( ) const = 0;
  495. };
  496.  
  497. class IEngineTrace
  498. {
  499. public:
  500.     virtual int GetPointContents( const Vector &vecAbsPosition, void** ppEntity = NULL ) = 0;
  501.     virtual int __pad0( ) = 0;
  502.     virtual void ClipRayToEntity( const Ray_t &ray, unsigned int fMask, CSPlayer* pEnt, trace_t* pTrace ) = 0;
  503.  
  504.     void TraceRay( const Ray_t& ray, unsigned int flMask, ITraceFilter* pTraceFilter, trace_t* pTrace )
  505.     {
  506.         typedef void ( __thiscall* TraceRayFn )( PVOID, const Ray_t&, unsigned int, ITraceFilter*, trace_t* );
  507.         GetMethod< TraceRayFn >( this, 4 )( this, ray, flMask, pTraceFilter, pTrace );
  508.     }
  509. };
  510.  
  511. class IPanel
  512. {
  513. public:
  514.     const char* GetName( unsigned int vguiPanel )
  515.     {
  516.         typedef const char* ( __thiscall* GetPanelNameFn )( void*, unsigned int );
  517.         return GetMethod< GetPanelNameFn >( this, 36 )( this, vguiPanel );
  518.     }
  519. };
  520.  
  521. class ISurface
  522. {
  523. public:
  524.     void DrawSetColor( int r, int g, int b, int a )
  525.     {
  526.         typedef void ( __thiscall* DrawSetColorFn )( PVOID, int, int, int, int );
  527.         GetMethod< DrawSetColorFn >( this, 11 )( this, r, g, b, a );
  528.     }
  529.  
  530.     void DrawFilledRect( int x0, int y0, int x1, int y1 )
  531.     {
  532.         typedef void ( __thiscall* DrawFilledRectFn )( PVOID, int, int, int, int );
  533.         GetMethod< DrawFilledRectFn >( this, 12 )( this, x0, y0, x1, y1 );
  534.     }
  535.  
  536.     void DrawOutlinedRect( int x0, int y0, int x1, int y1 )
  537.     {
  538.         typedef void ( __thiscall* DrawOutlinedFn )( PVOID, int, int, int, int );
  539.         GetMethod< DrawOutlinedFn >( this, 14 )( this, x0, y0, x1, y1 );
  540.     }
  541.  
  542.     void DrawLine( int x0, int y0, int x1, int y1 )
  543.     {
  544.         typedef void ( __thiscall* DrawLineFn )( PVOID, int, int, int, int );
  545.         GetMethod< DrawLineFn >( this, 15 )( this, x0, y0, x1, y1 );
  546.     }
  547.  
  548.     void DrawSetTextFont( unsigned long font )
  549.     {
  550.         typedef void ( __thiscall* DrawSetTextFontFn )( PVOID, unsigned long );
  551.         GetMethod< DrawSetTextFontFn >( this, 17 )( this, font );
  552.     }
  553.  
  554.     void DrawSetTextColor( int r, int g, int b, int a )
  555.     {
  556.         typedef void ( __thiscall* DrawSetTextColorFn )( PVOID, int, int, int, int );
  557.         GetMethod< DrawSetTextColorFn >( this, 19 )( this, r, g, b, a );
  558.     }
  559.  
  560.     void DrawSetTextPos( int x, int y )
  561.     {
  562.         typedef void ( __thiscall* DrawSetTextPosFn )( PVOID, int, int );
  563.         GetMethod< DrawSetTextPosFn >( this, 20 )( this, x, y );
  564.     }
  565.  
  566.     void DrawPrintText( const wchar_t* text, int textLen )
  567.     {
  568.         typedef void ( __thiscall* DrawPrintTextFn )( PVOID, const wchar_t*, int, int );
  569.         return GetMethod< DrawPrintTextFn >( this, 22 )( this, text, textLen, 0 );
  570.     }
  571.  
  572.     unsigned long CreateFont( )
  573.     {
  574.         typedef unsigned int ( __thiscall* CreateFontFn )( PVOID );
  575.         return GetMethod< CreateFontFn >( this, 66 )( this );
  576.     }
  577.  
  578.     void SetFontGlyphSet( unsigned long font, const char* windowsFontName, int tall, int weight, int blur, int scanlines, int flags )
  579.     {
  580.         typedef void ( __thiscall* SetFontGlyphSetFn )( PVOID, unsigned long, const char*, int, int, int, int, int, int, int );
  581.         GetMethod< SetFontGlyphSetFn >( this, 67 )( this, font, windowsFontName, tall, weight, blur, scanlines, flags, 0, 0 );
  582.     }
  583.  
  584.     void GetTextSize( unsigned long font, const wchar_t* text, int& wide, int& tall )
  585.     {
  586.         typedef void ( __thiscall* GetTextSizeFn )( PVOID, unsigned long, const wchar_t*, int&, int& );
  587.         GetMethod< GetTextSizeFn >( this, 75 )( this, font, text, wide, tall );
  588.     }
  589. };
  590.  
  591. class IPhysicsSurfaceProps
  592. {
  593. public:
  594.     surfacedata_t* GetSurfaceData ( int surfaceDataIndex )
  595.     {
  596.         typedef surfacedata_t* ( __thiscall* GetSurfaceDataFn )( void*, int );
  597.         return GetMethod< GetSurfaceDataFn >( this, 5 )( this, surfaceDataIndex );
  598.     }
  599. };
  600.  
  601. #define CONTENTS_EMPTY          0       // No contents
  602.  
  603. #define CONTENTS_SOLID          0x1     // an eye is never valid in a solid
  604. #define CONTENTS_WINDOW         0x2     // translucent, but not watery (glass)
  605. #define CONTENTS_AUX            0x4
  606. #define CONTENTS_GRATE          0x8     // alpha-tested "grate" textures.  Bullets/sight pass through, but solids don't
  607. #define CONTENTS_SLIME          0x10
  608. #define CONTENTS_WATER          0x20
  609. #define CONTENTS_BLOCKLOS       0x40    // block AI line of sight
  610. #define CONTENTS_OPAQUE         0x80    // things that cannot be seen through (may be non-solid though)
  611. #define LAST_VISIBLE_CONTENTS   0x80
  612.  
  613. #define ALL_VISIBLE_CONTENTS (LAST_VISIBLE_CONTENTS | (LAST_VISIBLE_CONTENTS-1))
  614.  
  615. #define CONTENTS_TESTFOGVOLUME  0x100
  616. #define CONTENTS_UNUSED         0x200  
  617.  
  618. // unused
  619. // NOTE: If it's visible, grab from the top + update LAST_VISIBLE_CONTENTS
  620. // if not visible, then grab from the bottom.
  621. #define CONTENTS_UNUSED6        0x400
  622.  
  623. #define CONTENTS_TEAM1          0x800   // per team contents used to differentiate collisions
  624. #define CONTENTS_TEAM2          0x1000  // between players and objects on different teams
  625.  
  626. // ignore CONTENTS_OPAQUE on surfaces that have SURF_NODRAW
  627. #define CONTENTS_IGNORE_NODRAW_OPAQUE   0x2000
  628.  
  629. // hits entities which are MOVETYPE_PUSH (doors, plats, etc.)
  630. #define CONTENTS_MOVEABLE       0x4000
  631.  
  632. // remaining contents are non-visible, and don't eat brushes
  633. #define CONTENTS_AREAPORTAL     0x8000
  634.  
  635. #define CONTENTS_PLAYERCLIP     0x10000
  636. #define CONTENTS_MONSTERCLIP    0x20000
  637.  
  638. // currents can be added to any other contents, and may be mixed
  639. #define CONTENTS_CURRENT_0      0x40000
  640. #define CONTENTS_CURRENT_90     0x80000
  641. #define CONTENTS_CURRENT_180    0x100000
  642. #define CONTENTS_CURRENT_270    0x200000
  643. #define CONTENTS_CURRENT_UP     0x400000
  644. #define CONTENTS_CURRENT_DOWN   0x800000
  645.  
  646. #define CONTENTS_ORIGIN         0x1000000   // removed before bsping an entity
  647.  
  648. #define CONTENTS_MONSTER        0x2000000   // should never be on a brush, only in game
  649. #define CONTENTS_DEBRIS         0x4000000
  650. #define CONTENTS_DETAIL         0x8000000   // brushes to be added after vis leafs
  651. #define CONTENTS_TRANSLUCENT    0x10000000  // auto set if any surface has trans
  652. #define CONTENTS_LADDER         0x20000000
  653. #define CONTENTS_HITBOX         0x40000000  // use accurate hitboxes on trace
  654.  
  655.  
  656. // NOTE: These are stored in a short in the engine now.  Don't use more than 16 bits
  657. #define SURF_LIGHT      0x0001      // value will hold the light strength
  658. #define SURF_SKY2D      0x0002      // don't draw, indicates we should skylight + draw 2d sky but not draw the 3D skybox
  659. #define SURF_SKY        0x0004      // don't draw, but add to skybox
  660. #define SURF_WARP       0x0008      // turbulent water warp
  661. #define SURF_TRANS      0x0010
  662. #define SURF_NOPORTAL   0x0020  // the surface can not have a portal placed on it
  663. #define SURF_TRIGGER    0x0040  // FIXME: This is an xbox hack to work around elimination of trigger surfaces, which breaks occluders
  664. #define SURF_NODRAW     0x0080  // don't bother referencing the texture
  665.  
  666. #define SURF_HINT       0x0100  // make a primary bsp splitter
  667.  
  668. #define SURF_SKIP       0x0200  // completely ignore, allowing non-closed brushes
  669. #define SURF_NOLIGHT    0x0400  // Don't calculate light
  670. #define SURF_BUMPLIGHT  0x0800  // calculate three lightmaps for the surface for bumpmapping
  671. #define SURF_NOSHADOWS  0x1000  // Don't receive shadows
  672. #define SURF_NODECALS   0x2000  // Don't receive decals
  673. #define SURF_NOCHOP     0x4000  // Don't subdivide patches on this surface
  674. #define SURF_HITBOX     0x8000  // surface is part of a hitbox
  675.  
  676.  
  677.  
  678. // -----------------------------------------------------
  679. // spatial content masks - used for spatial queries (traceline,etc.)
  680. // -----------------------------------------------------
  681. #define MASK_ALL                    (0xFFFFFFFF)
  682. // everything that is normally solid
  683. #define MASK_SOLID                  (CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_WINDOW|CONTENTS_MONSTER|CONTENTS_GRATE)
  684. // everything that blocks player movement
  685. #define MASK_PLAYERSOLID            (CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_PLAYERCLIP|CONTENTS_WINDOW|CONTENTS_MONSTER|CONTENTS_GRATE)
  686. // blocks npc movement
  687. #define MASK_NPCSOLID               (CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_MONSTERCLIP|CONTENTS_WINDOW|CONTENTS_MONSTER|CONTENTS_GRATE)
  688. // water physics in these contents
  689. #define MASK_WATER                  (CONTENTS_WATER|CONTENTS_MOVEABLE|CONTENTS_SLIME)
  690. // everything that blocks lighting
  691. #define MASK_OPAQUE                 (CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_OPAQUE)
  692. // everything that blocks lighting, but with monsters added.
  693. #define MASK_OPAQUE_AND_NPCS        (MASK_OPAQUE|CONTENTS_MONSTER)
  694. // everything that blocks line of sight for AI
  695. #define MASK_BLOCKLOS               (CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_BLOCKLOS)
  696. // everything that blocks line of sight for AI plus NPCs
  697. #define MASK_BLOCKLOS_AND_NPCS      (MASK_BLOCKLOS|CONTENTS_MONSTER)
  698. // everything that blocks line of sight for players
  699. #define MASK_VISIBLE                    (MASK_OPAQUE|CONTENTS_IGNORE_NODRAW_OPAQUE)
  700. // everything that blocks line of sight for players, but with monsters added.
  701. #define MASK_VISIBLE_AND_NPCS       (MASK_OPAQUE_AND_NPCS|CONTENTS_IGNORE_NODRAW_OPAQUE)
  702. // bullets see these as solid
  703. #define MASK_SHOT                   (CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_MONSTER|CONTENTS_WINDOW|CONTENTS_DEBRIS|CONTENTS_HITBOX)
  704. // non-raycasted weapons see this as solid (includes grates)
  705. #define MASK_SHOT_HULL              (CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_MONSTER|CONTENTS_WINDOW|CONTENTS_DEBRIS|CONTENTS_GRATE)
  706. // hits solids (not grates) and passes through everything else
  707. #define MASK_SHOT_PORTAL            (CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_WINDOW|CONTENTS_MONSTER)
  708. // everything normally solid, except monsters (world+brush only)
  709. #define MASK_SOLID_BRUSHONLY        (CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_WINDOW|CONTENTS_GRATE)
  710. // everything normally solid for player movement, except monsters (world+brush only)
  711. #define MASK_PLAYERSOLID_BRUSHONLY  (CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_WINDOW|CONTENTS_PLAYERCLIP|CONTENTS_GRATE)
  712. // everything normally solid for npc movement, except monsters (world+brush only)
  713. #define MASK_NPCSOLID_BRUSHONLY     (CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_WINDOW|CONTENTS_MONSTERCLIP|CONTENTS_GRATE)
  714. // just the world, used for route rebuilding
  715. #define MASK_NPCWORLDSTATIC         (CONTENTS_SOLID|CONTENTS_WINDOW|CONTENTS_MONSTERCLIP|CONTENTS_GRATE)
  716. // These are things that can split areaportals
  717. #define MASK_SPLITAREAPORTAL        (CONTENTS_WATER|CONTENTS_SLIME)
  718.  
  719. // UNDONE: This is untested, any moving water
  720. #define MASK_CURRENT                (CONTENTS_CURRENT_0|CONTENTS_CURRENT_90|CONTENTS_CURRENT_180|CONTENTS_CURRENT_270|CONTENTS_CURRENT_UP|CONTENTS_CURRENT_DOWN)
  721.  
  722. // everything that blocks corpse movement
  723. // UNDONE: Not used yet / may be deleted
  724. #define MASK_DEADSOLID              (CONTENTS_SOLID|CONTENTS_PLAYERCLIP|CONTENTS_WINDOW|CONTENTS_GRATE)
  725.  
  726. class CMoveData
  727. {
  728. public:
  729.     bool            m_bFirstRunOfFunctions : 1;
  730.     bool            m_bGameCodeMovedPlayer : 1;
  731.  
  732.     int             m_nPlayerHandle;    // edict index on server, client entity handle on client
  733.  
  734.     int             m_nImpulseCommand;  // Impulse command issued.
  735.     Vector          m_vecViewAngles;    // Command view angles (local space)
  736.     Vector          m_vecAbsViewAngles; // Command view angles (world space)
  737.     int             m_nButtons;         // Attack buttons.
  738.     int             m_nOldButtons;      // From host_client->oldbuttons;
  739.     float           m_flForwardMove;
  740.     float           m_flSideMove;
  741.     float           m_flUpMove;
  742.    
  743.     float           m_flMaxSpeed;
  744.     float           m_flClientMaxSpeed;
  745.  
  746.     // Variables from the player edict (sv_player) or entvars on the client.
  747.     // These are copied in here before calling and copied out after calling.
  748.     Vector          m_vecVelocity;      // edict::velocity      // Current movement direction.
  749.     Vector          m_vecAngles;        // edict::angles
  750.     Vector          m_vecOldAngles;
  751.    
  752. // Output only
  753.     float           m_outStepHeight;    // how much you climbed this move
  754.     Vector          m_outWishVel;       // This is where you tried
  755.     Vector          m_outJumpVel;       // This is your jump velocity
  756.  
  757.     // Movement constraints (radius 0 means no constraint)
  758.     Vector          m_vecConstraintCenter;
  759.     float           m_flConstraintRadius;
  760.     float           m_flConstraintWidth;
  761.     float           m_flConstraintSpeedFactor;
  762.  
  763.     void            SetAbsOrigin( const Vector &vec );
  764.     const Vector    &GetAbsOrigin() const;
  765.     Vector          m_vecAbsOrigin;     // edict::origin
  766.  
  767. private:
  768.  
  769. };
  770.  
  771. class IGameMovement
  772. {
  773. public:
  774.     virtual ~IGameMovement ( void ) {}
  775.     virtual void ProcessMovement ( CSPlayer* pPlayer, CMoveData* pMove ) = 0;
  776.     virtual void StartTrackPredictionErrors ( CSPlayer* pPlayer ) = 0;
  777.     virtual void FinishTrackPredictionErrors ( CSPlayer* pPlayer ) = 0;
  778.     virtual void DiffPrint ( const char* fmt, ... ) = 0;
  779.     virtual Vector GetPlayerMins ( bool ducked ) const = 0;
  780.     virtual Vector GetPlayerMaxs ( bool ducked ) const = 0;
  781.     virtual Vector GetPlayerViewOffset ( bool ducked ) const = 0;
  782. };
  783.  
  784. class CGameMovement : public IGameMovement
  785. {
  786. public:
  787.     CGameMovement ( void );
  788.  
  789.     virtual ~CGameMovement ( void );
  790.     virtual void            ProcessMovement ( CSPlayer* pPlayer, CMoveData* pMove );
  791.     virtual void            StartTrackPredictionErrors ( CSPlayer* pPlayer );
  792.     virtual void            FinishTrackPredictionErrors ( CSPlayer* pPlayer );
  793.     virtual void            DiffPrint ( const char* fmt, ... );
  794.     virtual Vector          GetPlayerMins ( bool ducked ) const;
  795.     virtual Vector          GetPlayerMaxs ( bool ducked ) const;
  796.     virtual Vector          GetPlayerViewOffset ( bool ducked ) const;
  797.     virtual void            TracePlayerBBox ();
  798.     virtual unsigned int    PlayerSolidMask ();
  799.  
  800.     CSPlayer*               player;
  801.  
  802.     CMoveData*              mv;
  803.  
  804.     int                     m_nOldWaterLevel;
  805.     float                   m_flWaterEntryTime;
  806.     int                     m_nOnLadder;
  807.  
  808.     Vector                  m_vecForward;
  809.     Vector                  m_vecRight;
  810.     Vector                  m_vecUp;
  811.  
  812.     virtual void            PlayerMove ( void );
  813.    
  814.     virtual void            CalcRoll ( const Vector& angles, const Vector& velocity, float rollangle, float rollspeed );
  815.  
  816.     virtual void            DecayPunchAngle ( void );
  817. };
  818.  
  819. class IPrediction
  820. {
  821. public:
  822.     virtual        ~IPrediction( void ) {};
  823.  
  824.     virtual void    Init( void ) = 0;
  825.     virtual void    Shutdown( void ) = 0;
  826.  
  827.     // Run prediction
  828.     virtual void    Update
  829.                     (
  830.                             int startframe,                         // World update ( un-modded ) most recently received
  831.                             bool validframe,                        // Is frame data valid
  832.                             int incoming_acknowledged,      // Last command acknowledged to have been run by server (un-modded)
  833.                             int outgoing_command            // Last command (most recent) sent to server (un-modded)
  834.                     ) = 0;
  835.  
  836.     // We are about to get a network update from the server.  We know the update #, so we can pull any
  837.     //  data purely predicted on the client side and transfer it to the new from data state.
  838.     virtual void    PreEntityPacketReceived( int commands_acknowledged, int current_world_update_packet ) = 0;
  839.     virtual void    PostEntityPacketReceived( void ) = 0;
  840.     virtual void    PostNetworkDataReceived( int commands_acknowledged ) = 0;
  841.  
  842.     virtual void    OnReceivedUncompressedPacket( void ) = 0;
  843.  
  844.     // The engine needs to be able to access a few predicted values
  845.     virtual void    GetViewOrigin( Vector& org ) = 0;
  846.     virtual void    SetViewOrigin( Vector& org ) = 0;
  847.     virtual void    GetViewAngles( Vector& ang ) = 0;
  848.     virtual void    SetViewAngles( Vector& ang ) = 0;
  849.     virtual void    GetLocalViewAngles( Vector& ang ) = 0;
  850.     virtual void    SetLocalViewAngles( Vector& ang ) = 0;
  851. };
  852.  
  853. class IMoveHelper;
  854.  
  855. class CPrediction : public IPrediction
  856. {
  857. public:
  858.     CPrediction( void );
  859.     virtual                 ~CPrediction( void );
  860.  
  861.     virtual void    Init( void );
  862.     virtual void    Shutdown( void );
  863.  
  864. // Implement IPrediction
  865. public:
  866.  
  867.     virtual void    Update
  868.                     (
  869.                             int startframe,         // World update ( un-modded ) most recently received
  870.                             bool validframe,                // Is frame data valid
  871.                             int incoming_acknowledged, // Last command acknowledged to have been run by server (un-modded)
  872.                             int outgoing_command    // Last command (most recent) sent to server (un-modded)
  873.                     );
  874.  
  875.     virtual void    OnReceivedUncompressedPacket( void );
  876.  
  877.     virtual void    PreEntityPacketReceived( int commands_acknowledged, int current_world_update_packet );
  878.     virtual void    PostEntityPacketReceived( void );
  879.     virtual void    PostNetworkDataReceived( int commands_acknowledged );
  880.  
  881.     virtual bool    InPrediction( void ) const;
  882.     virtual bool    IsFirstTimePredicted( void ) const;
  883.  
  884.     virtual int     GetIncomingPacketNumber( void ) const;
  885.  
  886.     // The engine needs to be able to access a few predicted values
  887.     virtual void    GetViewOrigin( Vector& org );
  888.     virtual void    SetViewOrigin( Vector& org );
  889.     virtual void    GetViewAngles( Vector& ang );
  890.     virtual void    SetViewAngles( Vector& ang );
  891.  
  892.     virtual void    GetLocalViewAngles( Vector& ang );
  893.     virtual void    SetLocalViewAngles( Vector& ang );
  894.  
  895.     virtual void    RunCommand( CSPlayer *player, CUserCmd *ucmd, IMoveHelper *moveHelper );
  896.  
  897. // Internal
  898. public:
  899.     virtual void    SetupMove( CSPlayer *player, CUserCmd *ucmd, IMoveHelper *pHelper, CMoveData *move );
  900.     virtual void    FinishMove( CSPlayer *player, CUserCmd *ucmd, CMoveData *move );
  901. };
  902.  
  903. #endif // SDK_H
Advertisement
Add Comment
Please, Sign In to add comment