Skip to content

Commit

Permalink
Merge branch 'stable' into release/0.9.4
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexMax committed Aug 8, 2021
2 parents f76f74f + 89a03d5 commit 88e0eb9
Showing 1 changed file with 28 additions and 5 deletions.
33 changes: 28 additions & 5 deletions common/p_user.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -798,9 +798,34 @@ bool P_CanSpy(player_t &viewer, player_t &other, bool demo)
if (demo)
return true;

// A teammate can see their other teammates.
// Spectators see anyone with one slight restriction.
if (P_AreTeammates(viewer, other) || viewer.spectator)
// Is the player a teammate?
bool isTeammate = false;
if (G_IsCoopGame())
{
// You are everyone's teammate in a coop game.
isTeammate = true;
}
else if (G_IsTeamGame())
{
if (viewer.userinfo.team == other.userinfo.team)
{
// You are on the same team.
isTeammate = true;
}
else
{
PlayerResults pr =
PlayerQuery().hasLives().onTeam(viewer.userinfo.team).execute();
if (pr.count == 0)
{
// You are on a different team but your teammates are dead, so
// it doesn't really matter if you spectate them.
isTeammate = true;
}
}
}

if (isTeammate || viewer.spectator)
{
// If a player has no more lives, don't show him.
if (::g_lives && other.lives < 1)
Expand All @@ -813,8 +838,6 @@ bool P_CanSpy(player_t &viewer, player_t &other, bool demo)
if (::sv_gametype == GM_DM && ::g_lives && viewer.lives < 1)
return true;



return false;
}

Expand Down

0 comments on commit 88e0eb9

Please sign in to comment.