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); }
bool AddNav_Waypoint(char *Nav, char *WP_Path, int node, int flags) { // find an empty nav - should be the end int empty = -1; int i; if (node == 0) node = 1; for (i = 0; i < MAX_NAVPOINTS && empty == -1; i++) { if (Navs[i].flags == 0) empty = i; } if (empty == -1) // no empty navpoint slots return false; // Create the NavPoint struct NavPoint tnav; strcpy_s(tnav.m_NavName, Nav); tnav.flags = NP_WAYPOINT | flags; Assert(!(tnav.flags & NP_SHIP)); tnav.target_obj = find_matching_waypoint_list(WP_Path); tnav.waypoint_num = node; // copy it into it's location Navs[empty] = tnav; return true; }
void waypoint_find_unique_name(char *dest_name, int start_index) { Assert(dest_name != NULL); Assert(start_index >= 0); int index = start_index; waypoint_list *collision; do { sprintf(dest_name, "Waypoint path %d", index); index++; // valid name if no collision collision = find_matching_waypoint_list(dest_name); } while (collision != NULL); }
waypoint_list::waypoint_list(const char *name) { Assert(name != NULL); Assert(find_matching_waypoint_list(name) == NULL); strcpy_s(this->m_name, name); }
void autopilot_ai_waypoint_goal_fixup(ai_goal* aigp) { // this function sets wp_index properly; aigp->wp_list = find_matching_waypoint_list(aigp->target_name); }