From f535b5b38fa0c6d0758d1004cad068e576a03400 Mon Sep 17 00:00:00 2001 From: s1lentq Date: Mon, 9 Nov 2020 01:20:53 +0700 Subject: [PATCH] ReHLDS API: Implemented SV_ShouldSendConsistencyList ReHLDS API: Bump minor --- gradle.properties | 2 +- rehlds/engine/sv_user.cpp | 18 +++++++++++++++++- rehlds/public/rehlds/rehlds_api.h | 11 ++++++++--- rehlds/public/rehlds/rehlds_interfaces.h | 3 +++ rehlds/rehlds/rehlds_api_impl.cpp | 4 ++++ rehlds/rehlds/rehlds_api_impl.h | 6 ++++++ rehlds/rehlds/rehlds_interfaces_impl.cpp | 10 ++++++++++ rehlds/rehlds/rehlds_interfaces_impl.h | 3 +++ 8 files changed, 52 insertions(+), 5 deletions(-) diff --git a/gradle.properties b/gradle.properties index 2743145..41b3fb9 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,3 @@ majorVersion=3 -minorVersion=7 +minorVersion=8 maintenanceVersion=0 diff --git a/rehlds/engine/sv_user.cpp b/rehlds/engine/sv_user.cpp index 4535117..93f7308 100644 --- a/rehlds/engine/sv_user.cpp +++ b/rehlds/engine/sv_user.cpp @@ -311,11 +311,27 @@ int EXT_FUNC SV_TransferConsistencyInfo_internal(void) return c; } +bool EXT_FUNC SV_ShouldSendConsistencyList_mod(IGameClient *cl, bool forceConsistency) +{ + if (g_psvs.maxclients == 1 || g_psv.num_consistency == 0 || cl->IsProxy()) + return false; + + if ((!forceConsistency && mp_consistency.value == 0.0f)) + return false; + + return true; +} + +bool SV_ShouldSendConsistencyList(client_t *client, bool forceConsistency) +{ + return g_RehldsHookchains.m_SV_ShouldSendConsistencyList.callChain(SV_ShouldSendConsistencyList_mod, GetRehldsApiClient(client), forceConsistency); +} + void SV_SendConsistencyList(sizebuf_t *msg) { host_client->has_force_unmodified = FALSE; - if (g_psvs.maxclients == 1 || mp_consistency.value == 0.0f || g_psv.num_consistency == 0 || host_client->proxy) + if (!SV_ShouldSendConsistencyList(host_client, false)) { MSG_WriteBits(0, 1); return; diff --git a/rehlds/public/rehlds/rehlds_api.h b/rehlds/public/rehlds/rehlds_api.h index 0a73b4f..9f4d51f 100644 --- a/rehlds/public/rehlds/rehlds_api.h +++ b/rehlds/public/rehlds/rehlds_api.h @@ -37,7 +37,7 @@ #include "pr_dlls.h" #define REHLDS_API_VERSION_MAJOR 3 -#define REHLDS_API_VERSION_MINOR 7 +#define REHLDS_API_VERSION_MINOR 8 //Steam_NotifyClientConnect hook typedef IHookChain IRehldsHook_Steam_NotifyClientConnect; @@ -203,6 +203,10 @@ typedef IHookChainRegistry IRehldsHookRe typedef IVoidHookChain<> IRehldsHook_SV_Frame; typedef IVoidHookChainRegistry<> IRehldsHookRegistry_SV_Frame; +//SV_ShouldSendConsistencyList hook +typedef IHookChain IRehldsHook_SV_ShouldSendConsistencyList; +typedef IHookChainRegistry IRehldsHookRegistry_SV_ShouldSendConsistencyList; + class IRehldsHookchains { public: virtual ~IRehldsHookchains() { } @@ -248,6 +252,7 @@ public: virtual IRehldsHookRegistry_CreateFakeClient* CreateFakeClient() = 0; virtual IRehldsHookRegistry_SV_CheckConnectionLessRateLimits* SV_CheckConnectionLessRateLimits() = 0; virtual IRehldsHookRegistry_SV_Frame* SV_Frame() = 0; + virtual IRehldsHookRegistry_SV_ShouldSendConsistencyList* SV_ShouldSendConsistencyList() = 0; }; struct RehldsFuncs_t { @@ -316,7 +321,7 @@ struct RehldsFuncs_t { char*(*MSG_ReadStringLine)(); float(*MSG_ReadAngle)(); float(*MSG_ReadHiresAngle)(); - void(*MSG_ReadUsercmd)(usercmd_t *to, usercmd_t *from); + void(*MSG_ReadUsercmd)(struct usercmd_s *to, struct usercmd_s *from); float(*MSG_ReadCoord)(); void(*MSG_ReadVec3Coord)(sizebuf_t *sb, vec3_t fa); @@ -340,7 +345,7 @@ struct RehldsFuncs_t { void(*MSG_WriteFloat)(sizebuf_t *sb, float f); void(*MSG_WriteAngle)(sizebuf_t *sb, float f); void(*MSG_WriteHiresAngle)(sizebuf_t *sb, float f); - void(*MSG_WriteUsercmd)(sizebuf_t *sb, usercmd_t *to, usercmd_t *from); + void(*MSG_WriteUsercmd)(sizebuf_t *sb, struct usercmd_s *to, struct usercmd_s *from); void(*MSG_WriteCoord)(sizebuf_t *sb, float f); void(*MSG_WriteVec3Coord)(sizebuf_t *sb, const vec3_t fa); diff --git a/rehlds/public/rehlds/rehlds_interfaces.h b/rehlds/public/rehlds/rehlds_interfaces.h index 8e12e33..7585d8d 100644 --- a/rehlds/public/rehlds/rehlds_interfaces.h +++ b/rehlds/public/rehlds/rehlds_interfaces.h @@ -73,6 +73,9 @@ public: virtual bool GetLoopback() = 0; virtual struct usercmd_s *GetLastCmd() = 0; + virtual bool IsProxy() = 0; + virtual void SetProxy(bool proxy) = 0; + // this must be the last virtual function in class #ifdef REHLDS_SELF virtual client_t* GetClient() = 0; diff --git a/rehlds/rehlds/rehlds_api_impl.cpp b/rehlds/rehlds/rehlds_api_impl.cpp index f4ade26..838305c 100644 --- a/rehlds/rehlds/rehlds_api_impl.cpp +++ b/rehlds/rehlds/rehlds_api_impl.cpp @@ -827,6 +827,10 @@ IRehldsHookRegistry_SV_Frame* CRehldsHookchains::SV_Frame() { return &m_SV_Frame; } +IRehldsHookRegistry_SV_ShouldSendConsistencyList* CRehldsHookchains::SV_ShouldSendConsistencyList() { + return &m_SV_ShouldSendConsistencyList; +} + int EXT_FUNC CRehldsApi::GetMajorVersion() { return REHLDS_API_VERSION_MAJOR; diff --git a/rehlds/rehlds/rehlds_api_impl.h b/rehlds/rehlds/rehlds_api_impl.h index 689556b..7c106c7 100644 --- a/rehlds/rehlds/rehlds_api_impl.h +++ b/rehlds/rehlds/rehlds_api_impl.h @@ -198,6 +198,10 @@ typedef IHookChainRegistryImpl CRehldsHo typedef IVoidHookChainImpl<> CRehldsHook_SV_Frame; typedef IVoidHookChainRegistryImpl<> CRehldsHookRegistry_SV_Frame; +//SV_ShouldSendConsistencyList hook +typedef IHookChainImpl CRehldsHook_SV_ShouldSendConsistencyList; +typedef IHookChainRegistryImpl CRehldsHookRegistry_SV_ShouldSendConsistencyList; + class CRehldsHookchains : public IRehldsHookchains { public: CRehldsHookRegistry_Steam_NotifyClientConnect m_Steam_NotifyClientConnect; @@ -241,6 +245,7 @@ public: CRehldsHookRegistry_CreateFakeClient m_CreateFakeClient; CRehldsHookRegistry_SV_CheckConnectionLessRateLimits m_SV_CheckConnectionLessRateLimits; CRehldsHookRegistry_SV_Frame m_SV_Frame; + CRehldsHookRegistry_SV_ShouldSendConsistencyList m_SV_ShouldSendConsistencyList; public: EXT_FUNC virtual IRehldsHookRegistry_Steam_NotifyClientConnect* Steam_NotifyClientConnect(); @@ -284,6 +289,7 @@ public: EXT_FUNC virtual IRehldsHookRegistry_CreateFakeClient* CreateFakeClient(); EXT_FUNC virtual IRehldsHookRegistry_SV_CheckConnectionLessRateLimits* SV_CheckConnectionLessRateLimits(); EXT_FUNC virtual IRehldsHookRegistry_SV_Frame* SV_Frame(); + EXT_FUNC virtual IRehldsHookRegistry_SV_ShouldSendConsistencyList* SV_ShouldSendConsistencyList(); }; extern CRehldsHookchains g_RehldsHookchains; diff --git a/rehlds/rehlds/rehlds_interfaces_impl.cpp b/rehlds/rehlds/rehlds_interfaces_impl.cpp index a1103a8..2044938 100644 --- a/rehlds/rehlds/rehlds_interfaces_impl.cpp +++ b/rehlds/rehlds/rehlds_interfaces_impl.cpp @@ -71,6 +71,16 @@ void EXT_FUNC CGameClient::SetSpawned(bool spawned) m_pClient->spawned = spawned ? 1 : 0; } +bool EXT_FUNC CGameClient::IsProxy() +{ + return m_pClient->proxy != 0; +} + +void EXT_FUNC CGameClient::SetProxy(bool proxy) +{ + m_pClient->proxy = proxy ? 1 : 0; +} + bool EXT_FUNC CGameClient::IsConnected() { return m_pClient->connected != 0; } diff --git a/rehlds/rehlds/rehlds_interfaces_impl.h b/rehlds/rehlds/rehlds_interfaces_impl.h index 431ca99..c22215f 100644 --- a/rehlds/rehlds/rehlds_interfaces_impl.h +++ b/rehlds/rehlds/rehlds_interfaces_impl.h @@ -98,6 +98,9 @@ public: virtual bool GetLoopback(); virtual struct usercmd_s *GetLastCmd(); + virtual bool IsProxy(); + virtual void SetProxy(bool proxy); + virtual client_t* GetClient(); public: