コード例 #1
0
CClientFrame *CGameClient::GetSendFrame()
{
	CClientFrame *pFrame = m_pCurrentFrame;

	// just return if replay is disabled
	if ( sv_maxreplay.GetFloat() <= 0 )
		return pFrame;
			
	int followEntity;

	int delayTicks = serverGameClients->GetReplayDelay( edict, followEntity );

	bool isInReplayMode = ( delayTicks > 0 );

	if ( isInReplayMode != m_bIsInReplayMode )
	{
		// force a full update when modes are switched
		m_nDeltaTick = -1; 

		m_bIsInReplayMode = isInReplayMode;

		if ( isInReplayMode )
		{
			m_nEntityIndex = followEntity;
		}
		else
		{
			m_nEntityIndex = m_nClientSlot+1;
		}
	}

	Assert( (m_nClientSlot+1 == m_nEntityIndex) || isInReplayMode );

	if ( isInReplayMode )
	{
		CGameClient *pFollowPlayer = sv.Client( followEntity-1 );

		if ( !pFollowPlayer )
			return NULL;

		pFrame = pFollowPlayer->GetClientFrame( sv.GetTick() - delayTicks, false );

		if ( !pFrame )
			return NULL;

		if ( m_pLastSnapshot == pFrame->GetSnapshot() )
			return NULL;
	}

	return pFrame;
}
コード例 #2
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 );
}