mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 22:48:18 +00:00
Backport IGameController::OnPlayerDisconnect() from the upstream
Upstream commit 5e4caa9b9c
This commit is contained in:
parent
7512ad285b
commit
19234987c9
|
@ -1394,7 +1394,7 @@ void CGameContext::OnClientConnected(int ClientID)
|
||||||
void CGameContext::OnClientDrop(int ClientID, const char *pReason)
|
void CGameContext::OnClientDrop(int ClientID, const char *pReason)
|
||||||
{
|
{
|
||||||
AbortVoteKickOnDisconnect(ClientID);
|
AbortVoteKickOnDisconnect(ClientID);
|
||||||
m_apPlayers[ClientID]->OnDisconnect(pReason);
|
m_pController->OnPlayerDisconnect(m_apPlayers[ClientID], pReason);
|
||||||
delete m_apPlayers[ClientID];
|
delete m_apPlayers[ClientID];
|
||||||
m_apPlayers[ClientID] = 0;
|
m_apPlayers[ClientID] = 0;
|
||||||
|
|
||||||
|
|
|
@ -385,6 +385,33 @@ bool IGameController::OnEntity(int Index, vec2 Pos, int Layer, int Flags, int Nu
|
||||||
return false;
|
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()
|
void IGameController::EndRound()
|
||||||
{
|
{
|
||||||
if(m_Warmup) // game can't end when we are running warmup
|
if(m_Warmup) // game can't end when we are running warmup
|
||||||
|
|
|
@ -113,6 +113,8 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual bool OnEntity(int Index, vec2 Pos, int Layer, int Flags, int Number = 0);
|
virtual bool OnEntity(int Index, vec2 Pos, int Layer, int Flags, int Number = 0);
|
||||||
|
|
||||||
|
void OnPlayerDisconnect(class CPlayer *pPlayer, const char *pReason);
|
||||||
|
|
||||||
void OnReset();
|
void OnReset();
|
||||||
|
|
||||||
// game
|
// game
|
||||||
|
|
|
@ -468,34 +468,11 @@ void CPlayer::FakeSnap()
|
||||||
pSpectatorInfo->m_Y = m_ViewPos.y;
|
pSpectatorInfo->m_Y = m_ViewPos.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPlayer::OnDisconnect(const char *pReason)
|
void CPlayer::OnDisconnect()
|
||||||
{
|
{
|
||||||
KillCharacter();
|
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;
|
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPlayer::OnPredictedInput(CNetObj_PlayerInput *NewInput)
|
void CPlayer::OnPredictedInput(CNetObj_PlayerInput *NewInput)
|
||||||
|
|
|
@ -47,7 +47,7 @@ public:
|
||||||
void OnDirectInput(CNetObj_PlayerInput *NewInput);
|
void OnDirectInput(CNetObj_PlayerInput *NewInput);
|
||||||
void OnPredictedInput(CNetObj_PlayerInput *NewInput);
|
void OnPredictedInput(CNetObj_PlayerInput *NewInput);
|
||||||
void OnPredictedEarlyInput(CNetObj_PlayerInput *NewInput);
|
void OnPredictedEarlyInput(CNetObj_PlayerInput *NewInput);
|
||||||
void OnDisconnect(const char *pReason);
|
void OnDisconnect();
|
||||||
|
|
||||||
void KillCharacter(int Weapon = WEAPON_GAME);
|
void KillCharacter(int Weapon = WEAPON_GAME);
|
||||||
CCharacter *GetCharacter();
|
CCharacter *GetCharacter();
|
||||||
|
|
Loading…
Reference in a new issue