예제 #1
0
/**
 * Render all function
 *
 * @note Only called by FRED
 */
void jumpnode_render_all()
{
	SCP_list<CJumpNode>::iterator jnp;
	
	for (jnp = Jump_nodes.begin(); jnp != Jump_nodes.end(); ++jnp) {	
		jnp->Render(&jnp->GetSCPObject()->pos);
	}
}
예제 #2
0
// NOTE: waypoint names are always in the format Name:index
waypoint *find_matching_waypoint(const char *name)
{
	Assert(name != NULL);
	SCP_list<waypoint_list>::iterator ii;

	for (ii = Waypoint_lists.begin(); ii != Waypoint_lists.end(); ++ii)
	{
		uint len = strlen(ii->get_name());

		// the first half (before the :) matches
		if (!strnicmp(ii->get_name(), name, len))
		{
			// this is ok because it could be "Waypoint path 1" vs. "Waypoint path 10"
			if (*(name + len) != ':')
				continue;

			// skip over the : to inspect a new string holding only the index
			const char *index_str = name + len + 1;
			if (*index_str == '\0')
			{
				nprintf(("waypoints", "possible error with waypoint name '%s': no waypoint number after the colon\n", name));
				continue;
			}

			// make sure it's actually a number
			bool valid = true;
			for (const char *ch = index_str; *ch != '\0'; ch++)
			{
				if (!isdigit(*ch))
				{
					valid = false;
					break;
				}
			}
			if (!valid)
			{
				nprintf(("waypoints", "possible error with waypoint name '%s': string after the colon is not a number\n", name));
				continue;
			}

			// get the number and make sure it's in range
			uint index = atoi(index_str);
			if (index < 1 || index > ii->get_waypoints().size())
			{
				nprintf(("waypoints", "possible error with waypoint name '%s': waypoint number is out of range\n", name));
				continue;
			}

			return find_waypoint_at_index(&(*ii), index - 1);
		}
	}

	return NULL;
}
예제 #3
0
/**
 * Get jump node by given name
 *
 * @param name Name of jump node
 * @return Jump node object
 */
CJumpNode *jumpnode_get_by_name(const char* name)
{
	Assert(name != NULL);
	SCP_list<CJumpNode>::iterator jnp;

	for (jnp = Jump_nodes.begin(); jnp != Jump_nodes.end(); ++jnp) {	
		if(!stricmp(jnp->GetName(), name)) 
			return &(*jnp);
	}

	return NULL;
}
예제 #4
0
waypoint_list *find_matching_waypoint_list(const char *name)
{
	Assert(name != NULL);
	SCP_list<waypoint_list>::iterator ii;

	for (ii = Waypoint_lists.begin(); ii != Waypoint_lists.end(); ++ii)
	{
		if (!stricmp(ii->get_name(), name))
			return &(*ii);
	}

	return NULL;
}
예제 #5
0
int find_index_of_waypoint_list(waypoint_list *wp_list)
{
	Assert(wp_list != NULL);
	SCP_list<waypoint_list>::iterator ii;

	int index = 0;
	for (ii = Waypoint_lists.begin(); ii != Waypoint_lists.end(); ++ii)
	{
		if (&(*ii) == wp_list)
			return index;
		index++;
	}

	return -1;
}
예제 #6
0
waypoint_list *find_waypoint_list_at_index(int index)
{
	Assert(index >= 0);

	int i = 0;
	SCP_list<waypoint_list>::iterator ii;

	for (ii = Waypoint_lists.begin(); ii != Waypoint_lists.end(); ++i, ++ii)
	{
		if (i == index)
			return &(*ii);
	}

	return NULL;
}
예제 #7
0
// done immediately after mission load; originally found in aicode.cpp
void waypoint_create_game_objects()
{
	SCP_list<waypoint_list>::iterator ii;
	SCP_vector<waypoint>::iterator jj;

	int list = 0;
	for (ii = Waypoint_lists.begin(); ii != Waypoint_lists.end(); ++ii)
	{
		int wpt = 0;
		for (jj = ii->get_waypoints().begin(); jj != ii->get_waypoints().end(); ++jj)
		{
			waypoint_create_game_object(&(*jj), list, wpt);
			wpt++;
		}
		list++;
	}
}
예제 #8
0
waypoint *find_waypoint_with_objnum(int objnum)
{
	if (objnum < 0 || Objects[objnum].type != OBJ_WAYPOINT)
		return NULL;

	SCP_list<waypoint_list>::iterator ii;
	SCP_vector<waypoint>::iterator jj;

	for (ii = Waypoint_lists.begin(); ii != Waypoint_lists.end(); ++ii)
	{
		for (jj = ii->get_waypoints().begin(); jj != ii->get_waypoints().end(); ++jj)
		{
			if (jj->get_objnum() == objnum)
				return &(*jj);
		}
	}

	return NULL;
}
예제 #9
0
/**
 * Given an object, returns which jump node it's inside (if any)
 *
 * @param objp Object
 * @return Jump node object or NULL if not in one
 */
CJumpNode *jumpnode_get_which_in(object *objp)
{
	Assert(objp != NULL);
	SCP_list<CJumpNode>::iterator jnp;
	float radius, dist;

	for (jnp = Jump_nodes.begin(); jnp != Jump_nodes.end(); ++jnp) {
		if(jnp->GetModelNumber() < 0)
			continue;

		radius = model_get_radius( jnp->GetModelNumber() );
		dist = vm_vec_dist( &objp->pos, &jnp->GetSCPObject()->pos );
		if ( dist <= radius ) {
			return &(*jnp);
		}
	}

	return NULL;
}
예제 #10
0
void waypoint_remove(waypoint *wpt)
{
	int objnum = wpt->get_objnum();
	waypoint_list *wp_list = wpt->get_parent_list();

	int this_list = calc_waypoint_list_index(Objects[objnum].instance);
	int this_index = calc_waypoint_index(Objects[objnum].instance);

	// special case... this is the only waypoint on its list
	if (wp_list->get_waypoints().size() == 1)
	{
		wp_list->get_waypoints().clear();

		// special special case... this is the only waypoint list!
		if (Waypoint_lists.size() == 1)
		{
			Waypoint_lists.clear();
		}
		// shift the other waypoint lists down
		else
		{
			// remove this particular waypoint list
			SCP_list<waypoint_list>::iterator ii;
			int i;
			for (i = 0, ii = Waypoint_lists.begin(); ii != Waypoint_lists.end(); ++i, ++ii)
			{
				if (i == this_list)
				{
					Waypoint_lists.erase(ii);
					break;
				}
			}
			Assert(ii != Waypoint_lists.end());

			// iterate through all waypoints that are in lists later than this one,
			// and edit their instances so that they point to a list one place lower
			for (object *objp = GET_FIRST(&obj_used_list); objp != END_OF_LIST(&obj_used_list); objp = GET_NEXT(objp))
			{
				if ((objp->type == OBJ_WAYPOINT) && (calc_waypoint_list_index(objp->instance) > this_list))
					objp->instance -= 0x10000;
			}
		}
	}
	// shift the other waypoints down
	else
	{
		// remove this particular waypoint
		SCP_vector<waypoint>::iterator ii;
		int i;
		for (i = 0, ii = wp_list->get_waypoints().begin(); ii != wp_list->get_waypoints().end(); ++i, ++ii)
		{
			if (i == this_index)
			{
				wp_list->get_waypoints().erase(ii);
				break;
			}
		}
		Assert(ii != wp_list->get_waypoints().end());

		// iterate through all waypoints that are later than this one,
		// and edit their instances so that they point to a waypoint one place lower
		for (object *objp = GET_FIRST(&obj_used_list); objp != END_OF_LIST(&obj_used_list); objp = GET_NEXT(objp))
		{
			if ((objp->type == OBJ_WAYPOINT) && (calc_waypoint_list_index(objp->instance) == this_list) && (calc_waypoint_index(objp->instance) > this_index))
				objp->instance--;
		}
	}

	// FRED has its own object removal logic
	if (!Fred_running)
		obj_delete(objnum);
}