From d05ab49a2b99fd343666e96c5cb61ea3e77fe02c Mon Sep 17 00:00:00 2001 From: tankefugl Date: Mon, 1 May 2006 17:54:56 +0000 Subject: [PATCH] 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 --- releases/3.2.0/source/mod/AvHConstants.h | 2 +- releases/3.2.0/source/mod/AvHGamerules.cpp | 80 ++++++++++++++++------ releases/3.2.0/source/mod/AvHGamerules.h | 4 ++ releases/3.2.0/source/mod/AvHPlayer.cpp | 6 ++ releases/3.2.0/source/mod/AvHPlayer.h | 2 + 5 files changed, 72 insertions(+), 22 deletions(-) diff --git a/releases/3.2.0/source/mod/AvHConstants.h b/releases/3.2.0/source/mod/AvHConstants.h index 23d1e99..e8d0ca6 100644 --- a/releases/3.2.0/source/mod/AvHConstants.h +++ b/releases/3.2.0/source/mod/AvHConstants.h @@ -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; diff --git a/releases/3.2.0/source/mod/AvHGamerules.cpp b/releases/3.2.0/source/mod/AvHGamerules.cpp index 06bd362..5f614f2 100644 --- a/releases/3.2.0/source/mod/AvHGamerules.cpp +++ b/releases/3.2.0/source/mod/AvHGamerules.cpp @@ -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(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(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(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(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; diff --git a/releases/3.2.0/source/mod/AvHGamerules.h b/releases/3.2.0/source/mod/AvHGamerules.h index 963691b..177c8be 100644 --- a/releases/3.2.0/source/mod/AvHGamerules.h +++ b/releases/3.2.0/source/mod/AvHGamerules.h @@ -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 mServerVariableList; AvHTeamNumber mCombatAttackingTeamNumber; + + bool mHasPlayersToReset; + float mLastPlayerResetTime; }; AvHGamerules* GetGameRules(); diff --git a/releases/3.2.0/source/mod/AvHPlayer.cpp b/releases/3.2.0/source/mod/AvHPlayer.cpp index bb47d47..c46df74 100644 --- a/releases/3.2.0/source/mod/AvHPlayer.cpp +++ b/releases/3.2.0/source/mod/AvHPlayer.cpp @@ -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() diff --git a/releases/3.2.0/source/mod/AvHPlayer.h b/releases/3.2.0/source/mod/AvHPlayer.h index 50f9c94..d572d40 100644 --- a/releases/3.2.0/source/mod/AvHPlayer.h +++ b/releases/3.2.0/source/mod/AvHPlayer.h @@ -478,6 +478,8 @@ public: // tankefugl: 0000953 bool JoinTeamCooledDown(float inCoolDownTime); // tankefugl + + bool GetHasSeenATeam(); private: void AcquireOverwatchTarget(); bool AttemptToBuildAlienStructure(AvHMessageID inMessageID);