From ab4a8437ce31dd682dbd3ab7239353c1a4d2129a Mon Sep 17 00:00:00 2001 From: s1lentq Date: Mon, 16 May 2016 21:30:14 +0600 Subject: [PATCH] Added API hook PM_Init, PM_Move, PM_AirMove --- regamedll/extra/cssdk/dlls/regamedll_api.h | 22 ++++++++++++++----- .../extra/cssdk/dlls/regamedll_interfaces.h | 4 +++- regamedll/pm_shared/pm_shared.cpp | 14 +++++++----- regamedll/pm_shared/pm_shared.h | 4 ++++ regamedll/public/regamedll/regamedll_api.h | 18 ++++++++++++--- .../public/regamedll/regamedll_interfaces.h | 1 + regamedll/regamedll/regamedll_api_impl.cpp | 3 +++ regamedll/regamedll/regamedll_api_impl.h | 20 +++++++++++++++-- .../regamedll/regamedll_interfaces_impl.cpp | 4 ++++ .../regamedll/regamedll_interfaces_impl.h | 1 + 10 files changed, 75 insertions(+), 16 deletions(-) diff --git a/regamedll/extra/cssdk/dlls/regamedll_api.h b/regamedll/extra/cssdk/dlls/regamedll_api.h index 716c5f12..92d82b55 100644 --- a/regamedll/extra/cssdk/dlls/regamedll_api.h +++ b/regamedll/extra/cssdk/dlls/regamedll_api.h @@ -55,8 +55,8 @@ typedef IVoidHookChain IReGameHookRegistry_CBasePlayer_TraceAttack; // CBasePlayer::TakeDamage hook -typedef IHookChain IReGameHook_CBasePlayer_TakeDamage; -typedef IHookChainRegistryClass IReGameHookRegistry_CBasePlayer_TakeDamage; +typedef IHookChain IReGameHook_CBasePlayer_TakeDamage; +typedef IHookChainRegistryClass IReGameHookRegistry_CBasePlayer_TakeDamage; // CBasePlayer::TakeHealth hook typedef IHookChain IReGameHook_CBasePlayer_TakeHealth; @@ -182,6 +182,18 @@ typedef IHookChainRegistry IReGameHookRegistry_C typedef IHookChain IReGameHook_InstallGameRules; typedef IHookChainRegistry IReGameHookRegistry_InstallGameRules; +// PM_Init hook +typedef IVoidHookChain IReGameHook_PM_Init; +typedef IVoidHookChainRegistry IReGameHookRegistry_PM_Init; + +// PM_Move hook +typedef IVoidHookChain IReGameHook_PM_Move; +typedef IVoidHookChainRegistry IReGameHookRegistry_PM_Move; + +// PM_AirMove hook +typedef IVoidHookChain<> IReGameHook_PM_AirMove; +typedef IVoidHookChainRegistry<> IReGameHookRegistry_PM_AirMove; + class IReGameHookchains { public: virtual ~IReGameHookchains() {} @@ -215,17 +227,17 @@ public: virtual IReGameHookRegistry_CBasePlayer_GiveNamedItem* CBasePlayer_GiveNamedItem() = 0; virtual IReGameHookRegistry_CBasePlayer_AddAccount* CBasePlayer_AddAccount() = 0; virtual IReGameHookRegistry_CBasePlayer_GiveShield* CBasePlayer_GiveShield() = 0; - - virtual IReGameHookRegistry_CBaseAnimating_ResetSequenceInfo* CBaseAnimating_ResetSequenceInfo() = 0; - virtual IReGameHookRegistry_GetForceCamera* GetForceCamera() = 0; virtual IReGameHookRegistry_PlayerBlind* PlayerBlind() = 0; virtual IReGameHookRegistry_RadiusFlash_TraceLine* RadiusFlash_TraceLine() = 0; virtual IReGameHookRegistry_RoundEnd* RoundEnd() = 0; virtual IReGameHookRegistry_CanBuyThis* CanBuyThis() = 0; virtual IReGameHookRegistry_InstallGameRules* InstallGameRules() = 0; + virtual IReGameHookRegistry_PM_Init* PM_Init() = 0; + virtual IReGameHookRegistry_PM_Move* PM_Move() = 0; + virtual IReGameHookRegistry_PM_AirMove* PM_AirMove() = 0; }; diff --git a/regamedll/extra/cssdk/dlls/regamedll_interfaces.h b/regamedll/extra/cssdk/dlls/regamedll_interfaces.h index 8abddd42..9898151e 100644 --- a/regamedll/extra/cssdk/dlls/regamedll_interfaces.h +++ b/regamedll/extra/cssdk/dlls/regamedll_interfaces.h @@ -2076,5 +2076,7 @@ class IReGameData { public: virtual ~IReGameData() {} - virtual class CGameRules** GetGameRules() = 0; + virtual class CGameRules* GetGameRules() = 0; + virtual struct WeaponInfoStruct *GetWeaponInfo(int weaponID) = 0; + virtual struct playermove_s *GetPlayerMove() = 0; }; diff --git a/regamedll/pm_shared/pm_shared.cpp b/regamedll/pm_shared/pm_shared.cpp index cdb56cf9..cd7469e9 100644 --- a/regamedll/pm_shared/pm_shared.cpp +++ b/regamedll/pm_shared/pm_shared.cpp @@ -1282,7 +1282,9 @@ void PM_WaterMove() PM_FlyMove(); } -void PM_AirMove() +LINK_HOOK_VOID_CHAIN2(PM_AirMove); + +void EXT_FUNC __API_HOOK(PM_AirMove)() { int i; vec3_t wishvel; @@ -2579,9 +2581,7 @@ float PM_CalcRoll(vec_t *angles, vec_t *velocity, float rollangle, float rollspe AngleVectors(angles, forward, right, up); side = DotProduct(velocity, right); - sign = side < 0 ? -1 : 1; - side = Q_fabs(side); value = rollangle; @@ -3107,11 +3107,13 @@ void PM_CreateStuckTable() } } +LINK_HOOK_VOID_CHAIN(PM_Move, (struct playermove_s *ppmove, int server), ppmove, server); + // This module implements the shared player physics code between any particular game and // the engine. The same PM_Move routine is built into the game .dll and the client .dll and is // invoked by each side as appropriate. There should be no distinction, internally, between server // and client. This will ensure that prediction behaves appropriately. -void EXT_FUNC PM_Move(struct playermove_s *ppmove, int server) +void EXT_FUNC __API_HOOK(PM_Move)(struct playermove_s *ppmove, int server) { assert(pm_shared_initialized); @@ -3150,7 +3152,9 @@ NOXREF int PM_GetPhysEntInfo(int ent) return -1; } -void EXT_FUNC PM_Init(struct playermove_s *ppmove) +LINK_HOOK_VOID_CHAIN(PM_Init, (struct playermove_s *ppmove), ppmove); + +void EXT_FUNC __API_HOOK(PM_Init)(struct playermove_s *ppmove) { assert(!pm_shared_initialized); diff --git a/regamedll/pm_shared/pm_shared.h b/regamedll/pm_shared/pm_shared.h index e9fe639e..082af619 100644 --- a/regamedll/pm_shared/pm_shared.h +++ b/regamedll/pm_shared/pm_shared.h @@ -81,6 +81,10 @@ void PM_Init(struct playermove_s *ppmove); void PM_Move(struct playermove_s *ppmove, int server); char PM_FindTextureType(char *name); +void PM_Init_(struct playermove_s *ppmove); +void PM_Move_(struct playermove_s *ppmove, int server); +void PM_AirMove_(); + extern struct playermove_s *pmove; #endif // PM_SHARED_H diff --git a/regamedll/public/regamedll/regamedll_api.h b/regamedll/public/regamedll/regamedll_api.h index 8b0e5a97..92d82b55 100644 --- a/regamedll/public/regamedll/regamedll_api.h +++ b/regamedll/public/regamedll/regamedll_api.h @@ -182,6 +182,18 @@ typedef IHookChainRegistry IReGameHookRegistry_C typedef IHookChain IReGameHook_InstallGameRules; typedef IHookChainRegistry IReGameHookRegistry_InstallGameRules; +// PM_Init hook +typedef IVoidHookChain IReGameHook_PM_Init; +typedef IVoidHookChainRegistry IReGameHookRegistry_PM_Init; + +// PM_Move hook +typedef IVoidHookChain IReGameHook_PM_Move; +typedef IVoidHookChainRegistry IReGameHookRegistry_PM_Move; + +// PM_AirMove hook +typedef IVoidHookChain<> IReGameHook_PM_AirMove; +typedef IVoidHookChainRegistry<> IReGameHookRegistry_PM_AirMove; + class IReGameHookchains { public: virtual ~IReGameHookchains() {} @@ -215,17 +227,17 @@ public: virtual IReGameHookRegistry_CBasePlayer_GiveNamedItem* CBasePlayer_GiveNamedItem() = 0; virtual IReGameHookRegistry_CBasePlayer_AddAccount* CBasePlayer_AddAccount() = 0; virtual IReGameHookRegistry_CBasePlayer_GiveShield* CBasePlayer_GiveShield() = 0; - - virtual IReGameHookRegistry_CBaseAnimating_ResetSequenceInfo* CBaseAnimating_ResetSequenceInfo() = 0; - virtual IReGameHookRegistry_GetForceCamera* GetForceCamera() = 0; virtual IReGameHookRegistry_PlayerBlind* PlayerBlind() = 0; virtual IReGameHookRegistry_RadiusFlash_TraceLine* RadiusFlash_TraceLine() = 0; virtual IReGameHookRegistry_RoundEnd* RoundEnd() = 0; virtual IReGameHookRegistry_CanBuyThis* CanBuyThis() = 0; virtual IReGameHookRegistry_InstallGameRules* InstallGameRules() = 0; + virtual IReGameHookRegistry_PM_Init* PM_Init() = 0; + virtual IReGameHookRegistry_PM_Move* PM_Move() = 0; + virtual IReGameHookRegistry_PM_AirMove* PM_AirMove() = 0; }; diff --git a/regamedll/public/regamedll/regamedll_interfaces.h b/regamedll/public/regamedll/regamedll_interfaces.h index aced5e1b..9898151e 100644 --- a/regamedll/public/regamedll/regamedll_interfaces.h +++ b/regamedll/public/regamedll/regamedll_interfaces.h @@ -2078,4 +2078,5 @@ public: virtual class CGameRules* GetGameRules() = 0; virtual struct WeaponInfoStruct *GetWeaponInfo(int weaponID) = 0; + virtual struct playermove_s *GetPlayerMove() = 0; }; diff --git a/regamedll/regamedll/regamedll_api_impl.cpp b/regamedll/regamedll/regamedll_api_impl.cpp index fbb06f42..be7335db 100644 --- a/regamedll/regamedll/regamedll_api_impl.cpp +++ b/regamedll/regamedll/regamedll_api_impl.cpp @@ -89,6 +89,9 @@ IReGameHookRegistry_RadiusFlash_TraceLine* CReGameHookchains::RadiusFlash_TraceL IReGameHookRegistry_RoundEnd* CReGameHookchains::RoundEnd() { return &m_RoundEnd; } IReGameHookRegistry_CanBuyThis* CReGameHookchains::CanBuyThis() { return &m_CanBuyThis; } IReGameHookRegistry_InstallGameRules* CReGameHookchains::InstallGameRules() { return &m_InstallGameRules; } +IReGameHookRegistry_PM_Init* CReGameHookchains::PM_Init() { return &m_PM_Init; } +IReGameHookRegistry_PM_Move* CReGameHookchains::PM_Move() { return &m_PM_Move; } +IReGameHookRegistry_PM_AirMove* CReGameHookchains::PM_AirMove() { return &m_PM_AirMove; } int CReGameApi::GetMajorVersion() { diff --git a/regamedll/regamedll/regamedll_api_impl.h b/regamedll/regamedll/regamedll_api_impl.h index a78940fd..f3862057 100644 --- a/regamedll/regamedll/regamedll_api_impl.h +++ b/regamedll/regamedll/regamedll_api_impl.h @@ -176,6 +176,18 @@ typedef IHookChainRegistryImpl CReGameHookRegist typedef IHookChainImpl CReGameHook_InstallGameRules; typedef IHookChainRegistryImpl CReGameHookRegistry_InstallGameRules; +// PM_Init hook +typedef IVoidHookChainImpl CReGameHook_PM_Init; +typedef IVoidHookChainRegistryImpl CReGameHookRegistry_PM_Init; + +// PM_Move hook +typedef IVoidHookChainImpl CReGameHook_PM_Move; +typedef IVoidHookChainRegistryImpl CReGameHookRegistry_PM_Move; + +// PM_AirMove hook +typedef IVoidHookChainImpl<> CReGameHook_PM_AirMove; +typedef IVoidHookChainRegistryImpl<> CReGameHookRegistry_PM_AirMove; + class CReGameHookchains: public IReGameHookchains { public: // CBasePlayer virtual @@ -209,7 +221,6 @@ public: CReGameHookRegistry_CBasePlayer_AddAccount m_CBasePlayer_AddAccount; CReGameHookRegistry_CBasePlayer_GiveShield m_CBasePlayer_GiveShield; - CReGameHookRegistry_CBaseAnimating_ResetSequenceInfo m_CBaseAnimating_ResetSequenceInfo; CReGameHookRegistry_GetForceCamera m_GetForceCamera; @@ -218,6 +229,9 @@ public: CReGameHookRegistry_RoundEnd m_RoundEnd; CReGameHookRegistry_CanBuyThis m_CanBuyThis; CReGameHookRegistry_InstallGameRules m_InstallGameRules; + CReGameHookRegistry_PM_Init m_PM_Init; + CReGameHookRegistry_PM_Move m_PM_Move; + CReGameHookRegistry_PM_AirMove m_PM_AirMove; public: virtual IReGameHookRegistry_CBasePlayer_Spawn* CBasePlayer_Spawn(); @@ -250,7 +264,6 @@ public: virtual IReGameHookRegistry_CBasePlayer_AddAccount* CBasePlayer_AddAccount(); virtual IReGameHookRegistry_CBasePlayer_GiveShield* CBasePlayer_GiveShield(); - virtual IReGameHookRegistry_CBaseAnimating_ResetSequenceInfo* CBaseAnimating_ResetSequenceInfo(); virtual IReGameHookRegistry_GetForceCamera* GetForceCamera(); @@ -259,6 +272,9 @@ public: virtual IReGameHookRegistry_RoundEnd* RoundEnd(); virtual IReGameHookRegistry_CanBuyThis* CanBuyThis(); virtual IReGameHookRegistry_InstallGameRules* InstallGameRules(); + virtual IReGameHookRegistry_PM_Init* PM_Init(); + virtual IReGameHookRegistry_PM_Move* PM_Move(); + virtual IReGameHookRegistry_PM_AirMove* PM_AirMove(); }; diff --git a/regamedll/regamedll/regamedll_interfaces_impl.cpp b/regamedll/regamedll/regamedll_interfaces_impl.cpp index a484f27e..583ef98a 100644 --- a/regamedll/regamedll/regamedll_interfaces_impl.cpp +++ b/regamedll/regamedll/regamedll_interfaces_impl.cpp @@ -142,3 +142,7 @@ CGameRules* EXT_FUNC CReGameData::GetGameRules() { WeaponInfoStruct* EXT_FUNC CReGameData::GetWeaponInfo(int weaponID) { return ::GetWeaponInfo(weaponID); } + +playermove_t* EXT_FUNC CReGameData::GetPlayerMove() { + return pmove; +} diff --git a/regamedll/regamedll/regamedll_interfaces_impl.h b/regamedll/regamedll/regamedll_interfaces_impl.h index f83cbe4c..1e08bd8a 100644 --- a/regamedll/regamedll/regamedll_interfaces_impl.h +++ b/regamedll/regamedll/regamedll_interfaces_impl.h @@ -2524,6 +2524,7 @@ class CReGameData: public IReGameData { public: virtual CGameRules* GetGameRules(); virtual WeaponInfoStruct *GetWeaponInfo(int weaponID); + virtual playermove_t *GetPlayerMove(); }; template