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:
parent
30af88faf5
commit
a16dfd08fa
@ -65,6 +65,12 @@ enum EngineFunc
|
||||
* Params: (const client)
|
||||
*/
|
||||
RH_ClientConnected,
|
||||
|
||||
/*
|
||||
* Description: Called when client it's in the scoreboard
|
||||
* Params: (const this)
|
||||
*/
|
||||
RH_SV_EmitPings
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -35,7 +35,7 @@
|
||||
#include "model.h"
|
||||
|
||||
#define REHLDS_API_VERSION_MAJOR 3
|
||||
#define REHLDS_API_VERSION_MINOR 0
|
||||
#define REHLDS_API_VERSION_MINOR 11
|
||||
|
||||
//Steam_NotifyClientConnect hook
|
||||
typedef IHookChain<qboolean, IGameClient*, const void*, unsigned int> IRehldsHook_Steam_NotifyClientConnect;
|
||||
@ -209,6 +209,18 @@ typedef IHookChainRegistry<bool, IGameClient *, bool> IRehldsHookRegistry_SV_Sho
|
||||
typedef IHookChain<struct entvars_s *, char *> IRehldsHook_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 {
|
||||
public:
|
||||
virtual ~IRehldsHookchains() { }
|
||||
@ -256,6 +268,9 @@ public:
|
||||
virtual IRehldsHookRegistry_SV_Frame* SV_Frame() = 0;
|
||||
virtual IRehldsHookRegistry_SV_ShouldSendConsistencyList* SV_ShouldSendConsistencyList() = 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 {
|
||||
|
@ -83,6 +83,24 @@ void ClientConnected(IRehldsHook_ClientConnected* chain, IGameClient* cl)
|
||||
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
|
||||
*/
|
||||
|
@ -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);
|
||||
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
|
||||
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);
|
||||
|
@ -88,7 +88,8 @@ hook_t hooklist_engine[] = {
|
||||
ENG(Cvar_DirectSet),
|
||||
ENG(SV_WriteFullClientUpdate, _AMXX),
|
||||
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}
|
||||
|
@ -99,7 +99,8 @@ enum EngineFunc
|
||||
RH_Cvar_DirectSet,
|
||||
RH_SV_WriteFullClientUpdate,
|
||||
RH_GetEntityInit,
|
||||
RH_ClientConnected
|
||||
RH_ClientConnected,
|
||||
RH_SV_EmitPings
|
||||
|
||||
// [...]
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user