| 655 | } |
| 656 | |
| 657 | int EBNode_AddNode(int roomnum, vector *pnt, bool f_from_editor, bool f_check_for_close_nodes) { |
| 658 | bn_list *nlist; |
| 659 | nlist = BNode_GetBNListPtr(roomnum); |
| 660 | if (!nlist) |
| 661 | return -1; |
| 662 | |
| 663 | BNode_verified = false; |
| 664 | |
| 665 | if (nlist->num_nodes >= MAX_BNODES_PER_ROOM) { |
| 666 | #ifndef NEWEDITOR |
| 667 | OutrageMessageBox("Too many BOA Nodes for this room/region.\nGet Chris if you need more nodes."); |
| 668 | #else |
| 669 | OutrageMessageBox("Too many BOA Nodes for this room/region."); |
| 670 | #endif |
| 671 | return -1; |
| 672 | } |
| 673 | |
| 674 | int i; |
| 675 | bool f_really_close_neighbor = false; |
| 676 | int new_node; |
| 677 | |
| 678 | if (f_check_for_close_nodes) { |
| 679 | for (i = 0; i < nlist->num_nodes; i++) { |
| 680 | float min_dist = 0.0f; |
| 681 | |
| 682 | if (f_check_for_close_nodes) { |
| 683 | min_dist = BNODE_VERY_CLOSE_DIST; |
| 684 | } |
| 685 | |
| 686 | if (vm_VectorDistance(&nlist->nodes[i].pos, pnt) <= min_dist) { |
| 687 | f_really_close_neighbor = true; |
| 688 | break; |
| 689 | } |
| 690 | } |
| 691 | |
| 692 | if (f_really_close_neighbor) { |
| 693 | if (f_from_editor) { |
| 694 | #ifndef NEWEDITOR |
| 695 | OutrageMessageBox( |
| 696 | "This node is really close to another one and isn't needed.\nSee Chris if this is a problem."); |
| 697 | #else |
| 698 | OutrageMessageBox("This node is really close to another one and isn't needed."); |
| 699 | #endif |
| 700 | } |
| 701 | |
| 702 | return -1; |
| 703 | } |
| 704 | } |
| 705 | // Makes sure that if there are no nodes, then the node pointer is NULL and that if |
| 706 | // there are nodes that the node pointer isn't NULL |
| 707 | ASSERT(!((nlist->num_nodes == 0) ^ (nlist->nodes == NULL))); |
| 708 | |
| 709 | new_node = nlist->num_nodes; |
| 710 | nlist->num_nodes++; |
| 711 | |
| 712 | if (new_node != 0) |
| 713 | nlist->nodes = (bn_node *)mem_realloc(nlist->nodes, sizeof(bn_node) * (nlist->num_nodes)); |
| 714 | else |
no test coverage detected