o Lowered the rate of players being forced to the RR from 8/sec to 5/sec.

o Added throttling to the resetting of players. It resets players at a rate of 6 players per 0.3s.

git-svn-id: https://unknownworlds.svn.cloudforge.com/ns1@441 67975925-1194-0748-b3d5-c16f83f1a3a1
This commit is contained in:
tankefugl 2006-05-01 17:54:56 +00:00
parent 3662dedb2e
commit d05ab49a2b
5 changed files with 72 additions and 22 deletions

View file

@ -136,7 +136,7 @@ const int kMaxUpgradeLevel = 3;
const int kFuncResourceMaxResources = 300;
//const float kPlayerResourceScalar = 2.0f; // 1.5 might be better
const int kVictoryIntermission = 12;
const int kResetPlayersPerSecond = 8;
const int kResetPlayersPerSecond = 5;
const float kBuildingUseWarmupTime = 2.0f;
const float kRedeemInvulnerableTime = 1.0f;

View file

@ -2511,6 +2511,8 @@ void AvHGamerules::ResetGame(bool inPreserveTeams)
this->mFirstUpdate = true;
this->mPreserveTeams = inPreserveTeams;
gSvCheatsLastUpdateTime = -1.0f;
this->mHasPlayersToReset = false;
this->mLastPlayerResetTime = -1.0f;
}
void AvHGamerules::RecalculateMapMode( void )
@ -2648,16 +2650,18 @@ void AvHGamerules::MarkDramaticEvent(int inPriority, short inPrimaryEntityIndex,
this->MarkDramaticEvent(inPriority, inPrimaryEntityIndex, secondaryEntityIndex);
}
void AvHGamerules::ResetEntities()
// Resets players in chunks of 6 and 6
void AvHGamerules::ResetPlayers()
{
// Now reset all the world entities and mark useable ones with AVH_USER3_USEABLE
//AvHSUPrintDevMessage("FOR_ALL_BASEENTITIES: AvHGamerules::ResetEntities\n");
const int maxReset = 6;
int numReset = 0;
FOR_ALL_BASEENTITIES();
// Reset the entity. Assumes that players in the ready room have already been reset recently.
// Reset the players
// Reset only players that have made it to the readyroom and have been on either team
AvHPlayer* thePlayer = dynamic_cast<AvHPlayer*>(theBaseEntity);
if(thePlayer && (thePlayer->GetPlayMode() == PLAYMODE_READYROOM))
if(thePlayer && (thePlayer->GetPlayMode() == PLAYMODE_READYROOM) && (thePlayer->GetHasSeenATeam()))
{
int theUser3 = thePlayer->pev->iuser3;
int theUser4 = thePlayer->pev->iuser4;
@ -2672,38 +2676,65 @@ void AvHGamerules::ResetEntities()
thePlayer->pev->playerclass = thePlayMode;
thePlayer->pev->team = thePlayerTeam;
thePlayer->pev->solid = theSolidType;
if (numReset++ >= maxReset)
{
this->mHasPlayersToReset = true;
return;
}
}
END_FOR_ALL_BASEENTITIES();
this->mHasPlayersToReset = false;
}
void AvHGamerules::ResetEntities()
{
// Now reset all the world entities and mark useable ones with AVH_USER3_USEABLE
//AvHSUPrintDevMessage("FOR_ALL_BASEENTITIES: AvHGamerules::ResetEntities\n");
FOR_ALL_BASEENTITIES();
// Reset non-player entities
AvHPlayer* thePlayer = dynamic_cast<AvHPlayer*>(theBaseEntity);
if(thePlayer && (thePlayer->GetPlayMode() == PLAYMODE_READYROOM)) // && (thePlayer->GetHasSeenATeam()))
{
// SNIP
}
else
{
theBaseEntity->ResetEntity();
}
// Don't mark commander stations as useable in this case
AvHCommandStation* theCommandStation = dynamic_cast<AvHCommandStation*>(theBaseEntity);
if(!theCommandStation)
{
int theObjectCaps = theBaseEntity->ObjectCaps();
if(theObjectCaps & (FCAP_IMPULSE_USE | FCAP_CONTINUOUS_USE | FCAP_ONOFF_USE))
// Don't mark commander stations as useable in this case
AvHCommandStation* theCommandStation = dynamic_cast<AvHCommandStation*>(theBaseEntity);
if(!theCommandStation)
{
// After playing once, this is no longer zero
if(theBaseEntity->pev->iuser3 == 0)
int theObjectCaps = theBaseEntity->ObjectCaps();
if(theObjectCaps & (FCAP_IMPULSE_USE | FCAP_CONTINUOUS_USE | FCAP_ONOFF_USE))
{
theBaseEntity->pev->iuser3 = AVH_USER3_USEABLE;
// Now also mark the target entity as useable!
if (!FStringNull(theBaseEntity->pev->target))
// After playing once, this is no longer zero
if(theBaseEntity->pev->iuser3 == 0)
{
CBaseEntity* theTarget = NULL;
theBaseEntity->pev->iuser3 = AVH_USER3_USEABLE;
while(theTarget = UTIL_FindEntityByTargetname(theTarget, STRING(theBaseEntity->pev->target)))
// Now also mark the target entity as useable!
if (!FStringNull(theBaseEntity->pev->target))
{
theTarget->pev->iuser3 = AVH_USER3_USEABLE;
CBaseEntity* theTarget = NULL;
while(theTarget = UTIL_FindEntityByTargetname(theTarget, STRING(theBaseEntity->pev->target)))
{
theTarget->pev->iuser3 = AVH_USER3_USEABLE;
}
}
}
}
}
}
END_FOR_ALL_BASEENTITIES();
this->mHasPlayersToReset = true;
}
void AvHGamerules::InternalResetGameRules()
@ -3196,6 +3227,13 @@ void AvHGamerules::Think(void)
this->mFirstUpdate = false;
}
const float playerResetDelay = 0.3f;
if(this->mHasPlayersToReset && (this->mLastPlayerResetTime + playerResetDelay < theTime) )
{
this->ResetPlayers();
this->mLastPlayerResetTime = theTime;
}
// Handle queued network messages
#ifdef USE_NETWORK_METERING
const float kNetworkUpdateInterval = .1f;

View file

@ -324,6 +324,7 @@ private:
void PostVictoryStatsToWeb(const string& inFormParams) const;
bool ReadyToStartCountdown();
void ResetGame(bool inPreserveTeams = false);
void ResetPlayers();
void SendGameTimeUpdate(bool inReliable = false);
void ProcessTeamUpgrades();
void ResetEntities();
@ -417,6 +418,9 @@ private:
std::vector<std::string> mServerVariableList;
AvHTeamNumber mCombatAttackingTeamNumber;
bool mHasPlayersToReset;
float mLastPlayerResetTime;
};
AvHGamerules* GetGameRules();

View file

@ -4029,6 +4029,11 @@ bool AvHPlayer::GetHasActiveAlienWeaponWithImpulse(AvHMessageID inMessageID) con
return theHasWeapon;
}
bool AvHPlayer::GetHasSeenATeam()
{
return (this->mHasSeenTeamA || this->mHasSeenTeamB);
}
bool AvHPlayer::GetHasSeenTeam(AvHTeamNumber inNumber) const
{
bool theHasBeenOnTeam = false;
@ -7095,6 +7100,7 @@ void AvHPlayer::ResetEntity(void)
this->mNewMap = theSavedNewMap;
this->mDesiredNetName = theSavedDesiredNetName;
this->mClientInfoLocations = theSavedClientInfoLocations;
}
void AvHPlayer::ResetOverwatch()

View file

@ -478,6 +478,8 @@ public:
// tankefugl: 0000953
bool JoinTeamCooledDown(float inCoolDownTime);
// tankefugl
bool GetHasSeenATeam();
private:
void AcquireOverwatchTarget();
bool AttemptToBuildAlienStructure(AvHMessageID inMessageID);