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
This commit is contained in:
puzl 2005-06-30 01:01:14 +00:00
parent afd0f999bb
commit 576a109c50
2 changed files with 30 additions and 22 deletions

View file

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

View file

@ -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)
{