Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add GetDispatch hook
  • Loading branch information
tmp64 committed Aug 19, 2023
commit 32348af364f0f20aab60f4c821fe024f30879e60
5 changes: 5 additions & 0 deletions rehlds/engine/sys_dll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,11 @@ qboolean EXT_FUNC Voice_SetClientListening(int iReceiver, int iSender, qboolean
}

DISPATCHFUNCTION GetDispatch(char *pname)
{
return g_RehldsHookchains.m_GetDispatch.callChain(GetDispatch_Internal, pname);
}

DISPATCHFUNCTION GetDispatch_Internal(char* pname)
{
int i;
DISPATCHFUNCTION pDispatch;
Expand Down
1 change: 1 addition & 0 deletions rehlds/engine/sys_dll.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ NOBODY void GameSetBackground(qboolean bNewSetting);
qboolean Voice_GetClientListening(int iReceiver, int iSender);
qboolean Voice_SetClientListening(int iReceiver, int iSender, qboolean bListen);
DISPATCHFUNCTION GetDispatch(char *pname);
DISPATCHFUNCTION GetDispatch_Internal(char* pname);
const char *FindAddressInTable(extensiondll_t *pDll, uint32 function);
uint32 FindNameInTable(extensiondll_t *pDll, const char *pName);
NOBODY const char *ConvertNameToLocalPlatform(const char *pchInName);
Expand Down
5 changes: 5 additions & 0 deletions rehlds/public/rehlds/rehlds_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,10 @@ typedef IVoidHookChainRegistry<const char *> IRehldsHookRegistry_SV_ClientPrintf
typedef IHookChain<bool, edict_t*, edict_t*> IRehldsHook_SV_AllowPhysent;
typedef IHookChainRegistry<bool, edict_t*, edict_t*> IRehldsHookRegistry_SV_AllowPhysent;

//GetDispatch hook
typedef IHookChain<DISPATCHFUNCTION, char*> IRehldsHook_GetDispatch;
typedef IHookChainRegistry<DISPATCHFUNCTION, char*> IRehldsHookRegistry_GetDispatch;

class IRehldsHookchains {
public:
virtual ~IRehldsHookchains() { }
Expand Down Expand Up @@ -318,6 +322,7 @@ class IRehldsHookchains {
virtual IRehldsHookRegistry_SV_AddResource* SV_AddResource() = 0;
virtual IRehldsHookRegistry_SV_ClientPrintf* SV_ClientPrintf() = 0;
virtual IRehldsHookRegistry_SV_AllowPhysent* SV_AllowPhysent() = 0;
virtual IRehldsHookRegistry_GetDispatch* GetDispatch() = 0;
};

struct RehldsFuncs_t {
Expand Down
4 changes: 4 additions & 0 deletions rehlds/rehlds/rehlds_api_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -883,6 +883,10 @@ IRehldsHookRegistry_SV_AllowPhysent* CRehldsHookchains::SV_AllowPhysent() {
return &m_SV_AllowPhysent;
}

EXT_FUNC IRehldsHookRegistry_GetDispatch* CRehldsHookchains::GetDispatch() {
return &m_GetDispatch;
}

int EXT_FUNC CRehldsApi::GetMajorVersion()
{
return REHLDS_API_VERSION_MAJOR;
Expand Down
6 changes: 6 additions & 0 deletions rehlds/rehlds/rehlds_api_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,10 @@ typedef IVoidHookChainRegistryImpl<const char*> CRehldsHookRegistry_SV_ClientPri
typedef IHookChainImpl<bool, edict_t*, edict_t*> CRehldsHook_SV_AllowPhysent;
typedef IHookChainRegistryImpl<bool, edict_t*, edict_t*> CRehldsHookRegistry_SV_AllowPhysent;

//GetDispatch hook
typedef IHookChainImpl<DISPATCHFUNCTION, char*> CRehldsHook_GetDispatch;
typedef IHookChainRegistryImpl<DISPATCHFUNCTION, char*> CRehldsHookRegistry_GetDispatch;

class CRehldsHookchains : public IRehldsHookchains {
public:
CRehldsHookRegistry_Steam_NotifyClientConnect m_Steam_NotifyClientConnect;
Expand Down Expand Up @@ -311,6 +315,7 @@ class CRehldsHookchains : public IRehldsHookchains {
CRehldsHookRegistry_SV_AddResource m_SV_AddResource;
CRehldsHookRegistry_SV_ClientPrintf m_SV_ClientPrintf;
CRehldsHookRegistry_SV_AllowPhysent m_SV_AllowPhysent;
CRehldsHookRegistry_GetDispatch m_GetDispatch;

public:
EXT_FUNC virtual IRehldsHookRegistry_Steam_NotifyClientConnect* Steam_NotifyClientConnect();
Expand Down Expand Up @@ -368,6 +373,7 @@ class CRehldsHookchains : public IRehldsHookchains {
EXT_FUNC virtual IRehldsHookRegistry_SV_AddResource* SV_AddResource();
EXT_FUNC virtual IRehldsHookRegistry_SV_ClientPrintf* SV_ClientPrintf();
EXT_FUNC virtual IRehldsHookRegistry_SV_AllowPhysent* SV_AllowPhysent();
EXT_FUNC virtual IRehldsHookRegistry_GetDispatch* GetDispatch();
};

extern CRehldsHookchains g_RehldsHookchains;
Expand Down