示例#1
0
// init networking code regardless of whether driver is available or not ------
//
PRIVATE
int InitNetCode()
{
	//NOTE:
	// these initializations even have to be done if
	// only simulated networking is available.

	if ( !netcode_init_done ) {

		// no other players yet
		NET_InitRemotePlayerTables();

		// init remote event list
		NET_RmEvListReset();

		// allocate received packets chain
		if ( !AllocPacketsChain() ) {
			return FALSE;
		}

		netcode_init_done = TRUE;
	}

	return TRUE;
}
示例#2
0
// init networking code regardless of whether driver is available or not ------
//
PRIVATE
int InitNetCode()
{
	//NOTE:
	// these initializations even have to be done if
	// only simulated networking is available.

#ifdef LINKED_PROTOCOL_GAMESERVER
	// if running gameserver, init the internal minor protocol version
	clsv_protocol_minor_internal = CLSV_PROTOCOL_MINOR;
#endif

	if ( !netcode_init_done ) {

		// no other players yet
		NET_InitRemotePlayerTables();

		// init remote event list
		NET_RmEvListReset();

		// allocate received packets chain
		if ( !AllocPacketsChain() ) {
			return FALSE;
		}

		netcode_init_done = TRUE;
	}

	return TRUE;
}
示例#3
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;
}