diff options
| author | oy <Tom_Adams@web.de> | 2010-10-09 19:14:42 +0200 |
|---|---|---|
| committer | oy <Tom_Adams@web.de> | 2010-10-09 19:14:42 +0200 |
| commit | cd95f1869e12a8ca2983a1b3300d195f043d6391 (patch) | |
| tree | b85b0cf35278fd6dc981986ff30f177683ab13c5 /src/game/server/gamecontroller.cpp | |
| parent | b3c81e7258cabc72cf9f610da0aa6aa494dd30a9 (diff) | |
| download | zcatch-cd95f1869e12a8ca2983a1b3300d195f043d6391.tar.gz zcatch-cd95f1869e12a8ca2983a1b3300d195f043d6391.zip | |
added inactive player kicking. Closes #51
Diffstat (limited to 'src/game/server/gamecontroller.cpp')
| -rw-r--r-- | src/game/server/gamecontroller.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/game/server/gamecontroller.cpp b/src/game/server/gamecontroller.cpp index 854787d6..03372ad1 100644 --- a/src/game/server/gamecontroller.cpp +++ b/src/game/server/gamecontroller.cpp @@ -443,7 +443,9 @@ void IGameController::Tick() } // move the player to the other team + int Temp = pP->m_LastActionTick; pP->SetTeam(M^1); + pP->m_LastActionTick = Temp; pP->Respawn(); pP->m_ForceBalanced = true; @@ -453,6 +455,47 @@ void IGameController::Tick() } m_UnbalancedTick = -1; } + + // check for inactive players + if(g_Config.m_SvInactiveKickTime > 0) + { + for(int i = 0; i < MAX_CLIENTS; ++i) + { + if(GameServer()->m_apPlayers[i] && GameServer()->m_apPlayers[i]->GetTeam() != -1) + { + if(Server()->Tick() > GameServer()->m_apPlayers[i]->m_LastActionTick+g_Config.m_SvInactiveKickTime*Server()->TickSpeed()*60) + { + switch(g_Config.m_SvInactiveKick) + { + case 0: + { + // move player to spectator + GameServer()->m_apPlayers[i]->SetTeam(-1); + } + break; + case 1: + { + // move player to spectator if the reserved slots aren't filled yet, kick him otherwise + int Spectators = 0; + for(int j = 0; j < MAX_CLIENTS; ++j) + if(GameServer()->m_apPlayers[j] && GameServer()->m_apPlayers[j]->GetTeam() == -1) + ++Spectators; + if(Spectators >= g_Config.m_SvSpectatorSlots) + Server()->Kick(i, "kicked for inactivity"); + else + GameServer()->m_apPlayers[i]->SetTeam(-1); + } + break; + case 2: + { + // kick the player + Server()->Kick(i, "Kicked for inactivity"); + } + } + } + } + } + } // update browse info int Prog = -1; |