diff --git a/src/game/server/info_camera_link.cpp b/src/game/server/info_camera_link.cpp index 8724008d2..119419501 100644 --- a/src/game/server/info_camera_link.cpp +++ b/src/game/server/info_camera_link.cpp @@ -145,9 +145,11 @@ CBaseEntity *CreateInfoCameraLink( CBaseEntity *pTarget, CPointCamera *pCamera ) //----------------------------------------------------------------------------- void PointCameraSetupVisibility( CBaseEntity *pPlayer, int area, unsigned char *pvs, int pvssize ) { + int nPlayerIndex = pPlayer->entindex(); + for ( CPointCamera *pCameraEnt = GetPointCameraList(); pCameraEnt != NULL; pCameraEnt = pCameraEnt->m_pNext ) { - pCameraEnt->SetActive( false ); + pCameraEnt->TransmitToPlayer( nPlayerIndex, false ); } intp nNext; @@ -175,7 +177,7 @@ void PointCameraSetupVisibility( CBaseEntity *pPlayer, int area, unsigned char * if ( pCameraEnt ) { engine->AddOriginToPVS( pCameraEnt->GetAbsOrigin() ); - pCameraEnt->SetActive( true ); + pCameraEnt->TransmitToPlayer( nPlayerIndex, true ); } } } diff --git a/src/game/server/point_camera.cpp b/src/game/server/point_camera.cpp index ebbd6fcd6..d1e390498 100644 --- a/src/game/server/point_camera.cpp +++ b/src/game/server/point_camera.cpp @@ -52,6 +52,9 @@ CPointCamera::CPointCamera() m_bFogEnable = false; m_bFogRadial = false; + // By default, transmit to everyone + m_bitsTransmitPlayers.SetAll(); + g_PointCameraList.Insert( this ); } @@ -74,34 +77,43 @@ void CPointCamera::Spawn( void ) SetActive( m_bIsOn ); } +//----------------------------------------------------------------------------- +// Purpose: Transmit only to players who are in PVS of the camera and its link +// See PointCameraSetupVisibility +//----------------------------------------------------------------------------- +int CPointCamera::ShouldTransmit( const CCheckTransmitInfo* pInfo ) +{ + if ( m_bitsTransmitPlayers.IsBitSet( pInfo->m_pClientEnt->m_EdictIndex ) ) + return FL_EDICT_ALWAYS; + + return FL_EDICT_DONTSEND; +} + //----------------------------------------------------------------------------- // Purpose: Override ShouldTransmit since we want to be sent even though we don't have a model, etc. // All that matters is if we are in the pvs. //----------------------------------------------------------------------------- int CPointCamera::UpdateTransmitState() { - if ( m_bActive ) - { - return SetTransmitState( FL_EDICT_ALWAYS ); - } - else - { - return SetTransmitState( FL_EDICT_DONTSEND ); - } + return SetTransmitState( FL_EDICT_FULLCHECK ); } +//----------------------------------------------------------------------------- +// Purpose: Toggle networking of the camera to the specified player +//----------------------------------------------------------------------------- +void CPointCamera::TransmitToPlayer( int nPlayerIndex, bool bTransmit ) +{ + if ( bTransmit ) + m_bitsTransmitPlayers.Set( nPlayerIndex ); + else + m_bitsTransmitPlayers.Clear( nPlayerIndex ); +} //----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CPointCamera::SetActive( bool bActive ) { - // If the mapmaker's told the camera it's off, it enforces inactive state - if ( !m_bIsOn ) - { - bActive = false; - } - if ( m_bActive != bActive ) { m_bActive = bActive; diff --git a/src/game/server/point_camera.h b/src/game/server/point_camera.h index f0c0567d8..6a983b4a0 100644 --- a/src/game/server/point_camera.h +++ b/src/game/server/point_camera.h @@ -29,7 +29,9 @@ public: // Tell the client that this camera needs to be rendered void SetActive( bool bActive ); - int UpdateTransmitState(void); + int ShouldTransmit( const CCheckTransmitInfo* pInfo ); + int UpdateTransmitState( void ); + void TransmitToPlayer( int nPlayerIndex, bool bTransmit ); void ChangeFOVThink( void ); @@ -56,6 +58,8 @@ private: // Allows the mapmaker to control whether a camera is active or not bool m_bIsOn; + CBitVec< MAX_PLAYERS > m_bitsTransmitPlayers; + public: CPointCamera *m_pNext; };