Skip to content

Commit

Permalink
Add SV_SendResources hook (#1024)
Browse files Browse the repository at this point in the history
* Implement `SV_AddResources` hook
  • Loading branch information
ShadowsAdi authored May 10, 2024
1 parent 693b51c commit 82a3d1d
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 2 deletions.
1 change: 1 addition & 0 deletions rehlds/engine/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions rehlds/engine/sv_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
7 changes: 6 additions & 1 deletion rehlds/public/rehlds/rehlds_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<qboolean, IGameClient*, const void*, unsigned int> IRehldsHook_Steam_NotifyClientConnect;
Expand Down 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;

//SV_SendResources hook
typedef IVoidHookChain<sizebuf_t *> IRehldsHook_SV_SendResources;
typedef IVoidHookChainRegistry<sizebuf_t *> IRehldsHookRegistry_SV_SendResources;

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_SV_SendResources* SV_SendResources() = 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 @@ -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;
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;

//SV_SendResources hook
typedef IVoidHookChainImpl<sizebuf_t *> CRehldsHook_SV_SendResources;
typedef IVoidHookChainRegistryImpl<sizebuf_t *> CRehldsHookRegistry_SV_SendResources;

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_SV_SendResources m_SV_SendResources;

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_SV_SendResources* SV_SendResources();
};

extern CRehldsHookchains g_RehldsHookchains;
Expand Down
2 changes: 1 addition & 1 deletion rehlds/version/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
#pragma once

#define VERSION_MAJOR 3
#define VERSION_MINOR 13
#define VERSION_MINOR 14
#define VERSION_MAINTENANCE 0

0 comments on commit 82a3d1d

Please sign in to comment.