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); }
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 ); }
void multiplayer_modem_dial_update_function ( void ) { char text_buffer [256]; int game_update_time; static int update_ticks = 0; game_update_time = TIME_1_SECOND; if ( update_ticks < get_system_time () ) { session_table_type *this_session; connection_data_type *this_connection; unsigned int connection_code; connection_code = direct_play_dial_modem_status (); if ( connection_code == DP_OK ) { // // Need to do the final enumeration // sprintf (text_buffer, "%s: %s", get_trans ("MP_STATUS"), get_trans ("MP_FINDING_GAMES")); if ( direct_play_enumerate_sessions () ) { set_comms_model ( COMMS_MODEL_CLIENT ); this_session = direct_play_get_session_table (); if ( this_session ) { int baudrate; this_connection = direct_play_get_connection_data (); this_connection->this_session.session = this_session->session; sprintf (text_buffer, "%s: %s", get_trans ("MP_STATUS"), get_trans ("MP_JOINING_GAMES")); direct_play_join_session (); direct_play_session_capabilities (); if (!direct_play_enumerate_groups ()) { debug_fatal ("SESSION: Client can't enumerate any groups - but connected someway"); } this_connection->this_group = direct_play_get_group_table (); direct_play_create_player (); direct_play_join_group (); baudrate = direct_play_get_connection_baudrate (); sprintf (text_buffer, "%s: %s %d", get_trans ("MP_STATUS"), get_trans ("MP_CONNECTED_AT"), baudrate * 100); set_ui_object_text (modem_status_text, text_buffer); // set_ui_object_drawable ( multi_player_back_button, UI_OBJECT_STATE_ON ); ghost_ui_objects_for_modem (NULL, FALSE); modem_state = MODEM_DIALLED_CONNECTED; ui_set_user_function ( multiplayer_modem_connection_update_function ); } } } else { if ( connection_code == DPERR_CONNECTING ) { sprintf (text_buffer, "%s: %s", get_trans ("MP_STATUS"), get_trans ("MP_CONNECTING")); set_ui_object_text ( modem_status_text, text_buffer ); } else { sprintf (text_buffer, "%s: %s", get_trans ("MP_STATUS"), get_trans ("MP_UNCONNECTED")); set_ui_object_text ( modem_status_text, text_buffer ); modem_state = MODEM_NOT_CONNECTED; // set_ui_object_drawable ( multi_player_back_button, UI_OBJECT_STATE_ON ); ghost_ui_objects_for_modem (NULL, FALSE); ui_set_user_function ( NULL ); } } update_ticks = get_system_time () + game_update_time; set_delta_time (); } }