diff --git a/src/game/server/gamecontext.cpp b/src/game/server/gamecontext.cpp index 38b649c56..2ea064a44 100644 --- a/src/game/server/gamecontext.cpp +++ b/src/game/server/gamecontext.cpp @@ -1394,7 +1394,7 @@ void CGameContext::OnClientConnected(int ClientID) void CGameContext::OnClientDrop(int ClientID, const char *pReason) { AbortVoteKickOnDisconnect(ClientID); - m_apPlayers[ClientID]->OnDisconnect(pReason); + m_pController->OnPlayerDisconnect(m_apPlayers[ClientID], pReason); delete m_apPlayers[ClientID]; m_apPlayers[ClientID] = 0; diff --git a/src/game/server/gamecontroller.cpp b/src/game/server/gamecontroller.cpp index b22a87c53..b36febfcb 100644 --- a/src/game/server/gamecontroller.cpp +++ b/src/game/server/gamecontroller.cpp @@ -385,6 +385,33 @@ bool IGameController::OnEntity(int Index, vec2 Pos, int Layer, int Flags, int Nu return false; } +void IGameController::OnPlayerDisconnect(class CPlayer *pPlayer, const char *pReason) +{ + bool WasModerator = pPlayer->m_Moderating; + + pPlayer->OnDisconnect(); + int ClientID = pPlayer->GetCID(); + if(Server()->ClientIngame(ClientID)) + { + char aBuf[512]; + if(pReason && *pReason) + str_format(aBuf, sizeof(aBuf), "'%s' has left the game (%s)", Server()->ClientName(ClientID), pReason); + else + str_format(aBuf, sizeof(aBuf), "'%s' has left the game", Server()->ClientName(ClientID)); + GameServer()->SendChat(-1, CGameContext::CHAT_ALL, aBuf, -1, CGameContext::CHAT_SIX); + + str_format(aBuf, sizeof(aBuf), "leave player='%d:%s'", ClientID, Server()->ClientName(ClientID)); + GameServer()->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "game", aBuf); + + if(!GameServer()->PlayerModerating() && WasModerator) + GameServer()->SendChat(-1, CGameContext::CHAT_ALL, "Server kick/spec votes are no longer actively moderated."); + } + + CGameControllerDDRace *Controller = (CGameControllerDDRace *)GameServer()->m_pController; + if(g_Config.m_SvTeam != 3) + Controller->m_Teams.SetForceCharacterTeam(ClientID, TEAM_FLOCK); +} + void IGameController::EndRound() { if(m_Warmup) // game can't end when we are running warmup diff --git a/src/game/server/gamecontroller.h b/src/game/server/gamecontroller.h index d1d540ac8..de262b742 100644 --- a/src/game/server/gamecontroller.h +++ b/src/game/server/gamecontroller.h @@ -113,6 +113,8 @@ public: */ virtual bool OnEntity(int Index, vec2 Pos, int Layer, int Flags, int Number = 0); + void OnPlayerDisconnect(class CPlayer *pPlayer, const char *pReason); + void OnReset(); // game diff --git a/src/game/server/player.cpp b/src/game/server/player.cpp index e119e1a9d..933435ca5 100644 --- a/src/game/server/player.cpp +++ b/src/game/server/player.cpp @@ -468,34 +468,11 @@ void CPlayer::FakeSnap() pSpectatorInfo->m_Y = m_ViewPos.y; } -void CPlayer::OnDisconnect(const char *pReason) +void CPlayer::OnDisconnect() { KillCharacter(); - if(Server()->ClientIngame(m_ClientID)) - { - char aBuf[512]; - if(pReason && *pReason) - str_format(aBuf, sizeof(aBuf), "'%s' has left the game (%s)", Server()->ClientName(m_ClientID), pReason); - else - str_format(aBuf, sizeof(aBuf), "'%s' has left the game", Server()->ClientName(m_ClientID)); - GameServer()->SendChat(-1, CGameContext::CHAT_ALL, aBuf, -1, CGameContext::CHAT_SIX); - - str_format(aBuf, sizeof(aBuf), "leave player='%d:%s'", m_ClientID, Server()->ClientName(m_ClientID)); - GameServer()->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "game", aBuf); - - bool WasModerator = m_Moderating; - - // Set this to false, otherwise PlayerModerating() will return true. - m_Moderating = false; - - if(!GameServer()->PlayerModerating() && WasModerator) - GameServer()->SendChat(-1, CGameContext::CHAT_ALL, "Server kick/spec votes are no longer actively moderated."); - } - - CGameControllerDDRace *Controller = (CGameControllerDDRace *)GameServer()->m_pController; - if(g_Config.m_SvTeam != 3) - Controller->m_Teams.SetForceCharacterTeam(m_ClientID, TEAM_FLOCK); + m_Moderating = false; } void CPlayer::OnPredictedInput(CNetObj_PlayerInput *NewInput) diff --git a/src/game/server/player.h b/src/game/server/player.h index b86804c55..16ae80f99 100644 --- a/src/game/server/player.h +++ b/src/game/server/player.h @@ -47,7 +47,7 @@ public: void OnDirectInput(CNetObj_PlayerInput *NewInput); void OnPredictedInput(CNetObj_PlayerInput *NewInput); void OnPredictedEarlyInput(CNetObj_PlayerInput *NewInput); - void OnDisconnect(const char *pReason); + void OnDisconnect(); void KillCharacter(int Weapon = WEAPON_GAME); CCharacter *GetCharacter();