Skip to content

Commit f57f4d5

Browse files
committed
GameController: Extract infclass-specifc Inactive kick stuff
1 parent 3fdc46b commit f57f4d5

File tree

4 files changed

+18
-4
lines changed

4 files changed

+18
-4
lines changed

src/game/server/gamecontroller.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,6 @@ void IGameController::DoActivityCheck()
127127
if(g_Config.m_SvInactiveKickTime == 0)
128128
return;
129129

130-
int HumanMaxInactiveTimeSecs = Config()->m_InfInactiveHumansKickTime ? Config()->m_InfInactiveHumansKickTime : Config()->m_SvInactiveKickTime * 60;
131-
int InfectedMaxInactiveTimeSecs = Config()->m_InfInactiveInfectedKickTime ? Config()->m_InfInactiveInfectedKickTime : Config()->m_SvInactiveKickTime * 60;
132-
133130
unsigned int nbPlayers = 0;
134131

135132
for(int i = 0; i < MAX_CLIENTS; ++i)
@@ -166,7 +163,7 @@ void IGameController::DoActivityCheck()
166163
if(pPlayer->IsBot())
167164
continue;
168165

169-
float PlayerMaxInactiveTimeSecs = pPlayer->IsHuman() ? HumanMaxInactiveTimeSecs : InfectedMaxInactiveTimeSecs;
166+
float PlayerMaxInactiveTimeSecs = GetMaxInactiveTimeSeconds(pPlayer);
170167
if(PlayerMaxInactiveTimeSecs < 20)
171168
{
172169
PlayerMaxInactiveTimeSecs = 20;
@@ -353,6 +350,11 @@ int IGameController::GetNextClientUniqueId()
353350
return m_NextUniqueClientId++;
354351
}
355352

353+
float IGameController::GetMaxInactiveTimeSeconds(const CPlayer *pPlayer) const
354+
{
355+
return Config()->m_SvInactiveKickTime * 60;
356+
}
357+
356358
void IGameController::DoTeamChange(CPlayer *pPlayer, int Team, bool DoChatMsg)
357359
{
358360
Team = ClampTeam(Team);

src/game/server/gamecontroller.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ class IGameController
114114
bool IsAmmoHudEnabled() const;
115115
void SetAmmoHudEnabled(bool Enabled);
116116

117+
virtual float GetMaxInactiveTimeSeconds(const CPlayer *pPlayer) const;
117118
virtual void DoWincheck();
118119

119120
// event

src/game/server/infclass/infcgamecontroller.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5137,6 +5137,16 @@ void CInfClassGameController::CheckRoundFailed()
51375137
}
51385138
}
51395139

5140+
float CInfClassGameController::GetMaxInactiveTimeSeconds(const CPlayer *pPlayer) const
5141+
{
5142+
const CInfClassPlayer *pInfPlayer = CInfClassPlayer::GetInstance(pPlayer);
5143+
5144+
int HumanMaxInactiveTimeSecs = Config()->m_InfInactiveHumansKickTime ? Config()->m_InfInactiveHumansKickTime : Config()->m_SvInactiveKickTime * 60;
5145+
int InfectedMaxInactiveTimeSecs = Config()->m_InfInactiveInfectedKickTime ? Config()->m_InfInactiveInfectedKickTime : Config()->m_SvInactiveKickTime * 60;
5146+
5147+
return pInfPlayer->IsHuman() ? HumanMaxInactiveTimeSecs : InfectedMaxInactiveTimeSecs;
5148+
}
5149+
51405150
void CInfClassGameController::DoWincheck()
51415151
{
51425152
if(!IsWinCheckEnabled())

src/game/server/infclass/infcgamecontroller.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ class CInfClassGameController : public IGameController
126126
void OnCharacterSpawned(CInfClassCharacter *pCharacter, const SpawnContext &Context);
127127
void OnClassChooserRequested(CInfClassCharacter *pCharacter);
128128
void CheckRoundFailed();
129+
float GetMaxInactiveTimeSeconds(const CPlayer *pPlayer) const override;
129130
void DoWincheck() override;
130131
void StartRound() override;
131132
void ResetRoundData();

0 commit comments

Comments
 (0)