void CNetworkManager::Pulse()
{
	// Is the game not loaded?
	if(!g_pCore->IsGameLoaded())
		return;

	// Are we disconnected from the network?
	if(GetNetworkState() == NETSTATE_DISCONNECTED)
		return;

	// Should we try connecting again?
	if(GetNetworkState() == NETSTATE_TIMEOUT && ((unsigned short)SharedUtility::GetTime() - m_uiLastConnectionTry) >= NETWORK_TIMEOUT)
	{
		// Attempt to reconnect
		Connect(m_strIp, m_usPort, m_strPass);

		// Set the network state
		SetNetworkState(NETSTATE_CONNECTING);

		// Set the last connection try
		m_uiLastConnectionTry = (unsigned int)SharedUtility::GetTime();
	}

	// Process the network
	UpdateNetwork();

	// Are we connected?
	if(IsConnected())
	{
		// Pulse the player manager
		g_pCore->GetGame()->GetPlayerManager()->Pulse();

		// Pulse the vehicle manager
		g_pCore->GetGame()->GetVehicleManager()->Pulse();
	}
}
Example #2
0
void CNetworkModule::Pulse( void )
{
	// Is the game not loaded?
	if( !pCore->IsGameLoaded() )
		return;

	// Are we disconnected from the network?
	if( GetNetworkState() == NETSTATE_DISCONNECTED )
		return;

	// Process the network
	UpdateNetwork ();

	// Are we connected?
	if( IsConnected() )
	{
		// Pulse the player manager
		pCore->GetPlayerManager()->Pulse ();

		// Pulse the vehicle manager
		pCore->GetVehicleManager()->Pulse ();
	}
}