diff --git a/src/entitycache.cpp b/src/entitycache.cpp index 37e0e967..4c18afa1 100644 --- a/src/entitycache.cpp +++ b/src/entitycache.cpp @@ -195,7 +195,7 @@ bool CachedEntity::IsVisible() { matrix3x4_t* CachedEntity::GetBones() { if (!m_bBonesSetup) { - m_bBonesSetup = RAW_ENT(this)->SetupBones(m_Bones, MAXSTUDIOBONES, 0x100, 0); // gvars->curtime + m_bBonesSetup = RAW_ENT(this)->SetupBones(m_Bones, MAXSTUDIOBONES, 0x100, g_GlobalVars->curtime); // gvars->curtime } return m_Bones; } diff --git a/src/helpers.cpp b/src/helpers.cpp index 47701613..4b05cbed 100644 --- a/src/helpers.cpp +++ b/src/helpers.cpp @@ -41,7 +41,7 @@ void EndConVars() { RegisterCatVars(); RegisterCatCommands(); if (hConVarsFile) { - fprintf(hConVarsFile, "\nexec cat_autoexec\n"); + //fprintf(hConVarsFile, "\nexec cat_autoexec\n"); fprintf(hConVarsFile, "cat_killsay_reload\ncat_spam_reload\n"); fclose(hConVarsFile); } diff --git a/src/hooks/CreateMove.cpp b/src/hooks/CreateMove.cpp index 4394a5f6..8dea7664 100644 --- a/src/hooks/CreateMove.cpp +++ b/src/hooks/CreateMove.cpp @@ -37,6 +37,31 @@ static CatVar minigun_jump(CV_SWITCH, "minigun_jump", "0", "TF2C minigun jump", CatVar jointeam(CV_SWITCH, "fb_autoteam", "1", "Joins player team automatically (NYI)"); CatVar joinclass(CV_STRING, "fb_autoclass", "spy", "Class that will be picked after joining a team (NYI)"); +namespace engine_prediction { + +float o_curtime; +float o_frametime; + +void Start() { + o_curtime = g_GlobalVars->curtime; + o_frametime = g_GlobalVars->frametime; + *g_PredictionRandomSeed = MD5_PseudoRandom(g_pUserCmd->command_number) & 0x7FFFFFFF; + g_GlobalVars->curtime = CE_INT(LOCAL_E, netvar.nTickBase) * g_GlobalVars->interval_per_tick; + g_GlobalVars->frametime = g_GlobalVars->interval_per_tick; + g_IGameMovement->StartTrackPredictionErrors((CBasePlayer*)(RAW_ENT(LOCAL_E))); + + CMoveData data; + +} + +void End() { + *g_PredictionRandomSeed = -1; + g_GlobalVars->curtime = o_curtime; + g_GlobalVars->frametime = o_frametime; +} + +} + bool CreateMove_hook(void* thisptr, float inputSample, CUserCmd* cmd) { SEGV_BEGIN; diff --git a/src/interfaces.cpp b/src/interfaces.cpp index f2fec726..88133c18 100644 --- a/src/interfaces.cpp +++ b/src/interfaces.cpp @@ -46,6 +46,7 @@ IVDebugOverlay* g_IVDebugOverlay = nullptr; IMaterialSystemFixed* g_IMaterialSystem = nullptr; IVRenderView* g_IVRenderView = nullptr; IMaterialSystem* g_IMaterialSystemHL = nullptr; +IMoveHelperServer* g_IMoveHelperServer = nullptr; template T* BruteforceInterface(std::string name, sharedobj::SharedObject* object, int start) { @@ -103,6 +104,9 @@ void CreateInterfaces() { g_pScreenSpaceEffects = **(IScreenSpaceEffectManager***)(gSignatures.GetClientSignature("FF 52 14 E9 E0 FE FF FF 8D 76 00 A1 ? ? ? ? 8B 5D F4 8B 75 F8 8B 7D FC 8B 10 C7 45 0C ? ? ? ? 89 45 08 8B 42 1C 89 EC 5D FF E0") + 12); g_ppScreenSpaceRegistrationHead = *(CScreenSpaceEffectRegistration***)(gSignatures.GetClientSignature("E8 ? ? ? ? 8B 10 C7 44 24 04 ? ? ? ? 89 04 24 FF 52 28 85 C0 75 4B 8B 35 ? ? ? ? 85 F6 74 31 90 8B 5E 04 85 DB 74 22 8B 03 89 1C 24") + 27); } + if (TF2) { + //g_IMoveHelper = *(reinterpret_cast(gSignatures.GetClientSignature("? ? ? ? 8B 10 89 04 24 FF 52 28 0F B7 CF 8B 10 89 4C 24 04 89 04 24 FF 52 1C 8B 13 89 1C 24 89 44 24 04 FF 92 74 05 00 00 8D 95 C8 FE FF FF C7 44 24 08 00 00 00 00"))); + } if (TF2) g_IInput = **(reinterpret_cast((uintptr_t)1 + gSignatures.GetClientSignature("A1 ? ? ? ? C6 05 ? ? ? ? 01 8B 10 89 04 24 FF 92 B4 00 00 00 A1 ? ? ? ? 8B 10"))); else if (TF2C) g_IInput = **(reinterpret_cast((uintptr_t)1 + gSignatures.GetClientSignature("A1 ? ? ? ? C6 05 ? ? ? ? 01 8B 10 89 04 24 FF 92 A8 00 00 00 A1 ? ? ? ? 8B 10"))); else if (HL2DM) g_IInput = **(reinterpret_cast((uintptr_t)1 + gSignatures.GetClientSignature("A1 ? ? ? ? 8B 10 89 04 24 FF 52 78 A1 ? ? ? ? 8B 10"))); diff --git a/src/interfaces.h b/src/interfaces.h index e585c8a3..d47544c9 100644 --- a/src/interfaces.h +++ b/src/interfaces.h @@ -47,6 +47,7 @@ class IVModelRender; class IVRenderView; class IMaterialSystemFixed; class IMaterialSystem; +class IMoveHelperServer; extern ISteamClient* g_ISteamClient; extern ISteamFriends* g_ISteamFriends; @@ -73,6 +74,7 @@ extern IMaterialSystemFixed* g_IMaterialSystem; extern IMaterialSystem* g_IMaterialSystemHL; extern IVModelRender* g_IVModelRender; extern IVRenderView* g_IVRenderView; +extern IMoveHelperServer* g_IMoveHelperServer; template T* BruteforceInterface(std::string name, sharedobj::SharedObject* object, int start = 0); diff --git a/src/sdk.h b/src/sdk.h index da879884..34ff558e 100644 --- a/src/sdk.h +++ b/src/sdk.h @@ -51,10 +51,12 @@ #include #include #include +#include #include "sdk/in_buttons.h" #include "sdk/imaterialsystemfixed.h" #include "sdk/ScreenSpaceEffects.h" #include "sdk/iinput.h" +#include "sdk/igamemovement.h" #endif /* SDK_H_ */ diff --git a/src/sdk/igamemovement.h b/src/sdk/igamemovement.h new file mode 100644 index 00000000..4d3d4682 --- /dev/null +++ b/src/sdk/igamemovement.h @@ -0,0 +1,131 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $Workfile: $ +// $Date: $ +// $NoKeywords: $ +//=============================================================================// + +#if !defined( IGAMEMOVEMENT_H ) +#define IGAMEMOVEMENT_H + +#ifdef _WIN32 +#pragma once +#endif + +class CBasePlayer; + +#include "mathlib/vector.h" +#include "interface.h" +//#include "imovehelper.h" +#include "const.h" + +//----------------------------------------------------------------------------- +// Name of the class implementing the game movement. +//----------------------------------------------------------------------------- + +#define INTERFACENAME_GAMEMOVEMENT "GameMovement001" + +//----------------------------------------------------------------------------- +// Forward declarations. +//----------------------------------------------------------------------------- + +class IMoveHelper; + +//----------------------------------------------------------------------------- +// Purpose: Encapsulated input parameters to player movement. +//----------------------------------------------------------------------------- + +class CMoveData +{ +public: + bool m_bFirstRunOfFunctions : 1; + bool m_bGameCodeMovedPlayer : 1; + + CBaseHandle m_nPlayerHandle; // edict index on server, client entity handle on client + + int m_nImpulseCommand; // Impulse command issued. + QAngle m_vecViewAngles; // Command view angles (local space) + QAngle m_vecAbsViewAngles; // Command view angles (world space) + int m_nButtons; // Attack buttons. + int m_nOldButtons; // From host_client->oldbuttons; + float m_flForwardMove; + float m_flSideMove; + float m_flUpMove; + + float m_flMaxSpeed; + float m_flClientMaxSpeed; + + // Variables from the player edict (sv_player) or entvars on the client. + // These are copied in here before calling and copied out after calling. + Vector m_vecVelocity; // edict::velocity // Current movement direction. + QAngle m_vecAngles; // edict::angles + QAngle m_vecOldAngles; + +// Output only + float m_outStepHeight; // how much you climbed this move + Vector m_outWishVel; // This is where you tried + Vector m_outJumpVel; // This is your jump velocity + + // Movement constraints (radius 0 means no constraint) + Vector m_vecConstraintCenter; + float m_flConstraintRadius; + float m_flConstraintWidth; + float m_flConstraintSpeedFactor; + + void SetAbsOrigin( const Vector &vec ); + const Vector &GetAbsOrigin() const; + +private: + Vector m_vecAbsOrigin; // edict::origin +}; + +inline const Vector &CMoveData::GetAbsOrigin() const +{ + return m_vecAbsOrigin; +} + +#if !defined( CLIENT_DLL ) && defined( _DEBUG ) +// We only ever want this code path on the server side in a debug build +// and you have to uncomment the code below and rebuild to have the test operate. +//#define PLAYER_GETTING_STUCK_TESTING + +#endif + +#if !defined( PLAYER_GETTING_STUCK_TESTING ) + +// This is implemented with a more exhaustive test in gamemovement.cpp. We check if the origin being requested is +// inside solid, which it never should be +inline void CMoveData::SetAbsOrigin( const Vector &vec ) +{ + m_vecAbsOrigin = vec; +} + +#endif + + +//----------------------------------------------------------------------------- +// Purpose: The basic player movement interface +//----------------------------------------------------------------------------- + +abstract_class IGameMovement +{ +public: + virtual ~IGameMovement( void ) {} + + // Process the current movement command + virtual void ProcessMovement( CBasePlayer *pPlayer, CMoveData *pMove ) = 0; + virtual void StartTrackPredictionErrors( CBasePlayer *pPlayer ) = 0; + virtual void FinishTrackPredictionErrors( CBasePlayer *pPlayer ) = 0; + virtual void DiffPrint( PRINTF_FORMAT_STRING char const *fmt, ... ) = 0; + + // Allows other parts of the engine to find out the normal and ducked player bbox sizes + virtual Vector GetPlayerMins( bool ducked ) const = 0; + virtual Vector GetPlayerMaxs( bool ducked ) const = 0; + virtual Vector GetPlayerViewOffset( bool ducked ) const = 0; + +}; + + +#endif // IGAMEMOVEMENT_H