| 120 | } |
| 121 | |
| 122 | int MovePathNodeToPos(int pathnum, int nodenum, vector *attempted_pos) { |
| 123 | fvi_query fq; |
| 124 | fvi_info hit_info; |
| 125 | |
| 126 | fq.p0 = &GamePaths[pathnum].pathnodes[nodenum].pos; |
| 127 | fq.startroom = GamePaths[pathnum].pathnodes[nodenum].roomnum; |
| 128 | fq.p1 = attempted_pos; |
| 129 | fq.rad = 0.0f; |
| 130 | fq.thisobjnum = -1; |
| 131 | fq.ignore_obj_list = NULL; |
| 132 | fq.flags = FQ_TRANSPOINT | FQ_IGNORE_RENDER_THROUGH_PORTALS; |
| 133 | |
| 134 | fvi_FindIntersection(&fq, &hit_info); |
| 135 | |
| 136 | // Check if new node is valid |
| 137 | if (nodenum >= 1) { |
| 138 | fvi_query fq1; |
| 139 | fvi_info hit_info1; |
| 140 | |
| 141 | fq1.p0 = &GamePaths[pathnum].pathnodes[nodenum - 1].pos; |
| 142 | fq1.startroom = GamePaths[pathnum].pathnodes[nodenum - 1].roomnum; |
| 143 | fq1.p1 = &hit_info.hit_pnt; |
| 144 | fq1.rad = 0.0f; |
| 145 | fq1.thisobjnum = -1; |
| 146 | fq1.ignore_obj_list = NULL; |
| 147 | fq1.flags = FQ_TRANSPOINT | FQ_IGNORE_RENDER_THROUGH_PORTALS; |
| 148 | |
| 149 | fvi_FindIntersection(&fq1, &hit_info1); |
| 150 | if (vm_VectorDistance(&hit_info.hit_pnt, &hit_info1.hit_pnt) > .005) { |
| 151 | OutrageMessageBox("Cannot move point. There is no line of sight from the previous node to the new position."); |
| 152 | return -1; |
| 153 | } |
| 154 | } |
| 155 | |
| 156 | // Check if new node is valid |
| 157 | if (nodenum < GamePaths[pathnum].num_nodes - 1) { |
| 158 | fvi_query fq1; |
| 159 | fvi_info hit_info1; |
| 160 | |
| 161 | fq1.p0 = &GamePaths[pathnum].pathnodes[nodenum + 1].pos; |
| 162 | fq1.startroom = GamePaths[pathnum].pathnodes[nodenum + 1].roomnum; |
| 163 | fq1.p1 = &hit_info.hit_pnt; |
| 164 | fq1.rad = 0.0f; |
| 165 | fq1.thisobjnum = -1; |
| 166 | fq1.ignore_obj_list = NULL; |
| 167 | fq1.flags = FQ_TRANSPOINT | FQ_IGNORE_RENDER_THROUGH_PORTALS; |
| 168 | |
| 169 | fvi_FindIntersection(&fq1, &hit_info1); |
| 170 | if (vm_VectorDistance(&hit_info.hit_pnt, &hit_info1.hit_pnt) > .005) { |
| 171 | OutrageMessageBox("Cannot move point. There is no line of sight from the next node to the new position."); |
| 172 | return -1; |
| 173 | } |
| 174 | } |
| 175 | |
| 176 | GamePaths[pathnum].pathnodes[nodenum].pos = hit_info.hit_pnt; |
| 177 | GamePaths[pathnum].pathnodes[nodenum].roomnum = hit_info.hit_room; |
| 178 | |
| 179 | return 0; |
no test coverage detected