From b012fd6b3d5057bdac128e9504c43fe7e3739868 Mon Sep 17 00:00:00 2001 From: Karol Szuster Date: Thu, 6 May 2021 19:25:34 +0200 Subject: [PATCH 1/2] Add GetEntityInit hook Signed-off-by: Karol Szuster --- rehlds/engine/sys_dll.cpp | 12 +++++++++++- rehlds/engine/sys_dll.h | 2 ++ rehlds/public/rehlds/rehlds_api.h | 8 +++++++- rehlds/rehlds/rehlds_api_impl.cpp | 6 +++++- rehlds/rehlds/rehlds_api_impl.h | 6 ++++++ 5 files changed, 31 insertions(+), 3 deletions(-) diff --git a/rehlds/engine/sys_dll.cpp b/rehlds/engine/sys_dll.cpp index add30daae..fb2a5fba8 100644 --- a/rehlds/engine/sys_dll.cpp +++ b/rehlds/engine/sys_dll.cpp @@ -770,11 +770,21 @@ const char* EXT_FUNC NameForFunction(uint32 function) return NULL; } -ENTITYINIT EXT_FUNC GetEntityInit(char *pClassName) +ENTITYINIT GetEntityInit_internal(char *pClassName) { return (ENTITYINIT)GetDispatch(pClassName); } +ENTITYINIT EXT_FUNC GetEntityInit_api(char *pClassName) +{ + return g_RehldsHookchains.m_GetEntityInit.callChain(GetEntityInit_internal, pClassName); +} + +ENTITYINIT GetEntityInit(char *pClassName) +{ + return GetEntityInit_api(pClassName); +} + FIELDIOFUNCTION GetIOFunction(char *pName) { return (FIELDIOFUNCTION)GetDispatch(pName); diff --git a/rehlds/engine/sys_dll.h b/rehlds/engine/sys_dll.h index 630235b23..228b09aed 100644 --- a/rehlds/engine/sys_dll.h +++ b/rehlds/engine/sys_dll.h @@ -120,6 +120,8 @@ uint32 FindNameInTable(extensiondll_t *pDll, const char *pName); NOBODY const char *ConvertNameToLocalPlatform(const char *pchInName); uint32 FunctionFromName(const char *pName); const char *NameForFunction(uint32 function); +ENTITYINIT GetEntityInit_internal(char *pClassName); +ENTITYINIT GetEntityInit_api(char *pClassName); ENTITYINIT GetEntityInit(char *pClassName); FIELDIOFUNCTION GetIOFunction(char *pName); NOBODY void DLL_SetModKey(modinfo_t *pinfo, char *pkey, char *pvalue); diff --git a/rehlds/public/rehlds/rehlds_api.h b/rehlds/public/rehlds/rehlds_api.h index 506d474b1..5b8a40d77 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 8 +#define REHLDS_API_VERSION_MINOR 9 //Steam_NotifyClientConnect hook typedef IHookChain IRehldsHook_Steam_NotifyClientConnect; @@ -207,6 +207,11 @@ typedef IVoidHookChainRegistry<> IRehldsHookRegistry_SV_Frame; typedef IHookChain IRehldsHook_SV_ShouldSendConsistencyList; typedef IHookChainRegistry IRehldsHookRegistry_SV_ShouldSendConsistencyList; +//GetEntityInit hook +typedef IHookChain IRehldsHook_GetEntityInit; +typedef IHookChainRegistry IRehldsHookRegistry_GetEntityInit; + + class IRehldsHookchains { public: virtual ~IRehldsHookchains() { } @@ -253,6 +258,7 @@ class IRehldsHookchains { virtual IRehldsHookRegistry_SV_CheckConnectionLessRateLimits* SV_CheckConnectionLessRateLimits() = 0; virtual IRehldsHookRegistry_SV_Frame* SV_Frame() = 0; virtual IRehldsHookRegistry_SV_ShouldSendConsistencyList* SV_ShouldSendConsistencyList() = 0; + virtual IRehldsHookRegistry_GetEntityInit* GetEntityInit() = 0; }; struct RehldsFuncs_t { diff --git a/rehlds/rehlds/rehlds_api_impl.cpp b/rehlds/rehlds/rehlds_api_impl.cpp index 838305c8c..7cfe15e8a 100644 --- a/rehlds/rehlds/rehlds_api_impl.cpp +++ b/rehlds/rehlds/rehlds_api_impl.cpp @@ -515,7 +515,7 @@ RehldsFuncs_t g_RehldsApiFuncs = &AddCvarListener_api, &RemoveExtDll_api, &RemoveCvarListener_api, - &GetEntityInit, + &GetEntityInit_api, &MSG_ReadChar_api, &MSG_ReadByte_api, &MSG_ReadLong_api, @@ -831,6 +831,10 @@ IRehldsHookRegistry_SV_ShouldSendConsistencyList* CRehldsHookchains::SV_ShouldSe return &m_SV_ShouldSendConsistencyList; } +IRehldsHookRegistry_GetEntityInit* CRehldsHookchains::GetEntityInit() { + return &m_GetEntityInit; +} + 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 3af1e9409..835a24b1d 100644 --- a/rehlds/rehlds/rehlds_api_impl.h +++ b/rehlds/rehlds/rehlds_api_impl.h @@ -202,6 +202,10 @@ typedef IVoidHookChainRegistryImpl<> CRehldsHookRegistry_SV_Frame; typedef IHookChainImpl CRehldsHook_SV_ShouldSendConsistencyList; typedef IHookChainRegistryImpl CRehldsHookRegistry_SV_ShouldSendConsistencyList; +//GetEntityInit hook +typedef IHookChainImpl CRehldsHook_GetEntityInit; +typedef IHookChainRegistryImpl CRehldsHookRegistry_GetEntityInit; + class CRehldsHookchains : public IRehldsHookchains { public: CRehldsHookRegistry_Steam_NotifyClientConnect m_Steam_NotifyClientConnect; @@ -246,6 +250,7 @@ class CRehldsHookchains : public IRehldsHookchains { CRehldsHookRegistry_SV_CheckConnectionLessRateLimits m_SV_CheckConnectionLessRateLimits; CRehldsHookRegistry_SV_Frame m_SV_Frame; CRehldsHookRegistry_SV_ShouldSendConsistencyList m_SV_ShouldSendConsistencyList; + CRehldsHookRegistry_GetEntityInit m_GetEntityInit; public: EXT_FUNC virtual IRehldsHookRegistry_Steam_NotifyClientConnect* Steam_NotifyClientConnect(); @@ -290,6 +295,7 @@ class CRehldsHookchains : public IRehldsHookchains { EXT_FUNC virtual IRehldsHookRegistry_SV_CheckConnectionLessRateLimits* SV_CheckConnectionLessRateLimits(); EXT_FUNC virtual IRehldsHookRegistry_SV_Frame* SV_Frame(); EXT_FUNC virtual IRehldsHookRegistry_SV_ShouldSendConsistencyList* SV_ShouldSendConsistencyList(); + EXT_FUNC virtual IRehldsHookRegistry_GetEntityInit* GetEntityInit(); }; extern CRehldsHookchains g_RehldsHookchains; From 26ef1170ce4f7bf107e200c019055897adae5105 Mon Sep 17 00:00:00 2001 From: s1lentq Date: Fri, 7 May 2021 02:57:57 +0700 Subject: [PATCH 2/2] version.h: bump minor version --- rehlds/version/version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rehlds/version/version.h b/rehlds/version/version.h index d2099330f..43f40089e 100644 --- a/rehlds/version/version.h +++ b/rehlds/version/version.h @@ -6,5 +6,5 @@ #pragma once #define VERSION_MAJOR 3 -#define VERSION_MINOR 8 +#define VERSION_MINOR 9 #define VERSION_MAINTENANCE 0