From 58ec211b688c8518d4abb6c57dca2f3adac459de Mon Sep 17 00:00:00 2001 From: tankefugl Date: Wed, 6 Jul 2005 00:43:42 +0000 Subject: [PATCH] Ported performance changes from SVN revision 224, 229, 231 and 233, 3.0.5 performance branch. git-svn-id: https://unknownworlds.svn.cloudforge.com/ns1@242 67975925-1194-0748-b3d5-c16f83f1a3a1 --- main/source/mod/AvHGamerules.cpp | 13 ++++++++++--- main/source/mod/AvHPlayer.cpp | 28 ++++++++++++++++------------ main/source/mod/AvHPlayer.h | 1 + 3 files changed, 27 insertions(+), 15 deletions(-) diff --git a/main/source/mod/AvHGamerules.cpp b/main/source/mod/AvHGamerules.cpp index b318c63b..9fa9f343 100644 --- a/main/source/mod/AvHGamerules.cpp +++ b/main/source/mod/AvHGamerules.cpp @@ -292,6 +292,7 @@ void SetGameRules(AvHGamerules* inGameRules) g_pGameRules = inGameRules; } +static float gSvCheatsLastUpdateTime; AvHGamerules::AvHGamerules() : mTeamA(TEAM_ONE), mTeamB(TEAM_TWO) { this->mGameStarted = false; @@ -299,7 +300,7 @@ AvHGamerules::AvHGamerules() : mTeamA(TEAM_ONE), mTeamB(TEAM_TWO) this->mTeamA.SetTeamType(AVH_CLASS_TYPE_MARINE); this->mTeamB.SetTeamType(AVH_CLASS_TYPE_ALIEN); - + gSvCheatsLastUpdateTime = -1.0f; this->mVictoryTime = -1; this->mMapMode = MAP_MODE_UNDEFINED; this->mLastParticleUpdate = -1; @@ -1039,7 +1040,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" ); + if (gpGlobals->time > (gSvCheatsLastUpdateTime + 0.5f)) + { + theCheatsEnabled = CVAR_GET_FLOAT( "sv_cheats" ); + gSvCheatsLastUpdateTime = gpGlobals->time; + } return (theCheatsEnabled == 1.0f); } @@ -2319,6 +2325,7 @@ void AvHGamerules::ResetGame(bool inPreserveTeams) // Reset game rules this->mFirstUpdate = true; this->mPreserveTeams = inPreserveTeams; + gSvCheatsLastUpdateTime = -1.0f; } void AvHGamerules::RecalculateMapMode( void ) @@ -2531,7 +2538,7 @@ void AvHGamerules::InternalResetGameRules() this->mSentCountdownMessage = false; this->mTimeWorldReset = gpGlobals->time; this->mCombatAttackingTeamNumber = TEAM_IND; - + gSvCheatsLastUpdateTime = -1.0f; if(this->mLastMapChange == -1) { this->mLastMapChange = gpGlobals->time; diff --git a/main/source/mod/AvHPlayer.cpp b/main/source/mod/AvHPlayer.cpp index b76fb27d..24a4ca40 100644 --- a/main/source/mod/AvHPlayer.cpp +++ b/main/source/mod/AvHPlayer.cpp @@ -3261,7 +3261,7 @@ void AvHPlayer::Init() AvHGamerules* theGameRules = GetGameRules(); mServerVariableList.clear(); - + mLastUpdateTime = -1; for (i = 0; i < theGameRules->GetNumServerVariables(); ++i) { mServerVariableList.push_back(ServerVariable()); @@ -6534,17 +6534,21 @@ void AvHPlayer::InternalCommonThink() void AvHPlayer::PropagateServerVariables() { - for (int i = 0; i < (signed)mServerVariableList.size(); ++i) - { - std::string theValue = CVAR_GET_STRING( mServerVariableList[i].mName.c_str() ); - - if ( mServerVariableList[i].mLastValueSent != theValue) - { - NetMsg_ServerVar( this->pev, mServerVariableList[i].mName, theValue ); - mServerVariableList[i].mLastValueSent = theValue; - break; // Only send one message per tick to avoid overflow. - } - } + if ( gpGlobals->time > (mLastUpdateTime + 0.5f) ) + { + for (int i = 0; i < (signed)mServerVariableList.size(); ++i) + { + std::string theValue = CVAR_GET_STRING( mServerVariableList[i].mName.c_str() ); + + if ( mServerVariableList[i].mLastValueSent != theValue) + { + NetMsg_ServerVar( this->pev, mServerVariableList[i].mName, theValue ); + mServerVariableList[i].mLastValueSent = theValue; + break; // Only send one message per tick to avoid overflow. + } + } + mLastUpdateTime = gpGlobals->time; + } } void AvHPlayer::InternalMarineThink() diff --git a/main/source/mod/AvHPlayer.h b/main/source/mod/AvHPlayer.h index 7c368408..c70ebb12 100644 --- a/main/source/mod/AvHPlayer.h +++ b/main/source/mod/AvHPlayer.h @@ -817,6 +817,7 @@ private: int mScore; int mSavedCombatFrags; + float mLastUpdateTime; string mNetworkAddress; int mLastModelIndex;