mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-12 19:18:20 +00:00
Check whether team has finished once a player in the team kills
This commit is contained in:
parent
3804c16f02
commit
2c2b77ac3b
|
@ -110,32 +110,37 @@ void CGameTeams::OnCharacterFinish(int ClientID)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_TeeFinished[ClientID] = true;
|
m_TeeFinished[ClientID] = true;
|
||||||
if (TeamFinished(m_Core.Team(ClientID)))
|
|
||||||
|
CheckTeamFinished(m_Core.Team(ClientID));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CGameTeams::CheckTeamFinished(int Team)
|
||||||
|
{
|
||||||
|
if (TeamFinished(Team))
|
||||||
|
{
|
||||||
|
ChangeTeamState(Team, TEAMSTATE_FINISHED); //TODO: Make it better
|
||||||
|
//ChangeTeamState(Team, TEAMSTATE_OPEN);
|
||||||
|
|
||||||
|
CPlayer *TeamPlayers[MAX_CLIENTS];
|
||||||
|
unsigned int PlayersCount = 0;
|
||||||
|
|
||||||
|
for (int i = 0; i < MAX_CLIENTS; ++i)
|
||||||
{
|
{
|
||||||
ChangeTeamState(m_Core.Team(ClientID), TEAMSTATE_FINISHED); //TODO: Make it better
|
if (Team == m_Core.Team(i))
|
||||||
//ChangeTeamState(m_Core.Team(ClientID), TEAMSTATE_OPEN);
|
|
||||||
|
|
||||||
CPlayer *TeamPlayers[MAX_CLIENTS];
|
|
||||||
unsigned int PlayersCount = 0;
|
|
||||||
|
|
||||||
for (int i = 0; i < MAX_CLIENTS; ++i)
|
|
||||||
{
|
{
|
||||||
if (m_Core.Team(ClientID) == m_Core.Team(i))
|
CPlayer* pPlayer = GetPlayer(i);
|
||||||
|
if (pPlayer && pPlayer->IsPlaying())
|
||||||
{
|
{
|
||||||
CPlayer* pPlayer = GetPlayer(i);
|
OnFinish(pPlayer);
|
||||||
if (pPlayer && pPlayer->IsPlaying())
|
m_TeeFinished[i] = false;
|
||||||
{
|
|
||||||
OnFinish(pPlayer);
|
|
||||||
m_TeeFinished[i] = false;
|
|
||||||
|
|
||||||
TeamPlayers[PlayersCount++] = pPlayer;
|
TeamPlayers[PlayersCount++] = pPlayer;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
OnTeamFinish(TeamPlayers, PlayersCount);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OnTeamFinish(TeamPlayers, PlayersCount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -599,7 +604,10 @@ void CGameTeams::OnCharacterDeath(int ClientID, int Weapon)
|
||||||
bool Locked = TeamLocked(Team) && Weapon != WEAPON_GAME;
|
bool Locked = TeamLocked(Team) && Weapon != WEAPON_GAME;
|
||||||
|
|
||||||
if (!Locked)
|
if (!Locked)
|
||||||
|
{
|
||||||
SetForceCharacterTeam(ClientID, 0);
|
SetForceCharacterTeam(ClientID, 0);
|
||||||
|
CheckTeamFinished(Team);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SetForceCharacterTeam(ClientID, Team);
|
SetForceCharacterTeam(ClientID, Team);
|
||||||
|
|
|
@ -48,6 +48,7 @@ public:
|
||||||
void OnCharacterSpawn(int ClientID);
|
void OnCharacterSpawn(int ClientID);
|
||||||
void OnCharacterDeath(int ClientID, int Weapon);
|
void OnCharacterDeath(int ClientID, int Weapon);
|
||||||
|
|
||||||
|
void CheckTeamFinished(int ClientID);
|
||||||
bool SetCharacterTeam(int ClientID, int Team);
|
bool SetCharacterTeam(int ClientID, int Team);
|
||||||
|
|
||||||
void ChangeTeamState(int Team, int State);
|
void ChangeTeamState(int Team, int State);
|
||||||
|
|
Loading…
Reference in a new issue