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

Function EBNode_RemoveEdge

editor/ebnode.cpp:605–655  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

603}
604
605void EBNode_RemoveEdge(int spnt, int sroom, int epnt, int eroom, bool f_remove_reverse) {
606 int i;
607
608 BNode_verified = false;
609
610 // Make sure there are no zero length paths
611 if (sroom == eroom && spnt == epnt) {
612 return;
613 }
614
615 bn_list *snlist;
616 snlist = BNode_GetBNListPtr(sroom);
617 bn_list *enlist;
618 enlist = BNode_GetBNListPtr(eroom);
619
620 if (!snlist)
621 return;
622
623 bool f_exists = false;
624 int e_index;
625
626 // Check to see if this edge already exists
627 for (i = 0; i < snlist->nodes[spnt].num_edges; i++) {
628 if (snlist->nodes[spnt].edges[i].end_index == epnt && snlist->nodes[spnt].edges[i].end_room == eroom) {
629 e_index = i;
630 f_exists = true;
631 break;
632 }
633 }
634
635 ASSERT(f_exists);
636
637 // Copy the edges down the list
638 for (i = e_index; i < snlist->nodes[spnt].num_edges - 1; i++) {
639 snlist->nodes[spnt].edges[i] = snlist->nodes[spnt].edges[i + 1];
640 }
641
642 snlist->nodes[spnt].num_edges--;
643
644 if (snlist->nodes[spnt].num_edges == 0) {
645 mem_free(snlist->nodes[spnt].edges);
646 snlist->nodes[spnt].edges = NULL;
647 } else {
648 snlist->nodes[spnt].edges =
649 (bn_edge *)mem_realloc(snlist->nodes[spnt].edges, sizeof(bn_edge) * snlist->nodes[spnt].num_edges);
650 }
651
652 if (f_remove_reverse && enlist) {
653 EBNode_RemoveEdge(epnt, eroom, spnt, sroom, false);
654 }
655}
656
657int EBNode_AddNode(int roomnum, vector *pnt, bool f_from_editor, bool f_check_for_close_nodes) {
658 bn_list *nlist;

Callers 5

OnAinDeleteEdgeMethod · 0.85
EBNode_VerifyGraphFunction · 0.85
EBNode_RemoveNodeFunction · 0.85
EBNode_InsertNodeOnEdgeFunction · 0.85
EBNode_MakeFirstPassFunction · 0.85

Calls 1

BNode_GetBNListPtrFunction · 0.85

Tested by

no test coverage detected