Skip to content

Commit

Permalink
Reduce code redundancy in observer.cpp (#872)
Browse files Browse the repository at this point in the history
  • Loading branch information
dystopm authored Oct 10, 2023
1 parent 2f50f5a commit e422a37
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion regamedll/dlls/observer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e422a37

Please sign in to comment.