Skip to content

Commit

Permalink
Observer_IsValidTarget: checks refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
SergeyShorokhov committed Jun 20, 2021
1 parent a9111f8 commit a390cad
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion regamedll/dlls/observer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,19 @@ CBasePlayer *CBasePlayer::__API_HOOK(Observer_IsValidTarget)(int iPlayerIndex, b
CBasePlayer *pPlayer = UTIL_PlayerByIndex(iPlayerIndex);

// Don't spec observers or players who haven't picked a class yet
if (!pPlayer || pPlayer == this || pPlayer->has_disconnected || pPlayer->GetObserverMode() != OBS_NONE || (pPlayer->pev->effects & EF_NODRAW) || pPlayer->m_iTeam == UNASSIGNED || (bSameTeam && pPlayer->m_iTeam != m_iTeam))
if (!pPlayer || pPlayer == this)
return nullptr;

if (pPlayer->has_disconnected)
return nullptr;

if (pPlayer->GetObserverMode() != OBS_NONE)
return nullptr;

if (pPlayer->pev->effects & EF_NODRAW)
return nullptr;

if (pPlayer->m_iTeam == UNASSIGNED || (bSameTeam && pPlayer->m_iTeam != m_iTeam))
return nullptr;

return pPlayer;
Expand Down

0 comments on commit a390cad

Please sign in to comment.