Reduce code redundancy in observer.cpp (#872)

This commit is contained in:
Francisco Muñoz 2023-10-10 19:03:11 -03:00 committed by GitHub
parent 2f50f5ab9d
commit e422a37d8b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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