2
0
mirror of https://github.com/s1lentq/reapi.git synced 2024-10-16 15:27:06 +03:00

Implement RH_SV_SendResources hook (#308)

This commit is contained in:
Adrian Cirstea 2024-05-13 16:06:11 +03:00 committed by GitHub
parent d98450249e
commit 6c6ff95e9b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 35 additions and 2 deletions

View File

@ -100,9 +100,10 @@ enum EngineFunc
/* /*
* Description: Called when client it's in the scoreboard * Description: Called when client it's in the scoreboard
* Params: (const this) * Params: (const client)
*/ */
RH_SV_EmitPings, RH_SV_EmitPings,
/* /*
* Description: Called when an entity is created. * Description: Called when an entity is created.
* Return type: Edict * (Entity index) * Return type: Edict * (Entity index)
@ -184,6 +185,12 @@ enum EngineFunc
*/ */
RH_ExecuteServerStringCmd, RH_ExecuteServerStringCmd,
/*
* Description: Called when server sends resources list and location.
* Params: (const client)
*/
RH_SV_SendResources,
}; };
/** /**

View File

@ -258,6 +258,10 @@ typedef IVoidHookChainRegistry<const char *> IRehldsHookRegistry_SV_ClientPrintf
typedef IHookChain<bool, edict_t*, edict_t*> IRehldsHook_SV_AllowPhysent; typedef IHookChain<bool, edict_t*, edict_t*> IRehldsHook_SV_AllowPhysent;
typedef IHookChainRegistry<bool, edict_t*, edict_t*> IRehldsHookRegistry_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 { class IRehldsHookchains {
public: public:
virtual ~IRehldsHookchains() { } virtual ~IRehldsHookchains() { }
@ -317,6 +321,7 @@ public:
virtual IRehldsHookRegistry_SV_AddResource* SV_AddResource() = 0; virtual IRehldsHookRegistry_SV_AddResource* SV_AddResource() = 0;
virtual IRehldsHookRegistry_SV_ClientPrintf* SV_ClientPrintf() = 0; virtual IRehldsHookRegistry_SV_ClientPrintf* SV_ClientPrintf() = 0;
virtual IRehldsHookRegistry_SV_AllowPhysent* SV_AllowPhysent() = 0; virtual IRehldsHookRegistry_SV_AllowPhysent* SV_AllowPhysent() = 0;
virtual IRehldsHookRegistry_SV_SendResources* SV_SendResources() = 0;
}; };
struct RehldsFuncs_t { struct RehldsFuncs_t {

View File

@ -242,6 +242,22 @@ void ExecuteServerStringCmd(IRehldsHook_ExecuteServerStringCmd* chain, const cha
callVoidForward(RH_ExecuteServerStringCmd, original, cmdName, cmdSrc, cmdSrc == src_client ? cl->GetId() + 1 : AMX_NULLENT); callVoidForward(RH_ExecuteServerStringCmd, original, cmdName, cmdSrc, cmdSrc == src_client ? cl->GetId() + 1 : AMX_NULLENT);
} }
void SV_SendResources_AMXX(SV_SendResources_t *data, IGameClient *cl)
{
auto original = [data](int _cl)
{
data->m_chain->callNext(data->m_args);
};
callVoidForward(RH_SV_SendResources, original, cl ? cl->GetId() + 1 : AMX_NULLENT);
}
void SV_SendResources(IRehldsHook_SV_SendResources *chain, sizebuf_t *msg)
{
SV_SendResources_t data(chain, msg);
SV_SendResources_AMXX(&data, g_RehldsFuncs->GetHostClient());
}
/* /*
* ReGameDLL functions * ReGameDLL functions
*/ */

View File

@ -371,6 +371,10 @@ int PF_precache_generic_I(IRehldsHook_PF_precache_generic_I *chain, const char *
int PF_precache_model_I(IRehldsHook_PF_precache_model_I *chain, 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); int PF_precache_sound_I(IRehldsHook_PF_precache_sound_I *chain, const char *s);
using SV_SendResources_t = hookdata_t<IRehldsHook_SV_SendResources *, sizebuf_t *>;
void SV_SendResources_AMXX(SV_SendResources_t *data, IGameClient *cl);
void SV_SendResources(IRehldsHook_SV_SendResources *chain, sizebuf_t *msg);
struct EventPrecache_args_t struct EventPrecache_args_t
{ {
EventPrecache_args_t(int _type) : type(_type) {} EventPrecache_args_t(int _type) : type(_type) {}

View File

@ -108,7 +108,7 @@ hook_t hooklist_engine[] = {
ENG(SV_ClientPrintf), ENG(SV_ClientPrintf),
ENG(SV_AllowPhysent), ENG(SV_AllowPhysent),
ENG(ExecuteServerStringCmd), ENG(ExecuteServerStringCmd),
ENG(SV_SendResources, _AMXX),
}; };
#define DLL(h,...) { {}, {}, #h, "ReGameDLL", [](){ return api_cfg.hasReGameDLL(); }, ((!(RG_##h & (MAX_REGION_RANGE - 1)) ? regfunc::current_cell = 1, true : false) || (RG_##h & (MAX_REGION_RANGE - 1)) == regfunc::current_cell++) ? regfunc(h##__VA_ARGS__) : regfunc(#h#__VA_ARGS__), [](){ g_ReGameHookchains->h()->registerHook(&h); }, [](){ g_ReGameHookchains->h()->unregisterHook(&h); }, false} #define DLL(h,...) { {}, {}, #h, "ReGameDLL", [](){ return api_cfg.hasReGameDLL(); }, ((!(RG_##h & (MAX_REGION_RANGE - 1)) ? regfunc::current_cell = 1, true : false) || (RG_##h & (MAX_REGION_RANGE - 1)) == regfunc::current_cell++) ? regfunc(h##__VA_ARGS__) : regfunc(#h#__VA_ARGS__), [](){ g_ReGameHookchains->h()->registerHook(&h); }, [](){ g_ReGameHookchains->h()->unregisterHook(&h); }, false}

View File

@ -117,6 +117,7 @@ enum EngineFunc
RH_SV_ClientPrintf, RH_SV_ClientPrintf,
RH_SV_AllowPhysent, RH_SV_AllowPhysent,
RH_ExecuteServerStringCmd, RH_ExecuteServerStringCmd,
RH_SV_SendResources,
// [...] // [...]
}; };