mirror of
https://github.com/ENSL/NS.git
synced 2025-02-17 01:21:45 +00:00
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:
parent
afd0f999bb
commit
576a109c50
2 changed files with 30 additions and 22 deletions
|
@ -1375,7 +1375,12 @@ const AvHBaseInfoLocationListType& AvHGamerules::GetInfoLocations() const
|
||||||
|
|
||||||
bool AvHGamerules::GetCheatsEnabled(void) 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);
|
return (theCheatsEnabled == 1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6969,31 +6969,34 @@ void AvHPlayer::InternalCommonThink()
|
||||||
|
|
||||||
void AvHPlayer::PropagateServerVariables()
|
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 theValue = CVAR_GET_STRING( mServerVariableList[i].mName.c_str() );
|
||||||
std::string lastValue = mServerVariableList[i].mLastValueSent;
|
std::string lastValue = mServerVariableList[i].mLastValueSent;
|
||||||
|
|
||||||
if ( mServerVariableList[i].mLastValueSent != theValue)
|
if ( mServerVariableList[i].mLastValueSent != theValue)
|
||||||
{
|
{
|
||||||
|
|
||||||
mServerVariableList[i].mLastValueSent = theValue;
|
mServerVariableList[i].mLastValueSent = theValue;
|
||||||
|
|
||||||
MESSAGE_BEGIN(MSG_ONE, gmsgServerVar, NULL, this->pev);
|
MESSAGE_BEGIN(MSG_ONE, gmsgServerVar, NULL, this->pev);
|
||||||
|
|
||||||
WRITE_STRING( mServerVariableList[i].mName.c_str() );
|
WRITE_STRING( mServerVariableList[i].mName.c_str() );
|
||||||
WRITE_STRING( mServerVariableList[i].mLastValueSent.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()
|
void AvHPlayer::InternalMarineThink()
|
||||||
|
@ -10370,10 +10373,10 @@ void AvHPlayer::UpdateVUser4()
|
||||||
// Update client with resources (as int)
|
// Update client with resources (as int)
|
||||||
int theResources = (short)(this->GetResources(true));
|
int theResources = (short)(this->GetResources(true));
|
||||||
|
|
||||||
if(CVAR_GET_FLOAT(kvTesting))
|
// if(CVAR_GET_FLOAT(kvTesting))
|
||||||
{
|
// {
|
||||||
theResources = g_engfuncs.pfnNumberOfEntities();
|
// theResources = g_engfuncs.pfnNumberOfEntities();
|
||||||
}
|
// }
|
||||||
|
|
||||||
if(this->pev)
|
if(this->pev)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue