From 3654c85da92a90014a8d4923883b2466967f4862 Mon Sep 17 00:00:00 2001 From: dystopm Date: Sun, 1 Oct 2023 22:48:27 -0300 Subject: [PATCH] Reduce code redundancy in observer.cpp --- regamedll/dlls/observer.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/regamedll/dlls/observer.cpp b/regamedll/dlls/observer.cpp index c35b17f9a..e0bdc6441 100644 --- a/regamedll/dlls/observer.cpp +++ b/regamedll/dlls/observer.cpp @@ -478,10 +478,19 @@ void EXT_FUNC CBasePlayer::__API_HOOK(Observer_SetMode)(int iMode) // verify observer target again if (m_hObserverTarget) { +#ifdef REGAMEDLL_FIXES + m_hObserverTarget = Observer_IsValidTarget( ENTINDEX(m_hObserverTarget->edict()), forcecamera != CAMERA_MODE_SPEC_ANYONE ); +#else CBasePlayer *pTarget = m_hObserverTarget; - if (pTarget == this || !pTarget || pTarget->has_disconnected || pTarget->GetObserverMode() != OBS_NONE || (pTarget->pev->effects & EF_NODRAW) || (forcecamera != CAMERA_MODE_SPEC_ANYONE && pTarget->m_iTeam != m_iTeam)) + if (pTarget == this + || !pTarget + || pTarget->has_disconnected + || pTarget->GetObserverMode() != OBS_NONE + || (pTarget->pev->effects & EF_NODRAW) + || (forcecamera != CAMERA_MODE_SPEC_ANYONE && pTarget->m_iTeam != m_iTeam)) m_hObserverTarget = nullptr; +#endif } // set spectator mode