Check whether team has finished once a player in the team kills

This commit is contained in:
def 2014-09-26 03:42:49 +02:00
parent 3804c16f02
commit 2c2b77ac3b
2 changed files with 28 additions and 19 deletions

View file

@ -110,32 +110,37 @@ void CGameTeams::OnCharacterFinish(int ClientID)
else
{
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
//ChangeTeamState(m_Core.Team(ClientID), TEAMSTATE_OPEN);
CPlayer *TeamPlayers[MAX_CLIENTS];
unsigned int PlayersCount = 0;
for (int i = 0; i < MAX_CLIENTS; ++i)
if (Team == m_Core.Team(i))
{
if (m_Core.Team(ClientID) == m_Core.Team(i))
CPlayer* pPlayer = GetPlayer(i);
if (pPlayer && pPlayer->IsPlaying())
{
CPlayer* pPlayer = GetPlayer(i);
if (pPlayer && pPlayer->IsPlaying())
{
OnFinish(pPlayer);
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;
if (!Locked)
{
SetForceCharacterTeam(ClientID, 0);
CheckTeamFinished(Team);
}
else
{
SetForceCharacterTeam(ClientID, Team);

View file

@ -48,6 +48,7 @@ public:
void OnCharacterSpawn(int ClientID);
void OnCharacterDeath(int ClientID, int Weapon);
void CheckTeamFinished(int ClientID);
bool SetCharacterTeam(int ClientID, int Team);
void ChangeTeamState(int Team, int State);