2
0
mirror of https://github.com/rehlds/rehlds.git synced 2024-12-29 08:05:50 +03:00

Add GetEntityInit hook (#832)

* Add GetEntityInit hook
This commit is contained in:
Karol Szuster 2021-06-14 00:43:27 +02:00 committed by GitHub
parent d9613d2093
commit 81fe334545
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 32 additions and 4 deletions

View File

@ -770,11 +770,21 @@ const char* EXT_FUNC NameForFunction(uint32 function)
return NULL; return NULL;
} }
ENTITYINIT EXT_FUNC GetEntityInit(char *pClassName) ENTITYINIT GetEntityInit_internal(char *pClassName)
{ {
return (ENTITYINIT)GetDispatch(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) FIELDIOFUNCTION GetIOFunction(char *pName)
{ {
return (FIELDIOFUNCTION)GetDispatch(pName); return (FIELDIOFUNCTION)GetDispatch(pName);

View File

@ -120,6 +120,8 @@ uint32 FindNameInTable(extensiondll_t *pDll, const char *pName);
NOBODY const char *ConvertNameToLocalPlatform(const char *pchInName); NOBODY const char *ConvertNameToLocalPlatform(const char *pchInName);
uint32 FunctionFromName(const char *pName); uint32 FunctionFromName(const char *pName);
const char *NameForFunction(uint32 function); const char *NameForFunction(uint32 function);
ENTITYINIT GetEntityInit_internal(char *pClassName);
ENTITYINIT GetEntityInit_api(char *pClassName);
ENTITYINIT GetEntityInit(char *pClassName); ENTITYINIT GetEntityInit(char *pClassName);
FIELDIOFUNCTION GetIOFunction(char *pName); FIELDIOFUNCTION GetIOFunction(char *pName);
NOBODY void DLL_SetModKey(modinfo_t *pinfo, char *pkey, char *pvalue); NOBODY void DLL_SetModKey(modinfo_t *pinfo, char *pkey, char *pvalue);

View File

@ -37,7 +37,7 @@
#include "pr_dlls.h" #include "pr_dlls.h"
#define REHLDS_API_VERSION_MAJOR 3 #define REHLDS_API_VERSION_MAJOR 3
#define REHLDS_API_VERSION_MINOR 8 #define REHLDS_API_VERSION_MINOR 9
//Steam_NotifyClientConnect hook //Steam_NotifyClientConnect hook
typedef IHookChain<qboolean, IGameClient*, const void*, unsigned int> IRehldsHook_Steam_NotifyClientConnect; typedef IHookChain<qboolean, IGameClient*, const void*, unsigned int> IRehldsHook_Steam_NotifyClientConnect;
@ -207,6 +207,11 @@ typedef IVoidHookChainRegistry<> IRehldsHookRegistry_SV_Frame;
typedef IHookChain<bool, IGameClient *, bool> IRehldsHook_SV_ShouldSendConsistencyList; typedef IHookChain<bool, IGameClient *, bool> IRehldsHook_SV_ShouldSendConsistencyList;
typedef IHookChainRegistry<bool, IGameClient *, bool> IRehldsHookRegistry_SV_ShouldSendConsistencyList; typedef IHookChainRegistry<bool, IGameClient *, bool> IRehldsHookRegistry_SV_ShouldSendConsistencyList;
//GetEntityInit hook
typedef IHookChain<ENTITYINIT, char *> IRehldsHook_GetEntityInit;
typedef IHookChainRegistry<ENTITYINIT, char *> IRehldsHookRegistry_GetEntityInit;
class IRehldsHookchains { class IRehldsHookchains {
public: public:
virtual ~IRehldsHookchains() { } virtual ~IRehldsHookchains() { }
@ -253,6 +258,7 @@ public:
virtual IRehldsHookRegistry_SV_CheckConnectionLessRateLimits* SV_CheckConnectionLessRateLimits() = 0; virtual IRehldsHookRegistry_SV_CheckConnectionLessRateLimits* SV_CheckConnectionLessRateLimits() = 0;
virtual IRehldsHookRegistry_SV_Frame* SV_Frame() = 0; virtual IRehldsHookRegistry_SV_Frame* SV_Frame() = 0;
virtual IRehldsHookRegistry_SV_ShouldSendConsistencyList* SV_ShouldSendConsistencyList() = 0; virtual IRehldsHookRegistry_SV_ShouldSendConsistencyList* SV_ShouldSendConsistencyList() = 0;
virtual IRehldsHookRegistry_GetEntityInit* GetEntityInit() = 0;
}; };
struct RehldsFuncs_t { struct RehldsFuncs_t {

View File

@ -515,7 +515,7 @@ RehldsFuncs_t g_RehldsApiFuncs =
&AddCvarListener_api, &AddCvarListener_api,
&RemoveExtDll_api, &RemoveExtDll_api,
&RemoveCvarListener_api, &RemoveCvarListener_api,
&GetEntityInit, &GetEntityInit_api,
&MSG_ReadChar_api, &MSG_ReadChar_api,
&MSG_ReadByte_api, &MSG_ReadByte_api,
&MSG_ReadLong_api, &MSG_ReadLong_api,
@ -831,6 +831,10 @@ IRehldsHookRegistry_SV_ShouldSendConsistencyList* CRehldsHookchains::SV_ShouldSe
return &m_SV_ShouldSendConsistencyList; return &m_SV_ShouldSendConsistencyList;
} }
IRehldsHookRegistry_GetEntityInit* CRehldsHookchains::GetEntityInit() {
return &m_GetEntityInit;
}
int EXT_FUNC CRehldsApi::GetMajorVersion() int EXT_FUNC CRehldsApi::GetMajorVersion()
{ {
return REHLDS_API_VERSION_MAJOR; return REHLDS_API_VERSION_MAJOR;

View File

@ -202,6 +202,10 @@ typedef IVoidHookChainRegistryImpl<> CRehldsHookRegistry_SV_Frame;
typedef IHookChainImpl<bool, IGameClient *, bool> CRehldsHook_SV_ShouldSendConsistencyList; typedef IHookChainImpl<bool, IGameClient *, bool> CRehldsHook_SV_ShouldSendConsistencyList;
typedef IHookChainRegistryImpl<bool, IGameClient *, bool> CRehldsHookRegistry_SV_ShouldSendConsistencyList; typedef IHookChainRegistryImpl<bool, IGameClient *, bool> CRehldsHookRegistry_SV_ShouldSendConsistencyList;
//GetEntityInit hook
typedef IHookChainImpl<ENTITYINIT, char *> CRehldsHook_GetEntityInit;
typedef IHookChainRegistryImpl<ENTITYINIT, char *> CRehldsHookRegistry_GetEntityInit;
class CRehldsHookchains : public IRehldsHookchains { class CRehldsHookchains : public IRehldsHookchains {
public: public:
CRehldsHookRegistry_Steam_NotifyClientConnect m_Steam_NotifyClientConnect; CRehldsHookRegistry_Steam_NotifyClientConnect m_Steam_NotifyClientConnect;
@ -246,6 +250,7 @@ public:
CRehldsHookRegistry_SV_CheckConnectionLessRateLimits m_SV_CheckConnectionLessRateLimits; CRehldsHookRegistry_SV_CheckConnectionLessRateLimits m_SV_CheckConnectionLessRateLimits;
CRehldsHookRegistry_SV_Frame m_SV_Frame; CRehldsHookRegistry_SV_Frame m_SV_Frame;
CRehldsHookRegistry_SV_ShouldSendConsistencyList m_SV_ShouldSendConsistencyList; CRehldsHookRegistry_SV_ShouldSendConsistencyList m_SV_ShouldSendConsistencyList;
CRehldsHookRegistry_GetEntityInit m_GetEntityInit;
public: public:
EXT_FUNC virtual IRehldsHookRegistry_Steam_NotifyClientConnect* Steam_NotifyClientConnect(); EXT_FUNC virtual IRehldsHookRegistry_Steam_NotifyClientConnect* Steam_NotifyClientConnect();
@ -290,6 +295,7 @@ public:
EXT_FUNC virtual IRehldsHookRegistry_SV_CheckConnectionLessRateLimits* SV_CheckConnectionLessRateLimits(); EXT_FUNC virtual IRehldsHookRegistry_SV_CheckConnectionLessRateLimits* SV_CheckConnectionLessRateLimits();
EXT_FUNC virtual IRehldsHookRegistry_SV_Frame* SV_Frame(); EXT_FUNC virtual IRehldsHookRegistry_SV_Frame* SV_Frame();
EXT_FUNC virtual IRehldsHookRegistry_SV_ShouldSendConsistencyList* SV_ShouldSendConsistencyList(); EXT_FUNC virtual IRehldsHookRegistry_SV_ShouldSendConsistencyList* SV_ShouldSendConsistencyList();
EXT_FUNC virtual IRehldsHookRegistry_GetEntityInit* GetEntityInit();
}; };
extern CRehldsHookchains g_RehldsHookchains; extern CRehldsHookchains g_RehldsHookchains;

View File

@ -6,5 +6,5 @@
#pragma once #pragma once
#define VERSION_MAJOR 3 #define VERSION_MAJOR 3
#define VERSION_MINOR 8 #define VERSION_MINOR 9
#define VERSION_MAINTENANCE 0 #define VERSION_MAINTENANCE 0