2
0
mirror of https://github.com/rehlds/reapi.git synced 2024-12-29 08:05:36 +03:00

Implement SV_EmitPings() hook (#212)

* Implement SV_EmitPings hook

* Remove sizebuf_t param and add description

* Change REHLDS_API_VERSION_MINOR

* Update rehlds_api.h

* FIX comment in reapi_engine_const.inc

* virtual SV_EmitPings() order fix

Co-authored-by: Sergey Shorokhov <wopox1337@ya.ru>
This commit is contained in:
Franco Romaniello 2021-10-23 10:24:17 +02:00 committed by GitHub
parent 30af88faf5
commit a16dfd08fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 58 additions and 5 deletions

View File

@ -65,6 +65,12 @@ enum EngineFunc
* Params: (const client) * Params: (const client)
*/ */
RH_ClientConnected, RH_ClientConnected,
/*
* Description: Called when client it's in the scoreboard
* Params: (const this)
*/
RH_SV_EmitPings
}; };
/** /**

View File

@ -35,7 +35,7 @@
#include "model.h" #include "model.h"
#define REHLDS_API_VERSION_MAJOR 3 #define REHLDS_API_VERSION_MAJOR 3
#define REHLDS_API_VERSION_MINOR 0 #define REHLDS_API_VERSION_MINOR 11
//Steam_NotifyClientConnect hook //Steam_NotifyClientConnect hook
typedef IHookChain<qboolean, IGameClient*, const void*, unsigned int> IRehldsHook_Steam_NotifyClientConnect; typedef IHookChain<qboolean, IGameClient*, const void*, unsigned int> IRehldsHook_Steam_NotifyClientConnect;
@ -202,13 +202,25 @@ typedef IVoidHookChain<> IRehldsHook_SV_Frame;
typedef IVoidHookChainRegistry<> IRehldsHookRegistry_SV_Frame; typedef IVoidHookChainRegistry<> IRehldsHookRegistry_SV_Frame;
//SV_ShouldSendConsistencyList hook //SV_ShouldSendConsistencyList hook
typedef IHookChain<bool, IGameClient *, bool> IRehldsHook_SV_ShouldSendConsistencyList; typedef IHookChain<bool, IGameClient*, bool> IRehldsHook_SV_ShouldSendConsistencyList;
typedef IHookChainRegistry<bool, IGameClient *, bool> IRehldsHookRegistry_SV_ShouldSendConsistencyList; typedef IHookChainRegistry<bool, IGameClient*, bool> IRehldsHookRegistry_SV_ShouldSendConsistencyList;
//GetEntityInit hook //GetEntityInit hook
typedef IHookChain<struct entvars_s *, char *> IRehldsHook_GetEntityInit; typedef IHookChain<struct entvars_s *, char *> IRehldsHook_GetEntityInit;
typedef IHookChainRegistry<struct entvars_s *, char *> IRehldsHookRegistry_GetEntityInit; typedef IHookChainRegistry<struct entvars_s *, char *> IRehldsHookRegistry_GetEntityInit;
//SV_EmitPings hook
typedef IHookChain<void, IGameClient *, sizebuf_t *> IRehldsHook_SV_EmitPings;
typedef IHookChainRegistry<void, IGameClient *, sizebuf_t *> IRehldsHookRegistry_SV_EmitPings;
//ED_Alloc hook
typedef IHookChain<edict_t *> IRehldsHook_ED_Alloc;
typedef IHookChainRegistry<edict_t *> IRehldsHookRegistry_ED_Alloc;
//ED_Free hook
typedef IVoidHookChain<edict_t *> IRehldsHook_ED_Free;
typedef IVoidHookChainRegistry<edict_t *> IRehldsHookRegistry_ED_Free;
class IRehldsHookchains { class IRehldsHookchains {
public: public:
virtual ~IRehldsHookchains() { } virtual ~IRehldsHookchains() { }
@ -256,6 +268,9 @@ public:
virtual IRehldsHookRegistry_SV_Frame* SV_Frame() = 0; virtual IRehldsHookRegistry_SV_Frame* SV_Frame() = 0;
virtual IRehldsHookRegistry_SV_ShouldSendConsistencyList* SV_ShouldSendConsistencyList() = 0; virtual IRehldsHookRegistry_SV_ShouldSendConsistencyList* SV_ShouldSendConsistencyList() = 0;
virtual IRehldsHookRegistry_GetEntityInit* GetEntityInit() = 0; virtual IRehldsHookRegistry_GetEntityInit* GetEntityInit() = 0;
virtual IRehldsHookRegistry_SV_EmitPings* SV_EmitPings() = 0;
virtual IRehldsHookRegistry_ED_Alloc* ED_Alloc() = 0;
virtual IRehldsHookRegistry_ED_Free* ED_Free() = 0;
}; };
struct RehldsFuncs_t { struct RehldsFuncs_t {

View File

@ -83,6 +83,24 @@ void ClientConnected(IRehldsHook_ClientConnected* chain, IGameClient* cl)
callVoidForward(RH_ClientConnected, original, cl->GetId() + 1); callVoidForward(RH_ClientConnected, original, cl->GetId() + 1);
} }
void SV_EmitPings_AMXX(SV_EmitPings_t* data, IGameClient* cl)
{
auto original = [data](int _cl)
{
data->m_chain->callNext(g_RehldsSvs->GetClient(_cl - 1), data->m_args.message);
};
callVoidForward(RH_SV_EmitPings, original, cl->GetId() + 1);
}
void SV_EmitPings(IRehldsHook_SV_EmitPings *chain, IGameClient *cl, sizebuf_t *msg)
{
SV_EmitPings_args_t args(cl, msg);
SV_EmitPings_t data(chain, args);
SV_EmitPings_AMXX(&data, cl);
}
/* /*
* ReGameDLL functions * ReGameDLL functions
*/ */

View File

@ -346,6 +346,18 @@ void SV_WriteFullClientUpdate_AMXX(SV_WriteFullClientUpdate_t *data, IGameClient
void SV_WriteFullClientUpdate(IRehldsHook_SV_WriteFullClientUpdate *chain, IGameClient *client, char *buffer, size_t maxlen, sizebuf_t *sb, IGameClient *receiver); void SV_WriteFullClientUpdate(IRehldsHook_SV_WriteFullClientUpdate *chain, IGameClient *client, char *buffer, size_t maxlen, sizebuf_t *sb, IGameClient *receiver);
entvars_s *GetEntityInit(IRehldsHook_GetEntityInit *chain, char *classname); entvars_s *GetEntityInit(IRehldsHook_GetEntityInit *chain, char *classname);
struct SV_EmitPings_args_t
{
SV_EmitPings_args_t(IGameClient* cl, sizebuf_t *msg) : client(cl), message(msg) {}
IGameClient *client;
sizebuf_t* message;
};
using SV_EmitPings_t = hookdata_t<IRehldsHook_SV_EmitPings *, SV_EmitPings_args_t &>;
void SV_EmitPings_AMXX(SV_EmitPings_t *data, IGameClient *client);
void SV_EmitPings(IRehldsHook_SV_EmitPings *chain, IGameClient *client, sizebuf_t *msg);
// regamedll functions // regamedll functions
int GetForceCamera(IReGameHook_GetForceCamera *chain, CBasePlayer *pObserver); int GetForceCamera(IReGameHook_GetForceCamera *chain, CBasePlayer *pObserver);
void PlayerBlind(IReGameHook_PlayerBlind *chain, CBasePlayer *pPlayer, entvars_t *pevInflictor, entvars_t *pevAttacker, float fadeTime, float fadeHold, int alpha, Vector& color); void PlayerBlind(IReGameHook_PlayerBlind *chain, CBasePlayer *pPlayer, entvars_t *pevInflictor, entvars_t *pevAttacker, float fadeTime, float fadeHold, int alpha, Vector& color);

View File

@ -88,7 +88,8 @@ hook_t hooklist_engine[] = {
ENG(Cvar_DirectSet), ENG(Cvar_DirectSet),
ENG(SV_WriteFullClientUpdate, _AMXX), ENG(SV_WriteFullClientUpdate, _AMXX),
ENG(GetEntityInit), ENG(GetEntityInit),
ENG(ClientConnected) ENG(ClientConnected),
ENG(SV_EmitPings, _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

@ -99,7 +99,8 @@ enum EngineFunc
RH_Cvar_DirectSet, RH_Cvar_DirectSet,
RH_SV_WriteFullClientUpdate, RH_SV_WriteFullClientUpdate,
RH_GetEntityInit, RH_GetEntityInit,
RH_ClientConnected RH_ClientConnected,
RH_SV_EmitPings
// [...] // [...]
}; };