void notify_show_realism_page (void) { set_ui_object_text (co_pilot_target_option_button, option_cpg_text [get_global_cpg_assist_type ()]); #if DEBUG_MODULE debug_filtered_log ("cpg_assist: %d text: %s",get_global_cpg_assist_type (), option_cpg_text [get_global_cpg_assist_type ()]); #endif set_ui_object_text (co_pilot_ecm_option_button, option_boolean_text [get_global_auto_counter_measures ()]); #if DEBUG_MODULE debug_filtered_log ("acm: %d text: %s", get_global_auto_counter_measures (), option_boolean_text [get_global_auto_counter_measures ()]); #endif set_ui_object_text (avionics_option_button, option_avionics_text [get_global_simple_avionics ()]); #if DEBUG_MODULE debug_filtered_log ("avionics: %d text: %s", get_global_simple_avionics (), option_avionics_text [get_global_simple_avionics ()]); #endif set_ui_object_text (difficulty_option_button, option_difficulty_text [get_global_difficulty_level () - 1]); #if DEBUG_MODULE debug_filtered_log ("diff: %d text: %s", get_global_difficulty_level (), option_difficulty_text [get_global_difficulty_level () - 1]); #endif set_ui_object_text (cpg_report_targets_button, option_cpg_report_targets_text[global_co_pilot_scans_for_targets]); display_options_page (OPTIONS_PAGE_REALISM); #if DEBUG_MODULE debug_filtered_log("Inside show_realism_page"); #endif }
void dump_guide_stack (entity *group) { entity *guide, *task; debug_filtered_log ("GUIDE STACK:-"); debug_filtered_log ("-------------"); guide = get_local_entity_first_child (group, LIST_TYPE_GUIDE_STACK); while (guide) { task = get_local_entity_parent (guide, LIST_TYPE_GUIDE); ASSERT (task); debug_filtered_log ("Task %s (%d) - Guide (%d) - Valid Members %d", get_local_entity_string (task, STRING_TYPE_FULL_NAME), get_local_entity_index (task), get_local_entity_index (guide), get_local_entity_int_value (guide, INT_TYPE_VALID_GUIDE_MEMBERS)); guide = get_local_entity_child_succ (guide, LIST_TYPE_GUIDE_STACK); } }
int award_air_medal_medal (int side, int success) { player_log_type *player; int *medals; ASSERT ((side >= 0) && (side <= NUM_ENTITY_SIDES)); player = get_current_player_log (); medals = player->side_log[side].medals; if (success) { player->side_log [side].air_medal_counter++; if (player->side_log [side].air_medal_counter >= NUM_NEEDED_TO_AWARD_AIR_MEDAL) { medals [MEDAL_AIR_MEDAL] += 1; player->side_log [side].air_medal_counter = 0; #if DEBUG_MODULE debug_filtered_log ("Awarded Air Medal, reset counter"); #endif return MEDAL_AIR_MEDAL; } else { #if DEBUG_MODULE debug_filtered_log ("Air Medal Not Awarded (count = %d)", player->side_log[side].air_medal_counter); #endif return MEDAL_TYPE_NONE; } } else { #if DEBUG_MODULE debug_filtered_log ("Air Medal Not Awarded: resetting air_medal_counter"); #endif player->side_log [side].air_medal_counter = 0; } return MEDAL_TYPE_NONE; }
int award_purple_heart_medal (int side) { player_log_type *player; int *medals, damage; ASSERT ((side >= 0) && (side <= NUM_ENTITY_SIDES)); player = get_current_player_log (); medals = player->side_log[side].medals; // get helicopter damage damage = get_dynamics_damage_type (DYNAMICS_DAMAGE_MAIN_ROTOR | DYNAMICS_DAMAGE_TAIL_ROTOR | DYNAMICS_DAMAGE_LEFT_ENGINE | DYNAMICS_DAMAGE_RIGHT_ENGINE | DYNAMICS_DAMAGE_LEFT_ENGINE_FIRE | DYNAMICS_DAMAGE_RIGHT_ENGINE_FIRE | DYNAMICS_DAMAGE_LOW_HYDRAULICS | DYNAMICS_DAMAGE_LOW_OIL_PRESSURE | DYNAMICS_DAMAGE_HIGH_OIL_PRESSURE | DYNAMICS_DAMAGE_STABILISER); if ((get_gunship_entity ()) && (get_local_entity_int_value (get_gunship_entity (), INT_TYPE_ALIVE))) { if (damage) { medals [MEDAL_PURPLE_HEART] += 1; #if DEBUG_MODULE debug_filtered_log ("Awarded Purple Heart Medal"); #endif return MEDAL_PURPLE_HEART; } } #if DEBUG_MODULE debug_filtered_log ("Purple Heart Medal Not Awarded"); #endif return MEDAL_TYPE_NONE; }
void notify_device_option_button ( ui_object *obj, void *arg ) { char *name[1]; if (number_of_joystick_devices > 1) { if ( get_global_joystick_device_index () < (number_of_joystick_devices - 1) ) { set_global_joystick_device_index (get_global_joystick_device_index () + 1); } else { set_global_joystick_device_index (0); } set_ui_object_text (device_option_button, joystick_devices[get_global_joystick_device_index ()].device_name); name[0] = &joystick_devices[get_global_joystick_device_index ()].device_name; preprocess_translation_object_size (device_graphic_area, device_option_button, name, 1, RESIZE_OPTION_CYCLE_BUTTON); } // don't leave text selected set_toggle_button_off (obj); #if DEBUG_MODULE debug_filtered_log ("no. jd's:%d jd index:%d", number_of_joystick_devices, get_global_joystick_device_index ()); #endif }
void deinitialise_division_database (void) { int side, type; for (side = 0; side < NUM_ENTITY_SIDES; side ++) { for (type = 0; type < NUM_ENTITY_SUB_TYPE_DIVISIONS; type ++) { if (division_id_database [side][type].valid) { #if DEBUG_MODULE debug_filtered_log ("SIDE %s - %s : Used %d / %d", entity_side_short_names [side], entity_sub_type_division_names [type], division_id_database [side][type].next, division_id_database [side][type].count); #endif debug_assert (division_id_database [side][type].count > 0); free_mem (division_id_database [side][type].number_list); memset (&division_id_database [side][type], 0, sizeof (division_id_data)); } } } }
void notify_clear_options_screen(void) { store_multiplayer_options (); // Save the global options data save_global_options_data (); // if the graphics display adapter has changed, boot the player out { int flag; flag = FALSE; if (old_graphics_card_automatic_selection != get_global_graphics_device_selection_automatic ()) { flag = TRUE; } else { flag = FALSE; } if (!old_graphics_card_automatic_selection) { if (old_graphics_card_selection != get_card_selection_device ()) { flag = TRUE; } else { flag = FALSE; } } if (flag) { push_ui_screen (exit_screen); } else { pop_ui_screen (SCREEN_POP_ACTUAL); } } #if DEBUG_MODULE debug_filtered_log("Inside clear_options_screen"); #endif }
void initialise_group_task_array (void) { int group, task; ASSERT (!group_task_array); group_task_array = malloc_heap_mem (sizeof (float *) * NUM_ENTITY_SUB_TYPE_GROUPS); for (group = 0; group < NUM_ENTITY_SUB_TYPE_GROUPS; group ++) { group_task_array [group] = malloc_heap_mem (sizeof (float) * NUM_ENTITY_SUB_TYPE_TASKS); for (task = 0; task < NUM_ENTITY_SUB_TYPE_TASKS; task ++) { group_task_array [group][task] = calculate_group_to_task_suitability (group, task); } } #if DEBUG_MODULE for (task = 0; task < NUM_ENTITY_SUB_TYPE_TASKS; task ++) { debug_filtered_log ("TASK %s", task_database [task].full_name); debug_filtered_log ("========================="); for (group = 0; group < NUM_ENTITY_SUB_TYPE_GROUPS; group ++) { if (group_task_array [group][task] > 0.0) { debug_filtered_log ("%s (%f)", group_database [group].full_name, group_task_array [group][task]); } } debug_filtered_log (""); debug_filtered_log (""); } #endif }
void show_options_page(void) { // pop_event (campaign_options_events); // initialise_options_screen(); push_ui_screen (options_screen); #if DEBUG_MODULE debug_filtered_log("Inside show_options_screen"); #endif }
void notify_avionics_option_button ( ui_object *obj, void *arg ) { set_global_simple_avionics (!get_global_simple_avionics ()); set_ui_object_text (obj, option_avionics_text [get_global_simple_avionics ()]); #if DEBUG_MODULE debug_filtered_log ("avionics: %d text: %s", get_global_simple_avionics (), option_avionics_text [get_global_simple_avionics ()]); #endif // don't leave text selected set_toggle_button_off (obj); }
void notify_co_pilot_target_option_button ( ui_object *obj, void *arg ) { int selection; selection = (get_global_cpg_assist_type () + 1) % NUM_CPG_ASSISTANCE_TYPES; set_global_cpg_assist_type ((cpg_assist_types) selection); set_ui_object_text (obj, option_cpg_text [selection]); // don't leave text selected set_toggle_button_off (obj); #if DEBUG_MODULE debug_filtered_log("selection:%d", selection); #endif }
void notify_reverse_throttle_option_button ( ui_object *obj, void *arg ) { int selection; selection = !get_global_dynamics_options_reverse_throttle_input (); set_global_dynamics_options_reverse_throttle_input (selection); set_ui_object_text (reverse_throttle_button, option_boolean_text [selection]); set_current_dynamics_options (DYNAMICS_OPTIONS_REVERSE_THROTTLE_INPUT, get_global_dynamics_options_reverse_throttle_input()); // don't leave text selected set_toggle_button_off (obj); #ifdef DEBUG_MODULE debug_filtered_log ("reverse throttle: %d", get_global_dynamics_options_reverse_throttle_input ()); #endif }
int get_next_free_division_id (int side, int type) { int id, index, count; if (!division_id_database [side][type].valid) { debug_fatal ("DIVISION: Side %s Type %d not valid", entity_side_short_names [side], type); } index = division_id_database [side][type].next; count = division_id_database [side][type].count; debug_assert (count > 0); debug_assert (index < count); id = division_id_database [side][type].number_list [index]; index ++; if (index == count) { debug_filtered_log ("DIVISION: WARNING Side %s - %s wrapped (count = %d)", entity_side_short_names [side], entity_sub_type_division_names [type], count); index = 0; } division_id_database [side][type].next = index; return id; }
static void save_game_function (ui_object *obj, void *arg) { char *text; #if DEBUG_MODULE debug_filtered_log("Filename query"); #endif text = get_ui_object_text (save_current_filename); if (text) { if (strlen (text) > 0) { strcpy (full_filename, current_session->data_path); strcat (full_filename, "//Campaign//"); strcat (full_filename, text); strcat (full_filename, ".sav"); if (file_exist (full_filename)) { save_session (obj, arg); } else { save_session (obj, arg); } } } }
void notify_show_controller_page (void) { // initialise button text if ( (get_global_cyclic_input () == JOYSTICK_INPUT) && (number_of_joystick_devices) ) { set_ui_object_text (cyclic_option_button, option_joystick_text[1]); } else { set_ui_object_text (cyclic_option_button, option_joystick_text[0]); } if ( (get_global_collective_input () == THROTTLE_INPUT) && (number_of_joystick_devices) ) { set_ui_object_text (collective_option_button, option_throttle_text[1]); } else { set_ui_object_text (collective_option_button, option_throttle_text[0]); } if ( (get_global_pedal_input () == RUDDER_INPUT) && (number_of_joystick_devices) ) { set_ui_object_text (pedal_option_button, option_pedal_text[1]); } else { set_ui_object_text (pedal_option_button, option_pedal_text[0]); } if (get_global_joystick_device_index () == -1) { set_ui_object_font_type (device_option_button, UI_FONT_THICK_ITALIC_ARIAL_18); set_ui_object_text (device_option_button, no_joystick_text); preprocess_translation_object_size (device_graphic_area, device_option_button, &no_joystick_text, 1, RESIZE_OPTION_CYCLE_BUTTON); } else { char *name[1]; set_ui_object_text (device_option_button, joystick_devices[get_global_joystick_device_index ()].device_name); name[0] = &joystick_devices[get_global_joystick_device_index ()].device_name; preprocess_translation_object_size (device_graphic_area, device_option_button, name, 1, RESIZE_OPTION_CYCLE_BUTTON); } set_ui_object_text (reverse_throttle_button, option_boolean_text [get_global_dynamics_options_reverse_throttle_input ()]); set_ui_object_text (keyboard_assist_option_button, option_boolean_text [get_global_dynamics_options_keyboard_assistance ()]); display_options_page(OPTIONS_PAGE_CONTROLLER); #if DEBUG_MODULE debug_filtered_log("Inside show_controller_page"); #endif }
int assign_primary_task_to_group (entity *group_en, entity *task_en) { entity_sub_types task_type, group_type; entity *force, *keysite; int side, formation, air_threat, enemy_sectors; unsigned int threat; ASSERT (get_comms_model () == COMMS_MODEL_SERVER); task_type = get_local_entity_int_value (task_en, INT_TYPE_ENTITY_SUB_TYPE); ASSERT (task_database [task_type].primary_task); group_type = get_local_entity_int_value (group_en, INT_TYPE_ENTITY_SUB_TYPE); ASSERT (!get_local_group_primary_task (group_en)); if (assign_task_to_group (group_en, task_en, TASK_ASSIGN_ALL_MEMBERS)) { // // set default group formation // formation = get_local_entity_int_value (group_en, INT_TYPE_GROUP_DEFAULT_FORMATION); if (formation != get_local_entity_int_value (group_en, INT_TYPE_GROUP_FORMATION)) { set_client_server_entity_int_value (group_en, INT_TYPE_GROUP_FORMATION, formation); } // // Link to new keysite // if (get_local_entity_int_value (group_en, INT_TYPE_GROUP_LIST_TYPE) == LIST_TYPE_KEYSITE_GROUP) { keysite = ( entity * ) get_local_entity_ptr_value (task_en, PTR_TYPE_RETURN_KEYSITE); if (keysite) { set_client_server_entity_parent (group_en, LIST_TYPE_KEYSITE_GROUP, keysite); } } // // Notify Force // side = get_local_entity_int_value (group_en, INT_TYPE_SIDE); force = get_local_force_entity ( ( entity_sides ) side ); ASSERT (force); notify_local_entity (ENTITY_MESSAGE_TASK_ASSIGNED, force, task_en); // // Assess for Escort task // if (task_database [task_type].escort_required_threshold != ESCORT_NEVER) { threat = assess_task_difficulty (task_en, &air_threat, &enemy_sectors); #if DEBUG_ESCORT_TASK_CREATION debug_filtered_log ("(ASSIGN) Side %s: Assigned %s to %s, objective %s", entity_side_short_names [side], get_local_entity_string (group_en, STRING_TYPE_FULL_NAME), get_local_entity_string (task_en, STRING_TYPE_FULL_NAME), get_task_objective_string (task_en) ); debug_filtered_log ("Threat: %d (air_threat: %d, enemy_sectors: %d) - Threshold %d", threat, air_threat, enemy_sectors, task_database [task_type].escort_required_threshold); #endif if (threat >= task_database [task_type].escort_required_threshold) { create_escort_task (group_en, (threat >= ESCORT_CRITICAL), task_database [ENTITY_SUB_TYPE_TASK_ESCORT].task_priority, NULL, NULL); ai_log ("(ASSIGN) Created Escort Task for %s :- Threat %d / Threshold %d", get_local_entity_string (task_en, STRING_TYPE_FULL_NAME), threat, task_database [task_type].escort_required_threshold ); } } // // Store Start Time // set_client_server_entity_float_value (task_en, FLOAT_TYPE_START_TIME, get_local_entity_float_value (get_session_entity (), FLOAT_TYPE_ELAPSED_TIME)); // // Clear Expire Timer (now also used for destroying completed tasks) // set_local_entity_float_value (task_en, FLOAT_TYPE_EXPIRE_TIMER, 0.0); ai_log ("(ASSIGN) Side %s: Assigned %s (%d) to %s (%d) - Priority %f", entity_side_short_names [side], get_local_entity_string (group_en, STRING_TYPE_FULL_NAME), get_local_entity_safe_index (group_en), get_local_entity_string (task_en, STRING_TYPE_FULL_NAME), get_local_entity_safe_index (task_en), get_local_entity_float_value (task_en, FLOAT_TYPE_TASK_PRIORITY)); return TRUE; } return FALSE; }
entity *push_task_onto_group_task_stack (entity *group, entity *task, unsigned int valid_members) { entity *task_parent, *guide; list_types list_type; #ifdef DEBUG unsigned int total_members, member_number; #endif ASSERT (get_comms_model () == COMMS_MODEL_SERVER); ASSERT (group); #ifdef DEBUG total_members = 0; // // Check not already on stack // guide = get_local_entity_first_child (task, LIST_TYPE_GUIDE); while (guide) { if (get_local_entity_parent (guide, LIST_TYPE_GUIDE_STACK) == group) { member_number = get_local_entity_int_value (guide, INT_TYPE_VALID_GUIDE_MEMBERS); total_members |= member_number; } guide = get_local_entity_child_succ (guide, LIST_TYPE_GUIDE); } // // A TASK may be on the stack many times, but any one member should not have the same task duplicated // e.g. ENGAGE tasks may be duplicated many times, but their guide "valid_members" should all be exclusive // if (valid_members & total_members) { debug_filtered_log ("Trying to assign task %s (%d) to group %s - members %d", get_local_entity_string (task, STRING_TYPE_FULL_NAME), get_local_entity_index (task), get_local_entity_string (group, STRING_TYPE_FULL_NAME), valid_members); debug_filtered_log (""); dump_guide_stack (group); debug_fatal ("ASSIGN: Task %s already on Group %s guide stack", get_local_entity_string (task, STRING_TYPE_FULL_NAME), get_local_entity_string (group, STRING_TYPE_FULL_NAME)); } #endif // // create guide entity for task // guide = create_client_server_guide_entity (task, NULL, valid_members); attach_group_to_guide_entity (group, guide); // // remove task and group from lists (must be done AFTER guide is created and attached) // list_type = get_local_task_list_type (task); if (list_type == LIST_TYPE_UNASSIGNED_TASK) { task_parent = get_local_entity_parent (task, list_type); if (task_parent) { delete_local_entity_from_parents_child_list (task, list_type); // // add task to assigned task list, if not already on it. // insert_local_entity_into_parents_child_list (task, LIST_TYPE_ASSIGNED_TASK, task_parent, NULL); transmit_entity_comms_message (ENTITY_COMMS_SWITCH_LIST, task, LIST_TYPE_UNASSIGNED_TASK, task_parent, LIST_TYPE_ASSIGNED_TASK); } } return guide; }
void get_kiowa_display_viewpoint (view_modes mode) { object_3d_sub_object_index_numbers index; object_3d_sub_object_search_data search; vec3d position; ASSERT (get_gunship_entity ()); ASSERT (virtual_cockpit_inst3d); switch (mode) { //////////////////////////////////////// case VIEW_MODE_VIRTUAL_COCKPIT_PILOT_LHS_DISPLAY: //////////////////////////////////////// { index = OBJECT_3D_SUB_OBJECT_COCKPIT_VIEW_MFD_FL; break; } //////////////////////////////////////// case VIEW_MODE_VIRTUAL_COCKPIT_PILOT_RHS_DISPLAY: //////////////////////////////////////// { index = OBJECT_3D_SUB_OBJECT_COCKPIT_VIEW_MFD_FR; break; } //////////////////////////////////////// case VIEW_MODE_VIRTUAL_COCKPIT_CO_PILOT_LHS_DISPLAY: //////////////////////////////////////// { index = OBJECT_3D_SUB_OBJECT_COCKPIT_VIEW_MFD_RL; break; } //////////////////////////////////////// case VIEW_MODE_VIRTUAL_COCKPIT_CO_PILOT_RHS_DISPLAY: //////////////////////////////////////// { index = OBJECT_3D_SUB_OBJECT_COCKPIT_VIEW_MFD_RR; break; } //////////////////////////////////////// default: //////////////////////////////////////// { debug_fatal ("Invalid view mode = %d", mode); break; } } virtual_cockpit_inst3d->vp.x = 0.0; virtual_cockpit_inst3d->vp.y = 0.0; virtual_cockpit_inst3d->vp.z = 0.0; //////////////////////////////////////// // #if DEBUG_MODULE_FINE_DISPLAY_CAMERA_POSITION_ADJUSTMENT get_identity_matrix3x3 (virtual_cockpit_inst3d->vp.attitude); #else get_local_entity_attitude_matrix (get_gunship_entity (), virtual_cockpit_inst3d->vp.attitude); #endif // //////////////////////////////////////// search.search_depth = 0; search.search_object = virtual_cockpit_inst3d; search.sub_object_index = index; if (find_object_3d_sub_object (&search) == SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND) { get_3d_sub_object_world_viewpoint (search.result_sub_object, &main_vp); } else { debug_fatal ("Failed to locate display viewpoint in virtual cockpit"); } position.x = -main_vp.x; position.y = -main_vp.y; position.z = -main_vp.z; //////////////////////////////////////// // #if DEBUG_MODULE_FINE_DISPLAY_CAMERA_POSITION_ADJUSTMENT { static float z_offset = 0.0; float dx, dy, dz; if (check_key (DIK_Q)) { z_offset -= 0.0001; } if (check_key (DIK_A)) { z_offset += 0.0001; } dx = main_vp.zv.x * z_offset; dy = main_vp.zv.y * z_offset; dz = main_vp.zv.z * z_offset; position.x += dx; position.y += dy; position.z += dz; debug_filtered_log ("offset=%.6f x=%.6f y=%.6f z=%.6f", z_offset, position.x, position.y, position.z); } #endif // //////////////////////////////////////// multiply_transpose_matrix3x3_vec3d (&virtual_cockpit_inst3d->vp.position, main_vp.attitude, &position); get_local_entity_vec3d (get_gunship_entity (), VEC3D_TYPE_POSITION, &position); main_vp.x += position.x; main_vp.y += position.y; main_vp.z += position.z; }
void notify_medals_screen (ui_object *obj) { int i; if ( get_ui_object_drawable (obj) ) { if (medals_screen_texture) { for (i = 1; i < NUMBER_OF_MEDAL_GRAPHICS; i++) { destroy_texture_graphic (medal_graphics [i]); medal_graphics [i] = NULL; } destroy_texture_graphic (medals_screen_texture); medals_screen_texture = NULL; } if (player_log_current_side == ENTITY_SIDE_BLUE_FORCE) { set_ui_object_text (medals_title_text, get_trans("US")); medals_screen_texture = create_texture_graphic ( "graphics//ui//cohokum//medalsus.psd" ); set_ui_object_drawable (russian_area, FALSE); set_ui_object_drawable (us_area, TRUE); // create medal texture graphic objects, except MEDAL_TYPE_NONE for (i = 1; i < NUMBER_OF_MEDAL_GRAPHICS; i++) { medal_graphics [i] = create_texture_graphic (us_medal_graphic_array[i].name); set_ui_object_texture_graphic (us_medal_objects [i], medal_graphics [i]); } medal_graphics [0] = NULL; // set medal states set_medal_states (us_medal_objects); } else { set_ui_object_text (medals_title_text, get_trans("Russian")); medals_screen_texture = create_texture_graphic ( "graphics//ui//cohokum//medalssv.psd" ); set_ui_object_drawable (russian_area, TRUE); set_ui_object_drawable (us_area, FALSE); // create medal texture graphic objects, except MEDAL_TYPE_NONE for (i = 1; i < NUMBER_OF_MEDAL_GRAPHICS; i++) { medal_graphics [i] = create_texture_graphic (russian_medal_graphic_array[i].name); set_ui_object_texture_graphic (russian_medal_objects [i], medal_graphics [i]); } medal_graphics [0] = NULL; // set medal states set_medal_states (russian_medal_objects); } set_ui_object_texture_graphic (player_medals_screen, medals_screen_texture); recursively_set_object_time (player_medals_screen, MEDALS_AREA_FADE_TIME, MEDALS_AREA_OFFSET_TIME); reset_time_values (player_medals_screen); blit_front_buffer_to_render_buffer (); } else { if (medals_screen_texture ) { for (i = 1; i < NUMBER_OF_MEDAL_GRAPHICS; i++) { destroy_texture_graphic (medal_graphics [i]); medal_graphics [i] = NULL; } destroy_texture_graphic (medals_screen_texture); medals_screen_texture = NULL; } } #if DEBUG_MODULE debug_filtered_log("Inside show_medals_screen"); #endif }
void comms_process_data (void) { session_list_data_type *current_session; connection_list_type *this_connection, *connection; char *received_data; int planner_event, frame_id, packet_id, receive_flag, received_size; GUID received_id = 0; entity *member; send_types send_type; packet_types type; // receive all packets in queue current_session = get_current_game_session (); received_size = MAX_RECEIVE_SIZE; connection = get_connection_list_head (); while (connection) { this_connection = connection; connection = connection->next; send_type = SEND_TYPE_GROUP; while (send_type >= SEND_TYPE_PERSONAL) { receive_flag = TRUE; while (receive_flag) { type = process_packet_list (send_type, this_connection, &received_id, &received_data, &received_size); switch (type) { /////////////////////////////////////////////////////////////////////////////////////////////// // // System packets, used internally // /////////////////////////////////////////////////////////////////////////////////////////////// case PACKET_TYPE_INVALID: { receive_flag = FALSE; if (get_comms_model () == COMMS_MODEL_SERVER) { if (this_connection->packet_rerequested > command_line_comms_packet_rerequest_limit) { debug_log ("COMM_MAN: REJECTING CONNECTION. CONNECTION TOO BAD (re-request limit %d reached)", command_line_comms_packet_rerequest_limit); send_packet (this_connection->connection_id, PACKET_TYPE_SERVER_REJECTED, NULL, 0, SEND_TYPE_PERSONAL); } } break; } case PACKET_TYPE_RESEND_PACKET: { send_types resend_send_type; frame_id = get_list_item (received_data, int); packet_id = get_list_item (received_data, int); resend_send_type = get_list_item (received_data, send_types); #if DEBUG_MODULE if (this_connection->pilot_entity) { debug_log ("COMMS MAN: received RESEND PACKET for frame %d packet %d from %s (dpid %d)", frame_id, packet_id, get_local_entity_string (this_connection->pilot_entity, STRING_TYPE_PILOTS_NAME), received_id); } else { debug_log ("COMMS MAN: received RESEND PACKET by unknown (pdid %d)", received_id); } #endif resend_packet (received_id, frame_id, packet_id, resend_send_type); break; } /////////////////////////////////////////////////////////////////////////////////////////////// // // Packets for initialisation and joining // /////////////////////////////////////////////////////////////////////////////////////////////// case PACKET_TYPE_SESSION_QUERY: { char *ptr; int server_version_number, player_count, size; connection_list_type *new_connection; if (get_comms_model () == COMMS_MODEL_SERVER) { #if DEBUG_MODULE if (this_connection->pilot_entity) { debug_log ("COMMS MAN: RECEIVED SESSION QUERY from %s (dpid %d)", get_local_entity_string (this_connection->pilot_entity, STRING_TYPE_PILOTS_NAME), received_id); } else { debug_log ("COMMS MAN: RECEIVED SESSION QUERY from %d", received_id); } #endif new_connection = get_connection_list_item (received_id); if (!new_connection->already_sent_query_data) { new_connection->already_sent_query_data = TRUE; while (TRUE) { ptr = new_connection->connection_receive_buffer; size = 0; ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // Check both client and server are running same campaign data // server_version_number = get_local_entity_int_value (get_session_entity (), INT_TYPE_VERSION_NUMBER); quick_set_list_item (ptr, int, server_version_number); size += sizeof (int); // ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // map details quick_set_list_item (ptr, int, NUM_MAP_X_SECTORS); quick_set_list_item (ptr, int, NUM_MAP_Z_SECTORS); quick_set_list_item (ptr, int, SECTOR_SIDE_LENGTH); size += sizeof (int) * 3; // data path strcpy (ptr, current_session->data_path); ptr += strlen (current_session->data_path) + 1; size += strlen (current_session->data_path) + 1; // population_placement filename if (population_placement_filename) { strcpy (ptr, population_placement_filename); ptr += strlen (population_placement_filename) + 1; size += strlen (population_placement_filename) + 1; } else { strcpy (ptr, "\0"); ptr += strlen ("\0") + 1; size += strlen ("\0") + 1; } // // side_data filename if (side_data_filename) { strcpy (ptr, side_data_filename); ptr += strlen (side_data_filename) + 1; size += strlen (side_data_filename) + 1; } else { strcpy (ptr, "\0"); ptr += strlen ("\0") + 1; size += strlen ("\0") + 1; } // campaign_population filename if (campaign_population_filename) { strcpy (ptr, campaign_population_filename); ptr += strlen (campaign_population_filename) + 1; size += strlen (campaign_population_filename) + 1; } else { strcpy (ptr, "\0"); ptr += strlen ("\0") + 1; size += strlen ("\0") + 1; } // // planner position and zoom // // quick_set_list_item (ptr, float, planner_map_data.centre_map_x); // quick_set_list_item (ptr, float, planner_map_data.centre_map_z); // size += sizeof (float) * 2; // quick_set_list_item (ptr, int, planner_map_data.map_zoom); // size += sizeof (int); // // Pilots // player_count = get_number_of_connected_players (); quick_set_list_item (ptr, int, player_count); size += sizeof (int); // // // #if DEBUG_MODULE debug_log ("COMM_MAN: sending data path %s, population placement %s, side data %s, campaign_pop file %s", current_session->data_path, population_placement_filename, side_data_filename, campaign_population_filename); #endif new_connection->connection_receive_buffer_size -= size; if (!pack_session (ptr, &new_connection->connection_receive_buffer_size, PACK_MODE_BROWSE_SESSION)) { break; } new_connection->connection_receive_buffer_size *= 2; #if DEBUG_MODULE debug_log ("COMMS MAN: Browse: connection_receive_buffer too small, mallocing to %d", new_connection->connection_receive_buffer_size); #endif free_mem (new_connection->connection_receive_buffer); new_connection->connection_receive_buffer = malloc_heap_mem (new_connection->connection_receive_buffer_size); } // // // send_packet (received_id, PACKET_TYPE_SESSION_INFO, new_connection->connection_receive_buffer, new_connection->connection_receive_buffer_size + size, SEND_TYPE_PERSONAL); /* { FILE *test_ptr; test_ptr = fopen ("out.txt", "wb"); fwrite (new_connection->connection_receive_buffer, 1, new_connection->connection_receive_buffer_size + size, test_ptr); fclose (test_ptr); } */ } else { debug_log ("COMM_MAN: not resending query data"); } } break; } case PACKET_TYPE_CONNECTION_VALIDATION: { debug_log ("COMM_MAN: received CONNECTION_VALIDATION, sending RESPONSE"); send_packet (received_id, PACKET_TYPE_CONNECTION_RESPONSE, NULL, 0, SEND_TYPE_PERSONAL); break; } case PACKET_TYPE_CONNECTION_RESPONSE: { connection_list_type *connection; connection = get_connection_list_item (received_id); connection->validation_count = 0; debug_log ("COMM_MAN: received CONNECTION_RESPONSE, connection still alive"); break; } case PACKET_TYPE_SESSION_INFO: { entity *force, *pilot; int client_version_number, server_version_number; int size, x_size, z_size, sector_size, player_count, loop; char *ptr, warzone_ffp_filename [256], temp_campaign_population_filename [256], temp_population_placement_filename [256], temp_side_data_filename [256], buffer [128]; session_data = FALSE; reinitialise_entity_system (); ptr = received_data; size = 0; set_ui_object_redraw (gunships_screen, TRUE); ui_force_update (); ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // Check both client and server are running same campaign data // client_version_number = get_global_version_number (); server_version_number = get_list_item (ptr, int); size += sizeof (int); if (client_version_number != server_version_number) { debug_fatal ("COMM_MAN: Incorrect version. Server Version No. %d, Client Version No. %d", server_version_number, client_version_number); } // ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // map details x_size = get_list_item (ptr, int); z_size = get_list_item (ptr, int); sector_size = get_list_item (ptr, int); size += (sizeof (int) * 3); set_entity_world_map_size (x_size, z_size, sector_size); // data path strncpy (current_session->data_path, ptr, sizeof (current_session->data_path)); ptr += strlen (current_session->data_path) + 1; size += strlen (current_session->data_path) + 1; // population_placement_filename strncpy (temp_population_placement_filename, ptr, sizeof (temp_population_placement_filename)); ptr += strlen (temp_population_placement_filename) + 1; size += strlen (temp_population_placement_filename) + 1; if (population_placement_filename) { free_mem (population_placement_filename); } if (strlen (temp_population_placement_filename) > 0) { population_placement_filename = (char *) malloc_heap_mem (strlen (temp_population_placement_filename) + 1); sprintf (population_placement_filename, "%s", temp_population_placement_filename); } else { population_placement_filename = NULL; } // side_data filename strncpy (temp_side_data_filename, ptr, sizeof (temp_side_data_filename)); ptr += strlen (temp_side_data_filename) + 1; size += strlen (temp_side_data_filename) + 1; if (side_data_filename) { free_mem (side_data_filename); } if (strlen (temp_side_data_filename) > 0) { side_data_filename = (char *) malloc_heap_mem (strlen (temp_side_data_filename) + 1); sprintf (side_data_filename, "%s", temp_side_data_filename); } else { side_data_filename = NULL; } // campaign_population_filename strncpy (temp_campaign_population_filename, ptr, sizeof (temp_campaign_population_filename)); ptr += strlen (temp_campaign_population_filename) + 1; size += strlen (temp_campaign_population_filename) + 1; if (campaign_population_filename) { free_mem (campaign_population_filename); } if (strlen (temp_campaign_population_filename) > 0) { campaign_population_filename = (char *) malloc_heap_mem (strlen (temp_campaign_population_filename) + 1); sprintf (campaign_population_filename, "%s", temp_campaign_population_filename); } else { campaign_population_filename = NULL; } // // // player_count = get_list_item (ptr, int); size += sizeof (int); // // // received_size -= size; #if DEBUG_MODULE debug_log ("COMM_MAN: data path %s population placement filename %s, side data filename %s", current_session->data_path, population_placement_filename, side_data_filename); debug_log ("COMM_MAN: campaign data path = %s", current_session->data_path); #endif // // check we have the correct warzone locally // sprintf (warzone_ffp_filename, "%s\\terrain\\terrain.ffp", current_session->data_path); if (!file_exist (warzone_ffp_filename)) { add_to_pop_up_list_with_word_wrap (get_trans ("UNRECOGNISED_WARZONE"), session_info_list, NULL, 0, UI_FONT_ARIAL_10, sys_col_white); //add_to_pop_up_list (get_trans ("Server using unrecognised warzone"), session_info_list, NULL, 0, UI_FONT_ARIAL_10, sys_col_white); break; } // // // create_local_only_entities (PACK_MODE_BROWSE_SESSION); if (unpack_session (ptr, received_size, PACK_MODE_BROWSE_SESSION)) { debug_fatal ("COMMS MAN: browse: received size overflow"); } #if DEBUG_MODULE if (this_connection->pilot_entity) { debug_log ("COMMS MAN: received SESSION INFO from %s (dpid %d) (setting server id)", get_local_entity_string (this_connection->pilot_entity, STRING_TYPE_PILOTS_NAME), received_id); } else { debug_log ("COMMS MAN: RECEIVED SESSION INFO from %d", received_id); } debug_log ("COMMS MAN: session info: time of day = %f", get_local_entity_float_value (get_session_entity (), FLOAT_TYPE_TIME_OF_DAY)); debug_log ("COMMS MAN: map dimensions %d, %d, sector size %d", x_size, z_size, sector_size); #endif set_ui_object_drawable (session_screen_next_button, TRUE); // // Display game info // ui_object_destroy_list_items (session_info_list); if (get_local_entity_int_value (get_session_entity (), INT_TYPE_CAMPAIGN_REQUIRES_APACHE_HAVOC)) { // campaign requires apache havoc to be installed // check it is... if (!get_global_apache_havoc_installed ()) { add_to_pop_up_list_with_word_wrap (get_trans ("REQUIRES_APACHE_HAVOC"), session_info_list, NULL, 0, UI_FONT_ARIAL_10, sys_col_white); set_ui_object_drawable (session_screen_next_button, FALSE); break; } } loop = 3; sprintf (buffer, "%s : %d", get_trans ("Players"), player_count); add_to_pop_up_list_with_word_wrap (buffer, session_info_list, NULL, 0, UI_FONT_ARIAL_10, sys_col_white); force = get_local_entity_first_child (get_session_entity (), LIST_TYPE_FORCE); while (force) { pilot = get_local_entity_first_child (force, LIST_TYPE_PILOT); while (pilot) { { rgb_colour col; sprintf (buffer, "%2d ", loop - 2); strncat (buffer, get_local_entity_string (pilot, STRING_TYPE_PILOTS_NAME), 64); switch (get_local_entity_int_value (pilot, INT_TYPE_SIDE)) { case ENTITY_SIDE_BLUE_FORCE: { col.r = 120; col.g = 158; col.b = 255; col.a = 255; break; } case ENTITY_SIDE_RED_FORCE: { col.r = 255; col.g = 120; col.b = 80; col.a = 255; break; } default: { col = ui_colour_white; break; } } add_to_pop_up_list_with_word_wrap (buffer, session_info_list, NULL, 0, UI_FONT_ARIAL_10, col); loop ++; } pilot = get_local_entity_child_succ (pilot, LIST_TYPE_PILOT); } force = get_local_entity_child_succ (force, LIST_TYPE_FORCE); } set_server_id (received_id); // // destroy all entities created by browse info // reinitialise_entity_system (); break; } case PACKET_TYPE_CLIENT_PILOT_REQUEST: { connection_list_type *new_connection; client_pilot_request_data pilot_data; entity *new_pilot; int index; ASSERT (get_comms_model () == COMMS_MODEL_SERVER); // #if DEBUG_MODULE debug_log ("COMMS MAN: RECEIVED PILOT REQUEST from %d", received_id); // #endif // // unpack name // memcpy (&pilot_data, (client_pilot_request_data *) received_data, sizeof (client_pilot_request_data)); new_pilot = create_new_pilot_entity ( pilot_data.name, pilot_data.side, pilot_data.rank, pilot_data.sub_type, pilot_data.unique_id, pilot_data.difficulty ); ASSERT (new_pilot); index = get_local_entity_safe_index (new_pilot); new_connection = get_connection_list_item (received_id); transmit_entity_comms_message (ENTITY_COMMS_PILOT_REQUEST_ACCEPTED, NULL, received_id, index); new_connection->pilot_entity = new_pilot; break; } case PACKET_TYPE_CLIENT_GUNSHIP_REQUEST: { connection_list_type *new_connection; client_gunship_request_data pilot_data; int index_number, buffer [2]; if (get_comms_model () == COMMS_MODEL_SERVER) { // #if DEBUG_MODULE if (this_connection->pilot_entity) { debug_log ("COMMS MAN: RECEIVED GUNSHIP REQUEST from %s (dpid %d)", get_local_entity_string (this_connection->pilot_entity, STRING_TYPE_PILOTS_NAME), received_id); } else { debug_log ("COMMS MAN: RECEIVED GUNSHIP REQUEST from %d", received_id); } // #endif memcpy (&pilot_data, (client_gunship_request_data *) received_data, sizeof (client_gunship_request_data)); index_number = pilot_data.gunship_index; ASSERT (index_number != ENTITY_INDEX_DONT_CARE); member = get_local_entity_safe_ptr (index_number); if (!member) { // #if DEBUG_MODULE if (this_connection->pilot_entity) { debug_log ("COMMS MAN: REFUSING GUNSHIP FOR PLAYER %s (dpid %d) for helicopter %d", get_local_entity_string (this_connection->pilot_entity, STRING_TYPE_PILOTS_NAME), received_id, pilot_data.gunship_index); } else { debug_log ("COMMS MAN: Refusing gunship for player %d to helicopter %d", received_id, pilot_data.gunship_index); } // #endif send_packet (received_id, PACKET_TYPE_GUNSHIP_REQUEST_REFUSED, NULL, 0, SEND_TYPE_PERSONAL); break; } new_connection = get_connection_list_item (received_id); // // send acceptance // buffer [0] = index_number; // #if DEBUG_MODULE debug_log ("COMMS MAN: sending gunship request accepted for gunship %d pilot id %d", index_number, received_id); // #endif send_packet (received_id, PACKET_TYPE_GUNSHIP_REQUEST_ACCEPTED, (void *) &buffer, 4, SEND_TYPE_PERSONAL); new_connection->gunship_number = pilot_data.gunship_index; new_connection->gunship_entity = member; } break; } case PACKET_TYPE_CLIENT_CAMPAIGN_DATA_REQUEST: { connection_list_type *new_connection; int index_number; if (get_comms_model () == COMMS_MODEL_SERVER) { #if DEBUG_MODULE if (this_connection->pilot_entity) { debug_log ("COMMS MAN: RECEIVED JOIN REQUEST by %s (dpid %d)", get_local_entity_string (this_connection->pilot_entity, STRING_TYPE_PILOTS_NAME), received_id); } else { debug_log ("COMMS MAN: received JOIN REQUEST by %d", received_id); } #endif // // flush group send buffer // send_comms_data (); // // pack mission data into packet // new_connection = get_connection_list_item (received_id); // // Store entity data // while (pack_session (new_connection->connection_receive_buffer, &new_connection->connection_receive_buffer_size, PACK_MODE_CLIENT_SESSION)) { new_connection->connection_receive_buffer_size *= 2; #if DEBUG_MODULE debug_log ("COMMS MAN: Mission data: connection_receive_buffer too small, mallocing to %d", new_connection->connection_receive_buffer_size); #endif free_mem (new_connection->connection_receive_buffer); new_connection->connection_receive_buffer = malloc_heap_mem (new_connection->connection_receive_buffer_size); memset (new_connection->connection_receive_buffer, 0, new_connection->connection_receive_buffer_size); } // add frame id index_number = get_group_frame_id (); memcpy (&new_connection->connection_receive_buffer [new_connection->connection_receive_buffer_size], (void *) &index_number, sizeof (int)); new_connection->connection_receive_buffer_size += sizeof (int); send_packet (received_id, PACKET_TYPE_MISSION_DATA, new_connection->connection_receive_buffer, new_connection->connection_receive_buffer_size, SEND_TYPE_PERSONAL); memset (new_connection->connection_receive_buffer, 0, new_connection->connection_receive_buffer_size); // // send group frame id // SDL_Delay (100); index_number = get_group_frame_id (); //send_packet (received_id, PACKET_TYPE_FRAME_ID, (void *) &index_number, 4, SEND_TYPE_PERSONAL); zero_average_pack_size (); } break; } case PACKET_TYPE_CLIENT_FRAME_ID: { int loop1, loop2, index_number; stub_packet_type *stub_packet; connection_list_type *new_connection; index_number = get_list_item (received_data, int); new_connection = get_connection_list_item (received_id); //#if DEBUG_MODULE if (new_connection) { debug_log ("COMMS MAN: received CLIENT FRAME ID (%d) by %d %s", index_number, received_id, direct_play_get_player_name (received_id)); } //#endif // // send all packets between when the client started to join and when it actually joined. // for (loop1 = index_number; loop1 < get_group_frame_id () - 1; loop1 ++) { //#if DEBUG_MODULE debug_log ("COMMS MAN: sending packet %d frame %d to recently joined client", loop1, 0); //#endif stub_packet = resend_packet (received_id, loop1, 1, SEND_TYPE_GROUP); ASSERT (stub_packet); for (loop2 = 2; loop2 <= stub_packet->packet->number_of_packets; loop2 ++) { //#if DEBUG_MODULE debug_log ("COMMS MAN: sending packet %d frame %d to recently joined client", loop1, loop2); //#endif stub_packet = resend_packet (received_id, loop1, loop2, SEND_TYPE_GROUP); } } break; } case PACKET_TYPE_GUNSHIP_REQUEST_REFUSED: { // #if DEBUG_MODULE debug_log ("COMMS MAN: Gunship refused"); // #endif set_server_response (SERVER_RESPONSE_REFUSE); break; } case PACKET_TYPE_GUNSHIP_REQUEST_ACCEPTED: { entity *gunship; int index_number; // #if DEBUG_MODULE debug_log ("COMMS MAN: received GUNSHIP ACCEPTED by %d", received_id); // #endif // // set gunship // index_number = get_list_item (received_data, int); ASSERT (get_pilot_entity ()); gunship = get_local_entity_safe_ptr (index_number); debug_filtered_log ("COMM_MAN: setting gunship"); planner_event = FALSE; if (get_event_stack_head_function() == ingame_screen_set_events) { pop_event (ingame_screen_set_events); planner_event = TRUE; } assign_entity_to_user (gunship); if (planner_event) { push_event (ingame_screen_set_events, "ingame screen events"); } debug_filtered_log ("COMM_MAN: gunship set"); //////////////////////////////////////////////////////////////////////// break; } case PACKET_TYPE_PILOT_REQUEST_ACCEPTED: { int index_number; ASSERT (get_comms_model () == COMMS_MODEL_CLIENT); // #if DEBUG_MODULE debug_log ("COMMS MAN: received PILOT ACCEPTED by %d", received_id); // #endif index_number = get_list_item (received_data, int); set_pilot_entity (get_local_entity_safe_ptr (index_number)); break; } case PACKET_TYPE_MISSION_DATA: { #if DEBUG_MODULE debug_log ("COMMS MAN: received MISSION DATA by %d", received_id); #endif set_mouse_graphic_off (); // // LOAD TERRAIN DATA // load_3d_terrain_game_data (); initialise_population_name_database (); load_route_data (); // might need to send what route filename to load... // // Initialise stuff // create_local_only_entities (PACK_MODE_CLIENT_SESSION); ///////////////////////////////////////////////////////////////// if (strstr ((char*) stoupper (side_data_filename), "SID")) { read_sector_side_file (side_data_filename); } else if (strstr ((char*) stoupper (side_data_filename), "DAT")) { load_ai_sector_data (side_data_filename); } ///////////////////////////////////////////////////////////////// deinitialise_formation_database (); initialise_formation_database (); deinitialise_formation_component_database (); initialise_formation_component_database (); if (unpack_session (received_data, received_size - 4, PACK_MODE_CLIENT_SESSION)) { debug_fatal ("COMMS MAN: received size overflow"); } /* force = get_local_entity_first_child (get_session_entity (), LIST_TYPE_FORCE); while (force) { create_frontline (force); force = get_local_entity_child_succ (force, LIST_TYPE_FORCE); } */ { int index_number; connection_list_type *new_connection; received_data += received_size - 4; index_number = get_list_item (received_data, int); new_connection = get_connection_list_item (received_id); new_connection->receive_group_frame_id = index_number; send_packet (get_server_id (), PACKET_TYPE_CLIENT_FRAME_ID, (void *) &index_number, 4, SEND_TYPE_PERSONAL); } session_data = TRUE; //direct_play_join_group (); set_gunship_waiting_for_connection ( FALSE ); zero_average_pack_size (); set_mouse_graphic_on (); break; } case PACKET_TYPE_FRAME_ID: { int index_number; connection_list_type *new_connection; index_number = get_list_item (received_data, int); #if DEBUG_MODULE debug_log ("COMMS MAN: received FRAME ID (%d) by %d", index_number, received_id); #endif new_connection = get_connection_list_item (received_id); new_connection->receive_group_frame_id = index_number; send_packet (get_server_id (), PACKET_TYPE_CLIENT_FRAME_ID, (void *) &index_number, 4, SEND_TYPE_PERSONAL); break; } /////////////////////////////////////////////////////////////////////////////////////////////// // // In game packets // /////////////////////////////////////////////////////////////////////////////////////////////// case PACKET_TYPE_AI_DATA: { int //padding, data_size; #if DEBUG_MODULE >= 2 debug_log ("COMMS MAN: received AI DATA by %d", received_id); #endif if (get_comms_model () == COMMS_MODEL_CLIENT) { ASSERT (session_data); } data_size = get_list_item (received_data, int); //debug //padding = get_list_item (received_data, int); //end open_unpack_buffer (received_data, received_size); process_received_entity_comms_messages (); ASSERT (!get_unpack_buffer_overflow ()); close_unpack_buffer (); //debug //padding = get_list_item (received_data, int); //end memset (received_data, 0, this_connection->connection_receive_buffer_size); break; } case PACKET_TYPE_END_GAME: { debug_log ("COMMS MAN: received END GAME from %d", received_id); if (get_comms_model () == COMMS_MODEL_SERVER) { if (this_connection->gunship_entity) { set_client_server_entity_int_value (this_connection->gunship_entity, INT_TYPE_PLAYER, ENTITY_PLAYER_AI); } if (this_connection->pilot_entity) { debug_log (" from %s ", get_local_entity_string (this_connection->pilot_entity, STRING_TYPE_PILOTS_NAME)); } unregister_connection (received_id); } else { if (received_id == get_server_id ()) { //setup_campaign_over_screen (get_local_force_entity (get_global_gunship_side ()), CAMPAIGN_RESULT_STALEMATE); start_game_exit (GAME_EXIT_KICKOUT, FALSE); } } receive_flag = FALSE; break; } case PACKET_TYPE_SERVER_REJECTED: { debug_log ("COMMS MAN: received SERVER REJECTED (server id %d)", received_id); //setup_campaign_over_screen (get_local_force_entity (get_global_gunship_side ()), CAMPAIGN_RESULT_SERVER_REJECTED); start_game_exit (GAME_EXIT_KICKOUT, FALSE); break; } default: { debug_fatal ("ERROR: Data Exchange, unknown packet type %d", type); break; } } } send_type --; } } }
static entity *create_local (entity_types type, int index, char *pargs) { entity *en; site_updatable *raw; //////////////////////////////////////// // // VALIDATE // //////////////////////////////////////// validate_local_create_entity_index (index); #if DEBUG_MODULE debug_log_entity_args (ENTITY_DEBUG_LOCAL, ENTITY_DEBUG_CREATE, NULL, type, index); #endif en = get_free_entity (index); if (en) { //////////////////////////////////////// // // MALLOC ENTITY DATA // //////////////////////////////////////// set_local_entity_type (en, type); raw = malloc_fast_mem (sizeof (site_updatable)); set_local_entity_data (en, raw); //////////////////////////////////////// // // INITIALISE ALL ENTITY DATA TO 'WORKING' DEFAULT VALUES // // DO NOT USE ACCESS FUNCTIONS // // DO NOT USE RANDOM VALUES // //////////////////////////////////////// memset (raw, 0, sizeof (site_updatable)); // // fixed // raw->fix.position.x = MID_MAP_X; raw->fix.position.y = MID_MAP_Y; raw->fix.position.z = MID_MAP_Z; raw->fix.sub_type = ENTITY_SUB_TYPE_FIXED_UNKNOWN; raw->fix.object_3d_shape = OBJECT_3D_INVALID_OBJECT_INDEX; raw->fix.alive = TRUE; raw->fix.side = ENTITY_SIDE_NEUTRAL; // // site_updatable // //////////////////////////////////////// // // OVERWRITE DEFAULT VALUES WITH GIVEN ATTRIBUTES // //////////////////////////////////////// set_local_entity_attributes (en, pargs); //////////////////////////////////////// // // CHECK MANDATORY ATTRIBUTES HAVE BEEN GIVEN // //////////////////////////////////////// ASSERT (raw->member_link.parent); //////////////////////////////////////// // // RESOLVE DEFAULT VALUES // //////////////////////////////////////// if (raw->fix.object_3d_shape == OBJECT_3D_INVALID_OBJECT_INDEX) { raw->fix.object_3d_shape = fixed_database[raw->fix.sub_type].default_3d_shape; } fixed_3d_object_database [raw->fix.object_3d_shape].keysite_object = TRUE; if (!fixed_3d_object_database[raw->fix.object_3d_shape].valid_entry) { raw->damage_level = 500; debug_filtered_log ("SU_CREAT: Warning no entry for %s (%d)", object_3d_enumeration_names [raw->fix.object_3d_shape], raw->fix.object_3d_shape); } else { raw->damage_level = fixed_3d_object_database[raw->fix.object_3d_shape].initial_damage; } ASSERT (raw->damage_level > 0); //////////////////////////////////////// // // BUILD COMPONENTS // //////////////////////////////////////// //////////////////////////////////////// // // LINK INTO SYSTEM // //////////////////////////////////////// insert_local_entity_into_parents_child_list (en, LIST_TYPE_MEMBER, raw->member_link.parent, raw->member_link.child_pred); insert_local_entity_into_parents_child_list (en, LIST_TYPE_SECTOR, get_local_sector_entity (&raw->fix.position), NULL); insert_local_entity_into_parents_child_list (en, LIST_TYPE_UPDATE, get_update_entity (), NULL); } return (en); }