From 7c5dc890df5f1478e4921fad6be82d1e4ff24934 Mon Sep 17 00:00:00 2001 From: s1lent Date: Sun, 11 Aug 2019 03:26:52 +0700 Subject: [PATCH] HLTV: Increased rates threshold for recording demofile, rate 100k and updaterate up to 100 --- rehlds/HLTV/Proxy/src/DemoClient.cpp | 18 ++++++++++++++++++ rehlds/HLTV/Proxy/src/DemoClient.h | 2 ++ rehlds/HLTV/Proxy/src/Proxy.cpp | 23 ++++++++++++++--------- rehlds/HLTV/Proxy/src/Proxy.h | 13 +++++++++++-- rehlds/HLTV/Proxy/src/ProxyClient.h | 2 ++ rehlds/HLTV/common/NetChannel.cpp | 2 +- rehlds/HLTV/common/NetChannel.h | 9 +++++++++ rehlds/public/HLTV/IClient.h | 5 +++++ 8 files changed, 62 insertions(+), 12 deletions(-) diff --git a/rehlds/HLTV/Proxy/src/DemoClient.cpp b/rehlds/HLTV/Proxy/src/DemoClient.cpp index 20e3657..5d48cd1 100644 --- a/rehlds/HLTV/Proxy/src/DemoClient.cpp +++ b/rehlds/HLTV/Proxy/src/DemoClient.cpp @@ -90,6 +90,24 @@ void DemoClient::Reconnect() FinishDemo(); } +void DemoClient::SetUpdateRate(int updaterate) +{ + m_DemoChannel.SetUpdateRate( + clamp(updaterate, + MIN_PROXY_UPDATERATE, + MAX_PROXY_UPDATERATE) + ); +} + +void DemoClient::SetRate(int rate) +{ + m_DemoChannel.SetRate( + clamp(rate, + MIN_PROXY_RATE, + MAX_PROXY_RATE) + ); +} + bool DemoClient::Connect(INetSocket *socket, NetAddress *adr, char *userinfo) { if (IsActive()) diff --git a/rehlds/HLTV/Proxy/src/DemoClient.h b/rehlds/HLTV/Proxy/src/DemoClient.h index a3fab45..b74074a 100644 --- a/rehlds/HLTV/Proxy/src/DemoClient.h +++ b/rehlds/HLTV/Proxy/src/DemoClient.h @@ -60,6 +60,8 @@ public: void FinishDemo(); void SendDatagram(); void WriteDatagram(double time, frame_t *frame); + void SetUpdateRate(int updaterate); + void SetRate(int rate); protected: IProxy *m_Proxy; diff --git a/rehlds/HLTV/Proxy/src/Proxy.cpp b/rehlds/HLTV/Proxy/src/Proxy.cpp index 351e9e2..cb842f4 100644 --- a/rehlds/HLTV/Proxy/src/Proxy.cpp +++ b/rehlds/HLTV/Proxy/src/Proxy.cpp @@ -904,7 +904,7 @@ bool Proxy::SetMaxClients(int number) void Proxy::SetMaxLoss(float maxloss) { - m_MaxLoss = Q_clamp(maxloss, 0.0f, 1.0f); + m_MaxLoss = clamp(maxloss, 0.0f, 1.0f); } int Proxy::GetMaxClients() @@ -1162,8 +1162,15 @@ void Proxy::CMD_Record(char *cmdLine) return; } - if (m_DemoClient.Connect()) { + if (m_DemoClient.Connect()) + { m_DemoClient.SetFileName(params.GetToken(1)); + +#ifdef HLTV_FIXES + // Increased rate for recording demofile + m_DemoClient.SetUpdateRate(m_MaxUpdateRate); + m_DemoClient.SetRate(m_MaxRate); +#endif } } @@ -1680,7 +1687,7 @@ void Proxy::CMD_ChatMode(char *cmdLine) return; } - m_ChatMode = Q_clamp((ChatMode_e)Q_atoi(params.GetToken(1)), CHAT_OFF, CHAT_GLOBAL); + m_ChatMode = clamp((ChatMode_e)Q_atoi(params.GetToken(1)), CHAT_OFF, CHAT_GLOBAL); } void Proxy::CMD_MaxQueries(char *cmdLine) @@ -1946,7 +1953,7 @@ void Proxy::CMD_DispatchMode(char *cmdLine) return; } - m_DispatchMode = Q_clamp((DispatchMode_e)Q_atoi(params.GetToken(1)), DISPATCH_OFF, DISPATCH_ALL); + m_DispatchMode = clamp((DispatchMode_e)Q_atoi(params.GetToken(1)), DISPATCH_OFF, DISPATCH_ALL); } bool Proxy::IsValidPassword(int type, char *pw) @@ -2454,14 +2461,12 @@ void Proxy::CreateServerInfoString(InfoString *info) void Proxy::SetMaxRate(int rate) { - // maxrate: 1.000 - 20.000 - m_MaxRate = Q_clamp(rate, 1000, MAX_PROXY_RATE); + m_MaxRate = clamp(rate, MIN_PROXY_RATE, MAX_PROXY_RATE); } void Proxy::SetMaxUpdateRate(int updaterate) { - // maxupdaterate: 1.0 - 40.0 - m_MaxUpdateRate = Q_clamp(updaterate, 1, MAX_PROXY_UPDATERATE); + m_MaxUpdateRate = clamp(updaterate, MIN_PROXY_UPDATERATE, MAX_PROXY_UPDATERATE); } void Proxy::SetDelay(float seconds) @@ -2495,7 +2500,7 @@ void Proxy::SetClientTime(double time, bool relative) void Proxy::SetClientTimeScale(float scale) { BitBuffer buf(32); - m_ClientTimeScale = Q_clamp(scale, 0.5f, 4.0f); + m_ClientTimeScale = clamp(scale, 0.5f, 4.0f); buf.WriteByte(svc_timescale); buf.WriteFloat(m_ClientTimeScale); diff --git a/rehlds/HLTV/Proxy/src/Proxy.h b/rehlds/HLTV/Proxy/src/Proxy.h index c650dfd..a7ab781 100644 --- a/rehlds/HLTV/Proxy/src/Proxy.h +++ b/rehlds/HLTV/Proxy/src/Proxy.h @@ -45,8 +45,17 @@ class IDirector; class IBaseSystem; #define MAX_NAME 32 -#define MAX_PROXY_RATE 20000 -#define MAX_PROXY_UPDATERATE 40 + +#ifdef HLTV_FIXES +const int MAX_PROXY_RATE = 100000; +const int MAX_PROXY_UPDATERATE = 100; +#else +const int MAX_PROXY_RATE = 20000; +const int MAX_PROXY_UPDATERATE = 40; +#endif + +const int MIN_PROXY_RATE = 1000; +const int MIN_PROXY_UPDATERATE = 1; #define PROXY_CHALLENGE_LIFE 40.0f #define PROXY_PRIVATE 0x8000 diff --git a/rehlds/HLTV/Proxy/src/ProxyClient.h b/rehlds/HLTV/Proxy/src/ProxyClient.h index b4db907..3ce2ec6 100644 --- a/rehlds/HLTV/Proxy/src/ProxyClient.h +++ b/rehlds/HLTV/Proxy/src/ProxyClient.h @@ -49,6 +49,8 @@ public: void DownloadFile(char *fileName); void SendDatagram(); void ParseHLTV(NetPacket *packet); + void SetUpdateRate(int updaterate) {} + void SetRate(int rate) {} private: enum LocalCommandIDs { diff --git a/rehlds/HLTV/common/NetChannel.cpp b/rehlds/HLTV/common/NetChannel.cpp index ce4c6e5..104ff5d 100644 --- a/rehlds/HLTV/common/NetChannel.cpp +++ b/rehlds/HLTV/common/NetChannel.cpp @@ -1201,7 +1201,7 @@ void NetChannel::SetConnected(bool flag) void NetChannel::SetRate(int newRate) { - m_max_bandwidth_rate = Q_clamp(newRate, 1000, 20000); + m_max_bandwidth_rate = Q_clamp(newRate, MIN_NETCHAN_RATE, MAX_NETCHAN_RATE); } void NetChannel::GetFlowStats(float *avgInKBSec, float *avgOutKBSec) diff --git a/rehlds/HLTV/common/NetChannel.h b/rehlds/HLTV/common/NetChannel.h index 4a3b292..1791f80 100644 --- a/rehlds/HLTV/common/NetChannel.h +++ b/rehlds/HLTV/common/NetChannel.h @@ -51,6 +51,15 @@ enum MAX_FLOWS }; +// Flow control bytes per second limits +#ifdef HLTV_FIXES +const int MAX_NETCHAN_RATE = 100000.0f; +#else +const int MAX_NETCHAN_RATE = 20000.0f; +#endif + +const int MIN_NETCHAN_RATE = 1000.0f; + #define MAX_LATENT 32 #define FRAGMENT_MAX_SIZE 1400 // Size of fragmentation buffer internal buffers #define CLIENT_FRAGMENT_SIZE_ONCONNECT 128 diff --git a/rehlds/public/HLTV/IClient.h b/rehlds/public/HLTV/IClient.h index fe51503..fc960ee 100644 --- a/rehlds/public/HLTV/IClient.h +++ b/rehlds/public/HLTV/IClient.h @@ -46,6 +46,11 @@ public: virtual bool IsActive() = 0; virtual bool IsHearingVoices() = 0; virtual bool HasChatEnabled() = 0; + +#ifdef HLTV_FIXES + virtual void SetUpdateRate(int updaterate) = 0; + virtual void SetRate(int rate) = 0; +#endif // HLTV_FIXES }; #define CLIENT_INTERFACE_VERSION "client001"