Ejemplo n.º 1
0
static void destroy_server_family (entity *en)
{

	destroy_client_server_entity_children (en, LIST_TYPE_MEMBER);

	destroy_client_server_entity (en);
}
Ejemplo n.º 2
0
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);
}
Ejemplo n.º 3
0
static void destroy_server_family (entity *en)
{
	destroy_client_server_entity_children (en, LIST_TYPE_MOVEMENT_DEPENDENT);

	destroy_client_server_sound_effects (en);

	destroy_client_server_entity (en);
}
Ejemplo n.º 4
0
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;
	}
}
Ejemplo n.º 5
0
static void destroy_server_family (entity *en)
{

	destroy_client_server_entity_children (en, LIST_TYPE_KEYSITE_FORCE);

	destroy_client_server_entity_children (en, LIST_TYPE_PILOT);

	destroy_client_server_entity_children (en, LIST_TYPE_AIR_REGISTRY);
	destroy_client_server_entity_children (en, LIST_TYPE_GROUND_REGISTRY);
	destroy_client_server_entity_children (en, LIST_TYPE_SEA_REGISTRY);

	destroy_client_server_entity (en);
}
Ejemplo n.º 6
0
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);
}
Ejemplo n.º 7
0
entity *free_flight_auto_assign_gunship (void)
{
	vec3d
		*pos;

	entity
		*force,
		*new_task,
		*group,
		*member,
		**gunship_list,
		*en;

	entity_sub_types
		sub_type;

	int
		c,
		index,
		count;

	//
	// Auto assign a helicopter for free flight
	//

	ASSERT (get_comms_model () == COMMS_MODEL_SERVER);

	ASSERT (get_game_type () == GAME_TYPE_FREE_FLIGHT);

	ASSERT (get_pilot_entity ());

	if (get_gunship_entity ())
	{
		return NULL;
	}

	force = get_local_entity_parent (get_pilot_entity (), LIST_TYPE_PILOT);

	ASSERT (force);

	//
	// Count up candidates
	//

	count = 0;

	en = get_local_entity_first_child (force, LIST_TYPE_AIR_REGISTRY);

	while (en)
	{
		if (get_local_entity_int_value (en, INT_TYPE_GROUP_MODE) == GROUP_MODE_IDLE)
		{
			member = get_local_entity_first_child (en, LIST_TYPE_MEMBER);

			while (member)
			{
				sub_type = get_local_entity_int_value (member, INT_TYPE_ENTITY_SUB_TYPE);

				if ((sub_type == ENTITY_SUB_TYPE_AIRCRAFT_RAH66_COMANCHE) || (sub_type == ENTITY_SUB_TYPE_AIRCRAFT_KA52_HOKUM_B))
				{
					if (get_local_entity_suitable_for_player (member, get_pilot_entity ()))
					{
						count ++;
					}
				}

				member = get_local_entity_child_succ (member, LIST_TYPE_MEMBER);
			}
		}

		en = get_local_entity_child_succ (en, LIST_TYPE_AIR_REGISTRY);
	}

	if (count == 0)
	{
		return NULL;
	}

	//
	// Create list of candidates
	//

	gunship_list = safe_malloc (sizeof (entity *) * count);

	count = 0;

	en = get_local_entity_first_child (force, LIST_TYPE_AIR_REGISTRY);

	while (en)
	{
		if (get_local_entity_int_value (en, INT_TYPE_GROUP_MODE) == GROUP_MODE_IDLE)
		{
			member = get_local_entity_first_child (en, LIST_TYPE_MEMBER);

			while (member)
			{
				sub_type = get_local_entity_int_value (member, INT_TYPE_ENTITY_SUB_TYPE);

				if ((sub_type == ENTITY_SUB_TYPE_AIRCRAFT_RAH66_COMANCHE) || (sub_type == ENTITY_SUB_TYPE_AIRCRAFT_KA52_HOKUM_B))
				{
					if (get_local_entity_suitable_for_player (member, get_pilot_entity ()))
					{
						gunship_list [count] = member;

						count ++;
					}
				}

				member = get_local_entity_child_succ (member, LIST_TYPE_MEMBER);
			}
		}

		en = get_local_entity_child_succ (en, LIST_TYPE_AIR_REGISTRY);
	}

	//
	// Pick one...
	//

	ASSERT (count > 0);

	index = rand16 () % count;

	for (c = 0; c < count; c ++)
	{
		en = gunship_list [index];

		group = get_local_entity_parent (en, LIST_TYPE_MEMBER);

		pos = get_local_entity_vec3d_ptr (en, VEC3D_TYPE_POSITION);

		new_task = create_user_task (en, ENTITY_SUB_TYPE_TASK_FREE_FLIGHT, pos, NULL, NULL);

		set_assign_create_waypoint_route (FALSE);

		if (assign_primary_task_to_group (group, new_task))
		{
			set_gunship_entity (en);

			set_view_mode (VIEW_MODE_COCKPIT_PANEL_LEVEL_AHEAD);

			safe_free (gunship_list);

			initialise_free_flight_screen_map_page_objects ();

			return en;
		}
		else
		{
			debug_log ("FLIGHT: can't assign user to Created task");

			destroy_client_server_entity (new_task);
		}

		set_assign_create_waypoint_route (TRUE);

		index ++;

		if (index == count)
		{
			index = 0;
		}
	}

	safe_free (gunship_list);

	return NULL;
}
Ejemplo n.º 8
0
static void destroy_server_family (entity *en)
{
	destroy_client_server_sound_effects (en);

	destroy_client_server_entity (en);
}
Ejemplo n.º 9
0
static void destroy_server_family (entity *en)
{
	destroy_client_server_entity (en);
}
Ejemplo n.º 10
0
int assign_new_task_to_group_member (entity *group, entity *member, entity *task, entity *guide)
{
	entity
		*current_guide,
		*current_task;

	unsigned int
		member_number;

	ASSERT (group);

	ASSERT (member);

	ASSERT (task);

	ASSERT (get_comms_model () == COMMS_MODEL_SERVER);

	if (get_local_entity_int_value (task, INT_TYPE_ENTITY_SUB_TYPE) == ENTITY_SUB_TYPE_TASK_ENGAGE)
	{
		ASSERT (!guide);
	}
	else
	{
		ASSERT (guide);
	}

	member_number = (1 << get_local_entity_int_value (member, INT_TYPE_GROUP_MEMBER_NUMBER));

	//
	// check what task the member is currently doing
	//

	current_guide = get_local_entity_parent (member, LIST_TYPE_FOLLOWER);

	if (current_guide)
	{
		current_task = get_local_entity_parent (current_guide, LIST_TYPE_GUIDE);

		ASSERT (current_task);

		if (current_task == task)
		{
			//
			// member is already doing the task
			//
			
			return TRUE;
		}

		if (get_local_entity_int_value (current_task, INT_TYPE_ENTITY_SUB_TYPE) == ENTITY_SUB_TYPE_TASK_ENGAGE)
		{
			//
			// member is doing an ENGAGE task - destroy the guide clone....
			//

			ASSERT (get_local_entity_int_value (current_guide, INT_TYPE_VALID_GUIDE_MEMBERS) == member_number);

			//
			// ...UNLESS the task has been terminated, in which case the guide will be destroyed elsewhere
			//

			if (get_local_entity_int_value (current_task, INT_TYPE_TASK_TERMINATED) == TASK_TERMINATED_IN_PROGRESS)
			{
				destroy_client_server_entity (current_guide);
			}
		}
	}

	//
	// assign member to new task
	//

	if (guide)
	{
		assign_task_to_group_members (group, guide, member_number);
	}
	else
	{
		assign_task_to_group (group, task, member_number);
	}

	//
	// ensure member was actually assigned to a new task (not always the desired task - e.g. in the case of when aircraft need to takeoff first)
	//

	#ifdef DEBUG

	current_guide = get_local_entity_parent (member, LIST_TYPE_FOLLOWER);

	ASSERT (current_guide);

	current_task = get_local_entity_parent (current_guide, LIST_TYPE_GUIDE);

	ASSERT (current_task);

	#endif

	return TRUE;
}
Ejemplo n.º 11
0
void validate_connections (void)
{

	connection_list_type
		*destroy_connection,
		*this_connection;
	unsigned int
		timeout_limit;

	this_connection = connection_list_head;

	while (this_connection)
	{

		destroy_connection = this_connection;

		this_connection = this_connection->next;

		if (get_comms_model () == COMMS_MODEL_SERVER) // Jabberwock 040603 cvc turned off for clients
		{
			
			// added count_limit for connecting players
			if (destroy_connection->pilot_entity)
			{
				timeout_limit = command_line_comms_timeout;
			}
			else
			{
				timeout_limit = command_line_comms_timeout + 15;
			}
		
			if ((get_system_time () - destroy_connection->connection_validation_time) > timeout_limit * TIME_1_SECOND)
			{
				if (destroy_connection->validation_count > 2) // Jabberwock 040603 Three passes
				{
// Jabberwock 031107 MP bug search - this is where original crash occurs, but it's symptom, not the cause!
/*                                 	if (destroy_connection->pilot_entity)
					{
 					     entity
 						*gunship;
      						gunship = get_local_entity_parent (destroy_connection->pilot_entity, LIST_TYPE_AIRCREW);
	
						if (gunship)
						{
							set_client_server_entity_int_value (gunship, INT_TYPE_PLAYER, ENTITY_PLAYER_AI);
							debug_log ("SERVER: TIMEOUT: Resetting clients gunship to AI");
						}
*/
// below is the replacement code for the above: sets back the helo to AI - OK
					if (destroy_connection->gunship_entity)
					{
						set_client_server_entity_int_value (destroy_connection->gunship_entity, INT_TYPE_PLAYER, ENTITY_PLAYER_AI);
					}
// the original destroy pilot_entity - may cause invalid assignment? (random entity)
//					destroy_client_server_entity (destroy_connection->pilot_entity);
//					debug_log ("SERVER: TIMEOUT: destroying clients pilot entity");
//					}

					if (destroy_connection->pilot_entity)
					{
						server_log("%s removed by cvc", get_local_entity_string (destroy_connection->pilot_entity, STRING_TYPE_PILOTS_NAME));

						destroy_client_server_entity (destroy_connection->pilot_entity);

						destroy_connection->pilot_entity = NULL;
					}
					else
					{
						server_log("Unknown player removed");
					}

// Jabberwock 031108 - ends - seems to work!
					
					if (get_comms_model () == COMMS_MODEL_SERVER)
					{
						debug_log ("SERVER: TIMEOUT: Unregistering connection %d", destroy_connection->connection_id);
						free_connection_packets (destroy_connection->connection_id); // Jabberwock 040602 Maybe this will clear DP groups... 
						// Jabberwock 0312073 MP bug search - Not working - DP timeout kills the player first....

						//direct_play_remove_player_from_group (destroy_connection->connection_id);
						unregister_connection (destroy_connection->connection_id);
					}
					else
					{
						debug_log ("SERVER: TIMEOUT: Quitting game", destroy_connection->connection_id); // Jabberwock 040603 cvc removed for clients - DP will crash anyway...
						start_game_exit (GAME_EXIT_KICKOUT, FALSE);
					}
				}
				else
				{
					debug_log ("SERVER: sending %d CONNECTION_VALIDATION", destroy_connection->connection_id);

					send_packet (destroy_connection->connection_id, PACKET_TYPE_CONNECTION_VALIDATION, NULL, 0, SEND_TYPE_PERSONAL);

					destroy_connection->connection_validation_time = get_system_time (); // Jabberwock 040603 Restored

					destroy_connection->validation_count ++;
				}
			}
		}
	}
}