2
0
mirror of https://github.com/rehlds/rehlds.git synced 2024-12-28 15:45:46 +03:00

ReHLDS API: Implemented SV_ShouldSendConsistencyList

ReHLDS API: Bump minor
This commit is contained in:
s1lentq 2020-11-09 01:20:53 +07:00
parent c11fdbe3f8
commit f535b5b38f
8 changed files with 52 additions and 5 deletions

View File

@ -1,3 +1,3 @@
majorVersion=3
minorVersion=7
minorVersion=8
maintenanceVersion=0

View File

@ -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;

View File

@ -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<qboolean, IGameClient*, const void*, unsigned int> IRehldsHook_Steam_NotifyClientConnect;
@ -203,6 +203,10 @@ typedef IHookChainRegistry<bool, netadr_t &, const uint8_t *, int> IRehldsHookRe
typedef IVoidHookChain<> IRehldsHook_SV_Frame;
typedef IVoidHookChainRegistry<> IRehldsHookRegistry_SV_Frame;
//SV_ShouldSendConsistencyList hook
typedef IHookChain<bool, IGameClient *, bool> IRehldsHook_SV_ShouldSendConsistencyList;
typedef IHookChainRegistry<bool, IGameClient *, bool> 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);

View File

@ -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;

View File

@ -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;

View File

@ -198,6 +198,10 @@ typedef IHookChainRegistryImpl<bool, netadr_t &, const uint8_t *, int> CRehldsHo
typedef IVoidHookChainImpl<> CRehldsHook_SV_Frame;
typedef IVoidHookChainRegistryImpl<> CRehldsHookRegistry_SV_Frame;
//SV_ShouldSendConsistencyList hook
typedef IHookChainImpl<bool, IGameClient *, bool> CRehldsHook_SV_ShouldSendConsistencyList;
typedef IHookChainRegistryImpl<bool, IGameClient *, bool> 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;

View File

@ -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;
}

View File

@ -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: