MCPcopy Create free account
hub / github.com/ddnet/ddnet / DoActivityCheck

Method DoActivityCheck

src/game/server/gamecontroller.cpp:46–87  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44IGameController::~IGameController() = default;
45
46void IGameController::DoActivityCheck()
47{
48 if(g_Config.m_SvInactiveKickTime == 0)
49 return;
50
51 for(int i = 0; i < MAX_CLIENTS; ++i)
52 {
53 if(GameServer()->m_apPlayers[i] && GameServer()->m_apPlayers[i]->GetTeam() != TEAM_SPECTATORS && !Server()->IsRconAuthed(i))
54 {
55 if(Server()->Tick() > GameServer()->m_apPlayers[i]->m_LastActionTick + g_Config.m_SvInactiveKickTime * Server()->TickSpeed() * 60)
56 {
57 switch(g_Config.m_SvInactiveKick)
58 {
59 case 0:
60 {
61 // move player to spectator
62 DoTeamChange(GameServer()->m_apPlayers[i], TEAM_SPECTATORS);
63 }
64 break;
65 case 1:
66 {
67 // move player to spectator if the reserved slots aren't filled yet, kick them otherwise
68 int Spectators = 0;
69 for(auto &pPlayer : GameServer()->m_apPlayers)
70 if(pPlayer && pPlayer->GetTeam() == TEAM_SPECTATORS)
71 ++Spectators;
72 if(Spectators >= g_Config.m_SvSpectatorSlots)
73 Server()->Kick(i, "Kicked for inactivity");
74 else
75 DoTeamChange(GameServer()->m_apPlayers[i], TEAM_SPECTATORS);
76 }
77 break;
78 case 2:
79 {
80 // kick the player
81 Server()->Kick(i, "Kicked for inactivity");
82 }
83 }
84 }
85 }
86 }
87}
88
89float IGameController::EvaluateSpawnPos(CSpawnEval *pEval, vec2 Pos, int ClientId)
90{

Callers

nothing calls this directly

Calls 6

GetTeamMethod · 0.80
IsRconAuthedMethod · 0.80
TickSpeedMethod · 0.80
ServerClass · 0.50
TickMethod · 0.45
KickMethod · 0.45

Tested by

no test coverage detected