mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Engine: revert server tick msg rebuild to old behavior
Only update statistics, this code was mainly added for testing, but testing revealed no additional performance or smoothness improvements, even during >6 hour sessions. The clock drift already gets corrected each frame from Host_RunFrame(). Only update statistics to update CPU and frame times on the client's debug panels if enabled.
This commit is contained in:
parent
a17a2c9feb
commit
b094040c64
@ -129,8 +129,6 @@ ConVar* sv_maxunlag = nullptr;
|
||||
ConVar* sv_unlag_clamp = nullptr;
|
||||
ConVar* sv_clockcorrection_msecs = nullptr;
|
||||
|
||||
ConVar* sv_clockSyncInterval = nullptr;
|
||||
|
||||
ConVar* sv_updaterate_sp = nullptr;
|
||||
ConVar* sv_updaterate_mp = nullptr;
|
||||
|
||||
@ -381,8 +379,6 @@ void ConVar_StaticInit(void)
|
||||
|
||||
sv_unlag_clamp = ConVar::StaticCreate("sv_unlag_clamp", "0", FCVAR_RELEASE, "Clamp the difference between the current time and received command time to sv_maxunlag + sv_clockcorrection_msecs.", false, 0.f, false, 0.f, nullptr, nullptr);
|
||||
|
||||
sv_clockSyncInterval = ConVar::StaticCreate("sv_clockSyncInterval", "5.0", FCVAR_RELEASE, "Interval in seconds in which the clients's clock will be synced with that of the server's.", false, 0.f, false, 0.f, nullptr, nullptr);
|
||||
|
||||
sv_showconnecting = ConVar::StaticCreate("sv_showconnecting" , "1", FCVAR_RELEASE, "Logs information about the connecting client to the console.", false, 0.f, false, 0.f, nullptr, nullptr);
|
||||
sv_globalBanlist = ConVar::StaticCreate("sv_globalBanlist" , "1", FCVAR_RELEASE, "Determines whether or not to use the global banned list.", false, 0.f, false, 0.f, nullptr, "0 = Disable, 1 = Enable.");
|
||||
sv_pylonVisibility = ConVar::StaticCreate("sv_pylonVisibility", "0", FCVAR_RELEASE, "Determines the visibility to the Pylon master server.", false, 0.f, false, 0.f, nullptr, "0 = Offline, 1 = Hidden, 2 = Public.");
|
||||
|
@ -118,8 +118,6 @@ extern ConVar* sv_maxunlag;
|
||||
extern ConVar* sv_unlag_clamp;
|
||||
extern ConVar* sv_clockcorrection_msecs;
|
||||
|
||||
extern ConVar* sv_clockSyncInterval;
|
||||
|
||||
extern ConVar* sv_updaterate_sp;
|
||||
extern ConVar* sv_updaterate_mp;
|
||||
|
||||
|
@ -226,10 +226,8 @@ public:
|
||||
{
|
||||
m_flNetProcessingTimeMsecs = 0.0;
|
||||
m_flNetProcessTimeBase = 0.0;
|
||||
m_flLastClockSyncTime = 0.0;
|
||||
m_flStringCommandQuotaTimeStart = 0.0;
|
||||
m_nStringCommandQuotaCount = NULL;
|
||||
m_bRetryClockSync = false;
|
||||
m_bInitialConVarsSet = false;
|
||||
}
|
||||
|
||||
@ -241,31 +239,21 @@ public: // Inlines:
|
||||
inline void SetNetProcessingTimeBase(const double flTime) { m_flNetProcessTimeBase = flTime; }
|
||||
inline double GetNetProcessingTimeBase(void) const { return m_flNetProcessTimeBase; }
|
||||
|
||||
inline void SetLastClockSyncTime(const double flTime) { m_flLastClockSyncTime = flTime; }
|
||||
inline double GetLastClockSyncTime(void) const { return m_flLastClockSyncTime; }
|
||||
|
||||
inline void SetStringCommandQuotaTimeStart(const double flTime) { m_flStringCommandQuotaTimeStart = flTime; }
|
||||
inline double GetStringCommandQuotaTimeStart(void) const { return m_flStringCommandQuotaTimeStart; }
|
||||
|
||||
inline void SetStringCommandQuotaCount(const int iCount) { m_nStringCommandQuotaCount = iCount; }
|
||||
inline int GetStringCommandQuotaCount(void) const { return m_nStringCommandQuotaCount; }
|
||||
|
||||
inline void SetRetryClockSync(const bool bSet) { m_bRetryClockSync = bSet; }
|
||||
inline bool ShouldRetryClockSync() const { return m_bRetryClockSync; }
|
||||
|
||||
private:
|
||||
// Measure how long this client's packets took to process.
|
||||
double m_flNetProcessingTimeMsecs;
|
||||
double m_flNetProcessTimeBase;
|
||||
|
||||
// When was the last clock sync?
|
||||
double m_flLastClockSyncTime;
|
||||
|
||||
// The start time of the first stringcmd since reset.
|
||||
double m_flStringCommandQuotaTimeStart;
|
||||
int m_nStringCommandQuotaCount;
|
||||
|
||||
bool m_bRetryClockSync; // Whether or not we should retry sending clock sync msg.
|
||||
bool m_bInitialConVarsSet; // Whether or not the initial ConVar KV's are set
|
||||
};
|
||||
|
||||
|
@ -154,15 +154,20 @@ bool CClientState::VProcessServerTick(CClientState* thisptr, SVC_ServerTick* msg
|
||||
{
|
||||
if (msg->m_NetTick.m_nCommandTick != -1)
|
||||
{
|
||||
// Updates statistics and updates clockdrift.
|
||||
return CClientState__ProcessServerTick(thisptr, msg);
|
||||
}
|
||||
else // Statistics only.
|
||||
{
|
||||
CClientState* const thisptr_ADJ = thisptr->GetShiftedBasePointer();
|
||||
|
||||
CNetChan* const pChan = thisptr_ADJ->m_NetChannel;
|
||||
pChan->SetRemoteFramerate(msg->m_NetTick.m_flHostFrameTime, msg->m_NetTick.m_flHostFrameTimeStdDeviation);
|
||||
pChan->SetRemoteCPUStatistics(msg->m_NetTick.m_nServerCPU);
|
||||
if (thisptr_ADJ->IsConnected())
|
||||
{
|
||||
CNetChan* const pChan = thisptr_ADJ->m_NetChannel;
|
||||
|
||||
pChan->SetRemoteFramerate(msg->m_NetTick.m_flHostFrameTime, msg->m_NetTick.m_flHostFrameTimeStdDeviation);
|
||||
pChan->SetRemoteCPUStatistics(msg->m_NetTick.m_nServerCPU);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -93,36 +93,18 @@ bool CNetworkStringTable::Lock(bool bLock)
|
||||
void CNetworkStringTableContainer::WriteUpdateMessage(CNetworkStringTableContainer* thisp, CClient* pClient, unsigned int nTickAck, bf_write* pMsg)
|
||||
{
|
||||
#ifndef CLIENT_DLL
|
||||
const double currentTime = Plat_FloatTime();
|
||||
|
||||
CClientExtended* const clientExtended = pClient->GetClientExtended();
|
||||
int commandTick = -1; // -1 means we update statistics only; see 'CClientState::VProcessServerTick()'.
|
||||
|
||||
// NOTE: if we send this message each tick, the client will start to
|
||||
// falter. Unlike other source games, we have to have some delay in
|
||||
// between each server tick message for this to work correctly.
|
||||
if (clientExtended->ShouldRetryClockSync() ||
|
||||
(currentTime - clientExtended->GetLastClockSyncTime()) > sv_clockSyncInterval->GetFloat())
|
||||
{
|
||||
// Sync the clocks on the client with that of the server's.
|
||||
commandTick = pClient->GetCommandTick();
|
||||
|
||||
clientExtended->SetLastClockSyncTime(currentTime);
|
||||
clientExtended->SetRetryClockSync(false);
|
||||
}
|
||||
|
||||
// If commandTick == statistics only while server opted out, do not
|
||||
// send the message.
|
||||
const bool shouldSend = (commandTick == -1 && !sv_stats->GetBool()) ? false : true;
|
||||
|
||||
if (shouldSend)
|
||||
if (sv_stats->GetBool())
|
||||
{
|
||||
const uint8_t nCPUPercentage = static_cast<uint8_t>(g_pServer->GetCPUUsage() * 100.0f);
|
||||
SVC_ServerTick serverTick(g_pServer->GetTick(), *host_frametime_unbounded, *host_frametime_stddeviation, nCPUPercentage);
|
||||
|
||||
serverTick.m_nGroup = 0;
|
||||
serverTick.m_bReliable = true;
|
||||
serverTick.m_NetTick.m_nCommandTick = commandTick;
|
||||
|
||||
// -1 means we update statistics only; see 'CClientState::VProcessServerTick()'.
|
||||
serverTick.m_NetTick.m_nCommandTick = -1;
|
||||
|
||||
pMsg->WriteUBitLong(serverTick.GetType(), NETMSG_TYPE_BITS);
|
||||
|
||||
@ -130,13 +112,10 @@ void CNetworkStringTableContainer::WriteUpdateMessage(CNetworkStringTableContain
|
||||
{
|
||||
serverTick.WriteToBuffer(pMsg);
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert(0, "Snapshot buffer overflowed before string table update!");
|
||||
clientExtended->SetRetryClockSync(true); // Retry on next snapshot for this client.
|
||||
}
|
||||
}
|
||||
#endif // !CLIENT_DLL
|
||||
|
||||
Assert(!pMsg->IsOverflowed(), "Snapshot buffer overflowed before string table update!");
|
||||
CNetworkStringTableContainer__WriteUpdateMessage(thisp, pClient, nTickAck, pMsg);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user