예제 #1
0
// try to connect to server ---------------------------------------------------
//
int NETs_Connect()
{
	ASSERT( !NetConnected && !NetJoined );
	//ASSERT( Player_Status[ LocalPlayerId ] == PLAYER_INACTIVE );
	ASSERT( CurServerToResolve != NULL );

	// set maximum number of players according to protocol
	CurMaxPlayers = MAX_NET_GMSV_PLAYERS;

	// (re)init tables
	NET_InitRemotePlayerTables();

	// discard old packets
	NETs_FlushListenBuffers();

	// already count local player
	//FIXME: why ????
	ASSERT( NumRemPlayers == 0 );
	NumRemPlayers = 1;

	// init the msg# of the last status change msg
	g_dwLastStatusChangeMsg = 0;

	// resolve the server name into a node
	if ( NET_ResolveServerNode() ) {

		// try to establish connection to server
		if ( NET_ServerConnect() ) {

			ASSERT( NetConnected );
			ASSERT( NumRemPlayers >= 1 );
			ASSERT( Player_Status[ LocalPlayerId ] == PLAYER_CONNECTED );

			return TRUE;

		}
	}

	//NOTE:
	// possible reasons for NET_ServerConnect() to fail:
	// - the DNS lookup failed.
	// - sending UDP packets failed.
	// - the server refused the connect request.

	ASSERT( !NetConnected );
	ASSERT( NumRemPlayers == 1 );

	// reset player count
	NumRemPlayers = 0;

	return FALSE;
}
예제 #2
0
// start playback of binary demo data -----------------------------------------
//
PRIVATE
void DEMO_BinaryStartDemo( int interactive, int enablenet )
{
	ASSERT( demo_data != NULL );

	//NOTE:
	// replay without enabling network replay explicitly
	// is only use for playback behind the main menu.

	//NOTE:
	// if the actual network game is not available we enable
	// the simulation layer to allow replay of recorded packets
	// via E_RECORD::REC_PlayRemotePacketBin().

	// set start replay position
	demo_replaypos = demo_data;

	// init demo info
	DEMO_InitInfo();

	if ( enablenet ) {

		// save partial state
		SaveEntryState();

		// turn off kill limit
		AUX_KILL_LIMIT_FOR_GAME_END = 0;

		// enable simulated network if necessary
		if ( ( NetConnected != NETWORK_GAME_ON ) &&
			 !AUX_DISABLE_REPLAY_NET_SIMULATION ) {

			NetConnected = NETWORK_GAME_SIMULATED;

			// set maximum number of players to peer-to-peer by default.
			// should be set correctly by "ac.remotemaxplayers" later on.
			CurMaxPlayers = MAX_NET_UDP_PEER_PLAYERS;
		}

		// remove dangling virtual packets
		NETs_FlushListenBuffers();
	}

	// replay until first wait command or eof reached
	DEMO_BinaryExecCommands( interactive );
}
예제 #3
0
// clear remnants of demo replay and stop demo optionally ---------------------
//
void DEMO_ClearDemo( int stopreplay )
{
	//NOTE:
	// this function has to be used after a demo containing network packets
	// has been replayed (and ended) to restore/ensure a proper game state.

	//NOTE:
	// if the network mode is not active or the net simulation has already
	// been stopped (e.g., the demo has finished) the network state will
	// be left untouched (i.e., not reset!).

	// make sure it's off
	ObjCamOff();

	// clean up network state
	if ( NetConnected ) {

		// update player status
		Player_Status[ LocalPlayerId ] = PLAYER_INACTIVE;

		// ensure no remote players
		NET_RemoveRemotePlayers();

		// remove dangling virtual packets
		NETs_FlushListenBuffers();
	}

	if ( stopreplay ) {

		// stop audio stream if started from demo
		if ( con_audio_stream_started ) {
			con_audio_stream_started = FALSE;
			AUDs_StopAudioStream();
		}

		// ensure replay stopped
		stop_from_clear_demo = TRUE;
		DEMO_StopReplay();
		stop_from_clear_demo = FALSE;

		// turn off fading
		SetScreenFade = 0;
	}

	// set proper entry-mode state
	if ( NetConnected ) {
		EntryMode		= NetJoined ? FALSE : TRUE;
		InFloatingMenu	= NetJoined ? FALSE : FloatingMenu;
	} else {
		EntryMode		= FALSE;
		InFloatingMenu	= FloatingMenu;
	}

	// reset the floating menu state
	if ( InFloatingMenu ) {
		ActivateFloatingMenu( FALSE );
	}

	// scroll demo text out
	if ( !AUX_DISABLE_CLEAR_TEXT_ON_CLEARDEMO ) {
//		HUD_ClearDemoText();
	}

	// stop local ship
	MyShip->CurSpeed = 0;

	// ensure automatic actions disabled
	REPLAY_StopAutomaticActions();

	// ensure local particle weapons are destroyed
	WFX_EnsureParticleWeaponsInactive( MyShip );

	// stop residual motion due to view camera filter
	if ( !AUX_DISABLE_CAMFILT_RESET_ON_CLEARDEMO ) {
		CAMERA_ResetFilter();
	}

	// reset mapping table for class ids
	ResetClassMapTable();

	// free objects and particles
	if ( !AUX_DISABLE_OBJECT_FREE_ON_CLEARDEMO ) {
		KillAllObjects();
	}
}