MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / InsertNodeIntoPath

Function InsertNodeIntoPath

editor/EPath.cpp:190–293  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

188int InsertNodeIntoPath(int pathnum, int nodenum, int flags)
189#else
190int InsertNodeIntoPath(int pathnum, int nodenum, int flags, int roomnum, vector pos, matrix orient)
191#endif
192{
193 int i;
194 vector attempted_pos;
195
196 fvi_query fq;
197 fvi_info hit_info;
198
199 if (Viewer_object->flags & OF_OUTSIDE_MINE) {
200 OutrageMessageBox("Error: Must be in mine or on terrain to insert a node.");
201 return -1;
202 }
203
204 if (GamePaths[pathnum].num_nodes >= MAX_NODES_PER_PATH) {
205 OutrageMessageBox("Error: Path already has its maximum amount of nodes.");
206 return -1;
207 }
208
209 // First, move all nodes up one
210 for (i = GamePaths[pathnum].num_nodes - 1; i > nodenum; i--) {
211 memcpy(&GamePaths[pathnum].pathnodes[i + 1], &GamePaths[pathnum].pathnodes[i], sizeof(node));
212 }
213
214#ifndef NEWEDITOR
215 attempted_pos = Viewer_object->pos; // + Viewer_object->orient.fvec * 10.0;
216#else
217 attempted_pos = pos; // + Viewer_object->orient.fvec * 10.0;
218#endif
219
220#ifndef NEWEDITOR
221 fq.p0 = &Viewer_object->pos;
222 fq.startroom = Viewer_object->roomnum;
223#else
224 fq.p0 = &pos;
225 fq.startroom = roomnum;
226#endif
227 fq.p1 = &attempted_pos;
228 fq.rad = 0.0f;
229 fq.thisobjnum = -1;
230 fq.ignore_obj_list = NULL;
231 fq.flags = FQ_TRANSPOINT | FQ_IGNORE_RENDER_THROUGH_PORTALS;
232
233 fvi_FindIntersection(&fq, &hit_info);
234
235 // Check if new node is valid
236 if (nodenum >= 0) {
237 fvi_query fq1;
238 fvi_info hit_info1;
239
240 fq1.p0 = &GamePaths[pathnum].pathnodes[nodenum].pos;
241 fq1.startroom = GamePaths[pathnum].pathnodes[nodenum].roomnum;
242 fq1.p1 = &hit_info.hit_pnt;
243 fq1.rad = 0.0f;
244 fq1.thisobjnum = -1;
245 fq1.ignore_obj_list = NULL;
246 fq1.flags = FQ_TRANSPOINT | FQ_IGNORE_RENDER_THROUGH_PORTALS;
247

Callers 2

OnPathpadAddPathMethod · 0.85
OnPathpadInsertNodeMethod · 0.85

Calls 3

OutrageMessageBoxFunction · 0.85
fvi_FindIntersectionFunction · 0.85
vm_VectorDistanceFunction · 0.50

Tested by

no test coverage detected