コード例 #1
0
ファイル: pilot.c プロジェクト: Comanche93/eech
int get_session_pilot_count (void)
{
	entity
		*force,
		*pilot;

	int
		count;
	
	ASSERT (get_session_entity ());

	count = 0;

	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)
		{
			count ++;

			pilot = get_local_entity_child_succ (pilot, LIST_TYPE_PILOT);
		}

		force = get_local_entity_child_succ (force, LIST_TYPE_FORCE);
	}

	return count;
}
コード例 #2
0
ファイル: group.c プロジェクト: DexterWard/comanche
entity *get_group_at_road_node (int node)
{
	entity
		*force,
		*group;

	force = get_local_entity_first_child (get_session_entity (), LIST_TYPE_FORCE);

	while (force)
	{
		group = get_local_entity_first_child (force, LIST_TYPE_GROUND_REGISTRY);

		while (group)
		{
			if ((get_local_entity_int_value (group, INT_TYPE_ROUTE_NODE) == node) &&
				(get_local_entity_int_value (group, INT_TYPE_ALIVE)))
			{
				#if DEBUG_MODULE

				debug_log ("GP_MSGS: found retreat group %d side %s at node %d", group, entity_side_names [get_local_entity_int_value (group, INT_TYPE_SIDE)], node);

				#endif

				return group;
			}

			group = get_local_entity_child_succ (group, LIST_TYPE_GROUND_REGISTRY);
		}

		force = get_local_entity_child_succ (force, LIST_TYPE_FORCE);
	}

	return NULL;
}
コード例 #3
0
ファイル: assign.c プロジェクト: Comanche93/eech
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);
	}
}
コード例 #4
0
ファイル: setup.c プロジェクト: DexterWard/comanche
void setup_campaign (void)
{
	entity
		*force;
		
	ASSERT (get_comms_model () == COMMS_MODEL_SERVER);

	ASSERT (get_session_entity ());

	//
	// Create force overall campaign objectives
	//

	force = get_local_entity_first_child (get_session_entity (), LIST_TYPE_FORCE);

	ASSERT (force);

	while (force)
	{
		create_force_campaign_objectives (force);

		force = get_local_entity_child_succ (force, LIST_TYPE_FORCE);
	}

	//
	// Setup Order Of Battle
	//

	initialise_order_of_battle ();
}
コード例 #5
0
ファイル: group.c プロジェクト: DexterWard/comanche
void set_group_member_numbers (entity *en)
{
	int
		number;

	entity
		*member;

	ASSERT (en);

	ASSERT (get_comms_model () == COMMS_MODEL_SERVER);

	number = 0;

	member = get_local_entity_first_child (en, LIST_TYPE_MEMBER);

	while (member)
	{
		set_client_server_entity_int_value (member, INT_TYPE_GROUP_MEMBER_NUMBER, number);

		member = get_local_entity_child_succ (member, LIST_TYPE_MEMBER);

		number ++;
	}
}
コード例 #6
0
ファイル: sh_move.c プロジェクト: DexterWard/comanche
int clear_ship_fires (entity *ship_en, entity_sub_types type)
{
	entity
		*en;

	vec3d
		*pos;

	en = get_local_entity_first_child (ship_en, LIST_TYPE_SPECIAL_EFFECT);

	while (en)
	{
		if (en->type == ENTITY_TYPE_SMOKE_LIST)
		{
			if (get_local_entity_int_value (en, INT_TYPE_ENTITY_SUB_TYPE) == type)
			{
				pos = get_local_entity_vec3d_ptr (en, VEC3D_TYPE_POSITION);

				if (pos->y < 0.0)
				{
					set_local_entity_float_value (en, FLOAT_TYPE_GENERATOR_LIFETIME, 0.0);
				}
			}
      }

		en = get_local_entity_child_succ (en, LIST_TYPE_SPECIAL_EFFECT);
	}

	return TRUE;
}
コード例 #7
0
ファイル: assign.c プロジェクト: Comanche93/eech
int assign_task_to_group_members (entity *group, entity *guide, unsigned int valid_members)
{
	entity
		*task,
		*member;

	ASSERT (group);

	ASSERT (guide);

	task = get_local_entity_parent (guide, LIST_TYPE_GUIDE);

	ASSERT (task);

	member = get_local_entity_first_child (group, LIST_TYPE_MEMBER);

	while (member)
	{
		if (valid_members & (1 << get_local_entity_int_value (member, INT_TYPE_GROUP_MEMBER_NUMBER)))
		{
			attach_group_member_to_guide_entity (member, guide);

			notify_local_entity (ENTITY_MESSAGE_TASK_ASSIGNED, member, task);
		}
		
		member = get_local_entity_child_succ (member, LIST_TYPE_MEMBER);
	}

	return TRUE;
}
コード例 #8
0
ファイル: en_sessn.c プロジェクト: DexterWard/comanche
int register_entity_list_root_for_post_unpack_validation (struct ENTITY *en, int list_type)
{

	comms_entity_list_validation_type
		*new_entity_list;

	new_entity_list = (comms_entity_list_validation_type *) malloc_heap_mem (sizeof (comms_entity_list_validation_type));

	new_entity_list->en = en;

	new_entity_list->list_type = list_type;

	new_entity_list->next = entity_list_root_validation;

	entity_list_root_validation = new_entity_list;

	#if DEBUG_MODULE
	{

		entity
			*first_child;

		debug_log ("EN_SESSN: registering entity %s (%d) for list root %s validation", get_local_entity_type_name (en), get_local_entity_index (en), get_list_type_name (list_type));

		first_child = get_local_entity_first_child (en, list_type);
	}
	#endif

	return TRUE;
}
コード例 #9
0
ファイル: gp_ptr.c プロジェクト: Comanche93/eech
static void *get_local_ptr_value (entity *en, ptr_types type)
{
	group
		*raw;

	void
		*ptr;

	raw = (group *) get_local_entity_data (en);

	switch (type)
	{
		////////////////////////////////////////
		case PTR_TYPE_GROUP_LEADER:
		////////////////////////////////////////
		{
			ptr = get_local_entity_first_child (en, LIST_TYPE_MEMBER);

			break;
		}
		////////////////////////////////////////
		default:
		////////////////////////////////////////
		{
			debug_fatal_invalid_ptr_type (en, type);

			break;
		}
	}

	return (ptr);
}
コード例 #10
0
ファイル: soundeff.c プロジェクト: DexterWard/comanche
int get_local_entity_sound_type_valid (entity *en, entity_sub_types type)
{
	entity
		*spec;

	sound_effect
		*raw;

	spec = get_local_entity_first_child (en, LIST_TYPE_SPECIAL_EFFECT);
	
	while (spec)
	{
		if (get_local_entity_type (spec) == ENTITY_TYPE_SOUND_EFFECT)
		{
			raw = get_local_entity_data (spec);

			if (raw->eff.sub_type == type)
			{
				return (raw->valid_sound_effect);
			}
		}

		spec = get_local_entity_child_succ (spec, LIST_TYPE_SPECIAL_EFFECT);
	}

	return FALSE;
}
コード例 #11
0
ファイル: engage.c プロジェクト: Comanche93/eech
void terminate_all_engage_tasks (entity *group)
{
	entity
		*guide,
		*task;

	ASSERT (group);

	ASSERT (get_comms_model () == COMMS_MODEL_SERVER);

	do
	{
		guide = get_local_entity_first_child (group, LIST_TYPE_GUIDE_STACK);

		while (guide)
		{
			if (get_local_entity_int_value (guide, INT_TYPE_VALID_GUIDE_MEMBERS) == 0)
			{
				task = get_local_entity_parent (guide, LIST_TYPE_GUIDE);

				ASSERT (get_local_entity_int_value (task, INT_TYPE_ENTITY_SUB_TYPE) == ENTITY_SUB_TYPE_TASK_ENGAGE);

				if (get_local_entity_int_value (task, INT_TYPE_TASK_TERMINATED) == TASK_TERMINATED_IN_PROGRESS)
				{
					notify_local_entity (ENTITY_MESSAGE_TASK_TERMINATED, task, group, TASK_TERMINATED_ABORTED);

					break;
				}
			}

			guide = get_local_entity_child_succ (guide, LIST_TYPE_GUIDE_STACK);
		}
	}
	while (guide);
}
コード例 #12
0
ファイル: group.c プロジェクト: DexterWard/comanche
int get_local_group_member_max_formation_position (entity *group)
{

	entity
		*member;

	int
		max_formation_position;

	max_formation_position = 0;

	member = get_local_entity_first_child (group, LIST_TYPE_MEMBER);

	while (member)
	{

		if (max_formation_position < get_local_entity_int_value (member, INT_TYPE_FORMATION_POSITION))
		{

			max_formation_position = get_local_entity_int_value (member, INT_TYPE_FORMATION_POSITION);
		}

		member = get_local_entity_child_succ (member, LIST_TYPE_MEMBER);
	}

	return max_formation_position;
}
コード例 #13
0
ファイル: group.c プロジェクト: DexterWard/comanche
int check_group_task_type (entity *group, entity_sub_types task_type)
{

	entity
		*guide,
		*task;

	guide = get_local_entity_first_child (group, LIST_TYPE_GUIDE_STACK);

	while (guide)
	{

		task = get_local_entity_parent (guide, LIST_TYPE_GUIDE);

		if (get_local_entity_int_value (task, INT_TYPE_ENTITY_SUB_TYPE) == task_type)
		{

			return TRUE;
		}

		guide = get_local_entity_child_succ (guide, LIST_TYPE_GUIDE_STACK);
	}

	return FALSE;
}
コード例 #14
0
ファイル: group.c プロジェクト: DexterWard/comanche
int check_group_task_type_valid_members (entity *group, entity_sub_types task_type)
{
	entity
		*guide,
		*task;

	guide = get_local_entity_first_child (group, LIST_TYPE_GUIDE_STACK);

	while (guide)
	{
		if (get_local_entity_int_value (guide, INT_TYPE_VALID_GUIDE_MEMBERS) != TASK_ASSIGN_NO_MEMBERS)
		{
			task = get_local_entity_parent (guide, LIST_TYPE_GUIDE);

			if (get_local_entity_int_value (task, INT_TYPE_ENTITY_SUB_TYPE) == task_type)
			{
				return TRUE;
			}
		}

		guide = get_local_entity_child_succ (guide, LIST_TYPE_GUIDE_STACK);
	}

	return FALSE;
}
コード例 #15
0
ファイル: group.c プロジェクト: DexterWard/comanche
void group_destroy_all_members (entity *en)
{
	entity
		*next,
		*member;

	ASSERT (get_comms_model () == COMMS_MODEL_SERVER);

	//
	// DESTROY each member
	//

	member = get_local_entity_first_child (en, LIST_TYPE_MEMBER);

	while (member)
	{
		next = get_local_entity_child_succ (member, LIST_TYPE_MEMBER);

		destroy_client_server_entity (member);

		member = next;
	}

	//
	// Must also KILL the group
	//

	kill_client_server_group_entity (en);
}
コード例 #16
0
ファイル: soundeff.c プロジェクト: DexterWard/comanche
void kill_client_server_entity_sound_type (entity *en, entity_sub_types type)
{
	entity
		*spec,
		*next;

	sound_effect
		*raw;

	spec = get_local_entity_first_child (en, LIST_TYPE_SPECIAL_EFFECT);
	
	while (spec)
	{
		next = get_local_entity_child_succ (spec, LIST_TYPE_SPECIAL_EFFECT);

		if (get_local_entity_type (spec) == ENTITY_TYPE_SOUND_EFFECT)
		{
			raw = get_local_entity_data (spec);

			if (raw->eff.sub_type == type)
			{
				//
				// "kill" sound
				//

				kill_client_server_entity (spec);
			}
		}

		spec = next;
	}
}
コード例 #17
0
ファイル: force.c プロジェクト: Comanche93/eech
entity *get_local_force_entity (entity_sides side)
{

	entity
		*force;

	if (!get_session_entity ())
	{

		return NULL;
	}

	force = get_local_entity_first_child (get_session_entity (), LIST_TYPE_FORCE);

	while (force)
	{

		debug_assert (get_local_entity_type (force) == ENTITY_TYPE_FORCE);

		if (get_local_entity_int_value (force, INT_TYPE_SIDE) == side)
		{

			return force;
		}

		force = get_local_entity_child_succ (force, LIST_TYPE_FORCE);
	}

	return NULL;
}
コード例 #18
0
ファイル: group.c プロジェクト: DexterWard/comanche
int get_group_suitable_for_player (entity *group, entity *pilot)
{
	entity
		*member;

	ASSERT (group);

	if (!group)
	{
		return FALSE;
	}

	member = get_local_entity_first_child (group, LIST_TYPE_MEMBER);

	while (member)
	{
		if (get_local_entity_suitable_for_player (member, pilot))
		{
			return TRUE;
		}

		member = get_local_entity_child_succ (member, LIST_TYPE_MEMBER);
	}

	return FALSE;
}
コード例 #19
0
ファイル: group.c プロジェクト: DexterWard/comanche
void kill_client_server_group_entity (entity *en)
{
	entity
		*guide,
		*task,
		*next;

	ASSERT (en);

	ASSERT (get_comms_model () == COMMS_MODEL_SERVER);

	//
	// abort tasks (NOTE: Notifying each guide could indirectly destroy other guides on the stack)
	//

	do
	{
		guide = get_local_entity_first_child (en, LIST_TYPE_GUIDE_STACK);

		if (guide)
		{
			notify_local_entity (ENTITY_MESSAGE_GROUP_KILLED, guide, en);
		}
	}
	while (guide);

	//
	// notify task dependents
	//

	task = get_local_entity_first_child (en, LIST_TYPE_TASK_DEPENDENT);

	while (task)
	{
		next = get_local_entity_child_succ (task, LIST_TYPE_TASK_DEPENDENT);

		if (task->type == ENTITY_TYPE_TASK)
		{
			notify_local_entity (ENTITY_MESSAGE_TASK_COMPLETED, task, en, TASK_TERMINATED_OBJECTIVE_MESSAGE);
		}

		task = next;
	}

	kill_client_server_entity (en);
}
コード例 #20
0
ファイル: hm_wpn.c プロジェクト: Comanche93/eech
float get_ka50_missile_flight_time (void)
{
	entity
		*en,
		*weapon,
		*target;

	vec3d
		*weapon_position,
		*target_position;

	float
		flight_time,
		weapon_velocity,
		target_range;

	flight_time = 0.0;

	en = get_gunship_entity ();

	//
	// find most recently launched Vikhr with a target (first found on list)
	//

	weapon = get_local_entity_first_child (en, LIST_TYPE_LAUNCHED_WEAPON);

	while (weapon)
	{
		if (get_local_entity_int_value (weapon, INT_TYPE_ENTITY_SUB_TYPE) == ENTITY_SUB_TYPE_WEAPON_VIKHR)
		{
			target = get_local_entity_parent (weapon, LIST_TYPE_TARGET);

			if (target)
			{
				weapon_position = get_local_entity_vec3d_ptr (weapon, VEC3D_TYPE_POSITION);

				target_position = get_local_entity_vec3d_ptr (target, VEC3D_TYPE_POSITION);

				target_range = get_3d_range (weapon_position, target_position);

				weapon_velocity = get_local_entity_float_value (weapon, FLOAT_TYPE_VELOCITY);

				if (weapon_velocity > 0.0)
				{
					flight_time = target_range / weapon_velocity;

					break;
				}
			}
		}

		weapon = get_local_entity_child_succ (weapon, LIST_TYPE_LAUNCHED_WEAPON);
	}

	return (flight_time);
}
コード例 #21
0
ファイル: dedi_sc.c プロジェクト: Comanche93/eech
static void dedicated_server_build_player_list (void)
{
	entity
		*force,
		*pilot;

	entity_sides
		side;

	rgb_colour
		col;

	ui_object_destroy_list_items (player_list);

	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)
		{
			if (pilot != get_pilot_entity ())
			{
				side = (entity_sides) get_local_entity_int_value (pilot, INT_TYPE_SIDE);

				col.r = 255;
				col.g = 255;
				col.b = 255;
				col.a = 255;

				add_to_pop_up_list (get_local_entity_string (pilot, STRING_TYPE_PILOTS_NAME), player_list, NULL, 0, UI_FONT_ARIAL_16, col);
			}
			
			pilot = get_local_entity_child_succ (pilot, LIST_TYPE_PILOT);
		}

		force = get_local_entity_child_succ (force, LIST_TYPE_FORCE);
	}
}
コード例 #22
0
ファイル: group.c プロジェクト: DexterWard/comanche
void set_group_formation_positions (entity *en)
{
	entity
		*member;

	ASSERT (en);

	ASSERT (get_comms_model () == COMMS_MODEL_SERVER);

	member = get_local_entity_first_child (en, LIST_TYPE_MEMBER);

	while (member)
	{
		set_client_server_entity_int_value (member, INT_TYPE_FORMATION_POSITION, get_local_entity_int_value (member, INT_TYPE_GROUP_MEMBER_NUMBER));

		member = get_local_entity_child_succ (member, LIST_TYPE_MEMBER);
	}
}
コード例 #23
0
ファイル: group.c プロジェクト: DexterWard/comanche
void group_kill_all_members (entity *en)
{
	entity
		*next,
		*member;

	ASSERT (get_comms_model () == COMMS_MODEL_SERVER);

	member = get_local_entity_first_child (en, LIST_TYPE_MEMBER);

	while (member)
	{
		next = get_local_entity_child_succ (member, LIST_TYPE_MEMBER);

		kill_client_server_entity (member);

		member = next;
	}
}
コード例 #24
0
ファイル: soundeff.c プロジェクト: DexterWard/comanche
int pause_local_entity_sound_type (entity *en, entity_sub_types type, float delay)
{
	entity
		*spec;

	sound_effect
		*raw;

	int
		count;

	count = 0;

	spec = get_local_entity_first_child (en, LIST_TYPE_SPECIAL_EFFECT);
	
	while (spec)
	{
		if (get_local_entity_type (spec) == ENTITY_TYPE_SOUND_EFFECT)
		{
			raw = get_local_entity_data (spec);

			if (raw->eff.sub_type == type)
			{
				//
				// "pause" sound
				//

				if (raw->valid_sound_effect)
				{
					raw->valid_sound_effect = FALSE;

					raw->valid_effect_lifetime = delay;

					count ++;
				}
			}
		}

		spec = get_local_entity_child_succ (spec, LIST_TYPE_SPECIAL_EFFECT);
	}

	return count;
}
コード例 #25
0
ファイル: engage.c プロジェクト: Comanche93/eech
unsigned int assign_specific_engage_task_to_group (entity *group, entity *task, unsigned int valid_members)
{
	entity
		*member;

	unsigned int
		member_number;

	ASSERT (group);

	ASSERT (task);

	ASSERT (get_comms_model () == COMMS_MODEL_SERVER);
		
	member = get_local_entity_first_child (group, LIST_TYPE_MEMBER);

	while ((member) && (valid_members))
	{
		//
		// Only assign AI entities to ENGAGE tasks
		//
		
		if (get_local_entity_int_value (member, INT_TYPE_PLAYER) == ENTITY_PLAYER_AI)
		{
			if (get_local_entity_int_value (member, INT_TYPE_ENGAGE_ENEMY))
			{
				member_number = (1 << get_local_entity_int_value (member, INT_TYPE_GROUP_MEMBER_NUMBER));
		
				if (member_number & valid_members)
				{
					if (assign_new_task_to_group_member (group, member, task, NULL))
					{
						valid_members &= (~member_number);
					}
				}
			}
		}
		
		member = get_local_entity_child_succ (member, LIST_TYPE_MEMBER);
	}

	return valid_members;
}
コード例 #26
0
ファイル: soundeff.c プロジェクト: DexterWard/comanche
void destroy_client_server_sound_effects (entity *en)
{
	entity
		*spec,
		*next;

	spec = get_local_entity_first_child (en, LIST_TYPE_SPECIAL_EFFECT);
	
	while (spec)
	{
		next = get_local_entity_child_succ (spec, LIST_TYPE_SPECIAL_EFFECT);

		if (get_local_entity_type (spec) == ENTITY_TYPE_SOUND_EFFECT)
		{
			destroy_client_server_entity_family (spec);
		}

		spec = next;
	}
}
コード例 #27
0
ファイル: group.c プロジェクト: DexterWard/comanche
void group_terminate_all_tasks (entity *en)
{
	entity
		*task,
		*guide;

	int
		task_type;

	ASSERT (en);

	ASSERT (get_comms_model () == COMMS_MODEL_SERVER);

	terminate_all_engage_tasks (en);

	do
	{
		guide = get_local_entity_first_child (en, LIST_TYPE_GUIDE_STACK);

		if (guide)
		{
			task = get_local_entity_parent (guide, LIST_TYPE_GUIDE);

			ASSERT (task);

			task_type = get_local_entity_int_value (task, INT_TYPE_ENTITY_SUB_TYPE);

			if (task_database [task_type].persistent_task)
			{
				destroy_client_server_entity (guide);
			}
			else
			{
				notify_local_entity (ENTITY_MESSAGE_TASK_TERMINATED, task, NULL, TASK_TERMINATED_ABORTED);
			}
		}
	}
	while (guide);
}
コード例 #28
0
ファイル: assign.c プロジェクト: Comanche93/eech
int check_group_members_awake (entity *group)
{

	entity
		*mb;

	mb = get_local_entity_first_child (group, LIST_TYPE_MEMBER);

	while (mb)
	{

		if (get_local_entity_float_value (mb, FLOAT_TYPE_SLEEP) > 0.0)
		{

			return FALSE;
		}

		mb = get_local_entity_child_succ (mb, LIST_TYPE_MEMBER);
	}

	return TRUE;
}
コード例 #29
0
ファイル: group.c プロジェクト: DexterWard/comanche
int get_local_group_member_count (entity *group)
{

	entity
		*member;

	int
		count;

	count = 0;

	member = get_local_entity_first_child (group, LIST_TYPE_MEMBER);

	while (member)
	{

		count ++;

		member = get_local_entity_child_succ (member, LIST_TYPE_MEMBER);
	}

	return count;
}
コード例 #30
0
ファイル: assign.c プロジェクト: Comanche93/eech
void respond_to_player_task_assign_request (entity *pilot, entity *task, entity *mobile)
{
	entity
		*group;
		
	ASSERT (pilot);

	ASSERT (mobile);

	ASSERT (task);

	ASSERT (get_comms_model () == COMMS_MODEL_SERVER);

	group = get_local_entity_parent (mobile, LIST_TYPE_MEMBER);

	if ((!get_local_entity_first_child (task, LIST_TYPE_GUIDE)) && (!get_local_group_primary_task (group)))
	{
		if (assign_primary_task_to_group (group, task))
		{
			transmit_entity_comms_message (ENTITY_COMMS_TASK_ASSIGN_RESULT, pilot, task, mobile);

			return;
		}
	}
	else
	{
		if (get_local_group_primary_task (group))
		{
			transmit_entity_comms_message (ENTITY_COMMS_TASK_ASSIGN_RESULT, pilot, task, mobile);

			return;
		}
	}

	transmit_entity_comms_message (ENTITY_COMMS_TASK_ASSIGN_RESULT, pilot, NULL, NULL);
}