From a390cadcd08e8507c16140a4d1932b55284ea7b5 Mon Sep 17 00:00:00 2001 From: Sergey Shorokhov Date: Sun, 20 Jun 2021 11:40:25 +0300 Subject: [PATCH] Observer_IsValidTarget: checks refactoring --- regamedll/dlls/observer.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/regamedll/dlls/observer.cpp b/regamedll/dlls/observer.cpp index 56f8a17a6..2f959d710 100644 --- a/regamedll/dlls/observer.cpp +++ b/regamedll/dlls/observer.cpp @@ -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;