示例#1
0
int server_create_session (void)
{

	int
		connection_created;

   connection_data_type
      *comms_connection;

	comms_connection = direct_play_get_connection_data ();

	if ( ( comms_connection ) && ( comms_connection->is_initialised ) )
	{

		if ( !comms_connection->one_way_hosting_setup )
		{
		
			direct_play_close_session ();

			connection_created = FALSE;

			if ( direct_play_create_session (get_game_type ()) )
			{
			
				if ( direct_play_session_capabilities () )
				{
				// Jabberwock 050303 Remove DP groups
				//	if ( direct_play_create_group () )
					{
					
						if ( direct_play_create_player () )
						{
						
							set_server_id (direct_play_get_player_id ());

							connection_created = TRUE;
						}
					}
				}
			}

			if ( !connection_created )
			{

				comms_connection->is_initialised = FALSE;
			}
		}
		else
		{

			direct_play_set_session_type_and_name ( get_game_type () );
		}
	}

	return ( TRUE );
}
示例#2
0
void start_service_provider ( service_provider_table_type *this_service )
{

	if ( this_service != current_active_service )
	{

		if ( modem_state != MODEM_NOT_CONNECTED )
		{

			break_modem_connection ();
		}

		direct_play_close_session ();

		current_active_service = this_service;

		if ( this_service )
		{

			if ( direct_play_create_interface ( this_service ) )
			{

				direct_play_interface_capabilities ();

				//
				// Set the override values for the service provider here.
				//

				initialise_service_provider_connection ();
			}
		}
		else
		{

			direct_play_destroy_interface ();
		}
	}
}
示例#3
0
void break_modem_connection ( void )
{

	char
		text_buffer [256];

	connection_data_type
		*this_connection;

	ui_set_user_function ( NULL );

	switch ( modem_state )
	{

		case MODEM_DIALING:
		case MODEM_DIALLED_CONNECTED:
		{

			//
			// We can't destroy groups, or sessions.
			//

			direct_play_leave_group ();

			direct_play_destroy_player ();

			direct_play_close_session ();

			break;
		}

		case MODEM_ANSWERING:
		case MODEM_ANSWERED_CONNECTED:
		{

			direct_play_leave_group ();

			direct_play_destroy_player ();

			direct_play_destroy_group ();

			direct_play_close_session ();

			break;
		}
	}

	sprintf ( text_buffer, "%s: %s", get_trans ("MP_STATUS"), get_trans("MP_UNCONNECTED"));

	set_ui_object_text (modem_status_text, text_buffer);

//	set_ui_object_drawable ( multi_player_back_button, UI_OBJECT_STATE_ON );

	direct_play_destroy_modem ();

	this_connection = direct_play_get_connection_data ();

	if ( this_connection )
	{

		this_connection->one_way_hosting_setup = TRUE;
		this_connection->is_initialised = FALSE;
		this_connection->is_hosting = FALSE;
	}

	modem_state = MODEM_NOT_CONNECTED;
}
示例#4
0
void set_serial_connection_status ( void )
{

	char
		text_buffer [256];

	connection_data_type
		*this_connection;

	this_connection = direct_play_get_connection_data ();
#ifdef _WIN32
	if ( ( this_connection ) && ( this_connection->service_provider.guid ) )
	{

		if ( memncmp ( ( char * ) this_connection->service_provider.guid, ( char * ) &DPSPGUID_SERIAL, sizeof ( GUID ) ) == TRUE )
		{

			set_direct_play_serial_address ( get_global_comms_port (), get_global_baud_rate (), get_global_stop_bits (), get_global_parity (), get_global_flow () );

			if ( direct_play_create_session ( 0 ) )
			{

				sprintf (text_buffer, "%s: %s", get_trans ("MP_STATUS"), get_trans ("MP_CONNECTED"));

				set_ui_object_text (serial_status_text, text_buffer);

				direct_play_close_session ();

				this_connection->is_initialised = TRUE;
			}
			else
			{

				sprintf (text_buffer, "%s: %s", get_trans ("MP_STATUS"), get_trans ("MP_INVALID_PROPERTIES"));

				set_ui_object_text (serial_status_text, text_buffer);

				this_connection->is_initialised = FALSE;
			}
		}
	}
#elif defined __unix__
if ( ( this_connection ) && ( this_connection->service_provider.guid ) )
	{

		if (1)//ö memncmp ( ( char * ) this_connection->service_provider.guid, ( char * ) &DPSPGUID_SERIAL, sizeof ( GUID ) ) == TRUE )
		{

			set_direct_play_serial_address ( get_global_comms_port (), get_global_baud_rate (), get_global_stop_bits (), get_global_parity (), get_global_flow () );

			if ( direct_play_create_session ( 0 ) )
			{

				sprintf (text_buffer, "%s: %s", get_trans ("MP_STATUS"), get_trans ("MP_CONNECTED"));

				set_ui_object_text (serial_status_text, text_buffer);

				direct_play_close_session ();

				this_connection->is_initialised = TRUE;
			}
			else
			{

				sprintf (text_buffer, "%s: %s", get_trans ("MP_STATUS"), get_trans ("MP_INVALID_PROPERTIES"));

				set_ui_object_text (serial_status_text, text_buffer);

				this_connection->is_initialised = FALSE;
			}
		}
	}
}