Example #1
0
void notify_modem_answer_function ( ui_object *obj, void *arg )
{
	char
		text_buffer [256];

	ghost_ui_objects_for_modem (obj, TRUE);

	switch ( modem_state )
	{

		case MODEM_NOT_CONNECTED:
		{

			char
				*modem;

			modem = current_modem->name;

			if ( modem )
			{

				//
				// Have to call create session to get the phone to answer
				//

				if ( direct_play_answer_modem ( modem, GAME_TYPE_INVALID ) )
				{

					direct_play_session_capabilities ();

					direct_play_create_group ();

					direct_play_create_player ();

					set_server_id (direct_play_get_player_id ());

					//
					// Turn off the back button while we connect
					//

//					set_ui_object_drawable ( multi_player_back_button, UI_OBJECT_STATE_OFF );

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

					set_ui_object_text (modem_status_text, text_buffer);

					modem_state = MODEM_ANSWERING;

					ui_set_user_function ( multiplayer_modem_answer_update_function );
				}
			}

			break;
		}
	}

	// don't leave text selected

	set_toggle_button_off (obj);
}
Example #2
0
void create_client_pilot (void)
{
	client_pilot_request_data
		pilot_data;

	ASSERT (get_comms_model () == COMMS_MODEL_CLIENT);

	//
	// pack required gunship data
	//

	strcpy (pilot_data.name, get_player_log_name (get_current_player_log ()));
	pilot_data.side = get_global_gunship_side ();
	pilot_data.rank = get_player_log_rank (get_global_gunship_side (), get_current_player_log ());
	pilot_data.sub_type = ENTITY_SUB_TYPE_PILOT_PILOT;
	pilot_data.unique_id = direct_play_get_player_id ();
	pilot_data.difficulty = get_global_difficulty_level ();

	//
	// Send request
	//

	send_packet (get_server_id (), PACKET_TYPE_CLIENT_PILOT_REQUEST, (unsigned char *) &pilot_data, sizeof (client_pilot_request_data), SEND_TYPE_PERSONAL);

	// turn off NEXT button while Pilot entity is being created client_server
	if (get_comms_model () == COMMS_MODEL_CLIENT)
	{

		set_display_gunship_buttons (FALSE, "ENGAGE");
	}
}
Example #3
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 );
}
Example #4
0
void create_server_pilot (void)
{
	entity
		*en;
		
	ASSERT (get_comms_model () == COMMS_MODEL_SERVER);

	en = create_new_pilot_entity
				(
					get_player_log_name (get_current_player_log ()),
					get_global_gunship_side (),
					get_player_log_rank (get_global_gunship_side (), get_current_player_log ()),
					ENTITY_SUB_TYPE_PILOT_PILOT,
					direct_play_get_player_id (),
					get_global_difficulty_level ()
				);

	set_pilot_entity (en);
}
Example #5
0
void initialise_comms_manager (void)
{

	#if DEBUG_MODULE

	debug_log ("COMMS MAN: initialising comms manager: data size = %d", command_line_comms_data_record_size, direct_play_get_player_id ());

	#endif

	set_server_response (SERVER_RESPONSE_UNKNOWN);

	data_record = (char *) malloc_heap_mem (command_line_comms_data_record_size);

	add_update_function (send_comms_data, 1.0 / command_line_max_game_update_rate , 1.0);
	//add_update_function (data_exchange, 1.0 / command_line_max_game_update_rate , 1.0);

	if (command_line_comms_validate_connections)
	{

		add_update_function (validate_connections, command_line_comms_timeout, 1.0);
	}

	tx_pack_buffer = (char *) malloc_heap_mem (sizeof (char) * command_line_comms_pack_buffer_size);
}