lordned

C_BasePlayer::SetObserverTarget

Apr 5th, 2011
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.07 KB | None | 0 0
  1. void C_BasePlayer::SetObserverTarget( EHANDLE hObserverTarget )
  2. {
  3.     // If the observer target is changing to an entity that the client doesn't know about yet,
  4.     // it can resolve to NULL.  If the client didn't have an observer target before, then
  5.     // comparing EHANDLEs directly will see them as equal, since it uses Get(), and compares
  6.     // NULL to NULL.  To combat this, we need to check against GetEntryIndex() and
  7.     // GetSerialNumber().
  8.     if ( hObserverTarget.GetEntryIndex() != m_hObserverTarget.GetEntryIndex() ||
  9.         hObserverTarget.GetSerialNumber() != m_hObserverTarget.GetSerialNumber())
  10.     {
  11.         // Init based on the new handle's entry index and serial number, so that it's Get()
  12.         // has a chance to become non-NULL even if it currently resolves to NULL.
  13.         m_hObserverTarget.Init( hObserverTarget.GetEntryIndex(), hObserverTarget.GetSerialNumber() );
  14.  
  15.         IGameEvent *event = gameeventmanager->CreateEvent( "spec_target_updated" );
  16.         if ( event )
  17.         {
  18.             gameeventmanager->FireEventClientSide( event );
  19.         }
  20.  
  21.         if ( IsLocalPlayer() )
  22.         {
  23.             ResetToneMapping(1.0);
  24.         }
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment