Add waypoint at location o, returns pointer of created wp
| 770 | |
| 771 | // Add waypoint at location o, returns pointer of created wp |
| 772 | node_s *CWaypointClass::AddWaypoint(vec o, bool connectwp) |
| 773 | { |
| 774 | short x, y; |
| 775 | int flags = 0; |
| 776 | if (S((int)o.x, (int)o.y)->tag) flags |= W_FL_INTAG; |
| 777 | |
| 778 | node_s *pNode = new node_s(o, flags, 0); |
| 779 | m_vLastCreatedWP = o; |
| 780 | |
| 781 | GetNodeIndexes(o, &x, &y); |
| 782 | |
| 783 | m_Waypoints[x][y].AddNode(pNode); |
| 784 | BotManager.AddWaypoint(pNode); |
| 785 | |
| 786 | m_iWaypointCount++; |
| 787 | |
| 788 | if (connectwp && m_bAutoPlacePaths) |
| 789 | { |
| 790 | // Connect new waypoint with other near waypoints. |
| 791 | |
| 792 | loopi(MAX_MAP_GRIDS) |
| 793 | { |
| 794 | loopj(MAX_MAP_GRIDS) |
| 795 | { |
| 796 | TLinkedList<node_s *>::node_s *p = m_Waypoints[i][j].GetFirst(); |
| 797 | |
| 798 | while(p) |
| 799 | { |
| 800 | if (p->Entry == pNode) |
| 801 | { |
| 802 | p = p->next; |
| 803 | continue; // skip the waypoint that was just added |
| 804 | } |
| 805 | |
| 806 | // check if the waypoint is reachable from the new one (one-way) |
| 807 | if (WPIsReachable(o, p->Entry->v_origin)) |
| 808 | AddPath(pNode, p->Entry); // Add a path from a to b |
| 809 | if (WPIsReachable(p->Entry->v_origin, pNode->v_origin)) |
| 810 | AddPath(p->Entry, pNode); // Add a path from b to a |
| 811 | |
| 812 | p = p->next; |
| 813 | } |
| 814 | } |
| 815 | } |
| 816 | } |
| 817 | |
| 818 | return pNode; |
| 819 | } |
| 820 | |
| 821 | void CWaypointClass::DeleteWaypoint(vec v_src) |
| 822 | { |
no test coverage detected