Example #1
0
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;
		}
	}
}
Example #2
0
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;
		}
	}
}
Example #3
0
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;
		}
	}
}
Example #4
0
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;
		}
	}
}
Example #5
0
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;
		}
	}
}