From 17964599538cab2edbf5bbbdac52171b9917670a Mon Sep 17 00:00:00 2001 From: Hamdi Date: Sat, 11 Feb 2023 00:03:53 +0000 Subject: [PATCH] Add SV_AllowPhysent hook (#951) * Add SV_AllowPhysent hook --- rehlds/engine/sv_user.cpp | 13 +++++++++++++ rehlds/public/rehlds/rehlds_api.h | 7 ++++++- rehlds/rehlds/rehlds_api_impl.cpp | 4 ++++ rehlds/rehlds/rehlds_api_impl.h | 6 ++++++ rehlds/version/version.h | 2 +- 5 files changed, 30 insertions(+), 2 deletions(-) diff --git a/rehlds/engine/sv_user.cpp b/rehlds/engine/sv_user.cpp index 5e2c001..0912cc0 100644 --- a/rehlds/engine/sv_user.cpp +++ b/rehlds/engine/sv_user.cpp @@ -511,6 +511,14 @@ void SV_CopyEdictToPhysent(physent_t *pe, int e, edict_t *check) pe->vuser4[2] = check->v.vuser4[2]; } +bool EXT_FUNC SV_AllowPhysent_mod(edict_t* check, edict_t* sv_player) { + return true; +} + +bool SV_AllowPhysent(edict_t* check, edict_t* sv_player) { + return g_RehldsHookchains.m_SV_AllowPhysent.callChain(SV_AllowPhysent_mod, check, sv_player); +} + void SV_AddLinksToPM_(areanode_t *node, float *pmove_mins, float *pmove_maxs) { struct link_s *l; @@ -547,6 +555,11 @@ void SV_AddLinksToPM_(areanode_t *node, float *pmove_mins, float *pmove_maxs) if (check->v.solid != SOLID_BSP && check->v.solid != SOLID_BBOX && check->v.solid != SOLID_SLIDEBOX && check->v.solid != SOLID_NOT) continue; + // Apply our own custom checks + if (!SV_AllowPhysent(check, sv_player)) { + continue; + } + e = NUM_FOR_EDICT(check); ve = &pmove->visents[pmove->numvisent]; pmove->numvisent = pmove->numvisent + 1; diff --git a/rehlds/public/rehlds/rehlds_api.h b/rehlds/public/rehlds/rehlds_api.h index debea33..bc83581 100644 --- a/rehlds/public/rehlds/rehlds_api.h +++ b/rehlds/public/rehlds/rehlds_api.h @@ -37,7 +37,7 @@ #include "pr_dlls.h" #define REHLDS_API_VERSION_MAJOR 3 -#define REHLDS_API_VERSION_MINOR 12 +#define REHLDS_API_VERSION_MINOR 13 //Steam_NotifyClientConnect hook typedef IHookChain IRehldsHook_Steam_NotifyClientConnect; @@ -255,6 +255,10 @@ typedef IVoidHookChainRegistry IRehldsHook_SV_ClientPrintf; typedef IVoidHookChainRegistry IRehldsHookRegistry_SV_ClientPrintf; +//SV_AllowPhysent hook +typedef IHookChain IRehldsHook_SV_AllowPhysent; +typedef IHookChainRegistry IRehldsHookRegistry_SV_AllowPhysent; + class IRehldsHookchains { public: virtual ~IRehldsHookchains() { } @@ -313,6 +317,7 @@ public: virtual IRehldsHookRegistry_EV_Precache* EV_Precache() = 0; virtual IRehldsHookRegistry_SV_AddResource* SV_AddResource() = 0; virtual IRehldsHookRegistry_SV_ClientPrintf* SV_ClientPrintf() = 0; + virtual IRehldsHookRegistry_SV_AllowPhysent* SV_AllowPhysent() = 0; }; struct RehldsFuncs_t { diff --git a/rehlds/rehlds/rehlds_api_impl.cpp b/rehlds/rehlds/rehlds_api_impl.cpp index 5a41c1e..d186220 100644 --- a/rehlds/rehlds/rehlds_api_impl.cpp +++ b/rehlds/rehlds/rehlds_api_impl.cpp @@ -879,6 +879,10 @@ IRehldsHookRegistry_SV_ClientPrintf* CRehldsHookchains::SV_ClientPrintf(){ return &m_SV_ClientPrintf; } +IRehldsHookRegistry_SV_AllowPhysent* CRehldsHookchains::SV_AllowPhysent() { + return &m_SV_AllowPhysent; +} + int EXT_FUNC CRehldsApi::GetMajorVersion() { return REHLDS_API_VERSION_MAJOR; diff --git a/rehlds/rehlds/rehlds_api_impl.h b/rehlds/rehlds/rehlds_api_impl.h index 28b1c3e..699bd16 100644 --- a/rehlds/rehlds/rehlds_api_impl.h +++ b/rehlds/rehlds/rehlds_api_impl.h @@ -250,6 +250,10 @@ typedef IVoidHookChainRegistryImpl CRehldsHook_SV_ClientPrintf; typedef IVoidHookChainRegistryImpl CRehldsHookRegistry_SV_ClientPrintf; +//SV_AllowPhysent hook +typedef IHookChainImpl CRehldsHook_SV_AllowPhysent; +typedef IHookChainRegistryImpl CRehldsHookRegistry_SV_AllowPhysent; + class CRehldsHookchains : public IRehldsHookchains { public: CRehldsHookRegistry_Steam_NotifyClientConnect m_Steam_NotifyClientConnect; @@ -306,6 +310,7 @@ public: CRehldsHookRegistry_EV_Precache m_EV_Precache; CRehldsHookRegistry_SV_AddResource m_SV_AddResource; CRehldsHookRegistry_SV_ClientPrintf m_SV_ClientPrintf; + CRehldsHookRegistry_SV_AllowPhysent m_SV_AllowPhysent; public: EXT_FUNC virtual IRehldsHookRegistry_Steam_NotifyClientConnect* Steam_NotifyClientConnect(); @@ -362,6 +367,7 @@ public: EXT_FUNC virtual IRehldsHookRegistry_EV_Precache* EV_Precache(); EXT_FUNC virtual IRehldsHookRegistry_SV_AddResource* SV_AddResource(); EXT_FUNC virtual IRehldsHookRegistry_SV_ClientPrintf* SV_ClientPrintf(); + EXT_FUNC virtual IRehldsHookRegistry_SV_AllowPhysent* SV_AllowPhysent(); }; extern CRehldsHookchains g_RehldsHookchains; diff --git a/rehlds/version/version.h b/rehlds/version/version.h index 9c1ad71..55a454b 100644 --- a/rehlds/version/version.h +++ b/rehlds/version/version.h @@ -6,5 +6,5 @@ #pragma once #define VERSION_MAJOR 3 -#define VERSION_MINOR 12 +#define VERSION_MINOR 13 #define VERSION_MAINTENANCE 0