From 9d66c2530be938439f47c0d4ddcbedb46c9898e3 Mon Sep 17 00:00:00 2001 From: def Date: Fri, 20 Nov 2020 18:11:06 +0100 Subject: [PATCH] Check finish of team after player joins spectators Reported by Jupeyy --- src/game/server/player.cpp | 6 ++++++ src/game/server/teams.h | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/game/server/player.cpp b/src/game/server/player.cpp index 0a914f62e..2f3270e49 100644 --- a/src/game/server/player.cpp +++ b/src/game/server/player.cpp @@ -631,7 +631,13 @@ void CPlayer::SetTeam(int Team, bool DoChatMsg) { CGameControllerDDRace *Controller = (CGameControllerDDRace *)GameServer()->m_pController; if(g_Config.m_SvTeam != 3) + { + // Joining spectators should not kill a locked team, but should still + // check if the team finished by you leaving it. + int DDRTeam = m_pCharacter->Team(); Controller->m_Teams.SetForceCharacterTeam(m_ClientID, TEAM_FLOCK); + Controller->m_Teams.CheckTeamFinished(DDRTeam); + } } KillCharacter(); diff --git a/src/game/server/teams.h b/src/game/server/teams.h index f2f446707..192126d5b 100644 --- a/src/game/server/teams.h +++ b/src/game/server/teams.h @@ -19,7 +19,6 @@ class CGameTeams class CGameContext *m_pGameContext; - void CheckTeamFinished(int ClientID); bool TeamFinished(int Team); void OnTeamFinish(CPlayer **Players, unsigned int Size, float Time, const char *pTimestamp); void OnFinish(CPlayer *Player, float Time, const char *pTimestamp); @@ -62,6 +61,7 @@ public: void OnCharacterDeath(int ClientID, int Weapon); bool SetCharacterTeam(int ClientID, int Team); + void CheckTeamFinished(int ClientID); void ChangeTeamState(int Team, int State); void onChangeTeamState(int Team, int State, int OldState);