3341: Check finish of team after player joins spectators r=heinrich5991 a=def-

Reported by Jupeyy

<!-- What is the motivation for the changes of this pull request -->

## Checklist

- [x] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test if it works standalone, system.c especially
- [x] Considered possible null pointers and out of bounds array indexing
- [x] Changed no physics that affect existing maps
- [x] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


Co-authored-by: def <dennis@felsin9.de>
This commit is contained in:
bors[bot] 2020-11-28 20:18:37 +00:00 committed by GitHub
commit 6eb56ffb13
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View file

@ -631,7 +631,13 @@ void CPlayer::SetTeam(int Team, bool DoChatMsg)
{ {
CGameControllerDDRace *Controller = (CGameControllerDDRace *)GameServer()->m_pController; CGameControllerDDRace *Controller = (CGameControllerDDRace *)GameServer()->m_pController;
if(g_Config.m_SvTeam != 3) 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.SetForceCharacterTeam(m_ClientID, TEAM_FLOCK);
Controller->m_Teams.CheckTeamFinished(DDRTeam);
}
} }
KillCharacter(); KillCharacter();

View file

@ -19,7 +19,6 @@ class CGameTeams
class CGameContext *m_pGameContext; class CGameContext *m_pGameContext;
void CheckTeamFinished(int ClientID);
bool TeamFinished(int Team); bool TeamFinished(int Team);
void OnTeamFinish(CPlayer **Players, unsigned int Size, float Time, const char *pTimestamp); void OnTeamFinish(CPlayer **Players, unsigned int Size, float Time, const char *pTimestamp);
void OnFinish(CPlayer *Player, 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); void OnCharacterDeath(int ClientID, int Weapon);
bool SetCharacterTeam(int ClientID, int Team); bool SetCharacterTeam(int ClientID, int Team);
void CheckTeamFinished(int ClientID);
void ChangeTeamState(int Team, int State); void ChangeTeamState(int Team, int State);
void onChangeTeamState(int Team, int State, int OldState); void onChangeTeamState(int Team, int State, int OldState);