Example #1
0
bool CGameClient::IsHearingClient( int index ) const
{
	if ( IsHLTV() )
		return true;

	if ( index == GetPlayerSlot() )
		return m_bVoiceLoopback;
	
	CGameClient *pClient = sv.Client( index );
	return pClient->m_VoiceStreams.Get( GetPlayerSlot() ) != 0;
}
Example #2
0
void CGameClient::Inactivate( void )
{
	if ( edict && !edict->IsFree() )
	{
		m_Server->RemoveClientFromGame( this );
	}
#ifndef _XBOX
	if ( IsHLTV() )
	{	
		hltv->Changelevel();
	}
#endif
	CBaseClient::Inactivate();

	m_Sounds.Purge();
	m_VoiceStreams.ClearAll();
	m_VoiceProximity.ClearAll();


	DeleteClientFrames( -1 ); // delete all
}
Example #3
0
CClientFrame *CGameClient::GetDeltaFrame( int nTick )
{
#ifndef _XBOX
	Assert ( !IsHLTV() ); // has no ClientFrames
#endif	

	if ( m_bIsInReplayMode )
	{
		int followEntity; 

		serverGameClients->GetReplayDelay( edict, followEntity );

		Assert( followEntity > 0 );

		CGameClient *pFollowEntity = sv.Client( followEntity-1 );

		if ( pFollowEntity )
			return pFollowEntity->GetClientFrame( nTick );
	}

	return GetClientFrame( nTick );
}
Example #4
0
void CGameClient::SendSound( SoundInfo_t &sound, bool isReliable )
{
	if ( IsFakeClient() && !IsHLTV() )
	{
		return; // dont send sound messages to bots
	}

	// don't send sound messages while client is replay mode
	if ( m_bIsInReplayMode )
	{
		return;
	}

	// reliable sounds are send as single messages
	if ( isReliable )
	{
		SVC_Sounds	sndmsg;
		char		buffer[32];

		m_nSoundSequence = ( m_nSoundSequence + 1 ) & SOUND_SEQNUMBER_MASK;	// increase own sound sequence counter
		sound.nSequenceNumber = 0; // don't transmit nSequenceNumber for reliable sounds

		sndmsg.m_DataOut.StartWriting(buffer, sizeof(buffer) );
		sndmsg.m_nNumSounds = 1;
		sndmsg.m_bReliableSound = true;
				
		SoundInfo_t	defaultSound; defaultSound.SetDefault();

		sound.WriteDelta( &defaultSound, sndmsg.m_DataOut );

		// send reliable sound as single message
		SendNetMsg( sndmsg, true );
		return;
	}

	sound.nSequenceNumber = m_nSoundSequence;

	m_Sounds.AddToTail( sound );	// queue sounds until snapshot is send
}
Example #5
0
// returns true if the selection has been handled and the player's menu 
// can be closed...false if the menu should be displayed again
bool CSDKPlayer::HandleCommand_JoinTeam( int team )
{
	CSDKGameRules *mp = SDKGameRules();
	int iOldTeam = GetTeamNumber();
	if ( !GetGlobalTeam( team ) )
	{
		Warning( "HandleCommand_JoinTeam( %d ) - invalid team index.\n", team );
		return false;
	}

#if defined ( SDK_USE_TEAMS )
	// If we already died and changed teams once, deny
	if( m_bTeamChanged && team != TEAM_SPECTATOR && iOldTeam != TEAM_SPECTATOR )
	{
		ClientPrint( this, HUD_PRINTCENTER, "game_switch_teams_once" );
		return true;
	}
#endif
	if ( team == TEAM_UNASSIGNED )
	{
		// Attempt to auto-select a team, may set team to T, CT or SPEC
		team = mp->SelectDefaultTeam();

		if ( team == TEAM_UNASSIGNED )
		{
			// still team unassigned, try to kick a bot if possible	
			 
			ClientPrint( this, HUD_PRINTTALK, "#All_Teams_Full" );

			team = TEAM_SPECTATOR;
		}
	}

	if ( team == iOldTeam )
		return true;	// we wouldn't change the team

#if defined ( SDK_USE_TEAMS )
	if ( mp->TeamFull( team ) )
	{
		if ( team == SDK_TEAM_BLUE )
		{
			ClientPrint( this, HUD_PRINTTALK, "#BlueTeam_Full" );
		}
		else if ( team == SDK_TEAM_RED )
		{
			ClientPrint( this, HUD_PRINTTALK, "#RedTeam_Full" );
		}
		ShowViewPortPanel( PANEL_TEAM );
		return false;
	}
#endif

	if ( team == TEAM_SPECTATOR )
	{
		// Prevent this if the cvar is set
		if ( !mp_allowspectators.GetInt() && !IsHLTV() )
		{
			ClientPrint( this, HUD_PRINTTALK, "#Cannot_Be_Spectator" );
			ShowViewPortPanel( PANEL_TEAM );
			return false;
		}

		ChangeTeam( TEAM_SPECTATOR );

		return true;
	}
	
	// If the code gets this far, the team is not TEAM_UNASSIGNED

	// Player is switching to a new team (It is possible to switch to the
	// same team just to choose a new appearance)
#if defined ( SDK_USE_TEAMS )
	if (mp->TeamStacked( team, GetTeamNumber() ))//players are allowed to change to their own team so they can just change their model
	{
		// The specified team is full
		ClientPrint( 
			this,
			HUD_PRINTCENTER,
			( team == SDK_TEAM_BLUE ) ?	"#BlueTeam_full" : "#RedTeam_full" );

		ShowViewPortPanel( PANEL_TEAM );
		return false;
	}
#endif
	// Switch their actual team...
	ChangeTeam( team );

#if defined ( SDK_USE_PLAYERCLASSES )
	// Force them to choose a new class
	m_Shared.SetDesiredPlayerClass( PLAYERCLASS_UNDEFINED );
	m_Shared.SetPlayerClass( PLAYERCLASS_UNDEFINED );
#endif
	return true;
}
Example #6
0
void CGameClient::SetupPackInfo( CFrameSnapshot *pSnapshot )
{
	// Compute Vis for each client
	m_PackInfo.m_nPVSSize = (GetCollisionBSPData()->numclusters + 7) / 8;
	serverGameClients->ClientSetupVisibility( (edict_t *)m_pViewEntity,
		m_PackInfo.m_pClientEnt, m_PackInfo.m_PVS, m_PackInfo.m_nPVSSize );

	// This is the frame we are creating, i.e., the next
	// frame after the last one that the client acknowledged

	m_pCurrentFrame = AllocateFrame();
	m_pCurrentFrame->Init( pSnapshot );

	m_PackInfo.m_pTransmitEdict = &m_pCurrentFrame->transmit_entity;

	// if this client is the HLTV client, add the nocheck PVS bit array
	// normal clients don't need that extra array
#ifndef _XBOX
	if ( IsHLTV() )
	{
		// the hltv client doesn't has a ClientFrame list
		m_pCurrentFrame->transmit_always = new CBitVec<MAX_EDICTS>;
		m_PackInfo.m_pTransmitAlways = m_pCurrentFrame->transmit_always;
	}
	else
#endif
	{
		m_PackInfo.m_pTransmitAlways = NULL;
	}

	// Add frame to ClientFrame list 

	int nMaxFrames = MAX_CLIENT_FRAMES;

	if ( sv_maxreplay.GetFloat() > 0 )
	{
		// if the server has replay features enabled, allow a way bigger frame buffer
		nMaxFrames = max ( nMaxFrames, sv_maxreplay.GetFloat() / m_Server->GetTickInterval() );
	}
		
	if ( nMaxFrames < AddClientFrame( m_pCurrentFrame ) )
	{
		// If the client has more than 64 frames, the server will start to eat too much memory.
		RemoveOldestFrame(); 
	}
		
	// Since area to area visibility is determined by each player's PVS, copy
	//  the area network lookups into the ClientPackInfo_t
	m_PackInfo.m_AreasNetworked = 0;
	int areaCount = g_AreasNetworked.Count();
	for ( int j = 0; j < areaCount; j++ )
	{
		m_PackInfo.m_Areas[m_PackInfo.m_AreasNetworked] = g_AreasNetworked[ j ];
		m_PackInfo.m_AreasNetworked++;

		// Msg("CGameClient::SetupPackInfo: too much areas (%i)", areaCount );
		Assert( m_PackInfo.m_AreasNetworked < MAX_WORLD_AREAS );
	}
	
	CM_SetupAreaFloodNums( m_PackInfo.m_AreaFloodNums, &m_PackInfo.m_nMapAreas );
}