diff --git a/rehlds/engine/server.h b/rehlds/engine/server.h index d444140..3fb0f78 100644 --- a/rehlds/engine/server.h +++ b/rehlds/engine/server.h @@ -557,7 +557,8 @@ qboolean SV_ShouldUpdatePing(client_t *client); NOXREF qboolean SV_HasEventsInQueue(client_t *client); void SV_GetNetInfo(client_t *client, int *ping, int *packet_loss); int SV_CheckVisibility(edict_t *entity, unsigned char *pset); -void SV_EmitPings(client_t *client, sizebuf_t *msg); +void SV_EmitPings(client_t* client, sizebuf_t* msg); +void SV_EmitPings_internal(client_t*client, sizebuf_t *msg); void SV_WriteEntitiesToClient(client_t *client, sizebuf_t *msg); void SV_CleanupEnts(void); qboolean SV_SendClientDatagram(client_t *client); diff --git a/rehlds/engine/sv_main.cpp b/rehlds/engine/sv_main.cpp index 74a285f..68dcc23 100644 --- a/rehlds/engine/sv_main.cpp +++ b/rehlds/engine/sv_main.cpp @@ -4566,7 +4566,16 @@ int EXT_FUNC SV_CheckVisibility(edict_t *entity, unsigned char *pset) } } -void SV_EmitPings(client_t *client, sizebuf_t *msg) +void EXT_FUNC SV_EmitPings_hook(IGameClient *cl, sizebuf_t *msg) +{ + SV_EmitPings_internal(cl->GetClient(), msg); +} + +void SV_EmitPings(client_t* client, sizebuf_t* msg) { + g_RehldsHookchains.m_SV_EmitPings.callChain(SV_EmitPings_hook, GetRehldsApiClient(client), msg); +} + +void EXT_FUNC SV_EmitPings_internal(client_t* client, sizebuf_t* msg) { int ping; int packet_loss; diff --git a/rehlds/public/rehlds/rehlds_api.h b/rehlds/public/rehlds/rehlds_api.h index 3b384ea..23413af 100644 --- a/rehlds/public/rehlds/rehlds_api.h +++ b/rehlds/public/rehlds/rehlds_api.h @@ -211,6 +211,10 @@ typedef IHookChainRegistry IRehldsHookRegistry_SV_Sho typedef IHookChain IRehldsHook_GetEntityInit; typedef IHookChainRegistry IRehldsHookRegistry_GetEntityInit; +//SV_EmitPings hook +typedef IHookChain IRehldsHook_SV_EmitPings; +typedef IHookChainRegistry IRehldsHookRegistry_SV_EmitPings; + //ED_Alloc hook typedef IHookChain IRehldsHook_ED_Alloc; typedef IHookChainRegistry IRehldsHookRegistry_ED_Alloc; @@ -267,6 +271,7 @@ 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; }; diff --git a/rehlds/rehlds/rehlds_api_impl.cpp b/rehlds/rehlds/rehlds_api_impl.cpp index c1274b5..60aa4a7 100644 --- a/rehlds/rehlds/rehlds_api_impl.cpp +++ b/rehlds/rehlds/rehlds_api_impl.cpp @@ -835,6 +835,10 @@ IRehldsHookRegistry_GetEntityInit* CRehldsHookchains::GetEntityInit() { return &m_GetEntityInit; } +IRehldsHookRegistry_SV_EmitPings* CRehldsHookchains::SV_EmitPings() { + return &m_SV_EmitPings; +} + IRehldsHookRegistry_ED_Alloc* CRehldsHookchains::ED_Alloc() { return &m_ED_Alloc; } diff --git a/rehlds/rehlds/rehlds_api_impl.h b/rehlds/rehlds/rehlds_api_impl.h index 6438f7b..1fa3472 100644 --- a/rehlds/rehlds/rehlds_api_impl.h +++ b/rehlds/rehlds/rehlds_api_impl.h @@ -206,6 +206,10 @@ typedef IHookChainRegistryImpl CRehldsHookRegistry_SV typedef IHookChainImpl CRehldsHook_GetEntityInit; typedef IHookChainRegistryImpl CRehldsHookRegistry_GetEntityInit; +//SV_EmitPings hook +typedef IHookChainImpl CRehldsHook_SV_EmitPings; +typedef IHookChainRegistryImpl CRehldsHookRegistry_SV_EmitPings; + //ED_Alloc hook typedef IHookChainImpl CRehldsHook_ED_Alloc; typedef IHookChainRegistryImpl CRehldsHookRegistry_ED_Alloc; @@ -259,6 +263,7 @@ public: CRehldsHookRegistry_SV_Frame m_SV_Frame; CRehldsHookRegistry_SV_ShouldSendConsistencyList m_SV_ShouldSendConsistencyList; CRehldsHookRegistry_GetEntityInit m_GetEntityInit; + CRehldsHookRegistry_SV_EmitPings m_SV_EmitPings; CRehldsHookRegistry_ED_Alloc m_ED_Alloc; CRehldsHookRegistry_ED_Free m_ED_Free; @@ -306,6 +311,7 @@ public: EXT_FUNC virtual IRehldsHookRegistry_SV_Frame* SV_Frame(); EXT_FUNC virtual IRehldsHookRegistry_SV_ShouldSendConsistencyList* SV_ShouldSendConsistencyList(); EXT_FUNC virtual IRehldsHookRegistry_GetEntityInit* GetEntityInit(); + EXT_FUNC virtual IRehldsHookRegistry_SV_EmitPings* SV_EmitPings(); EXT_FUNC virtual IRehldsHookRegistry_ED_Alloc* ED_Alloc(); EXT_FUNC virtual IRehldsHookRegistry_ED_Free* ED_Free(); };