void pack_effect_data (entity *en, effect *raw, pack_modes mode) { ASSERT ((mode >= 0) && (mode < NUM_PACK_MODES)); switch (mode) { //////////////////////////////////////// case PACK_MODE_SERVER_SESSION: case PACK_MODE_CLIENT_SESSION: //////////////////////////////////////// { // // some effects should never be packed up ( should be re-constructed when the vehicle is unpacked ) // ASSERT (!effect_database [raw->sub_type].constructed_locally); pack_int_value (en, INT_TYPE_ENTITY_SUB_TYPE, raw->sub_type); pack_vec3d (en, VEC3D_TYPE_POSITION, &raw->position); ///////////////////////////////////////////////////////////////// // // Special effect packing, manually packing link data // if (raw->special_effect_link.parent) { list_link link; entity *spec; pack_int_value (en, INT_TYPE_VALID, TRUE); // // parent // link.parent = raw->special_effect_link.parent; // // succ : search forwards through special effect list for valid child succ // spec = get_local_entity_child_succ (en, LIST_TYPE_SPECIAL_EFFECT); while (TRUE) { if ((spec == NULL) || (effect_database [get_local_entity_int_value (spec, INT_TYPE_ENTITY_SUB_TYPE)].constructed_locally == FALSE)) { link.child_succ = spec; break; } spec = get_local_entity_child_succ (spec, LIST_TYPE_SPECIAL_EFFECT); } // // pred : search backwards through special effect list for valid child pred // spec = get_local_entity_child_pred (en, LIST_TYPE_SPECIAL_EFFECT); while (TRUE) { if ((spec == NULL) || (effect_database [get_local_entity_int_value (spec, INT_TYPE_ENTITY_SUB_TYPE)].constructed_locally == FALSE)) { link.child_pred = spec; break; } spec = get_local_entity_child_pred (spec, LIST_TYPE_SPECIAL_EFFECT); } pack_list_link (en, LIST_TYPE_SPECIAL_EFFECT, &link); } else { pack_int_value (en, INT_TYPE_VALID, FALSE); } ///////////////////////////////////////////////////////////////// // update_link break; } //////////////////////////////////////// case PACK_MODE_BROWSE_SESSION: //////////////////////////////////////// { break; } //////////////////////////////////////// case PACK_MODE_UPDATE_ENTITY: //////////////////////////////////////// { // // cannot update entity at this level as the update may not apply to all entity types below // break; } } }
void pack_local_keysite_data (pack_modes mode) { entity *en, *landing_en; landing *landing_raw; keysite *raw; ASSERT (mode != PACK_MODE_UPDATE_ENTITY); if (mode == PACK_MODE_BROWSE_SESSION) { return; } en = get_local_entity_list (); while (en) { if (get_local_entity_type (en) == ENTITY_TYPE_KEYSITE) { // // pack keysite data // pack_entity_safe_ptr (en); raw = (keysite *) get_local_entity_data (en); pack_float_value (en, FLOAT_TYPE_AMMO_SUPPLY_LEVEL, raw->supplies.ammo_supply_level); pack_float_value (en, FLOAT_TYPE_FUEL_SUPPLY_LEVEL, raw->supplies.fuel_supply_level); pack_float_value (en, FLOAT_TYPE_KEYSITE_STRENGTH, raw->keysite_strength); pack_float_value (en, FLOAT_TYPE_KEYSITE_MAXIMUM_STRENGTH, raw->keysite_maximum_strength); pack_int_value (en, INT_TYPE_ALIVE, raw->alive); pack_int_value (en, INT_TYPE_SIDE, raw->side); pack_int_value (en, INT_TYPE_IN_USE, raw->in_use); pack_int_value (en, INT_TYPE_KEYSITE_ID, raw->keysite_id); pack_int_value (en, INT_TYPE_KEYSITE_USABLE_STATE, raw->keysite_usable_state); pack_list_root (en, LIST_TYPE_UNASSIGNED_TASK, &raw->unassigned_task_root); pack_list_root (en, LIST_TYPE_ASSIGNED_TASK, &raw->assigned_task_root); pack_list_root (en, LIST_TYPE_COMPLETED_TASK, &raw->completed_task_root); // pack_list_root (en, LIST_TYPE_KEYSITE_GROUP, &raw->keysite_group_root); pack_list_root (en, LIST_TYPE_DIVISION_HEADQUARTERS, &raw->division_headquarters_root); if (raw->campaign_objective_link.parent) { pack_int_value (en, INT_TYPE_VALID, TRUE); pack_list_link (en, LIST_TYPE_CAMPAIGN_OBJECTIVE, &raw->campaign_objective_link); } else { pack_int_value (en, INT_TYPE_VALID, FALSE); } #if DEBUG_MODULE debug_log ("KS_PACK: packing up keysite %s", raw->keysite_name); #endif if (mode == PACK_MODE_SERVER_SESSION) { pack_float_value (en, FLOAT_TYPE_REPAIR_TIMER, raw->repair_timer); pack_float_value (en, FLOAT_TYPE_SLEEP, raw->sleep); pack_float_value (en, FLOAT_TYPE_ASSIST_TIMER, raw->assist_timer); pack_float_value (en, FLOAT_TYPE_ASSIGN_TIMER, raw->assign_timer); // // pack landing data // landing_en = get_local_entity_first_child (en, LIST_TYPE_LANDING_SITE); while (landing_en) { landing_raw = (landing *) get_local_entity_data (landing_en); pack_int_value (landing_en, INT_TYPE_RESERVED_LANDING_SITES, landing_raw->reserved_landing_sites); //pack_int_value (en, INT_TYPE_FREE_LANDING_SITES, landing_raw->free_landing_sites); pack_int_value (landing_en, INT_TYPE_LANDING_LOCK, landing_raw->landing_lock); pack_int_value (landing_en, INT_TYPE_LANDED_LOCK, landing_raw->landed_lock); pack_int_value (landing_en, INT_TYPE_TAKEOFF_LOCK, landing_raw->takeoff_lock); pack_list_root (landing_en, LIST_TYPE_TAKEOFF_QUEUE, &landing_raw->takeoff_queue_root); #if DEBUG_MODULE debug_log ("KS_PACK: packing up %s landing entity, reserved %d, free %d, locks (landing %d, landed %d, takeoff %d)", entity_sub_type_landing_names [landing_raw->sub_type], landing_raw->reserved_landing_sites, landing_raw->free_landing_sites, landing_raw->landing_lock, landing_raw->landed_lock, landing_raw->takeoff_lock ); #endif landing_en = get_local_entity_child_succ (landing_en, LIST_TYPE_LANDING_SITE); } } } en = get_local_entity_succ (en); } }
void pack_vehicle_data (entity *en, vehicle *raw, pack_modes mode) { int package; ASSERT ((mode >= 0) && (mode < NUM_PACK_MODES)); switch (mode) { //////////////////////////////////////// case PACK_MODE_SERVER_SESSION: case PACK_MODE_CLIENT_SESSION: //////////////////////////////////////// { // // pack mobile data // pack_mobile_data (en, &raw->mob, mode); // // pack vehicle data // pack_int_value (en, INT_TYPE_OBJECT_3D_SHAPE, raw->object_3d_shape); // inst3d if (mode == PACK_MODE_SERVER_SESSION) { ///////////////////////////////////////////////////////////////// if (raw->task_dependent_root.first_child) { pack_int_value (en, INT_TYPE_VALID, TRUE); pack_list_root (en, LIST_TYPE_TASK_DEPENDENT, &raw->task_dependent_root); } else { pack_int_value (en, INT_TYPE_VALID, FALSE); } ///////////////////////////////////////////////////////////////// } ///////////////////////////////////////////////////////////////// if (raw->launched_weapon_root.first_child) { pack_int_value (en, INT_TYPE_VALID, TRUE); pack_list_root (en, LIST_TYPE_LAUNCHED_WEAPON, &raw->launched_weapon_root); } else { pack_int_value (en, INT_TYPE_VALID, FALSE); } ///////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////// if (raw->movement_dependent_root.first_child) { pack_int_value (en, INT_TYPE_VALID, TRUE); pack_list_root (en, LIST_TYPE_MOVEMENT_DEPENDENT, &raw->movement_dependent_root); } else { pack_int_value (en, INT_TYPE_VALID, FALSE); } ///////////////////////////////////////////////////////////////// pack_list_link (en, LIST_TYPE_FOLLOWER, &raw->follower_link); // gunship_target_link pack_list_link (en, LIST_TYPE_MEMBER, &raw->member_link); ///////////////////////////////////////////////////////////////// if (raw->movement_dependent_link.parent) { pack_int_value (en, INT_TYPE_VALID, TRUE); pack_list_link (en, LIST_TYPE_MOVEMENT_DEPENDENT, &raw->movement_dependent_link); } else { pack_int_value (en, INT_TYPE_VALID, FALSE); } ///////////////////////////////////////////////////////////////// // view_link if (mode == PACK_MODE_SERVER_SESSION) { pack_list_link (en, LIST_TYPE_TAKEOFF_QUEUE, &raw->takeoff_queue_link); } pack_int_value (en, INT_TYPE_OPERATIONAL_STATE, raw->operational_state); pack_float_value (en, FLOAT_TYPE_SLEEP, raw->sleep); if (mode == PACK_MODE_SERVER_SESSION) { pack_float_value (en, FLOAT_TYPE_DISTANCE, raw->distance); // only needed by server? } ///////////////////////////////////////////////////////////////// if (raw->operational_state == OPERATIONAL_STATE_LANDED) { pack_float_value (en, FLOAT_TYPE_LOADING_DOOR_STATE, raw->loading_door_state); } ///////////////////////////////////////////////////////////////// // radar_rotation_state if (mode == PACK_MODE_SERVER_SESSION) { pack_float_value (en, FLOAT_TYPE_DEATH_TIMER, raw->death_timer); pack_float_value (en, FLOAT_TYPE_TARGET_FIRE_TIMER, raw->target_fire_timer); pack_float_value (en, FLOAT_TYPE_TARGET_SCAN_TIMER, raw->target_scan_timer); } // view_interest_level // weapon_burst_timer pack_float_value (en, FLOAT_TYPE_WEAPON_SYSTEM_READY_STATE, raw->weapon_system_ready_state); if (mode == PACK_MODE_SERVER_SESSION) { pack_float_value (en, FLOAT_TYPE_DECOY_RELEASE_TIMER, raw->decoy_release_timer); } //////////////////////////////////////// pack_int_value (en, INT_TYPE_WEAPON_CONFIG_TYPE, raw->weapon_config_type); for (package = 0; package < NUM_WEAPON_PACKAGES; package++) { if (weapon_config_database[raw->weapon_config_type][package].sub_type == ENTITY_SUB_TYPE_WEAPON_NO_WEAPON) { break; } pack_int_value (en, INT_TYPE_WEAPON_PACKAGE_NUMBER, raw->weapon_package_status_array[package].number); pack_int_value (en, INT_TYPE_WEAPON_PACKAGE_DAMAGED, raw->weapon_package_status_array[package].damaged); if (weapon_config_database[raw->weapon_config_type][package].rotate) { pack_float_value (en, FLOAT_TYPE_WEAPON_SYSTEM_HEADING, raw->weapon_package_status_array[package].weapon_system_heading); pack_float_value (en, FLOAT_TYPE_WEAPON_SYSTEM_PITCH, raw->weapon_package_status_array[package].weapon_system_pitch); } // muzzle_flash_timer } pack_int_value (en, INT_TYPE_SELECTED_WEAPON, raw->selected_weapon); //////////////////////////////////////// // sound_effect_data pack_int_value (en, INT_TYPE_FORMATION_POSITION, raw->formation_position); // selected_weapon_system_ready // weapon_and_target_vectors_valid // gunship_radar_los_clear // los_to_target pack_int_value (en, INT_TYPE_LIGHTS_ON, raw->lights_on); // cpg_identified pack_int_value (en, INT_TYPE_GROUP_MEMBER_NUMBER, raw->group_member_number); // id_number_significant_digits pack_int_value (en, INT_TYPE_DAMAGE_LEVEL, raw->damage_level); // id_number // weapon_vector // weapon_to_target_vector // terrain_info break; } //////////////////////////////////////// case PACK_MODE_BROWSE_SESSION: //////////////////////////////////////// { break; } //////////////////////////////////////// case PACK_MODE_UPDATE_ENTITY: //////////////////////////////////////// { // // cannot update entity at this level as the update may not apply to all entity types below // break; } } }
void pack_local_force_data (entity *en, pack_modes mode) { int count, loop; force *raw; campaign_criteria_type *campaign_criteria; ASSERT ((mode >= 0) && (mode < NUM_PACK_MODES)); ASSERT (en); raw = (force *) get_local_entity_data (en); switch (mode) { //////////////////////////////////////// case PACK_MODE_SERVER_SESSION: //////////////////////////////////////// { pack_string (en, STRING_TYPE_FORCE_NAME, raw->force_name); // keysite_force // pilot root pack_list_root (en, LIST_TYPE_DIVISION, &raw->division_root); pack_list_root (en, LIST_TYPE_CAMPAIGN_OBJECTIVE, &raw->campaign_objective_root); // air_registry_root // ground_registry_root // sea_registry_root // pack_list_root (en, LIST_TYPE_INDEPENDENT_GROUP, &raw->independent_group_root); // force_link // update link // task generation ////////////////////////////////////////////// for (loop = 0; loop < NUM_ENTITY_SUB_TYPE_TASKS; loop ++) { pack_int_value (en, INT_TYPE_VALID, raw->task_generation [loop].valid); pack_int_value (en, INT_TYPE_TASK_GENERATION, raw->task_generation [loop].created); } ///////////////////////////////////////////////////////////////// // campaign criteria //////////////////////////////////////////// count = 0; campaign_criteria = raw->campaign_criteria; while (campaign_criteria) { count ++; campaign_criteria = campaign_criteria->next; } pack_int_value (en, INT_TYPE_CAMPAIGN_CRITERIA_COUNT, count); campaign_criteria = raw->campaign_criteria; while (campaign_criteria) { pack_int_value (en, INT_TYPE_CAMPAIGN_CRITERIA_TYPE, campaign_criteria->criteria_type); pack_int_value (en, INT_TYPE_VALID, campaign_criteria->valid); pack_int_value (en, INT_TYPE_CAMPAIGN_CRITERIA_RESULT, campaign_criteria->result); pack_int_value (en, INT_TYPE_CAMPAIGN_CRITERIA_VALUE, campaign_criteria->value1); pack_int_value (en, INT_TYPE_CAMPAIGN_CRITERIA_VALUE, campaign_criteria->value2); pack_int_value (en, INT_TYPE_CAMPAIGN_CRITERIA_VALUE, campaign_criteria->value3); pack_int_value (en, INT_TYPE_CAMPAIGN_CRITERIA_VALUE, campaign_criteria->value4); campaign_criteria = campaign_criteria->next; } ///////////////////////////////////////////////////////////////// // force_info_criteria for (loop = 0; loop < NUM_FORCE_INFO_CATAGORIES; loop ++) { pack_int_value (en, INT_TYPE_VALUE, raw->force_info_current_hardware [loop]); pack_int_value (en, INT_TYPE_VALUE, raw->force_info_reserve_hardware [loop]); } ///////////////////////////////////////////////////////////////// for (loop = 0; loop < NUM_ENTITY_SUB_TYPE_GROUPS; loop ++) { pack_int_value (en, INT_TYPE_VALUE, raw->kills [loop]); pack_int_value (en, INT_TYPE_VALUE, raw->losses [loop]); // pack_int_value (en, INT_TYPE_VALUE, raw->group_count [loop]); } pack_float_value (en, FLOAT_TYPE_SLEEP, raw->sleep); pack_int_value (en, INT_TYPE_FORCE_ATTITUDE, raw->force_attitude); // sector_count pack_int_value (en, INT_TYPE_COLOUR, raw->colour); pack_int_value (en, INT_TYPE_SIDE, raw->side); break; } //////////////////////////////////////// case PACK_MODE_CLIENT_SESSION: //////////////////////////////////////// { pack_string (en, STRING_TYPE_FORCE_NAME, raw->force_name); // keysite_force pack_list_root (en, LIST_TYPE_PILOT, &raw->pilot_root); pack_list_root (en, LIST_TYPE_DIVISION, &raw->division_root); pack_list_root (en, LIST_TYPE_CAMPAIGN_OBJECTIVE, &raw->campaign_objective_root); // air_registry_root // ground_registry_root // sea_registry_root // pack_list_root (en, LIST_TYPE_INDEPENDENT_GROUP, &raw->independent_group_root); pack_list_link (en, LIST_TYPE_FORCE, &raw->force_link); // update link // task generation ////////////////////////////////////////////// for (loop = 0; loop < NUM_ENTITY_SUB_TYPE_TASKS; loop ++) { pack_int_value (en, INT_TYPE_VALID, raw->task_generation [loop].valid); pack_int_value (en, INT_TYPE_TASK_GENERATION, raw->task_generation [loop].created); } ///////////////////////////////////////////////////////////////// // campaign criteria //////////////////////////////////////////// count = 0; campaign_criteria = raw->campaign_criteria; while (campaign_criteria) { count ++; campaign_criteria = campaign_criteria->next; } pack_int_value (en, INT_TYPE_CAMPAIGN_CRITERIA_COUNT, count); campaign_criteria = raw->campaign_criteria; while (campaign_criteria) { pack_int_value (en, INT_TYPE_CAMPAIGN_CRITERIA_TYPE, campaign_criteria->criteria_type); pack_int_value (en, INT_TYPE_VALID, campaign_criteria->valid); pack_int_value (en, INT_TYPE_CAMPAIGN_CRITERIA_RESULT, campaign_criteria->result); pack_int_value (en, INT_TYPE_CAMPAIGN_CRITERIA_VALUE, campaign_criteria->value1); pack_int_value (en, INT_TYPE_CAMPAIGN_CRITERIA_VALUE, campaign_criteria->value2); pack_int_value (en, INT_TYPE_CAMPAIGN_CRITERIA_VALUE, campaign_criteria->value3); pack_int_value (en, INT_TYPE_CAMPAIGN_CRITERIA_VALUE, campaign_criteria->value4); campaign_criteria = campaign_criteria->next; } ///////////////////////////////////////////////////////////////// // force_info_criteria for (loop = 0; loop < NUM_FORCE_INFO_CATAGORIES; loop ++) { pack_int_value (en, INT_TYPE_VALUE, raw->force_info_current_hardware [loop]); pack_int_value (en, INT_TYPE_VALUE, raw->force_info_reserve_hardware [loop]); } ///////////////////////////////////////////////////////////////// for (loop = 0; loop < NUM_ENTITY_SUB_TYPE_GROUPS; loop ++) { pack_int_value (en, INT_TYPE_VALUE, raw->kills [loop]); pack_int_value (en, INT_TYPE_VALUE, raw->losses [loop]); // pack_int_value (en, INT_TYPE_VALUE, raw->group_count [loop]); } pack_float_value (en, FLOAT_TYPE_SLEEP, raw->sleep); pack_int_value (en, INT_TYPE_FORCE_ATTITUDE, raw->force_attitude); pack_int_value (en, INT_TYPE_FORCE_SECTOR_COUNT, raw->sector_count); pack_int_value (en, INT_TYPE_COLOUR, raw->colour); pack_int_value (en, INT_TYPE_SIDE, raw->side); break; } //////////////////////////////////////// case PACK_MODE_BROWSE_SESSION: //////////////////////////////////////// { pack_string (en, STRING_TYPE_FORCE_NAME, raw->force_name); // keysite_force_root pack_list_root (en, LIST_TYPE_PILOT, &raw->pilot_root); pack_list_link (en, LIST_TYPE_FORCE, &raw->force_link); // update link // task_generation // campaign_criteria // force_info_catagories // sleep pack_int_value (en, INT_TYPE_FORCE_ATTITUDE, raw->force_attitude); pack_int_value (en, INT_TYPE_COLOUR, raw->colour); pack_int_value (en, INT_TYPE_SIDE, raw->side); break; } } }
static void pack_local_data (entity *en, pack_modes mode) { ASSERT ((mode >= 0) && (mode < NUM_PACK_MODES)); switch (mode) { //////////////////////////////////////// case PACK_MODE_SERVER_SESSION: //////////////////////////////////////// { break; } //////////////////////////////////////// case PACK_MODE_CLIENT_SESSION: //////////////////////////////////////// { pilot *raw; raw = get_local_entity_data (en); pack_entity_type (get_local_entity_type (en)); pack_entity_safe_ptr (en); // // pack data // pack_int_value (en, INT_TYPE_ENTITY_SUB_TYPE, raw->sub_type); pack_string (en, STRING_TYPE_PILOTS_NAME, raw->pilots_name); pack_int_value (en, INT_TYPE_PILOT_RANK, raw->rank); pack_int_value (en, INT_TYPE_KILLS, raw->kills); pack_int_value (en, INT_TYPE_UNIQUE_ID, raw->unique_id); // crew_role pack_list_root (en, LIST_TYPE_PILOT_LOCK, &raw->pilot_lock_root); pack_list_link (en, LIST_TYPE_AIRCREW, &raw->aircrew_link); pack_list_link (en, LIST_TYPE_PILOT, &raw->pilot_link); pack_list_link (en, LIST_TYPE_PLAYER_TASK, &raw->player_task_link); pack_int_value (en, INT_TYPE_SIDE, raw->side); pack_int_value (en, INT_TYPE_DIFFICULTY_LEVEL, raw->difficulty_level); break; } //////////////////////////////////////// case PACK_MODE_BROWSE_SESSION: //////////////////////////////////////// { pilot *raw; raw = get_local_entity_data (en); pack_entity_type (get_local_entity_type (en)); pack_entity_safe_ptr (en); // // pack data // pack_int_value (en, INT_TYPE_ENTITY_SUB_TYPE, raw->sub_type); pack_string (en, STRING_TYPE_PILOTS_NAME, raw->pilots_name); pack_int_value (en, INT_TYPE_PILOT_RANK, raw->rank); pack_int_value (en, INT_TYPE_KILLS, raw->kills); pack_int_value (en, INT_TYPE_UNIQUE_ID, raw->unique_id); // crew_role // aircrew_link pack_list_link (en, LIST_TYPE_PILOT, &raw->pilot_link); pack_int_value (en, INT_TYPE_SIDE, raw->side); // difficulty level break; } //////////////////////////////////////// case PACK_MODE_UPDATE_ENTITY: //////////////////////////////////////// { break; } } }