From 82a3d1d08412d53a0f48f01283ea36d38dd905c8 Mon Sep 17 00:00:00 2001 From: Adrian Cirstea <54354938+ShadowsAdi@users.noreply.github.com> Date: Fri, 10 May 2024 14:15:22 +0300 Subject: [PATCH] Add `SV_SendResources` hook (#1024) * Implement `SV_AddResources` hook --- rehlds/engine/server.h | 1 + rehlds/engine/sv_main.cpp | 5 +++++ 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 +- 6 files changed, 23 insertions(+), 2 deletions(-) diff --git a/rehlds/engine/server.h b/rehlds/engine/server.h index cbf31e8..9446f14 100644 --- a/rehlds/engine/server.h +++ b/rehlds/engine/server.h @@ -461,6 +461,7 @@ void SV_QueryMovevarsChanged(void); void SV_SendServerinfo(sizebuf_t *msg, client_t *client); void SV_SendServerinfo_internal(sizebuf_t *msg, client_t *client); void SV_SendResources(sizebuf_t *msg); +void SV_SendResources_internal(sizebuf_t *msg); void SV_WriteClientdataToMessage(client_t *client, sizebuf_t *msg); void SV_WriteSpawn(sizebuf_t *msg); void SV_SendUserReg(sizebuf_t *msg); diff --git a/rehlds/engine/sv_main.cpp b/rehlds/engine/sv_main.cpp index dc2c517..c015f49 100644 --- a/rehlds/engine/sv_main.cpp +++ b/rehlds/engine/sv_main.cpp @@ -1199,6 +1199,11 @@ void SV_SendServerinfo_internal(sizebuf_t *msg, client_t *client) } void SV_SendResources(sizebuf_t *msg) +{ + g_RehldsHookchains.m_SV_SendResources.callChain(SV_SendResources_internal, msg); +} + +void EXT_FUNC SV_SendResources_internal(sizebuf_t *msg) { unsigned char nullbuffer[32]; Q_memset(nullbuffer, 0, sizeof(nullbuffer)); diff --git a/rehlds/public/rehlds/rehlds_api.h b/rehlds/public/rehlds/rehlds_api.h index bc83581..b82f332 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 13 +#define REHLDS_API_VERSION_MINOR 14 //Steam_NotifyClientConnect hook typedef IHookChain IRehldsHook_Steam_NotifyClientConnect; @@ -259,6 +259,10 @@ typedef IVoidHookChainRegistry IRehldsHookRegistry_SV_ClientPrintf typedef IHookChain IRehldsHook_SV_AllowPhysent; typedef IHookChainRegistry IRehldsHookRegistry_SV_AllowPhysent; +//SV_SendResources hook +typedef IVoidHookChain IRehldsHook_SV_SendResources; +typedef IVoidHookChainRegistry IRehldsHookRegistry_SV_SendResources; + class IRehldsHookchains { public: virtual ~IRehldsHookchains() { } @@ -318,6 +322,7 @@ public: virtual IRehldsHookRegistry_SV_AddResource* SV_AddResource() = 0; virtual IRehldsHookRegistry_SV_ClientPrintf* SV_ClientPrintf() = 0; virtual IRehldsHookRegistry_SV_AllowPhysent* SV_AllowPhysent() = 0; + virtual IRehldsHookRegistry_SV_SendResources* SV_SendResources() = 0; }; struct RehldsFuncs_t { diff --git a/rehlds/rehlds/rehlds_api_impl.cpp b/rehlds/rehlds/rehlds_api_impl.cpp index 8d7f9da..2b4ede0 100644 --- a/rehlds/rehlds/rehlds_api_impl.cpp +++ b/rehlds/rehlds/rehlds_api_impl.cpp @@ -885,6 +885,10 @@ IRehldsHookRegistry_SV_AllowPhysent* CRehldsHookchains::SV_AllowPhysent() { return &m_SV_AllowPhysent; } +IRehldsHookRegistry_SV_SendResources* CRehldsHookchains::SV_SendResources() { + return &m_SV_SendResources; +} + 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 699bd16..6aece98 100644 --- a/rehlds/rehlds/rehlds_api_impl.h +++ b/rehlds/rehlds/rehlds_api_impl.h @@ -254,6 +254,10 @@ typedef IVoidHookChainRegistryImpl CRehldsHookRegistry_SV_ClientPri typedef IHookChainImpl CRehldsHook_SV_AllowPhysent; typedef IHookChainRegistryImpl CRehldsHookRegistry_SV_AllowPhysent; +//SV_SendResources hook +typedef IVoidHookChainImpl CRehldsHook_SV_SendResources; +typedef IVoidHookChainRegistryImpl CRehldsHookRegistry_SV_SendResources; + class CRehldsHookchains : public IRehldsHookchains { public: CRehldsHookRegistry_Steam_NotifyClientConnect m_Steam_NotifyClientConnect; @@ -311,6 +315,7 @@ public: CRehldsHookRegistry_SV_AddResource m_SV_AddResource; CRehldsHookRegistry_SV_ClientPrintf m_SV_ClientPrintf; CRehldsHookRegistry_SV_AllowPhysent m_SV_AllowPhysent; + CRehldsHookRegistry_SV_SendResources m_SV_SendResources; public: EXT_FUNC virtual IRehldsHookRegistry_Steam_NotifyClientConnect* Steam_NotifyClientConnect(); @@ -368,6 +373,7 @@ public: 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_SV_SendResources* SV_SendResources(); }; extern CRehldsHookchains g_RehldsHookchains; diff --git a/rehlds/version/version.h b/rehlds/version/version.h index 55a454b..3bed179 100644 --- a/rehlds/version/version.h +++ b/rehlds/version/version.h @@ -6,5 +6,5 @@ #pragma once #define VERSION_MAJOR 3 -#define VERSION_MINOR 13 +#define VERSION_MINOR 14 #define VERSION_MAINTENANCE 0