From 576a109c50999c6f8ba972180f813167168d49f7 Mon Sep 17 00:00:00 2001 From: puzl Date: Thu, 30 Jun 2005 01:01:14 +0000 Subject: [PATCH] Performance Changes: Throttle the rate at which AvHPlayer::PropagateServerVariables and AvHGameRules::GetCheatsEnabled execute. git-svn-id: https://unknownworlds.svn.cloudforge.com/ns1@224 67975925-1194-0748-b3d5-c16f83f1a3a1 --- .../source/mod/AvHGamerules.cpp | 7 ++- .../source/mod/AvHPlayer.cpp | 45 ++++++++++--------- 2 files changed, 30 insertions(+), 22 deletions(-) diff --git a/dev/performance-3.0.5/source/mod/AvHGamerules.cpp b/dev/performance-3.0.5/source/mod/AvHGamerules.cpp index e00c6375..1cf127b7 100644 --- a/dev/performance-3.0.5/source/mod/AvHGamerules.cpp +++ b/dev/performance-3.0.5/source/mod/AvHGamerules.cpp @@ -1375,7 +1375,12 @@ const AvHBaseInfoLocationListType& AvHGamerules::GetInfoLocations() const bool AvHGamerules::GetCheatsEnabled(void) const { - float theCheatsEnabled = CVAR_GET_FLOAT( "sv_cheats" ); + static float theCheatsEnabled = CVAR_GET_FLOAT( "sv_cheats" ); + static float theLastUpdateTime = gpGlobals->time; + if ( gpGlobals->time > (theLastUpdateTime + 0.5f ) ) { + theCheatsEnabled = CVAR_GET_FLOAT( "sv_cheats" ); + theLastUpdateTime = gpGlobals->time; + } return (theCheatsEnabled == 1.0f); } diff --git a/dev/performance-3.0.5/source/mod/AvHPlayer.cpp b/dev/performance-3.0.5/source/mod/AvHPlayer.cpp index 41868a3a..e9b3e3a6 100644 --- a/dev/performance-3.0.5/source/mod/AvHPlayer.cpp +++ b/dev/performance-3.0.5/source/mod/AvHPlayer.cpp @@ -6969,31 +6969,34 @@ void AvHPlayer::InternalCommonThink() void AvHPlayer::PropagateServerVariables() { + static float theLastUpdateTime = -1.0f; + if ( gpGlobals->time > (theLastUpdateTime + 0.5f ) ) { - for (int i = 0; i < (signed)mServerVariableList.size(); ++i) - { + for (int i = 0; i < (signed)mServerVariableList.size(); ++i) + { - std::string theValue = CVAR_GET_STRING( mServerVariableList[i].mName.c_str() ); - std::string lastValue = mServerVariableList[i].mLastValueSent; - - if ( mServerVariableList[i].mLastValueSent != theValue) - { + std::string theValue = CVAR_GET_STRING( mServerVariableList[i].mName.c_str() ); + std::string lastValue = mServerVariableList[i].mLastValueSent; + + if ( mServerVariableList[i].mLastValueSent != theValue) + { - mServerVariableList[i].mLastValueSent = theValue; - - MESSAGE_BEGIN(MSG_ONE, gmsgServerVar, NULL, this->pev); + mServerVariableList[i].mLastValueSent = theValue; + + MESSAGE_BEGIN(MSG_ONE, gmsgServerVar, NULL, this->pev); - WRITE_STRING( mServerVariableList[i].mName.c_str() ); - WRITE_STRING( mServerVariableList[i].mLastValueSent.c_str() ); + WRITE_STRING( mServerVariableList[i].mName.c_str() ); + WRITE_STRING( mServerVariableList[i].mLastValueSent.c_str() ); - MESSAGE_END(); + MESSAGE_END(); - break; // Only send one message per tick to avoid overflow. + break; // Only send one message per tick to avoid overflow. - } - - } + } + } + theLastUpdateTime = gpGlobals->time; + } } void AvHPlayer::InternalMarineThink() @@ -10370,10 +10373,10 @@ void AvHPlayer::UpdateVUser4() // Update client with resources (as int) int theResources = (short)(this->GetResources(true)); - if(CVAR_GET_FLOAT(kvTesting)) - { - theResources = g_engfuncs.pfnNumberOfEntities(); - } +// if(CVAR_GET_FLOAT(kvTesting)) +// { +// theResources = g_engfuncs.pfnNumberOfEntities(); +// } if(this->pev) {