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

API: Add hooks "ED_<Alloc|Free>" (#867)

* Update pr_edict.h

* Update pr_edict.cpp

* Update rehlds_api_impl.cpp

* Update rehlds_api_impl.h

* Update rehlds_api.h

* Update pr_edict.h

* Update pr_edict.cpp

* Update rehlds_api_impl.cpp

* Update rehlds_api_impl.h

* Update rehlds_api.h

* Update pr_edict.cpp
This commit is contained in:
StevenKal 2021-10-20 16:39:19 +02:00 committed by GitHub
parent aaffe43e3e
commit 04ddafe637
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 43 additions and 1 deletions

View File

@ -37,6 +37,11 @@ void ED_ClearEdict(edict_t *e)
} }
edict_t *ED_Alloc(void) edict_t *ED_Alloc(void)
{
return g_RehldsHookchains.m_ED_Alloc.callChain(ED_Alloc_internal);
}
edict_t *EXT_FUNC ED_Alloc_internal(void)
{ {
int i; int i;
edict_t *e; edict_t *e;
@ -71,6 +76,11 @@ edict_t *ED_Alloc(void)
} }
void ED_Free(edict_t *ed) void ED_Free(edict_t *ed)
{
g_RehldsHookchains.m_ED_Free.callChain(ED_Free_internal, ed);
}
void EXT_FUNC ED_Free_internal(edict_t *ed)
{ {
if (!ed->free) if (!ed->free)
{ {

View File

@ -35,7 +35,9 @@
void ED_ClearEdict(edict_t *e); void ED_ClearEdict(edict_t *e);
edict_t *ED_Alloc(void); edict_t *ED_Alloc(void);
edict_t *ED_Alloc_internal(void);
void ED_Free(edict_t *ed); void ED_Free(edict_t *ed);
void ED_Free_internal(edict_t *ed);
NOXREF void ED_Count(void); NOXREF void ED_Count(void);
char *ED_NewString(const char *string); char *ED_NewString(const char *string);
char *ED_ParseEdict(char *data, edict_t *ent); char *ED_ParseEdict(char *data, edict_t *ent);

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 10 #define REHLDS_API_VERSION_MINOR 11
//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;
@ -211,6 +211,14 @@ typedef IHookChainRegistry<bool, IGameClient *, bool> IRehldsHookRegistry_SV_Sho
typedef IHookChain<ENTITYINIT, char *> IRehldsHook_GetEntityInit; typedef IHookChain<ENTITYINIT, char *> IRehldsHook_GetEntityInit;
typedef IHookChainRegistry<ENTITYINIT, char *> IRehldsHookRegistry_GetEntityInit; typedef IHookChainRegistry<ENTITYINIT, char *> IRehldsHookRegistry_GetEntityInit;
//ED_Alloc hook
typedef IHookChain<edict_t *> IRehldsHook_ED_Alloc;
typedef IHookChainRegistry<edict_t *> IRehldsHookRegistry_ED_Alloc;
//ED_Free hook
typedef IVoidHookChain<edict_t *> IRehldsHook_ED_Free;
typedef IVoidHookChainRegistry<edict_t *> IRehldsHookRegistry_ED_Free;
class IRehldsHookchains { class IRehldsHookchains {
public: public:
@ -259,6 +267,8 @@ public:
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; virtual IRehldsHookRegistry_GetEntityInit* GetEntityInit() = 0;
virtual IRehldsHookRegistry_ED_Alloc* ED_Alloc() = 0;
virtual IRehldsHookRegistry_ED_Free* ED_Free() = 0;
}; };
struct RehldsFuncs_t { struct RehldsFuncs_t {

View File

@ -835,6 +835,14 @@ IRehldsHookRegistry_GetEntityInit* CRehldsHookchains::GetEntityInit() {
return &m_GetEntityInit; return &m_GetEntityInit;
} }
IRehldsHookRegistry_ED_Alloc* CRehldsHookchains::ED_Alloc() {
return &m_ED_Alloc;
}
IRehldsHookRegistry_ED_Free* CRehldsHookchains::ED_Free() {
return &m_ED_Free;
}
int EXT_FUNC CRehldsApi::GetMajorVersion() int EXT_FUNC CRehldsApi::GetMajorVersion()
{ {
return REHLDS_API_VERSION_MAJOR; return REHLDS_API_VERSION_MAJOR;

View File

@ -206,6 +206,14 @@ typedef IHookChainRegistryImpl<bool, IGameClient *, bool> CRehldsHookRegistry_SV
typedef IHookChainImpl<ENTITYINIT, char *> CRehldsHook_GetEntityInit; typedef IHookChainImpl<ENTITYINIT, char *> CRehldsHook_GetEntityInit;
typedef IHookChainRegistryImpl<ENTITYINIT, char *> CRehldsHookRegistry_GetEntityInit; typedef IHookChainRegistryImpl<ENTITYINIT, char *> CRehldsHookRegistry_GetEntityInit;
//ED_Alloc hook
typedef IHookChainImpl<edict_t *> CRehldsHook_ED_Alloc;
typedef IHookChainRegistryImpl<edict_t *> CRehldsHookRegistry_ED_Alloc;
//ED_Free hook
typedef IVoidHookChainImpl<edict_t *> CRehldsHook_ED_Free;
typedef IVoidHookChainRegistryImpl<edict_t *> CRehldsHookRegistry_ED_Free;
class CRehldsHookchains : public IRehldsHookchains { class CRehldsHookchains : public IRehldsHookchains {
public: public:
CRehldsHookRegistry_Steam_NotifyClientConnect m_Steam_NotifyClientConnect; CRehldsHookRegistry_Steam_NotifyClientConnect m_Steam_NotifyClientConnect;
@ -251,6 +259,8 @@ public:
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; CRehldsHookRegistry_GetEntityInit m_GetEntityInit;
CRehldsHookRegistry_ED_Alloc m_ED_Alloc;
CRehldsHookRegistry_ED_Free m_ED_Free;
public: public:
EXT_FUNC virtual IRehldsHookRegistry_Steam_NotifyClientConnect* Steam_NotifyClientConnect(); EXT_FUNC virtual IRehldsHookRegistry_Steam_NotifyClientConnect* Steam_NotifyClientConnect();
@ -296,6 +306,8 @@ public:
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(); EXT_FUNC virtual IRehldsHookRegistry_GetEntityInit* GetEntityInit();
EXT_FUNC virtual IRehldsHookRegistry_ED_Alloc* ED_Alloc();
EXT_FUNC virtual IRehldsHookRegistry_ED_Free* ED_Free();
}; };
extern CRehldsHookchains g_RehldsHookchains; extern CRehldsHookchains g_RehldsHookchains;