本文整理汇总了C++中SCP_list类的典型用法代码示例。如果您正苦于以下问题:C++ SCP_list类的具体用法?C++ SCP_list怎么用?C++ SCP_list使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SCP_list类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: jumpnode_render_all
/**
* 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: Assert
// 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: Assert
/**
* 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: find_index_of_waypoint_list
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;
}
示例5: waypoint_create_game_objects
// 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++;
}
}
示例6:
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;
}
示例7: waypoint_remove
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);
}
示例8: waypoint_add_list
void waypoint_add_list(const char *name, SCP_vector<vec3d> &vec_list)
{
Assert(name != NULL);
if (find_matching_waypoint_list(name) != NULL)
{
Warning(LOCATION, "Waypoint list '%s' already exists in this mission! Not adding the new list...", name);
return;
}
waypoint_list new_list(name);
Waypoint_lists.push_back(new_list);
waypoint_list *wp_list = &Waypoint_lists.back();
wp_list->get_waypoints().reserve(vec_list.size());
SCP_vector<vec3d>::iterator ii;
for (ii = vec_list.begin(); ii != vec_list.end(); ++ii)
{
waypoint new_waypoint(&(*ii), wp_list);
wp_list->get_waypoints().push_back(new_waypoint);
}
// so that masking in the other function works
// though if you actually hit this Assert, you have other problems
Assert(wp_list->get_waypoints().size() <= 0xffff);
}
示例9: XSTR
/**
* Constructor for CJumpNode class, with world position argument
*/
CJumpNode::CJumpNode(vec3d *position) : m_radius(0.0f), m_modelnum(-1), m_objnum(-1), m_flags(0)
{
Assert(position != NULL);
gr_init_alphacolor(&m_display_color, 0, 255, 0, 255);
// Set m_name
sprintf(m_name, XSTR( "Jump Node %d", 632), Jump_nodes.size());
// Set m_modelnum and m_radius
m_modelnum = model_load(NOX("subspacenode.pof"), 0, NULL, 0);
if (m_modelnum == -1)
Warning(LOCATION, "Could not load default model for %s", m_name);
else
m_radius = model_get_radius(m_modelnum);
m_pos.xyz.x = position->xyz.x;
m_pos.xyz.y = position->xyz.y;
m_pos.xyz.z = position->xyz.z;
// Create the object
m_objnum = obj_create(OBJ_JUMP_NODE, -1, -1, NULL, &m_pos, m_radius, OF_RENDERS);
}
示例10: waypoint_add
int waypoint_add(vec3d *pos, int waypoint_instance)
{
Assert(pos != NULL);
waypoint_list *wp_list;
waypoint *wpt;
int i, wp_list_index, wp_index;
// find a new list to start
if (waypoint_instance < 0)
{
// get a name for it
char buf[NAME_LENGTH];
waypoint_find_unique_name(buf, Waypoint_lists.size() + 1);
// add new list with that name
waypoint_list new_list(buf);
Waypoint_lists.push_back(new_list);
wp_list = &Waypoint_lists.back();
// set up references
wp_list_index = Waypoint_lists.size() - 1;
wp_index = wp_list->get_waypoints().size();
}
// create the waypoint on the same list as, and immediately after, waypoint_instance
else
{
calc_waypoint_indexes(waypoint_instance, wp_list_index, wp_index);
wp_list = find_waypoint_list_at_index(wp_list_index);
// theoretically waypoint_instance points to a current waypoint, so advance past it
wp_index++;
// it has to be on, or at the end of, an existing list
Assert(wp_list != NULL);
Assert((uint) wp_index <= wp_list->get_waypoints().size());
// iterate through all waypoints that are at this index or later,
// and edit their instances so that they point to a waypoint one place higher
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) == wp_list_index) && (calc_waypoint_index(objp->instance) >= wp_index))
objp->instance++;
}
}
// so that masking in the other function works
// (though if you actually hit this Assert, you have other problems)
Assert(wp_index < 0x10000);
// create the waypoint object
waypoint new_waypoint(pos, wp_list);
// add it at its appropriate spot, which may be the end of the list
SCP_vector<waypoint>::iterator ii = wp_list->get_waypoints().begin();
for (i = 0; i < wp_index; i++)
++ii;
wp_list->get_waypoints().insert(ii, new_waypoint);
wpt = find_waypoint_at_index(wp_list, wp_index);
// apparently we create it in-game too; this is called by both scripting and FRED
waypoint_create_game_object(wpt, wp_list_index, wp_index);
return wpt->get_objnum();
}
示例11: waypoint_level_close
void waypoint_level_close()
{
Waypoint_lists.clear();
}
示例12: waypoint_parse_init
//********************FUNCTIONS********************
void waypoint_parse_init()
{
Waypoint_lists.clear();
}
示例13: jumpnode_level_close
/**
* Level cleanup
*/
void jumpnode_level_close()
{
Jump_nodes.clear();
}