Cleanup TeamMask

This commit is contained in:
def 2014-01-20 20:12:03 +01:00
parent 214d32fadd
commit 4114e00564

View file

@ -262,19 +262,45 @@ int64_t CGameTeams::TeamMask(int Team, int ExceptID, int Asker)
if (Team == TEAM_SUPER) if (Team == TEAM_SUPER)
return -1LL; return -1LL;
int Mask = 0; int Mask = 0;
if (m_Core.GetSolo(Asker) && ExceptID != Asker)
Mask = 1LL << Asker;
for (int i = 0; i < MAX_CLIENTS; ++i) for (int i = 0; i < MAX_CLIENTS; ++i)
if (i != ExceptID) {
if ((!(GetPlayer(i) && (GetPlayer(i)->GetTeam() == -1 || GetPlayer(i)->m_Paused)) if (i == ExceptID)
&& Character(i) && !m_Core.GetSolo(Asker) continue; // Explicitly excluded
&& ((!m_Core.GetSolo(i) && m_Core.Team(i) == Team) if (!GetPlayer(i))
|| m_Core.Team(i) == TEAM_SUPER)) continue; // Player doesn't exist
|| ((GetPlayer(i) && (GetPlayer(i)->GetTeam() == -1 || GetPlayer(i)->m_Paused))
&& (GetPlayer(i)->m_SpectatorID == SPEC_FREEVIEW if (GetPlayer(i)->m_ShowOthers)
|| GetPlayer(i)->m_SpectatorID == Asker {} // ShowOthers sees all
|| (m_Core.Team(GetPlayer(i)->m_SpectatorID) == Team && !m_Core.GetSolo(Asker))))) else if (!(GetPlayer(i)->GetTeam() == -1 || GetPlayer(i)->m_Paused))
Mask |= 1LL << i; { // Not spectator
if (i != Asker)
{ // Actions of other players
if (!Character(i))
continue; // Player is currently dead
if (m_Core.GetSolo(Asker))
continue; // When in solo part don't show others
if (m_Core.GetSolo(i))
continue; // When in solo part don't show others
if (m_Core.Team(i) != Team && m_Core.Team(i) != TEAM_SUPER)
continue; // In different teams
} // See everything of yourself
}
else if (GetPlayer(i)->m_SpectatorID != SPEC_FREEVIEW)
{ // Spectating specific player
if (GetPlayer(i)->m_SpectatorID != Asker)
{ // Actions of other players
if (m_Core.Team(GetPlayer(i)->m_SpectatorID) != Team)
continue; // In different teams
if (m_Core.GetSolo(Asker))
continue; // When in solo part don't show others
if (m_Core.GetSolo(GetPlayer(i)->m_SpectatorID))
continue; // When in solo part don't show others
} // See everything of player you're spectating
} // Freeview sees all
Mask |= 1LL << i;
}
return Mask; return Mask;
} }