Skip to content

Commit

Permalink
Implement RH_SV_SendResources hook
Browse files Browse the repository at this point in the history
  • Loading branch information
ShadowsAdi committed Mar 3, 2024
1 parent a7043d1 commit 69b223c
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 0 deletions.
6 changes: 6 additions & 0 deletions reapi/extra/amxmodx/scripting/include/reapi_engine_const.inc
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,12 @@ enum EngineFunc
* Params: (const cmd[], source, id)
*/
RH_ExecuteServerStringCmd,

/*
* Description: Called when server sends resources list and location.
* Params: ()
*/
RH_SV_SendResources,

};

Expand Down
5 changes: 5 additions & 0 deletions reapi/include/cssdk/engine/rehlds_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,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 @@ -317,6 +321,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
10 changes: 10 additions & 0 deletions reapi/src/hook_callback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,16 @@ void ExecuteServerStringCmd(IRehldsHook_ExecuteServerStringCmd* chain, const cha
callVoidForward(RH_ExecuteServerStringCmd, original, cmdName, cmdSrc, cmdSrc == src_client ? cl->GetId() + 1 : AMX_NULLENT);
}

void SV_SendResources(IRehldsHook_SV_SendResources* chain, sizebuf_t *msg)
{
auto original = [chain](sizebuf_t *_msg)
{
chain->callNext(_msg);
};

callVoidForward(RH_SV_SendResources, original, msg);
}

/*
* ReGameDLL functions
*/
Expand Down
1 change: 1 addition & 0 deletions reapi/src/hook_callback.h
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@ void Con_Printf(IRehldsHook_Con_Printf *chain, const char *string);
int PF_precache_generic_I(IRehldsHook_PF_precache_generic_I *chain, const char *s);
int PF_precache_model_I(IRehldsHook_PF_precache_model_I *chain, char *s);
int PF_precache_sound_I(IRehldsHook_PF_precache_sound_I *chain, const char *s);
void SV_SendResources(IRehldsHook_SV_SendResources *chain, sizebuf_t *msg);

struct EventPrecache_args_t
{
Expand Down
1 change: 1 addition & 0 deletions reapi/src/hook_list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ hook_t hooklist_engine[] = {
ENG(SV_ClientPrintf),
ENG(SV_AllowPhysent),
ENG(ExecuteServerStringCmd),
ENG(SV_SendResources),

};

Expand Down
1 change: 1 addition & 0 deletions reapi/src/hook_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ enum EngineFunc
RH_SV_ClientPrintf,
RH_SV_AllowPhysent,
RH_ExecuteServerStringCmd,
RH_SV_SendResources,

// [...]
};
Expand Down

0 comments on commit 69b223c

Please sign in to comment.