void unpack_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: //////////////////////////////////////// { raw->sub_type = unpack_int_value (en, INT_TYPE_ENTITY_SUB_TYPE); // // some effects should never be packed up ( should be re-constructed when the vehicle is unpacked ) // ASSERT (!effect_database [raw->sub_type].constructed_locally); unpack_vec3d (en, VEC3D_TYPE_POSITION, &raw->position); ///////////////////////////////////////////////////////////////// if (unpack_int_value (en, INT_TYPE_VALID)) { unpack_list_link (en, LIST_TYPE_SPECIAL_EFFECT, &raw->special_effect_link); } ///////////////////////////////////////////////////////////////// // 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 unpack_local_only_sound_effect_data (entity *parent, pack_modes mode) { int side, entity_index, sample_index, valid; entity_sub_types sub_type; ASSERT (parent); // // unpack data // if (mode == PACK_MODE_CLIENT_SESSION) { entity_index = unpack_entity_safe_index (); } else { entity_index = ENTITY_INDEX_DONT_CARE; } side = unpack_int_value (NULL, INT_TYPE_SIDE); sub_type = unpack_int_value (NULL, INT_TYPE_ENTITY_SUB_TYPE); valid = unpack_int_value (NULL, INT_TYPE_VALID_SOUND_EFFECT); sample_index = unpack_int_value (NULL, INT_TYPE_SOUND_EFFECT_INDEX); register_attach_sound_effect_to_object (parent, entity_index, side, sub_type, valid, sample_index); #if DEBUG_MODULE debug_log ("SE_PACK: Unpacked Local-Only %d - Sub-type %d", entity_index, sub_type); #endif }
void unpack_local_division_database (pack_modes mode) { int side, type, loop, count, valid; if (mode == PACK_MODE_SERVER_SESSION) { for (side = 0; side < NUM_ENTITY_SIDES; side ++) { for (type = 0; type < NUM_ENTITY_SUB_TYPE_DIVISIONS; type ++) { valid = unpack_int_value (NULL, INT_TYPE_VALID); division_id_database [side][type].valid = valid; if (valid) { count = unpack_int_value (NULL, INT_TYPE_COUNT); ASSERT (count > 0); division_id_database [side][type].count = count; division_id_database [side][type].next = unpack_int_value (NULL, INT_TYPE_COUNT); division_id_database [side][type].number_list = (int *) malloc_heap_mem (sizeof (int) * count); for (loop = 0; loop < count; loop ++) { division_id_database [side][type].number_list [loop] = unpack_int_value (NULL, INT_TYPE_COUNT); } } } } } }
static void unpack_local_data (entity *en, entity_types type, pack_modes mode) { ASSERT ((mode >= 0) && (mode < NUM_PACK_MODES)); switch (mode) { //////////////////////////////////////// case PACK_MODE_SERVER_SESSION: case PACK_MODE_CLIENT_SESSION: //////////////////////////////////////// { int loop, index; sound_effect *raw; // // create entity // index = unpack_entity_safe_index (); en = get_free_entity (index); set_local_entity_type (en, type); raw = malloc_heap_mem (sizeof (sound_effect)); set_local_entity_data (en, raw); memset (raw, 0, sizeof (sound_effect)); // // unpack effect data (in exactly the same order as the data was packed) // unpack_effect_data( en, &raw->eff, mode ); // // unpack sound data // raw->sound_effect_sequence_count = unpack_int_value (en, INT_TYPE_SOUND_EFFECT_SEQUENCE_COUNT); ASSERT (raw->sound_effect_sequence_count > 0); raw->effect_index = malloc_fast_mem (sizeof (sound_sample_indices) * raw->sound_effect_sequence_count); for (loop = 0; loop < raw->sound_effect_sequence_count; loop ++) { raw->effect_index [loop] = unpack_int_value (en, INT_TYPE_SOUND_EFFECT_INDEX); } raw->amplification = unpack_float_value (en, FLOAT_TYPE_AMPLIFICATION); raw->effect_lifetime = unpack_float_value (en, FLOAT_TYPE_EFFECT_LIFETIME); raw->valid_effect_lifetime = unpack_float_value (en, FLOAT_TYPE_VALID_EFFECT_LIFETIME); //sound_effect_data raw->sound_channel = unpack_int_value (en, INT_TYPE_SOUND_CHANNEL); raw->sound_locality = unpack_int_value (en, INT_TYPE_SOUND_LOCALITY); raw->valid_sound_effect = unpack_int_value (en, INT_TYPE_VALID_SOUND_EFFECT); raw->looping = unpack_int_value (en, INT_TYPE_SOUND_EFFECT_LOOPING); raw->panning = unpack_int_value (en, INT_TYPE_SOUND_EFFECT_PANNING); // // link into system // // sound effect needs a parent //ASSERT (raw->eff.special_effect_link.parent); if (unpack_int_value (en, INT_TYPE_VALID)) { insert_local_entity_into_parents_child_list (en, LIST_TYPE_UPDATE, get_update_entity (), NULL); } #if DEBUG_MODULE debug_log ("SE_PACK: Unpacked %d - Sub-type %d", get_local_entity_safe_index (en), raw->eff.sub_type); #endif break; } //////////////////////////////////////// case PACK_MODE_BROWSE_SESSION: //////////////////////////////////////// { break; } //////////////////////////////////////// case PACK_MODE_UPDATE_ENTITY: //////////////////////////////////////// { // // always use access functions to set the data // break; } } }
static void unpack_local_data (entity *en, entity_types type, pack_modes mode) { ASSERT ((mode >= 0) && (mode < NUM_PACK_MODES)); switch (mode) { //////////////////////////////////////// case PACK_MODE_SERVER_SESSION: case PACK_MODE_CLIENT_SESSION: //////////////////////////////////////// { int index; routed_vehicle *raw; node_link_data *route_data; // // create entity // index = unpack_entity_safe_index (); en = get_free_entity (index); set_local_entity_type (en, type); raw = (routed_vehicle *) malloc_fast_mem (sizeof (routed_vehicle)); set_local_entity_data (en, raw); memset (raw, 0, sizeof (routed_vehicle)); // // unpack vehicle data (in exactly the same order as the data was packed) // unpack_vehicle_data (en, &raw->vh, mode); if (unpack_int_value (en, INT_TYPE_VALID)) { raw->vh.mob.velocity = 0.0; raw->desired_velocity = 0.0; } else { raw->vh.mob.velocity = unpack_float_value (en, FLOAT_TYPE_LOW_VELOCITY); raw->desired_velocity = unpack_float_value (en, FLOAT_TYPE_DESIRED_VELOCITY); } // // unpack routed data // if (unpack_int_value (en, INT_TYPE_VALID)) { raw->sub_waypoint_count = unpack_int_value (en, INT_TYPE_SUB_WAYPOINT_COUNT); raw->waypoint_next_index = unpack_int_value (en, INT_TYPE_WAYPOINT_NEXT_INDEX); raw->waypoint_this_index = unpack_int_value (en, INT_TYPE_WAYPOINT_THIS_INDEX); } // // turn lights on if necessary // set_vehicle_headlight_state (en, raw->vh.lights_on); // // setup waypoint route pointer // #if DEBUG_MODULE debug_log ("ROUTED ENTITY PACK: client setting up waypoint list pointer"); #endif route_data = get_road_sub_route (raw->waypoint_this_index, raw->waypoint_next_index, &index, NULL); if ((route_data) && (route_data->link_positions)) { raw->sub_route = route_data; } else { if ((raw->waypoint_this_index + raw->waypoint_next_index) != 0) { debug_log ("RV_PACK: WARNING NO SUB ROUTE FOUND BETWEEN %d AND %d", raw->waypoint_this_index, raw->waypoint_next_index); } } // // radar dish rotation (ok to use a random number as this is for visual effect only) // raw->vh.radar_rotation_state = frand1 (); set_routed_vehicle_id_number (en); set_initial_rotation_angle_of_routed_vehicle_wheels (raw->vh.inst3d); // // link into system // insert_local_entity_into_parents_child_list (en, LIST_TYPE_VIEW, get_camera_entity (), NULL); insert_local_entity_into_parents_child_list (en, LIST_TYPE_SECTOR, get_local_sector_entity (&raw->vh.mob.position), NULL); insert_local_entity_into_parents_child_list (en, LIST_TYPE_UPDATE, get_update_entity (), NULL); add_to_force_info (get_local_force_entity ((entity_sides) raw->vh.mob.side), en); // // attached smoke lists must be unpacked after the entity is linked into the world // unpack_routed_vehicle_meta_smoke_lists (en, mode); unpack_mobile_local_sound_effects (en, mode); break; } //////////////////////////////////////// case PACK_MODE_BROWSE_SESSION: //////////////////////////////////////// { break; } //////////////////////////////////////// case PACK_MODE_UPDATE_ENTITY: //////////////////////////////////////// { // // always use access functions to set the data // vec3d position; matrix3x3 attitude; int sub_waypoint_count; // // unpack all data (even if the echoed data is to be ignored) // unpack_vec3d (en, VEC3D_TYPE_POSITION, &position); unpack_attitude_matrix (en, attitude); sub_waypoint_count = unpack_int_value (en, INT_TYPE_SUB_WAYPOINT_COUNT); set_local_entity_vec3d (en, VEC3D_TYPE_POSITION, &position); set_local_entity_attitude_matrix (en, attitude); set_local_entity_int_value (en, INT_TYPE_SUB_WAYPOINT_COUNT, sub_waypoint_count); // Vehicle is moving so sleep must equal 0 set_local_entity_float_value (en, FLOAT_TYPE_SLEEP, 0.0); break; } } }
void unpack_fixed_data (entity *en, fixed *raw, pack_modes mode) { ASSERT ((mode >= 0) && (mode < NUM_PACK_MODES)); switch (mode) { //////////////////////////////////////// case PACK_MODE_SERVER_SESSION: case PACK_MODE_CLIENT_SESSION: //////////////////////////////////////// { unpack_vec3d (en, VEC3D_TYPE_POSITION, &raw->position); ///////////////////////////////////////////////////////////////// if (mode == PACK_MODE_SERVER_SESSION) { if (unpack_int_value (en, INT_TYPE_VALID)) { unpack_list_root (en, LIST_TYPE_TASK_DEPENDENT, &raw->task_dependent_root); } } ///////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////// if (unpack_int_value (en, INT_TYPE_VALID)) { unpack_list_root (en, LIST_TYPE_TARGET, &raw->target_root); } ///////////////////////////////////////////////////////////////// // gunship_target_link // sector_link raw->sub_type = unpack_int_value (en, INT_TYPE_ENTITY_SUB_TYPE); raw->object_3d_shape = unpack_int_value (en, INT_TYPE_OBJECT_3D_SHAPE); raw->alive = unpack_int_value (en, INT_TYPE_ALIVE); raw->side = unpack_int_value (en, INT_TYPE_SIDE); // gunship_radar_los_clear // object_drawn_once_this_frame raw->heading = unpack_float_value (en, FLOAT_TYPE_HEADING); 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 unpack_local_site_updatable_data (pack_modes mode) { site_updatable *raw; entity *en; int count, alive; if ((mode != PACK_MODE_SERVER_SESSION) && (mode != PACK_MODE_CLIENT_SESSION)) { return; } // // RLE encoded // debug_log ("RLE SITE UPDATEABLE"); en = get_local_entity_list (); count = unpack_int_value (NULL, INT_TYPE_LENGTH); alive = unpack_int_value (NULL, INT_TYPE_ALIVE); #if DEBUG_MODULE debug_log ("SU_PACK: unpacking count %d, alive %d", count, alive); #endif while (en) { if (get_local_entity_type (en) == ENTITY_TYPE_SITE_UPDATABLE) { if (count == 0) { count = unpack_int_value (NULL, INT_TYPE_LENGTH); alive = unpack_int_value (NULL, INT_TYPE_ALIVE); #if DEBUG_MODULE debug_log ("SU_PACK: unpacking count %d, alive %d", count, alive); #endif } count --; raw = get_local_entity_data (en); if (!alive) { delete_local_entity_from_parents_child_list (en, LIST_TYPE_UPDATE); // must be done BEFORE alive flag set, and BEFORE shape changed // subtract_local_entity_importance_from_keysite (en); raw->fix.object_3d_shape = get_3d_object_destroyed_object_index (raw->fix.object_3d_shape); } raw->fix.alive = alive; } en = get_local_entity_succ (en); } }
static void unpack_local_data (entity *en, entity_types type, pack_modes mode) { ASSERT ((mode >= 0) && (mode < NUM_PACK_MODES)); switch (mode) { //////////////////////////////////////// case PACK_MODE_SERVER_SESSION: //////////////////////////////////////// { break; } //////////////////////////////////////// case PACK_MODE_CLIENT_SESSION: //////////////////////////////////////// { int index; pilot *raw; // // create entity // index = unpack_entity_safe_index (); en = get_free_entity (index); set_local_entity_type (en, type); raw = malloc_fast_mem (sizeof (pilot)); set_local_entity_data (en, raw); memset (raw, 0, sizeof (pilot)); // // unpack data (in exactly the same order as the data was packed) // raw->sub_type = unpack_int_value (en, INT_TYPE_ENTITY_SUB_TYPE); unpack_string (en, STRING_TYPE_PILOTS_NAME, raw->pilots_name); raw->rank = unpack_int_value (en, INT_TYPE_PILOT_RANK); raw->kills = unpack_int_value (en, INT_TYPE_KILLS); raw->unique_id = unpack_int_value (en, INT_TYPE_UNIQUE_ID); raw->crew_role = CREW_ROLE_PILOT; unpack_list_root (en, LIST_TYPE_PILOT_LOCK, &raw->pilot_lock_root); unpack_list_link (en, LIST_TYPE_AIRCREW, &raw->aircrew_link); unpack_list_link (en, LIST_TYPE_PILOT, &raw->pilot_link); unpack_list_link (en, LIST_TYPE_PLAYER_TASK, &raw->player_task_link); raw->side = unpack_int_value (en, INT_TYPE_SIDE); raw->difficulty_level = unpack_int_value (en, INT_TYPE_DIFFICULTY_LEVEL); break; } //////////////////////////////////////// case PACK_MODE_BROWSE_SESSION: //////////////////////////////////////// { int index; pilot *raw; // // create entity // index = unpack_entity_safe_index (); en = get_free_entity (index); set_local_entity_type (en, type); raw = malloc_fast_mem (sizeof (pilot)); set_local_entity_data (en, raw); memset (raw, 0, sizeof (pilot)); // // unpack data (in exactly the same order as the data was packed) // raw->sub_type = unpack_int_value (en, INT_TYPE_ENTITY_SUB_TYPE); unpack_string (en, STRING_TYPE_PILOTS_NAME, raw->pilots_name); raw->rank = unpack_int_value (en, INT_TYPE_PILOT_RANK); raw->kills = unpack_int_value (en, INT_TYPE_KILLS); raw->unique_id = unpack_int_value (en, INT_TYPE_UNIQUE_ID); raw->crew_role = CREW_ROLE_PILOT; // aircrew_link unpack_list_link (en, LIST_TYPE_PILOT, &raw->pilot_link); raw->side = unpack_int_value (en, INT_TYPE_SIDE); break; } //////////////////////////////////////// case PACK_MODE_UPDATE_ENTITY: //////////////////////////////////////// { // // always use access functions to set the data // break; } } }
void unpack_local_bridge_data (pack_modes mode) { entity *en; bridge *raw; int dead_bridge_count, alive, count; ASSERT (mode != PACK_MODE_UPDATE_ENTITY); if (mode != PACK_MODE_SERVER_SESSION) { return; } // // unpack alive status for each bridge // debug_log ("RLE BRIDGE"); count = 0; count = unpack_int_value (NULL, INT_TYPE_LENGTH); alive = unpack_int_value (NULL, INT_TYPE_ALIVE); #if DEBUG_MODULE debug_log ("BR_PACK: unpacking count %d, alive %d", count, alive); #endif en = get_local_entity_list (); while (en) { if (en->type == ENTITY_TYPE_BRIDGE) { if (count == 0) { count = unpack_int_value (NULL, INT_TYPE_LENGTH); alive = unpack_int_value (NULL, INT_TYPE_ALIVE); #if DEBUG_MODULE debug_log ("BR_PACK: unpacking count %d, alive %d", count, alive); #endif } count --; raw = (bridge *) get_local_entity_data (en); raw->alive = alive; if (!alive) { // // Break road network link // dead_bridge_count = get_road_link_breaks (raw->start_node, raw->end_node); dead_bridge_count ++; set_road_link_breaks (raw->start_node, raw->end_node, dead_bridge_count); } } en = get_local_entity_succ (en); } }
void unpack_local_sector_data (pack_modes mode) { entity *en; sector *raw; entity_sides side; int z_sec, x_sec, side_count; ASSERT (mode != PACK_MODE_UPDATE_ENTITY); if (mode == PACK_MODE_BROWSE_SESSION) { return; } // // RLE unencode the sector sides // debug_log ("RLE SECTOR"); en = NULL; side = unpack_int_value (NULL, INT_TYPE_SIDE); side_count = unpack_int_value (NULL, INT_TYPE_LENGTH); en = *entity_sector_map; while (side_count != 0) { while (side_count > 0) { raw = get_local_entity_data (en); raw->side = side; side_count --; en ++; } side = unpack_int_value (NULL, INT_TYPE_SIDE); side_count = unpack_int_value (NULL, INT_TYPE_LENGTH); } // // Unpack FOG OF WAR // for (z_sec = MIN_MAP_Z_SECTOR; z_sec <= MAX_MAP_Z_SECTOR; z_sec++) { for (x_sec = MIN_MAP_X_SECTOR; x_sec <= MAX_MAP_X_SECTOR; x_sec++) { en = get_local_raw_sector_entity(x_sec, z_sec); raw = get_local_entity_data (en); raw->fog_of_war [ENTITY_SIDE_BLUE_FORCE] = unpack_float_value (en, FLOAT_TYPE_FOG_OF_WAR); raw->fog_of_war [ENTITY_SIDE_RED_FORCE] = unpack_float_value (en, FLOAT_TYPE_FOG_OF_WAR); } } // // If loading game read in sector values (threat etc) // if (mode == PACK_MODE_SERVER_SESSION) { for (z_sec = MIN_MAP_Z_SECTOR; z_sec <= MAX_MAP_Z_SECTOR; z_sec++) { for (x_sec = MIN_MAP_X_SECTOR; x_sec <= MAX_MAP_X_SECTOR; x_sec++) { en = get_local_raw_sector_entity(x_sec, z_sec); raw = get_local_entity_data (en); if (unpack_int_value (en, INT_TYPE_VALID)) { unpack_list_root (en, LIST_TYPE_SECTOR_TASK, &raw->sector_task_root); } if (unpack_int_value (en, INT_TYPE_VALID)) { unpack_list_root (en, LIST_TYPE_SPECIAL_EFFECT, &raw->special_effect_root); } //debug_log ("SC_PACK: unpacking sector %d, %d", raw->x_sector, raw->z_sector); raw->keysite_count = unpack_int_value (en, INT_TYPE_CAMPAIGN_CRITERIA_COUNT); raw->tallest_structure_height = unpack_float_value (en, FLOAT_TYPE_PROTOTYPE_1); } } } }
void unpack_local_force_data (entity *en, pack_modes mode) { int count, loop; force *raw; campaign_criteria_type *last_campaign_criteria, *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: //////////////////////////////////////// { unpack_string (en, STRING_TYPE_FORCE_NAME, raw->force_name); // keysite_force // pilot root unpack_list_root (en, LIST_TYPE_DIVISION, &raw->division_root); unpack_list_root (en, LIST_TYPE_CAMPAIGN_OBJECTIVE, &raw->campaign_objective_root); // air_registry_root // ground_registry_root // sea_registry_root // unpack_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 ++) { raw->task_generation [loop].valid = unpack_int_value (en, INT_TYPE_VALID); raw->task_generation [loop].created = unpack_int_value (en, INT_TYPE_TASK_GENERATION); } ///////////////////////////////////////////////////////////////// // campaign criteria //////////////////////////////////////////// count = unpack_int_value (en, INT_TYPE_CAMPAIGN_CRITERIA_COUNT); last_campaign_criteria = NULL; while (count) { campaign_criteria = (campaign_criteria_type *) malloc_heap_mem (sizeof (campaign_criteria_type)); memset (campaign_criteria, 0, sizeof (campaign_criteria_type)); campaign_criteria->criteria_type = unpack_int_value (en, INT_TYPE_CAMPAIGN_CRITERIA_TYPE); campaign_criteria->valid = unpack_int_value (en, INT_TYPE_VALID); campaign_criteria->result = unpack_int_value (en, INT_TYPE_CAMPAIGN_CRITERIA_RESULT); campaign_criteria->value1 = unpack_int_value (en, INT_TYPE_CAMPAIGN_CRITERIA_VALUE); campaign_criteria->value2 = unpack_int_value (en, INT_TYPE_CAMPAIGN_CRITERIA_VALUE); campaign_criteria->value3 = unpack_int_value (en, INT_TYPE_CAMPAIGN_CRITERIA_VALUE); campaign_criteria->value4 = unpack_int_value (en, INT_TYPE_CAMPAIGN_CRITERIA_VALUE); campaign_criteria->next = last_campaign_criteria; raw->campaign_criteria = campaign_criteria; last_campaign_criteria = campaign_criteria; count --; } ///////////////////////////////////////////////////////////////// // force_info_criteria for (loop = 0; loop < NUM_FORCE_INFO_CATAGORIES; loop ++) { raw->force_info_current_hardware [loop] = unpack_int_value (en, INT_TYPE_VALUE); raw->force_info_reserve_hardware [loop] = unpack_int_value (en, INT_TYPE_VALUE); } ///////////////////////////////////////////////////////////////// for (loop = 0; loop < NUM_ENTITY_SUB_TYPE_GROUPS; loop ++) { raw->kills [loop] = unpack_int_value (en, INT_TYPE_VALUE); raw->losses [loop] = unpack_int_value (en, INT_TYPE_VALUE); // raw->group_count [loop] = unpack_int_value (en, INT_TYPE_VALUE); } raw->sleep = unpack_float_value (en, FLOAT_TYPE_SLEEP); raw->force_attitude = unpack_int_value (en, INT_TYPE_FORCE_ATTITUDE); // sector_count raw->colour = unpack_int_value (en, INT_TYPE_COLOUR); raw->side = unpack_int_value (en, INT_TYPE_SIDE); break; } //////////////////////////////////////// case PACK_MODE_CLIENT_SESSION: //////////////////////////////////////// { // // create entity // debug_assert (get_free_entity (get_local_entity_safe_index (en))); set_local_entity_type (en, ENTITY_TYPE_FORCE); raw = (force *) malloc_fast_mem (sizeof (force)); set_local_entity_data (en, raw); memset (raw, 0, sizeof (force)); // // unpack data (in exactly the same order as the data was packed) // unpack_string (en, STRING_TYPE_FORCE_NAME, raw->force_name); // keysite_force unpack_list_root (en, LIST_TYPE_PILOT, &raw->pilot_root); unpack_list_root (en, LIST_TYPE_DIVISION, &raw->division_root); unpack_list_root (en, LIST_TYPE_CAMPAIGN_OBJECTIVE, &raw->campaign_objective_root); // air_registry_root // ground_registry_root // sea_registry_root // unpack_list_root (en, LIST_TYPE_INDEPENDENT_GROUP, &raw->independent_group_root); unpack_list_link (en, LIST_TYPE_FORCE, &raw->force_link); // update_link //////////////////////////////////////////// // task_generation for (loop = 0; loop < NUM_ENTITY_SUB_TYPE_TASKS; loop ++) { raw->task_generation [loop].valid = unpack_int_value (en, INT_TYPE_VALID); raw->task_generation [loop].created = unpack_int_value (en, INT_TYPE_TASK_GENERATION); } //////////////////////////////////////////// //////////////////////////////////////////// // campaign criteria raw->campaign_criteria = NULL; count = unpack_int_value (en, INT_TYPE_CAMPAIGN_CRITERIA_COUNT); while (count) { count --; campaign_criteria = (campaign_criteria_type *) malloc_heap_mem (sizeof (campaign_criteria_type)); memset (campaign_criteria, 0, sizeof (campaign_criteria_type)); campaign_criteria->next = raw->campaign_criteria; raw->campaign_criteria = campaign_criteria; campaign_criteria->criteria_type = unpack_int_value (en, INT_TYPE_CAMPAIGN_CRITERIA_TYPE); campaign_criteria->valid = unpack_int_value (en, INT_TYPE_VALID); campaign_criteria->result = unpack_int_value (en, INT_TYPE_CAMPAIGN_CRITERIA_RESULT); campaign_criteria->value1 = unpack_int_value (en, INT_TYPE_CAMPAIGN_CRITERIA_VALUE); campaign_criteria->value2 = unpack_int_value (en, INT_TYPE_CAMPAIGN_CRITERIA_VALUE); campaign_criteria->value3 = unpack_int_value (en, INT_TYPE_CAMPAIGN_CRITERIA_VALUE); campaign_criteria->value4 = unpack_int_value (en, INT_TYPE_CAMPAIGN_CRITERIA_VALUE); } ///////////////////////////////////////////////////////////////// //////////////////////////////////////////// // force_info_criteria for (loop = 0; loop < NUM_FORCE_INFO_CATAGORIES; loop ++) { raw->force_info_current_hardware [loop] = unpack_int_value (en, INT_TYPE_VALUE); raw->force_info_reserve_hardware [loop] = unpack_int_value (en, INT_TYPE_VALUE); } // force_info_criteria for (loop = 0; loop < NUM_ENTITY_SUB_TYPE_GROUPS; loop ++) { raw->kills [loop] = unpack_int_value (en, INT_TYPE_VALUE); raw->losses [loop] = unpack_int_value (en, INT_TYPE_VALUE); // raw->group_count [loop] = unpack_int_value (en, INT_TYPE_VALUE); } raw->sleep = unpack_float_value (en, FLOAT_TYPE_SLEEP); raw->force_attitude = unpack_int_value (en, INT_TYPE_FORCE_ATTITUDE); raw->sector_count = unpack_int_value (en, INT_TYPE_FORCE_SECTOR_COUNT); raw->colour = unpack_int_value (en, INT_TYPE_COLOUR); raw->side = unpack_int_value (en, INT_TYPE_SIDE); insert_local_entity_into_parents_child_list (en, LIST_TYPE_UPDATE, get_update_entity (), NULL); break; } //////////////////////////////////////// case PACK_MODE_BROWSE_SESSION: //////////////////////////////////////// { // // create entity // debug_assert (get_free_entity (get_local_entity_safe_index (en))); set_local_entity_type (en, ENTITY_TYPE_FORCE); raw = (force *) malloc_fast_mem (sizeof (force)); set_local_entity_data (en, raw); memset (raw, 0, sizeof (force)); // // unpack data (in exactly the same order as the data was packed) // unpack_string (en, STRING_TYPE_FORCE_NAME, raw->force_name); // keysite_force_root unpack_list_root (en, LIST_TYPE_PILOT, &raw->pilot_root); unpack_list_link (en, LIST_TYPE_FORCE, &raw->force_link); // update_link // task_generation // campaign_criteria // force_info_catagories // sleep raw->force_attitude = unpack_int_value (en, INT_TYPE_FORCE_ATTITUDE); raw->colour = unpack_int_value (en, INT_TYPE_COLOUR); raw->side = unpack_int_value (en, INT_TYPE_SIDE); break; } } }
void unpack_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: //////////////////////////////////////// { // // unpack mobile data // unpack_mobile_data (en, &raw->mob, mode); // // unpack vehicle data // raw->object_3d_shape = unpack_int_value (en, INT_TYPE_OBJECT_3D_SHAPE); raw->inst3d = construct_3d_object (raw->object_3d_shape); if (mode == PACK_MODE_SERVER_SESSION) { ///////////////////////////////////////////////////////////////// if (unpack_int_value (en, INT_TYPE_VALID)) { unpack_list_root (en, LIST_TYPE_TASK_DEPENDENT, &raw->task_dependent_root); } ///////////////////////////////////////////////////////////////// } ///////////////////////////////////////////////////////////////// if (unpack_int_value (en, INT_TYPE_VALID)) { unpack_list_root (en, LIST_TYPE_LAUNCHED_WEAPON, &raw->launched_weapon_root); } ///////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////// if (unpack_int_value (en, INT_TYPE_VALID)) { unpack_list_root (en, LIST_TYPE_MOVEMENT_DEPENDENT, &raw->movement_dependent_root); } ///////////////////////////////////////////////////////////////// unpack_list_link (en, LIST_TYPE_FOLLOWER, &raw->follower_link); // gunship_target_link unpack_list_link (en, LIST_TYPE_MEMBER, &raw->member_link); ///////////////////////////////////////////////////////////////// if (unpack_int_value (en, INT_TYPE_VALID)) { unpack_list_link (en, LIST_TYPE_MOVEMENT_DEPENDENT, &raw->movement_dependent_link); } ///////////////////////////////////////////////////////////////// // view_link if (mode == PACK_MODE_SERVER_SESSION) { unpack_list_link (en, LIST_TYPE_TAKEOFF_QUEUE, &raw->takeoff_queue_link); } raw->operational_state = unpack_int_value (en, INT_TYPE_OPERATIONAL_STATE); raw->sleep = unpack_float_value (en, FLOAT_TYPE_SLEEP); if (mode == PACK_MODE_SERVER_SESSION) { raw->distance = unpack_float_value (en, FLOAT_TYPE_DISTANCE); // only needed by server? } ///////////////////////////////////////////////////////////////// if (raw->operational_state == OPERATIONAL_STATE_LANDED) { raw->loading_door_state = unpack_float_value (en, FLOAT_TYPE_LOADING_DOOR_STATE); } ///////////////////////////////////////////////////////////////// // radar_rotation_state if (mode == PACK_MODE_SERVER_SESSION) { raw->death_timer = unpack_float_value (en, FLOAT_TYPE_DEATH_TIMER); raw->target_fire_timer = unpack_float_value (en, FLOAT_TYPE_TARGET_FIRE_TIMER); raw->target_scan_timer = unpack_float_value (en, FLOAT_TYPE_TARGET_SCAN_TIMER); } // view_interest_level // weapon_burst_timer raw->weapon_system_ready_state = unpack_float_value (en, FLOAT_TYPE_WEAPON_SYSTEM_READY_STATE); if (mode == PACK_MODE_SERVER_SESSION) { raw->decoy_release_timer = unpack_float_value (en, FLOAT_TYPE_DECOY_RELEASE_TIMER); } //////////////////////////////////////// raw->weapon_config_type = (weapon_config_types) unpack_int_value (en, INT_TYPE_WEAPON_CONFIG_TYPE); raw->weapon_package_status_array = (weapon_package_status *) malloc_fast_mem (SIZE_WEAPON_PACKAGE_STATUS_ARRAY); memset (raw->weapon_package_status_array, 0, SIZE_WEAPON_PACKAGE_STATUS_ARRAY); 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; } raw->weapon_package_status_array[package].number = unpack_int_value (en, INT_TYPE_WEAPON_PACKAGE_NUMBER); raw->weapon_package_status_array[package].damaged = unpack_int_value (en, INT_TYPE_WEAPON_PACKAGE_DAMAGED); if (weapon_config_database[raw->weapon_config_type][package].rotate) { raw->weapon_package_status_array[package].weapon_system_heading = unpack_float_value (en, FLOAT_TYPE_WEAPON_SYSTEM_HEADING); raw->weapon_package_status_array[package].weapon_system_pitch = unpack_float_value (en, FLOAT_TYPE_WEAPON_SYSTEM_PITCH); } // muzzle_flash_timer } reset_entity_weapon_config_animation (en); raw->selected_weapon = unpack_int_value (en, INT_TYPE_SELECTED_WEAPON); //////////////////////////////////////// // sound_effect_data raw->formation_position = unpack_int_value (en, INT_TYPE_FORMATION_POSITION); // selected_weapon_system_ready // weapon_and_target_vectors_valid // gunship_radar_los_clear // los_to_target raw->lights_on = unpack_int_value (en, INT_TYPE_LIGHTS_ON); // cpg_identified raw->group_member_number = unpack_int_value (en, INT_TYPE_GROUP_MEMBER_NUMBER); // id_number_significant_digits raw->damage_level = unpack_int_value (en, INT_TYPE_DAMAGE_LEVEL); // id_number raw->weapon_vector.x = 0.0; raw->weapon_vector.y = 0.0; raw->weapon_vector.z = 1.0; raw->weapon_to_target_vector.x = 0.0; raw->weapon_to_target_vector.y = 0.0; raw->weapon_to_target_vector.z = -1.0; // 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 unpack_local_session_data (pack_modes mode) { session *raw; entity *en; int index; ASSERT ((mode >= 0) && (mode < NUM_PACK_MODES)); switch (mode) { //////////////////////////////////////// case PACK_MODE_SERVER_SESSION: //////////////////////////////////////// { en = get_session_entity (); ASSERT (en); raw = (session *) get_local_entity_data (en); raw->version_number = unpack_int_value (en, INT_TYPE_VERSION_NUMBER); unpack_list_root (en, LIST_TYPE_FORCE, &raw->force_root); // special_effect_root // update_link raw->elapsed_time = unpack_float_value (en, FLOAT_TYPE_ELAPSED_TIME); raw->lightning_timer = unpack_float_value (en, FLOAT_TYPE_LIGHTNING_TIMER); raw->start_time = unpack_float_value (en, FLOAT_TYPE_START_TIME); // time_of_day_resync raw->time_of_day_acceleration = unpack_float_value (en, FLOAT_TYPE_TIME_OF_DAY_ACCELERATION); raw->fog_of_war_maximum_value = unpack_float_value (en, FLOAT_TYPE_FOG_OF_WAR_MAXIMUM_VALUE); // // rain effect // raw->weather_radius = unpack_float_value (en, FLOAT_TYPE_WEATHER_RADIUS); raw->weather_mode_transitional_period = unpack_float_value (en, FLOAT_TYPE_WEATHER_MODE_TRANSITIONAL_PERIOD); raw->weather_mode_transitional_status = unpack_float_value (en, FLOAT_TYPE_WEATHER_MODE_TRANSITIONAL_STATUS); raw->weather_mode = (weathermodes) unpack_int_value (en, INT_TYPE_WEATHER_MODE); raw->target_weather_mode = (weathermodes) unpack_int_value (en, INT_TYPE_TARGET_WEATHER_MODE); unpack_vec3d (en, VEC3D_TYPE_WEATHER_POSITION, &raw->weather_position); unpack_vec3d (en, VEC3D_TYPE_WEATHER_VELOCITY, &raw->weather_velocity); // // wind effect // raw->wind_effect_radius = unpack_float_value (en, FLOAT_TYPE_WIND_EFFECT_RADIUS); raw->wind_gusting_value = unpack_float_value (en, FLOAT_TYPE_WIND_GUSTING_VALUE); raw->wind_minimum_speed = unpack_float_value (en, FLOAT_TYPE_WIND_MINIMUM_SPEED); raw->wind_maximum_speed = unpack_float_value (en, FLOAT_TYPE_WIND_MAXIMUM_SPEED); unpack_vec3d (en, VEC3D_TYPE_WIND_DIRECTION_VECTOR, &raw->wind_direction_vector); unpack_vec3d (en, VEC3D_TYPE_WIND_EFFECT_POSITION, &raw->wind_effect_position); unpack_vec3d (en, VEC3D_TYPE_WIND_EFFECT_VELOCITY, &raw->wind_effect_velocity); // raw->day_segment_type = (day_segment_types) unpack_int_value (en, INT_TYPE_DAY_SEGMENT_TYPE); raw->population_x_min = unpack_float_value (en, FLOAT_TYPE_POPULATION_X_MIN); raw->population_x_max = unpack_float_value (en, FLOAT_TYPE_POPULATION_X_MAX); raw->population_z_min = unpack_float_value (en, FLOAT_TYPE_POPULATION_Z_MIN); raw->population_z_max = unpack_float_value (en, FLOAT_TYPE_POPULATION_Z_MAX); raw->campaign_medal = unpack_int_value (en, INT_TYPE_CAMPAIGN_MEDAL); raw->campaign_requires_apache_havoc = unpack_int_value (en, INT_TYPE_CAMPAIGN_REQUIRES_APACHE_HAVOC); raw->auto_assign_gunship = unpack_int_value (en, INT_TYPE_AUTO_ASSIGN_GUNSHIP); raw->infinite_fuel = unpack_int_value (en, INT_TYPE_INFINITE_FUEL); raw->infinite_weapons = unpack_int_value (en, INT_TYPE_INFINITE_WEAPONS); raw->suppress_ai_fire = unpack_int_value (en, INT_TYPE_SUPPRESS_AI_FIRE); raw->invulnerable_from_collisions = unpack_int_value (en, INT_TYPE_INVULNERABLE_FROM_COLLISIONS); raw->invulnerable_from_weapons = unpack_int_value (en, INT_TYPE_INVULNERABLE_FROM_WEAPONS); raw->cheats_enabled = unpack_int_value (en, INT_TYPE_CHEATS_ENABLED); raw->skip_night_time = unpack_int_value (en, INT_TYPE_SKIP_NIGHT_TIME); raw->weather_increasing = unpack_int_value (en, INT_TYPE_WEATHER_INCREASING); raw->wind_increasing = unpack_int_value (en, INT_TYPE_WIND_INCREASING); raw->local_weather_model = unpack_int_value (en, INT_TYPE_LOCAL_WEATHER_MODEL); break; } //////////////////////////////////////// case PACK_MODE_CLIENT_SESSION: //////////////////////////////////////// { // // create entity // ASSERT (!get_session_entity ()); index = unpack_entity_safe_index (); en = get_free_entity (index); set_local_entity_type (en, ENTITY_TYPE_SESSION); raw = (session *) malloc_fast_mem (sizeof (session)); set_local_entity_data (en, raw); memset (raw, 0, sizeof (session)); // // unpack data (in exactly the same order as the data was packed) // raw->version_number = unpack_int_value (en, INT_TYPE_VERSION_NUMBER); raw->session_complete = unpack_int_value (en, INT_TYPE_SESSION_COMPLETE); unpack_list_root (en, LIST_TYPE_FORCE, &raw->force_root); unpack_list_root (en, LIST_TYPE_SPECIAL_EFFECT, &raw->special_effect_root); // update_link raw->elapsed_time = unpack_float_value (en, FLOAT_TYPE_ELAPSED_TIME); raw->lightning_timer = unpack_float_value (en, FLOAT_TYPE_LIGHTNING_TIMER); raw->start_time = unpack_float_value (en, FLOAT_TYPE_START_TIME); // time_of_day_resync raw->time_of_day_acceleration = unpack_float_value (en, FLOAT_TYPE_TIME_OF_DAY_ACCELERATION); raw->fog_of_war_maximum_value = unpack_float_value (en, FLOAT_TYPE_FOG_OF_WAR_MAXIMUM_VALUE); // // rain effect // raw->weather_radius = unpack_float_value (en, FLOAT_TYPE_WEATHER_RADIUS); raw->weather_mode_transitional_period = unpack_float_value (en, FLOAT_TYPE_WEATHER_MODE_TRANSITIONAL_PERIOD); raw->weather_mode_transitional_status = unpack_float_value (en, FLOAT_TYPE_WEATHER_MODE_TRANSITIONAL_STATUS); raw->weather_mode = (weathermodes) unpack_int_value (en, INT_TYPE_WEATHER_MODE); raw->target_weather_mode = (weathermodes) unpack_int_value (en, INT_TYPE_TARGET_WEATHER_MODE); unpack_vec3d (en, VEC3D_TYPE_WEATHER_POSITION, &raw->weather_position); unpack_vec3d (en, VEC3D_TYPE_WEATHER_VELOCITY, &raw->weather_velocity); // // wind effect // raw->wind_effect_radius = unpack_float_value (en, FLOAT_TYPE_WIND_EFFECT_RADIUS); raw->wind_gusting_value = unpack_float_value (en, FLOAT_TYPE_WIND_GUSTING_VALUE); raw->wind_minimum_speed = unpack_float_value (en, FLOAT_TYPE_WIND_MINIMUM_SPEED); raw->wind_maximum_speed = unpack_float_value (en, FLOAT_TYPE_WIND_MAXIMUM_SPEED); unpack_vec3d (en, VEC3D_TYPE_WIND_DIRECTION_VECTOR, &raw->wind_direction_vector); unpack_vec3d (en, VEC3D_TYPE_WIND_EFFECT_POSITION, &raw->wind_effect_position); unpack_vec3d (en, VEC3D_TYPE_WIND_EFFECT_VELOCITY, &raw->wind_effect_velocity); // raw->day_segment_type = (day_segment_types) unpack_int_value (en, INT_TYPE_DAY_SEGMENT_TYPE); raw->population_x_min = unpack_float_value (en, FLOAT_TYPE_POPULATION_X_MIN); raw->population_x_max = unpack_float_value (en, FLOAT_TYPE_POPULATION_X_MAX); raw->population_z_min = unpack_float_value (en, FLOAT_TYPE_POPULATION_Z_MIN); raw->population_z_max = unpack_float_value (en, FLOAT_TYPE_POPULATION_Z_MAX); raw->campaign_medal = unpack_int_value (en, INT_TYPE_CAMPAIGN_MEDAL); raw->campaign_requires_apache_havoc = unpack_int_value (en, INT_TYPE_CAMPAIGN_REQUIRES_APACHE_HAVOC); raw->auto_assign_gunship = unpack_int_value (en, INT_TYPE_AUTO_ASSIGN_GUNSHIP); raw->infinite_fuel = unpack_int_value (en, INT_TYPE_INFINITE_FUEL); raw->infinite_weapons = unpack_int_value (en, INT_TYPE_INFINITE_WEAPONS); raw->suppress_ai_fire = unpack_int_value (en, INT_TYPE_SUPPRESS_AI_FIRE); raw->invulnerable_from_collisions = unpack_int_value (en, INT_TYPE_INVULNERABLE_FROM_COLLISIONS); raw->invulnerable_from_weapons = unpack_int_value (en, INT_TYPE_INVULNERABLE_FROM_WEAPONS); raw->cheats_enabled = unpack_int_value (en, INT_TYPE_CHEATS_ENABLED); raw->skip_night_time = unpack_int_value (en, INT_TYPE_SKIP_NIGHT_TIME); raw->weather_increasing = unpack_int_value (en, INT_TYPE_WEATHER_INCREASING); raw->wind_increasing = unpack_int_value (en, INT_TYPE_WIND_INCREASING); raw->local_weather_model = unpack_int_value (en, INT_TYPE_LOCAL_WEATHER_MODEL); // // link into system // // // need to insert session into update list after camera entity // ASSERT (get_camera_entity ()); insert_local_entity_into_parents_child_list (en, LIST_TYPE_UPDATE, get_update_entity (), get_camera_entity ()); set_session_entity (en); set_display_campaign_timer_valid (FALSE); break; } //////////////////////////////////////// case PACK_MODE_BROWSE_SESSION: //////////////////////////////////////// { // // create entity // ASSERT (!get_session_entity ()); index = unpack_entity_safe_index (); en = get_free_entity (index); set_local_entity_type (en, ENTITY_TYPE_SESSION); raw = (session *) malloc_fast_mem (sizeof (session)); set_local_entity_data (en, raw); memset (raw, 0, sizeof (session)); // // unpack data (in exactly the same order as the data was packed) // raw->version_number = unpack_int_value (en, INT_TYPE_VERSION_NUMBER); unpack_list_root (en, LIST_TYPE_FORCE, &raw->force_root); // update_link // tour of duty time raw->elapsed_time = unpack_float_value (en, FLOAT_TYPE_ELAPSED_TIME); raw->start_time = unpack_float_value (en, FLOAT_TYPE_START_TIME); // time_of_day_resync // time_of_day_acceleration // weather radius // weather_mode_transitional_period // weather_mode_transitional_status raw->weather_mode = (weathermodes) unpack_int_value (en, INT_TYPE_WEATHER_MODE); // target_weather_mode // weather position // weather velocity raw->day_segment_type = (day_segment_types) unpack_int_value (en, INT_TYPE_DAY_SEGMENT_TYPE); raw->population_x_min = unpack_float_value (en, FLOAT_TYPE_POPULATION_X_MIN); raw->population_x_max = unpack_float_value (en, FLOAT_TYPE_POPULATION_X_MAX); raw->population_z_min = unpack_float_value (en, FLOAT_TYPE_POPULATION_Z_MIN); raw->population_z_max = unpack_float_value (en, FLOAT_TYPE_POPULATION_Z_MAX); raw->campaign_requires_apache_havoc = unpack_int_value (en, INT_TYPE_CAMPAIGN_REQUIRES_APACHE_HAVOC); // infinite_weapons // skip_night_time // weather increasing set_session_entity (en); break; } } }
static void unpack_local_data (entity *en, entity_types type, pack_modes mode) { ASSERT ((mode >= 0) && (mode < NUM_PACK_MODES)); switch (mode) { //////////////////////////////////////// case PACK_MODE_SERVER_SESSION: case PACK_MODE_CLIENT_SESSION: case PACK_MODE_BROWSE_SESSION: //////////////////////////////////////// { break; } //////////////////////////////////////// case PACK_MODE_UPDATE_ENTITY: //////////////////////////////////////// { vec3d v; // // always use access functions to set the data // set_local_entity_float_value (en, FLOAT_TYPE_ELAPSED_TIME, unpack_float_value (en, FLOAT_TYPE_ELAPSED_TIME)); set_local_entity_float_value (en, FLOAT_TYPE_LIGHTNING_TIMER, unpack_float_value (en, FLOAT_TYPE_LIGHTNING_TIMER)); // // rain effect // set_local_entity_float_value (en, FLOAT_TYPE_WEATHER_RADIUS, unpack_float_value (en, FLOAT_TYPE_WEATHER_RADIUS)); unpack_vec3d (en, VEC3D_TYPE_WEATHER_POSITION, &v); set_local_entity_vec3d (en, VEC3D_TYPE_WEATHER_POSITION, &v); unpack_vec3d (en, VEC3D_TYPE_WEATHER_VELOCITY, &v); set_local_entity_vec3d (en, VEC3D_TYPE_WEATHER_VELOCITY, &v); // // wind effect // set_local_entity_float_value (en, FLOAT_TYPE_WIND_EFFECT_RADIUS, unpack_float_value (en, FLOAT_TYPE_WIND_EFFECT_RADIUS)); set_local_entity_float_value (en, FLOAT_TYPE_WIND_GUSTING_VALUE, unpack_float_value (en, FLOAT_TYPE_WIND_GUSTING_VALUE)); unpack_vec3d (en, VEC3D_TYPE_WIND_DIRECTION_VECTOR, &v); set_local_entity_vec3d (en, VEC3D_TYPE_WIND_DIRECTION_VECTOR, &v); unpack_vec3d (en, VEC3D_TYPE_WIND_EFFECT_POSITION, &v); set_local_entity_vec3d (en, VEC3D_TYPE_WIND_EFFECT_POSITION, &v); unpack_vec3d (en, VEC3D_TYPE_WIND_EFFECT_VELOCITY, &v); set_local_entity_vec3d (en, VEC3D_TYPE_WIND_EFFECT_VELOCITY, &v); // set_local_entity_int_value (en, INT_TYPE_WEATHER_INCREASING, unpack_int_value (en, INT_TYPE_WEATHER_INCREASING)); set_local_entity_int_value (en, INT_TYPE_WIND_INCREASING, unpack_int_value (en, INT_TYPE_WIND_INCREASING)); set_display_campaign_timer_valid (TRUE); break; } } }
void unpack_local_keysite_data (pack_modes mode) { entity *en, *landing_en; landing *landing_raw; keysite *raw; int side, landing_lock, landed_lock, takeoff_lock, in_use, index; 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) { // // unpack keysite // index = unpack_entity_safe_index (); raw = (keysite *) get_local_entity_data (en); raw->supplies.ammo_supply_level = unpack_float_value (en, FLOAT_TYPE_AMMO_SUPPLY_LEVEL); raw->supplies.fuel_supply_level = unpack_float_value (en, FLOAT_TYPE_FUEL_SUPPLY_LEVEL); raw->keysite_strength = unpack_float_value (en, FLOAT_TYPE_KEYSITE_STRENGTH); raw->keysite_maximum_strength = unpack_float_value (en, FLOAT_TYPE_KEYSITE_MAXIMUM_STRENGTH); raw->alive = unpack_int_value (en, INT_TYPE_ALIVE); side = unpack_int_value (en, INT_TYPE_SIDE); if (side != raw->side) { // // update I-Maps (remove old side) // if (raw->in_use) { update_imap_sector_side (en, FALSE); if (mode == PACK_MODE_SERVER_SESSION) { update_imap_importance_level (en, FALSE); } } // // change side of keysite buildings // change_local_keysite_building_sides (en, (entity_sides) side); // // place into other sides force // delete_local_entity_from_parents_child_list (en, LIST_TYPE_KEYSITE_FORCE); insert_local_entity_into_parents_child_list (en, LIST_TYPE_KEYSITE_FORCE, get_local_force_entity ((entity_sides) side), NULL); if (mode == PACK_MODE_SERVER_SESSION) { // Must be done after removed from force update_imap_distance_to_friendly_base ((entity_sides) raw->side); } // // switch sides // raw->side = side; // // update I-Maps (add new side) // if (raw->in_use) { update_imap_sector_side (en, TRUE); if (mode == PACK_MODE_SERVER_SESSION) { update_imap_importance_level (en, TRUE); update_keysite_distance_to_friendly_base (en, (entity_sides) side); } } } in_use = unpack_int_value (en, INT_TYPE_IN_USE); raw->keysite_id = unpack_int_value (en, INT_TYPE_KEYSITE_ID); raw->keysite_usable_state = unpack_int_value (en, INT_TYPE_KEYSITE_USABLE_STATE); if (raw->in_use != in_use) { // // Update I-Maps (in use flag changed) // raw->in_use = in_use; update_imap_sector_side (en, in_use); if (mode == PACK_MODE_SERVER_SESSION) { update_imap_importance_level (en, in_use); if (in_use) { update_keysite_distance_to_friendly_base (en, (entity_sides) side); } else { update_imap_distance_to_friendly_base ((entity_sides) side); } } } unpack_list_root (en, LIST_TYPE_UNASSIGNED_TASK, &raw->unassigned_task_root); unpack_list_root (en, LIST_TYPE_ASSIGNED_TASK, &raw->assigned_task_root); unpack_list_root (en, LIST_TYPE_COMPLETED_TASK, &raw->completed_task_root); // unpack_list_root (en, LIST_TYPE_KEYSITE_GROUP, &raw->keysite_group_root); unpack_list_root (en, LIST_TYPE_DIVISION_HEADQUARTERS, &raw->division_headquarters_root); if (unpack_int_value (en, INT_TYPE_VALID)) { unpack_list_link (en, LIST_TYPE_CAMPAIGN_OBJECTIVE, &raw->campaign_objective_link); } #if DEBUG_MODULE debug_log ("KS_PACK: unpacking keysite %s", raw->keysite_name); #endif if (mode == PACK_MODE_SERVER_SESSION) { raw->repair_timer = unpack_float_value (en, FLOAT_TYPE_REPAIR_TIMER); raw->sleep = unpack_float_value (en, FLOAT_TYPE_SLEEP); raw->assist_timer = unpack_float_value (en, FLOAT_TYPE_ASSIST_TIMER); raw->assign_timer = unpack_float_value (en, FLOAT_TYPE_ASSIGN_TIMER); // // unpack 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); landing_raw->reserved_landing_sites = unpack_int_value (landing_en, INT_TYPE_RESERVED_LANDING_SITES); //landing_raw->free_landing_sites = unpack_int_value (en, INT_TYPE_FREE_LANDING_SITES); landing_raw->free_landing_sites = landing_raw->total_landing_sites; landing_lock = unpack_int_value (landing_en, INT_TYPE_LANDING_LOCK); landed_lock = unpack_int_value (landing_en, INT_TYPE_LANDED_LOCK); takeoff_lock = unpack_int_value (landing_en, INT_TYPE_TAKEOFF_LOCK); #if DEBUG_MODULE debug_log ("KS_PACK: %s (%d) unpacking %s landing entity, reserved %d, free %d, locks (saved :landing %d, landed %d, takeoff %d, calc landing %d, landed %d, takeoff %d)", raw->keysite_name, get_local_entity_index (en), entity_sub_type_landing_names [landing_raw->sub_type], landing_raw->reserved_landing_sites, landing_raw->free_landing_sites, landing_lock, landed_lock, takeoff_lock, landing_raw->landing_lock, landing_raw->landed_lock, landing_raw->takeoff_lock); if (landing_raw->landing_lock != landing_lock) { debug_log ("KS_PACK: %s %s landing entity needs landing_lock repairing", raw->keysite_name, entity_sub_type_landing_names [landing_raw->sub_type]); } if (landing_raw->landed_lock != landed_lock) { debug_log ("KS_PACK: %s %s landing entity needs landed_lock repairing", raw->keysite_name, entity_sub_type_landing_names [landing_raw->sub_type]); } if (landing_raw->takeoff_lock != takeoff_lock) { debug_log ("KS_PACK: %s %s landing entity needs takeoff_lock repairing", raw->keysite_name, entity_sub_type_landing_names [landing_raw->sub_type]); } #endif unpack_list_root (landing_en, LIST_TYPE_TAKEOFF_QUEUE, &landing_raw->takeoff_queue_root); landing_en = get_local_entity_child_succ (landing_en, LIST_TYPE_LANDING_SITE); } } } en = get_local_entity_succ (en); } }
void unpack_local_city_building_data (pack_modes mode) { city_building *raw; entity *destroy_en, *en; int city_building_count, city_building_alive; if ((mode != PACK_MODE_SERVER_SESSION) && (mode != PACK_MODE_CLIENT_SESSION)) { return; } // // RLE encoded // debug_log ("RLE CITY BLOCK"); en = get_local_entity_list (); city_building_count = unpack_int_value (NULL, INT_TYPE_LENGTH); city_building_alive = unpack_int_value (NULL, INT_TYPE_ALIVE); while (en) { destroy_en = en; en = get_local_entity_succ (en); if (get_local_entity_type (destroy_en) == ENTITY_TYPE_CITY_BUILDING) { if (city_building_count == 0) { city_building_count = unpack_int_value (NULL, INT_TYPE_LENGTH); city_building_alive = unpack_int_value (NULL, INT_TYPE_ALIVE); } city_building_count --; raw = get_local_entity_data (destroy_en); raw->fix.alive = city_building_alive; if (!city_building_alive) { raw->fix.object_3d_shape = get_3d_object_destroyed_object_index (raw->fix.object_3d_shape); } } } }
void unpack_local_anti_aircraft_data (pack_modes mode) { anti_aircraft *raw; entity *destroy_en, *en; int count, alive; if ((mode != PACK_MODE_SERVER_SESSION) && (mode != PACK_MODE_CLIENT_SESSION)) { return; } // // RLE encoded // debug_log ("RLE SAM & AAA"); en = get_local_entity_list (); count = unpack_int_value (NULL, INT_TYPE_LENGTH); alive = unpack_int_value (NULL, INT_TYPE_ALIVE); #if DEBUG_MODULE debug_log ("AA_PACK: unpacking count %d, alive %d", count, alive); #endif while (en) { destroy_en = en; en = get_local_entity_succ (en); if (get_local_entity_type (destroy_en) == ENTITY_TYPE_ANTI_AIRCRAFT) { if (count == 0) { count = unpack_int_value (NULL, INT_TYPE_LENGTH); alive = unpack_int_value (NULL, INT_TYPE_ALIVE); #if DEBUG_MODULE debug_log ("AA_PACK: unpacking count %d, alive %d", count, alive); #endif } count --; raw = (anti_aircraft *) get_local_entity_data (destroy_en); raw->vh.mob.alive = TRUE; if (!alive) { kill_local_restored_anti_aircraft_entity (destroy_en); } } } }