コード例 #1
0
ファイル: pilot.c プロジェクト: Comanche93/eech
void create_client_pilot (void)
{
	client_pilot_request_data
		pilot_data;

	ASSERT (get_comms_model () == COMMS_MODEL_CLIENT);

	//
	// pack required gunship data
	//

	strcpy (pilot_data.name, get_player_log_name (get_current_player_log ()));
	pilot_data.side = get_global_gunship_side ();
	pilot_data.rank = get_player_log_rank (get_global_gunship_side (), get_current_player_log ());
	pilot_data.sub_type = ENTITY_SUB_TYPE_PILOT_PILOT;
	pilot_data.unique_id = direct_play_get_player_id ();
	pilot_data.difficulty = get_global_difficulty_level ();

	//
	// Send request
	//

	send_packet (get_server_id (), PACKET_TYPE_CLIENT_PILOT_REQUEST, (unsigned char *) &pilot_data, sizeof (client_pilot_request_data), SEND_TYPE_PERSONAL);

	// turn off NEXT button while Pilot entity is being created client_server
	if (get_comms_model () == COMMS_MODEL_CLIENT)
	{

		set_display_gunship_buttons (FALSE, "ENGAGE");
	}
}
コード例 #2
0
void unpack_client_server_entity_data (entity *en)
{
    if (get_comms_model () == COMMS_MODEL_SERVER)
    {
        unpack_local_entity_data (en, get_local_entity_type (en), PACK_MODE_UPDATE_ENTITY);

        transmit_entity_comms_message (ENTITY_COMMS_UPDATE, en);
    }
    else
    {
        ASSERT (get_comms_model () == COMMS_MODEL_CLIENT);

        unpack_local_entity_data (en, get_local_entity_type (en), PACK_MODE_UPDATE_ENTITY);
    }
}
コード例 #3
0
ファイル: ac_msgs.c プロジェクト: Comanche93/eech
static int response_to_waypoint_lower_undercarriage_action (entity_messages message, entity *receiver, entity *sender, va_list pargs)
{

	#if DEBUG_MODULE

	debug_log_entity_message (message, receiver, sender, pargs);

	#endif

	if (get_comms_model () == COMMS_MODEL_SERVER)
	{
		if (
				(get_local_entity_int_value (receiver, INT_TYPE_PLAYER) == ENTITY_PLAYER_AI) ||
				(get_local_entity_int_value (receiver, INT_TYPE_AUTO_PILOT))
			)
		{
			lower_client_server_entity_undercarriage (receiver);
		}
	}

	/////////////////////////////////////////////////////////////////
	//
	//
	/////////////////////////////////////////////////////////////////

	return (TRUE);
}
コード例 #4
0
ファイル: en_stats.c プロジェクト: DexterWard/comanche
void update_create_entity_statistics (entity_types type)
{
	ASSERT ((type > ENTITY_TYPE_UNKNOWN) && (type < NUM_ENTITY_TYPES));

	//
	// ignore client create on transmit (wait until client create on receive)
	//

	if ((get_comms_model () == COMMS_MODEL_CLIENT) && (get_comms_data_flow () == COMMS_DATA_FLOW_TX))
	{
		return;
	}

	if (++entity_count > entity_peak_count)
	{
		entity_peak_count = entity_count;
	}

	entity_type_stats[type].total_created++;

	if (++entity_type_stats[type].count > entity_type_stats[type].peak_count)
	{
		entity_type_stats[type].peak_count = entity_type_stats[type].count;
	}
}
コード例 #5
0
ファイル: wn_cllsn.c プロジェクト: DexterWard/comanche
entity *collision_test_weapon_with_any_target (entity *weapon, vec3d *weapon_old_position, vec3d *weapon_new_position)
{
	entity
		*launcher,
		*collision_entity;

	vec3d
		weapon_intercept_point,
		face_normal;

	ASSERT (weapon);

	ASSERT (weapon_old_position);

	ASSERT (weapon_new_position);

	ASSERT (get_comms_model () == COMMS_MODEL_SERVER);

	launcher = get_local_entity_parent (weapon, LIST_TYPE_LAUNCHED_WEAPON);

	collision_entity = get_line_of_sight_collision_entity (launcher, NULL, weapon_old_position, weapon_new_position, &weapon_intercept_point, &face_normal);

	if (collision_entity)
	{
		*weapon_new_position = weapon_intercept_point;
	}

	return (collision_entity);
}
コード例 #6
0
ファイル: rv_creat.c プロジェクト: DexterWard/comanche
entity *create_local_entity_routed_vehicle (int index, entity_sub_types sub_type, entity *group, vec3d *position)
{
	entity
		*new_entity;

	ASSERT (get_comms_model() == COMMS_MODEL_SERVER);

	//
	// create routed entity
	//

	new_entity = create_local_entity
	(
		ENTITY_TYPE_ROUTED_VEHICLE,
		index,
		ENTITY_ATTR_PARENT (LIST_TYPE_MEMBER, group),
		ENTITY_ATTR_INT_VALUE (INT_TYPE_ENTITY_SUB_TYPE, sub_type),
		ENTITY_ATTR_VEC3D (VEC3D_TYPE_POSITION, position->x, position->y, position->z),
		ENTITY_ATTR_END
	);

	//
	// create and attach special effects
	//

	//
	//
	//

	return new_entity;
}
コード例 #7
0
ファイル: en_valid.c プロジェクト: Comanche93/eech
int assert_local_create_entity_index (int index)
{
	//Xhit: Added so that ENTITY_INDEX_CREATE_LOCAL are also accepted (030428)
	//VJ 030508 if downwash 
	if (command_line_downwash && index == ENTITY_INDEX_CREATE_LOCAL)
	{
		return (TRUE);	
	}
	
	if (get_comms_model () == COMMS_MODEL_SERVER)
	{
		return (index == ENTITY_INDEX_DONT_CARE);
	}
	else
	{
		if (get_comms_data_flow () == COMMS_DATA_FLOW_TX)
		{
			return (FALSE);
		}
		else
		{
			return (index != ENTITY_INDEX_DONT_CARE);
		}
	}
}
コード例 #8
0
ファイル: pilot.c プロジェクト: Comanche93/eech
entity *create_new_pilot_entity (const char *name, entity_sides side, int rank, entity_sub_types sub_type, int unique_id, int difficulty)
{
	entity
		*en,
		*force;

	ASSERT (get_comms_model () == COMMS_MODEL_SERVER);
	
	ASSERT (name);

	force = get_local_force_entity (side);

	ASSERT (force);

	en = create_client_server_entity
				(
					ENTITY_TYPE_PILOT,
					ENTITY_INDEX_DONT_CARE,
					ENTITY_ATTR_PARENT (LIST_TYPE_PILOT, force),
					ENTITY_ATTR_STRING (STRING_TYPE_PILOTS_NAME, name),
					ENTITY_ATTR_INT_VALUE (INT_TYPE_ENTITY_SUB_TYPE, sub_type),
					ENTITY_ATTR_INT_VALUE (INT_TYPE_UNIQUE_ID, unique_id),
					ENTITY_ATTR_INT_VALUE (INT_TYPE_SIDE, side),
					ENTITY_ATTR_INT_VALUE (INT_TYPE_PILOT_RANK, rank),
					ENTITY_ATTR_INT_VALUE (INT_TYPE_DIFFICULTY_LEVEL, difficulty),
					ENTITY_ATTR_END
				);

	send_pilot_joined_message (en);

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

	int
		side,
		index;

	if (get_comms_model () != COMMS_MODEL_SERVER)
	{

		return;
	}

	if (get_local_entity_int_value (en, INT_TYPE_AIRCRAFT_GROUP))
	{

		side = get_local_entity_int_value (en, INT_TYPE_SIDE);

		index = get_local_entity_int_value (en, INT_TYPE_GROUP_CALLSIGN);

		ASSERT (group_callsign_names [index].side [side] > 0);

		group_callsign_names [index].side [side] --;
	}
}
コード例 #10
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 ++;
	}
}
コード例 #11
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 ();
}
コード例 #12
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);
}
コード例 #13
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);
}
コード例 #14
0
ファイル: uisession.c プロジェクト: Comanche93/eech
void set_current_game_session (session_list_data_type *game_session)
{

	current_game_session = game_session;

	if (game_session)
	{

		if (get_comms_model () == COMMS_MODEL_SERVER)
		{

			//set_ui_object_drawable (session_screen_next_button_mask, FALSE);

			set_ui_object_drawable (session_screen_next_bdrop, TRUE);

			set_ui_object_drawable (session_screen_next_button, TRUE);

			// 15JUN09 Casm setting map information for saved games
			notify_session_parameters ();
			if (game_session->type == SESSION_LIST_TYPE_RESTORE)
			{
				set_ui_object_drawable (session_briefing_overlay, TRUE);
			}
		}
		else if (get_comms_model () == COMMS_MODEL_CLIENT)
		{
			set_ui_object_drawable (session_briefing_overlay, TRUE);
		}
	}
	else
	{

		//set_ui_object_drawable (session_screen_next_button_mask, TRUE);

		notify_clear_all_session_parameters ();

		set_ui_object_drawable (session_screen_next_bdrop, FALSE);

		set_ui_object_drawable (session_screen_next_button, FALSE);

		set_ui_object_drawable (session_screen_continue_button, FALSE); // Jabberwock 031118 Server side settings

		set_ui_object_drawable (session_screen_continue_bdrop, FALSE);

		set_ui_object_drawable (session_briefing_overlay, FALSE);
	}
}
コード例 #15
0
ファイル: soundeff.c プロジェクト: DexterWard/comanche
entity *create_client_server_sound_effect_entity
			(
				entity *parent,
				entity_sides side,
				entity_sub_types sub_type,
				sound_channel_types channel,
				sound_locality_types locality,
				vec3d *position,
				float amp,
				int valid,
				int looping,
				int sample_count,
				sound_sample_indices *sample_indices
			)
{
	entity
		*en;

	ASSERT (get_comms_model () == COMMS_MODEL_SERVER);

	ASSERT (side < NUM_ENTITY_SIDES);

	en = create_local_sound_effect_entity
	(
		ENTITY_INDEX_DONT_CARE,
		parent,
		side,
		sub_type,
		channel,
		locality,
		position,
		amp,
		valid,
		looping,
		sample_count,
		sample_indices
	);

	transmit_entity_comms_message
	(
		ENTITY_COMMS_CREATE_SOUND_EFFECT,
		NULL,
		get_local_entity_safe_index (en),
		parent,
		side,
		sub_type,
		channel,
		locality,
		position,
		amp,
		valid,
		looping,
		sample_count,
		sample_indices
	);

	return en;
}
コード例 #16
0
ファイル: pilot.c プロジェクト: Comanche93/eech
void set_pilot_entity (entity *en)
{
	comms_data_flow_types
		store_data_flow;

	if (en)
	{
		debug_log ("PILOT: Setting pilot_entity to %s", get_local_entity_string (en, STRING_TYPE_PILOTS_NAME));

		ASSERT (pilot_entity == NULL);

		ASSERT (get_local_entity_type (en) == ENTITY_TYPE_PILOT);
	
		pilot_entity = en;

		// turn on NEXT button now Pilot entity has arrived
		if (get_comms_model () == COMMS_MODEL_CLIENT)
		{

			set_display_gunship_buttons (FALSE, "ENGAGE");

			// turn on only the gunship_next button
			set_ui_object_drawable (gunship_screen_next_button, TRUE);
		}
		//-- Werewolf
		else
		{
			// If we're the server, remember our player name. This will be sent out in the heartbeat packets.
			net_set_hostname( get_local_entity_string (en, STRING_TYPE_PILOTS_NAME) );
		}
		//-- Werewolf
	}
	else if (pilot_entity)
	{
		debug_log ("PILOT: Setting pilot_entity to NULL");

		ASSERT (pilot_entity);

		//
		// Program MUST be in TX mode otherwise clients pilot will not be destroyed on the server
		//
		
		store_data_flow = get_comms_data_flow ();

		set_comms_data_flow (COMMS_DATA_FLOW_TX);

		destroy_client_server_entity (pilot_entity);

		set_comms_data_flow (store_data_flow);

		pilot_entity = NULL;
	}
}
コード例 #17
0
ファイル: soundeff.c プロジェクト: DexterWard/comanche
void pause_client_server_continuous_weapon_sound_effect (entity *en, entity_sub_types weapon_sub_type)
{
	ASSERT (en);

	ASSERT ((get_comms_model () == COMMS_MODEL_SERVER) || (en == get_gunship_entity ()));

	if (weapon_sub_type != ENTITY_SUB_TYPE_WEAPON_NO_WEAPON)
	{
		pause_local_continuous_weapon_sound_effect (en, weapon_sub_type);

		transmit_entity_comms_message (ENTITY_COMMS_PAUSE_WEAPON_SOUND_TYPE, en, weapon_sub_type);
	}
}
コード例 #18
0
ファイル: py_creat.c プロジェクト: DexterWard/comanche
void create_local_pylon_entities (pack_modes pack_mode)
{
	debug_assert (get_comms_model () == COMMS_MODEL_SERVER);

	if (pack_mode == PACK_MODE_BROWSE_SESSION)
	{
		return;
	}

	if (!load_local_pylon_entities ("utils"))
	{
		load_local_pylon_entities ("utildata");
	}
}
コード例 #19
0
ファイル: ac_msgs.c プロジェクト: Comanche93/eech
static int response_to_articulate_undercarriage (entity_messages message, entity *receiver, entity *sender, va_list pargs)
{
	vec3d
		*position;

	object_3d_instance
		*inst3d;

	sound_sample_indices
		sample_index;

	#if DEBUG_MODULE

	//debug_log_entity_message (message, receiver, sender, pargs);

	#endif

	ASSERT (get_comms_model () == COMMS_MODEL_SERVER);

	inst3d = (object_3d_instance *) get_local_entity_ptr_value (receiver, PTR_TYPE_INSTANCE_3D_OBJECT);

	if (inst3d)
	{
		if (object_contains_sub_object_type (inst3d, OBJECT_3D_SUB_OBJECT_UNDERCARRIAGE, 0, NULL))
		{
			position = get_local_entity_vec3d_ptr (receiver, VEC3D_TYPE_POSITION);

			sample_index = SOUND_SAMPLE_INDEX_UNDERCARRIAGE;

			create_client_server_sound_effect_entity
			(
				receiver,
				ENTITY_SIDE_NEUTRAL,
				ENTITY_SUB_TYPE_EFFECT_SOUND_MISC,
				SOUND_CHANNEL_SOUND_EFFECT,
				SOUND_LOCALITY_ALL,
				NULL, 											// position
				1.0,												// amplification
				1.0,												// Werewolf pitch
				TRUE,												// valid sound effect
				FALSE,											// looping
				1,													// sample count
				&sample_index									// sample index list
			);
		}
	}

	return (TRUE);
}
コード例 #20
0
ファイル: en_dbarg.c プロジェクト: DexterWard/comanche
static void debug_log_text (entity_debug_modes mode, entity *en, char *format, ...)
{
	va_list
		pargs;

	char
		s1[400],
		s2[400],
		*name;

	//
	// prefix
	//

	strcpy (s1, debug_log_comms_prefix[get_comms_model ()][get_comms_data_flow ()]);

	strcat (s1, debug_log_mode_prefix[mode]);

	//
	// entity type and index
	//

	if (en)
	{
		name = get_local_entity_type_name (en);
	}
	else
	{
		name = get_entity_type_name (ENTITY_TYPE_UNKNOWN);
	}

	sprintf (s2, "%-25.25s (index = %5d): ", name, get_local_entity_safe_index (en));

	strcat (s1, s2);

	//
	// args
	//

	va_start (pargs, format);

	vsprintf (s2, format, pargs);

	va_end (pargs);

	strcat (s1, s2);

	debug_log (s1);
}
コード例 #21
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);
}
コード例 #22
0
ファイル: hc_updt.c プロジェクト: DexterWard/comanche
void reset_interpolation_timer (void)
{

	connection_list_type
		*connection;

	if (get_comms_model () == COMMS_MODEL_CLIENT)
	{

		connection = get_connection_list_item (get_server_id ());

		if (connection)
		{

			connection->interpolation_time = get_system_time ();
		}
	}
}
コード例 #23
0
ファイル: en_valid.c プロジェクト: Comanche93/eech
int assert_remote_create_entity_index (int index)
{
	if (get_comms_model () == COMMS_MODEL_SERVER)
	{
		return (index != ENTITY_INDEX_DONT_CARE);
	}
	else
	{
		if (get_comms_data_flow () == COMMS_DATA_FLOW_TX)
		{
			return (index == ENTITY_INDEX_DONT_CARE);
		}
		else
		{
			return (FALSE);
		}
	}
}
コード例 #24
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);
	}
}
コード例 #25
0
ファイル: group.c プロジェクト: DexterWard/comanche
int assign_group_callsign (entity *en)
{

	int
		start_position,
		side,
		index;

	index = 0;

	if (get_comms_model () != COMMS_MODEL_SERVER)
	{

		return index;
	}

	if (get_local_entity_int_value (en, INT_TYPE_AIRCRAFT_GROUP))
	{

		index = get_local_entity_index (en) % NUM_GROUP_CALLSIGNS;

		start_position = index;

		side = get_local_entity_int_value (en, INT_TYPE_SIDE);

		while (group_callsign_names [index].side [side])
		{

			index = (++ index) % NUM_GROUP_CALLSIGNS;

			if (index == start_position)
			{

				debug_log ("GROUP: WARNING: reusing group callsign %s for group %s", group_callsign_names [index].callsign, get_local_entity_string (en, STRING_TYPE_FULL_NAME));

				break;
			}
		}

		group_callsign_names [index].side [side] ++;
	}

	return index;
}
コード例 #26
0
ファイル: wn_spch.c プロジェクト: DexterWard/comanche
void play_entity_weapon_selected_speech (entity *en, entity_sub_types weapon_type)
{
	int
		speech_index;

	entity_sides
		side;

	//
	// only play speech for players
	//

	ASSERT (get_comms_model () == COMMS_MODEL_SERVER);

	speech_index = weapon_database [weapon_type].weapon_selected_cpg_speech;

	if (speech_index != -1)
	{
		if (get_local_entity_int_value (en, INT_TYPE_PLAYER) != ENTITY_PLAYER_AI)
		{
			side = get_local_entity_int_value (en, INT_TYPE_SIDE);

			remove_speech_category_from_buffers (side, SPEECH_ORIGINATOR_CO_PILOT, SPEECH_CATEGORY_WEAPONS_SYSTEMS);

			play_client_server_speech
			(
				en,
				en,
				side,
				ENTITY_SUB_TYPE_EFFECT_SOUND_CPG_MESSAGE,
				SOUND_LOCALITY_RADIO,
				0.4,		// delay
				0.2,		// priority
				1.5,		// expire time
				SPEECH_ORIGINATOR_CO_PILOT,
				SPEECH_CATEGORY_WEAPONS_SYSTEMS,
				-1.0,		// category silence timer
				SPEECH_ARRAY_CPG_MESSAGES, speech_index,
				-1
			);
		}
	}
}
コード例 #27
0
ファイル: pilot.c プロジェクト: Comanche93/eech
void create_server_pilot (void)
{
	entity
		*en;
		
	ASSERT (get_comms_model () == COMMS_MODEL_SERVER);

	en = create_new_pilot_entity
				(
					get_player_log_name (get_current_player_log ()),
					get_global_gunship_side (),
					get_player_log_rank (get_global_gunship_side (), get_current_player_log ()),
					ENTITY_SUB_TYPE_PILOT_PILOT,
					direct_play_get_player_id (),
					get_global_difficulty_level ()
				);

	set_pilot_entity (en);
}
コード例 #28
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;
	}
}
コード例 #29
0
ファイル: division.c プロジェクト: Comanche93/eech
entity *create_new_division (entity_sub_types type, entity_sides side, entity *parent, entity *hq, int local_only)
{
	entity
		*new_entity;

	int
		id;

	ASSERT (get_comms_model () == COMMS_MODEL_SERVER);

	ASSERT (parent);

	id = get_next_free_division_id (side, type);

	if (local_only)
	{
		new_entity = create_local_entity
		(
			ENTITY_TYPE_DIVISION,
			ENTITY_INDEX_DONT_CARE,
			ENTITY_ATTR_PARENT (LIST_TYPE_DIVISION, parent),
			ENTITY_ATTR_PARENT (LIST_TYPE_DIVISION_HEADQUARTERS, hq),
			ENTITY_ATTR_INT_VALUE (INT_TYPE_ENTITY_SUB_TYPE, type),
			ENTITY_ATTR_INT_VALUE (INT_TYPE_DIVISION_ID, id),
			ENTITY_ATTR_END
		);
	}
	else
	{
		new_entity = create_client_server_entity
		(
			ENTITY_TYPE_DIVISION,
			ENTITY_INDEX_DONT_CARE,
			ENTITY_ATTR_PARENT (LIST_TYPE_DIVISION, parent),
			ENTITY_ATTR_PARENT (LIST_TYPE_DIVISION_HEADQUARTERS, hq),
			ENTITY_ATTR_INT_VALUE (INT_TYPE_ENTITY_SUB_TYPE, type),
			ENTITY_ATTR_INT_VALUE (INT_TYPE_DIVISION_ID, id),
			ENTITY_ATTR_END
		);
	}

	return new_entity;
}
コード例 #30
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;
}