| 1 | /* |
| 2 | * Descent 3 |
| 3 | * Copyright (C) 2024 Parallax Software |
| 4 | * |
| 5 | * This program is free software: you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation, either version 3 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 | */ |
| 18 | |
| 19 | #include "aipath.h"cxx . . $ `<file>/Descent3/aipath.h`/ |
| 20 | #include "gamepath.h"cxx . . $ `<file>/Descent3/gamepath.h`/ |
| 21 | #include "AIGoal.h"cxx . . $ `<file>/Descent3/AIGoal.h`/ |
| 22 | #include "BOA.h"cxx . . $ `<file>/Descent3/BOA.h`/ |
| 23 | #include "AIMain.h"cxx . . $ `<file>/Descent3/AIMain.h`/ |
| 24 | #include "object.h"cxx . . $ `<file>/Descent3/object.h`/ |
| 25 | #include "objinfo.h"cxx . . $ `<file>/Descent3/objinfo.h`/ |
| 26 | #include "memory.h" |
| 27 | #include "doorway.h"cxx . . $ `<file>/Descent3/doorway.h`/ |
| 28 | #include "aistruct.h"cxx . . $ `<file>/Descent3/aistruct.h`/ |
| 29 | #include "terrain.h"cxx . . $ `<file>/Descent3/terrain.h`/ |
| 30 | #include "psrand.h"cxx . . $ `<file>/misc/psrand.h`/ |
| 31 | #include "findintersection.h"cxx . . $ `<file>/physics/findintersection.h`/ |
| 32 | |
| 33 | #define MAX_DYNAMIC_PATHScxx . . $ `Descent3/aipath.cpp:33:9`! 50 |
| 34 | #define MAX_NODEScxx . . $ `Descent3/aipath.cpp:34:9`! 50 |
| 35 | |
| 36 | ai_dynamic_pathcxx . . $ ai_dynamic_path# AIDynamicPathcxx . . $ AIDynamicPath.[MAX_DYNAMIC_PATHScxx . . $ `Descent3/aipath.cpp:33:9`!]; |
| 37 | int AIAltPathcxx . . $ AIAltPath.[MAX_ROOMScxx . . $ `Descent3/room.h:377:9`!]; |
| 38 | int AIAltPathNumNodescxx . . $ AIAltPathNumNodes.; |
| 39 | |
| 40 | static void AIUpdatePathInfocxx . . $ AIUpdatePathInfo(9761af3f47d3a154).(q_itemcxx . . $ q_item# **node_list, int start, int end) { |
| 41 | int cur_room = end; |
| 42 | int i; |
| 43 | |
| 44 | AIAltPathNumNodescxx . . $ AIAltPathNumNodes. = 0; |
| 45 | |
| 46 | // mprintf(0, "start crash loop\n"); |
| 47 | while (cur_room != -1) { |
| 48 | AIAltPathcxx . . $ AIAltPath.[AIAltPathNumNodescxx . . $ AIAltPathNumNodes.++] = cur_room; |
| 49 | cur_room = node_list[cur_room]->parentcxx . . $ q_item#parent.; |
| 50 | } |
| 51 | // mprintf(0, "end crash loop\n"); |
| 52 | |
| 53 | // Reverse the list (so it is what we want) |
| 54 | for (i = 0; i < (AIAltPathNumNodescxx . . $ AIAltPathNumNodes. >> 1); i++) { |
| 55 | int temp; |
| 56 | |
| 57 | temp = AIAltPathcxx . . $ AIAltPath.[i]; |
| 58 | AIAltPathcxx . . $ AIAltPath.[i] = AIAltPathcxx . . $ AIAltPath.[AIAltPathNumNodescxx . . $ AIAltPathNumNodes. - i - 1]; |
| 59 | AIAltPathcxx . . $ AIAltPath.[AIAltPathNumNodescxx . . $ AIAltPathNumNodes. - i - 1] = temp; |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | // Ok to use Highest_room_index offset stuff |
| 64 | bool AIFindAltPathcxx . . $ AIFindAltPath(4c063a45e14c3cfe).(objectcxx . . $ object# *obj, int i, int j, float *dist) { |
| 65 | i = BOA_INDEXcxx . . $ `Descent3/BOA.h:197:9`!(i); |
| 66 | j = BOA_INDEXcxx . . $ `Descent3/BOA.h:197:9`!(j); |
| 67 | |
| 68 | pqcxx . . $ pq# PQPathcxx . . $ pq#pq(49f6e7a06ebc5aa8).; |
| 69 | int counter; |
| 70 | q_itemcxx . . $ q_item# *start_node = new q_itemcxx . . $ q_item#(i, -1, 0.0f); |
| 71 | q_itemcxx . . $ q_item# *cur_node; |
| 72 | bool f_found = false; |
| 73 | |
| 74 | q_itemcxx . . $ q_item# *node_list[MAX_ROOMScxx . . $ `Descent3/room.h:377:9`! + 8]; |
| 75 | |
| 76 | // mprintf(0, "AI: Finding an alternate path from %d to %d\n", i, j); |
| 77 | |
| 78 | if (i == -1 || j == -1) { |
| 79 | delete start_node; |
| 80 | return false; |
| 81 | } |
| 82 | |
| 83 | memset(node_list, 0, sizeof(q_itemcxx . . $ q_item# *) * (MAX_ROOMScxx . . $ `Descent3/room.h:377:9`! + 8)); |
| 84 | |
| 85 | PQPath.pushcxx . . $ pq#push(240407348a0b1927).(start_node); |
| 86 | |
| 87 | while ((cur_node = PQPath.popcxx . . $ pq#pop(df628bf610f7b0b3).())) { |
| 88 | node_list[BOA_INDEXcxx . . $ `Descent3/BOA.h:197:9`!(cur_node->roomnum)] = cur_node; |
| 89 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(BOA_INDEXcxx . . $ `Descent3/BOA.h:197:9`!(cur_node->roomnum) >= 0 && BOA_INDEXcxx . . $ `Descent3/BOA.h:197:9`!(cur_node->roomnum) <= Highest_room_index + 8); |
| 90 | |
| 91 | if (cur_node->roomnumcxx . . $ q_item#roomnum. == j) { |
| 92 | AIUpdatePathInfocxx . . $ AIUpdatePathInfo(9761af3f47d3a154).(node_list, i, j); |
| 93 | f_found = true; |
| 94 | goto done; |
| 95 | } |
| 96 | |
| 97 | int num_portals; |
| 98 | bool f_room = true; |
| 99 | int t_index; |
| 100 | |
| 101 | if (cur_node->roomnumcxx . . $ q_item#roomnum. <= Highest_room_indexcxx . . $ Highest_room_index.) { |
| 102 | num_portals = Roomscxx . . $ Rooms.[cur_node->roomnumcxx . . $ q_item#roomnum.].num_portalscxx . . $ room#num_portals.; |
| 103 | } else { |
| 104 | t_index = cur_node->roomnumcxx . . $ q_item#roomnum. - Highest_room_indexcxx . . $ Highest_room_index. - 1; |
| 105 | num_portals = BOA_num_connectcxx . . $ BOA_num_connect.[t_index]; |
| 106 | f_room = false; |
| 107 | } |
| 108 | |
| 109 | for (counter = 0; counter < num_portals; counter++) { |
| 110 | int next_room; |
| 111 | q_itemcxx . . $ q_item# *list_item; |
| 112 | float new_cost; |
| 113 | |
| 114 | if (!BOA_PassablePortalcxx . . $ BOA_PassablePortal(1c87feb9d04b51db).(cur_node->roomnumcxx . . $ q_item#roomnum., counter, false, false)) |
| 115 | continue; |
| 116 | |
| 117 | if (f_room) |
| 118 | next_room = Roomscxx . . $ Rooms.[cur_node->roomnumcxx . . $ q_item#roomnum.].portalscxx . . $ room#portals.[counter].croomcxx . . $ portal#croom.; |
| 119 | else |
| 120 | next_room = BOA_connectcxx . . $ BOA_connect.[t_index][counter].roomnumcxx . . $ connect_data#roomnum.; |
| 121 | |
| 122 | if (next_room <= Highest_room_indexcxx . . $ Highest_room_index. && Roomscxx . . $ Rooms.[next_room].flagscxx . . $ room#flags. & RF_EXTERNALcxx . . $ `Descent3/room_external.h:177:9`!) { |
| 123 | int next_portal; |
| 124 | next_portal = BOA_DetermineStartRoomPortalcxx . . $ BOA_DetermineStartRoomPortal(836cef11f1e7b2ee).(BOA_INDEXcxx . . $ `Descent3/BOA.h:197:9`!(next_room), NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, BOA_INDEXcxx . . $ `Descent3/BOA.h:197:9`!(cur_node->roomnum), NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!); |
| 125 | |
| 126 | int cell = GetTerrainCellFromPoscxx . . $ GetTerrainCellFromPos(177d9005acf670a0).(&Roomscxx . . $ Rooms.[next_room].portalscxx . . $ room#portals.[next_portal].path_pntcxx . . $ portal#path_pnt.); |
| 127 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(cell != -1); // DAJ -1FIX |
| 128 | next_room = Highest_room_indexcxx . . $ Highest_room_index. + TERRAIN_REGIONcxx . . $ TERRAIN_REGION(7864480464b09eea).(cell) + 1; |
| 129 | } |
| 130 | |
| 131 | if (next_room < 0 || next_room == BOA_NO_PATHcxx . . $ `Descent3/BOA.h:198:9`!) |
| 132 | continue; |
| 133 | |
| 134 | if (BOA_LockedDoorcxx . . $ BOA_LockedDoor(9985ed114f2bfc78).(obj, next_room)) |
| 135 | continue; |
| 136 | |
| 137 | int next_portal = 0; |
| 138 | |
| 139 | if (BOA_INDEXcxx . . $ `Descent3/BOA.h:197:9`!(next_room) != BOA_INDEXcxx . . $ `Descent3/BOA.h:197:9`!(cur_node->roomnum)) { |
| 140 | next_portal = BOA_DetermineStartRoomPortalcxx . . $ BOA_DetermineStartRoomPortal(836cef11f1e7b2ee).(BOA_INDEXcxx . . $ `Descent3/BOA.h:197:9`!(next_room), NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, BOA_INDEXcxx . . $ `Descent3/BOA.h:197:9`!(cur_node->roomnum), NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, |
| 141 | false, false, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!); |
| 142 | } |
| 143 | |
| 144 | if (next_portal == -1) |
| 145 | continue; |
| 146 | |
| 147 | if (BOA_cost_arraycxx . . $ BOA_cost_array.[cur_node->roomnumcxx . . $ q_item#roomnum.][counter] >= 0.0f) |
| 148 | new_cost = cur_node->costcxx . . $ q_item#cost. + |
| 149 | (1.0f + 0.1f * ((float)ps_randcxx . . $ ps_rand(b126dc7c1de90089).() - (float)D3_RAND_MAXcxx . . $ `misc/psrand.h:41:9`! / 2.0f) / ((float)D3_RAND_MAXcxx . . $ `misc/psrand.h:41:9`! / 2.0f)) * |
| 150 | (BOA_cost_arraycxx . . $ BOA_cost_array.[cur_node->roomnumcxx . . $ q_item#roomnum.][counter] + BOA_cost_arraycxx . . $ BOA_cost_array.[BOA_INDEXcxx . . $ `Descent3/BOA.h:197:9`!(next_room)][next_portal]); |
| 151 | else |
| 152 | continue; |
| 153 | |
| 154 | // new_cost = cur_node->cost + BOA_cost_array[cur_node->roomnum][counter]; |
| 155 | list_item = node_list[BOA_INDEXcxx . . $ `Descent3/BOA.h:197:9`!(next_room)]; |
| 156 | |
| 157 | if (list_item != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! && list_item->costcxx . . $ q_item#cost. < new_cost) |
| 158 | continue; |
| 159 | |
| 160 | if (list_item == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) { |
| 161 | list_item = new q_itemcxx . . $ q_item#(BOA_INDEXcxx . . $ `Descent3/BOA.h:197:9`!(next_room), cur_node->roomnumcxx . . $ q_item#roomnum., new_cost); |
| 162 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(BOA_INDEXcxx . . $ `Descent3/BOA.h:197:9`!(cur_node->roomnum) >= 0 && BOA_INDEXcxx . . $ `Descent3/BOA.h:197:9`!(cur_node->roomnum) <= Highest_room_index + 8); |
| 163 | |
| 164 | node_list[BOA_INDEXcxx . . $ `Descent3/BOA.h:197:9`!(next_room)] = list_item; |
| 165 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(BOA_INDEXcxx . . $ `Descent3/BOA.h:197:9`!(next_room) >= 0 && BOA_INDEXcxx . . $ `Descent3/BOA.h:197:9`!(next_room) <= Highest_room_index + 8); |
| 166 | PQPath.pushcxx . . $ pq#push(240407348a0b1927).(list_item); |
| 167 | } else { |
| 168 | list_item->costcxx . . $ q_item#cost. = new_cost; |
| 169 | list_item->parentcxx . . $ q_item#parent. = cur_node->roomnumcxx . . $ q_item#roomnum.; |
| 170 | } |
| 171 | } |
| 172 | } |
| 173 | |
| 174 | // Mark as an impossible path. |
| 175 | |
| 176 | // mprintf(0, "Found an impossible path\n"); |
| 177 | |
| 178 | done: |
| 179 | for (counter = 0; counter < MAX_ROOMScxx . . $ `Descent3/room.h:377:9`! + 8; counter++) { |
| 180 | if (node_list[counter]) |
| 181 | delete node_list[counter]; |
| 182 | } |
| 183 | |
| 184 | if (f_found && dist) { |
| 185 | *dist = 0.0f; |
| 186 | |
| 187 | if (AIAltPathNumNodescxx . . $ AIAltPathNumNodes. > 1) { |
| 188 | int x; |
| 189 | |
| 190 | for (x = 0; x < AIAltPathNumNodescxx . . $ AIAltPathNumNodes. - 1; x++) { |
| 191 | int cur_room = AIAltPathcxx . . $ AIAltPath.[x]; |
| 192 | int next_room = AIAltPathcxx . . $ AIAltPath.[x + 1]; |
| 193 | |
| 194 | int cur_portal = BOA_DetermineStartRoomPortalcxx . . $ BOA_DetermineStartRoomPortal(836cef11f1e7b2ee).(cur_room, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, next_room, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!); |
| 195 | int next_portal = BOA_DetermineStartRoomPortalcxx . . $ BOA_DetermineStartRoomPortal(836cef11f1e7b2ee).(next_room, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, cur_room, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!); |
| 196 | |
| 197 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(cur_portal != -1 && next_portal != -1); |
| 198 | |
| 199 | *dist += BOA_cost_arraycxx . . $ BOA_cost_array.[cur_room][cur_portal] + BOA_cost_arraycxx . . $ BOA_cost_array.[next_room][next_portal]; |
| 200 | } |
| 201 | } |
| 202 | } |
| 203 | |
| 204 | // mprintf(0, "Done\n"); |
| 205 | return f_found; |
| 206 | } |
| 207 | |
| 208 | bool AIPathGetCurrentNodePoscxx . . $ AIPathGetCurrentNodePos(ea4bd046b9d29bc1).(ai_path_infocxx . . $ ai_path_info# *aip, vectorcxx . . $ vector# *pos, int *room) { |
| 209 | int c_path = aip->cur_pathcxx . . $ ai_path_info#cur_path.; |
| 210 | int c_node = aip->cur_nodecxx . . $ ai_path_info#cur_node.; |
| 211 | |
| 212 | int p_type = aip->path_typecxx . . $ ai_path_info#path_type.[c_path]; |
| 213 | int p_index = aip->path_idcxx . . $ ai_path_info#path_id.[c_path]; |
| 214 | |
| 215 | if (p_type == AIP_DYNAMICcxx . . $ `Descent3/aistruct.h:484:9`!) { |
| 216 | // chrishack -- add asserts |
| 217 | |
| 218 | *pos =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). AIDynamicPathcxx . . $ AIDynamicPath.[p_index].poscxx . . $ ai_dynamic_path#pos.[c_node]; |
| 219 | if (room) { |
| 220 | *room = AIDynamicPathcxx . . $ AIDynamicPath.[p_index].roomnumcxx . . $ ai_dynamic_path#roomnum.[c_node]; |
| 221 | } |
| 222 | |
| 223 | return true; |
| 224 | } else if (p_type == AIP_STATICcxx . . $ `Descent3/aistruct.h:483:9`!) { |
| 225 | // chrishack -- add asserts |
| 226 | |
| 227 | *pos =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). GamePathscxx . . $ GamePaths.[p_index].pathnodescxx . . $ game_path#pathnodes.[c_node].poscxx . . $ node#pos.; |
| 228 | if (room) { |
| 229 | *room = GamePathscxx . . $ GamePaths.[p_index].pathnodescxx . . $ game_path#pathnodes.[c_node].roomnumcxx . . $ node#roomnum.; |
| 230 | } |
| 231 | |
| 232 | return true; |
| 233 | } |
| 234 | |
| 235 | return false; |
| 236 | } |
| 237 | |
| 238 | // Chrishack -- need to add static path flag stuff |
| 239 | static bool AIPathMoveToNextNodecxx . . $ AIPathMoveToNextNode(211cadd9cc3984f1).(ai_path_infocxx . . $ ai_path_info# *aip) { |
| 240 | int c_path = aip->cur_pathcxx . . $ ai_path_info#cur_path.; |
| 241 | int c_node = aip->cur_nodecxx . . $ ai_path_info#cur_node.; |
| 242 | |
| 243 | int p_type = aip->path_typecxx . . $ ai_path_info#path_type.[c_path]; |
| 244 | int p_index = aip->path_idcxx . . $ ai_path_info#path_id.[c_path]; |
| 245 | |
| 246 | c_node++; |
| 247 | |
| 248 | if (c_node <= aip->path_end_nodecxx . . $ ai_path_info#path_end_node.[c_path]) { |
| 249 | aip->cur_nodecxx . . $ ai_path_info#cur_node.++; |
| 250 | return true; |
| 251 | } |
| 252 | |
| 253 | c_path++; |
| 254 | |
| 255 | // We must want to check the next path |
| 256 | if (c_path < aip->num_pathscxx . . $ ai_path_info#num_paths.) { |
| 257 | aip->cur_pathcxx . . $ ai_path_info#cur_path.++; |
| 258 | aip->cur_nodecxx . . $ ai_path_info#cur_node. = aip->path_start_nodecxx . . $ ai_path_info#path_start_node.[aip->cur_pathcxx . . $ ai_path_info#cur_path.]; |
| 259 | |
| 260 | return true; |
| 261 | } |
| 262 | |
| 263 | return false; |
| 264 | } |
| 265 | |
| 266 | bool AIPathAtStartcxx . . $ AIPathAtStart(211cadd9cc3984f1).(ai_path_infocxx . . $ ai_path_info# *aip) { |
| 267 | if (aip->cur_pathcxx . . $ ai_path_info#cur_path. == 0 && aip->cur_nodecxx . . $ ai_path_info#cur_node. == aip->path_start_nodecxx . . $ ai_path_info#path_start_node.[0]) |
| 268 | return true; |
| 269 | else |
| 270 | return false; |
| 271 | } |
| 272 | |
| 273 | bool AIPathAtEndcxx . . $ AIPathAtEnd(211cadd9cc3984f1).(ai_path_infocxx . . $ ai_path_info# *aip) { |
| 274 | if (aip->cur_pathcxx . . $ ai_path_info#cur_path. == aip->num_pathscxx . . $ ai_path_info#num_paths. - 1 && aip->cur_nodecxx . . $ ai_path_info#cur_node. == aip->path_end_nodecxx . . $ ai_path_info#path_end_node.[aip->num_pathscxx . . $ ai_path_info#num_paths. - 1]) |
| 275 | return true; |
| 276 | else |
| 277 | return false; |
| 278 | } |
| 279 | |
| 280 | static void AIPathSetAtEndcxx . . $ AIPathSetAtEnd(8fcc2cafb3819f41).(ai_path_infocxx . . $ ai_path_info# *aip) { |
| 281 | aip->cur_pathcxx . . $ ai_path_info#cur_path. = aip->num_pathscxx . . $ ai_path_info#num_paths. - 1; |
| 282 | aip->cur_nodecxx . . $ ai_path_info#cur_node. = aip->path_end_nodecxx . . $ ai_path_info#path_end_node.[aip->num_pathscxx . . $ ai_path_info#num_paths. - 1]; |
| 283 | } |
| 284 | |
| 285 | void AIPathSetAtStartcxx . . $ AIPathSetAtStart(8fcc2cafb3819f41).(ai_path_infocxx . . $ ai_path_info# *aip) { |
| 286 | aip->cur_pathcxx . . $ ai_path_info#cur_path. = 0; |
| 287 | aip->cur_nodecxx . . $ ai_path_info#cur_node. = aip->path_start_nodecxx . . $ ai_path_info#path_start_node.[0]; |
| 288 | } |
| 289 | |
| 290 | static bool AIPathMoveToPrevNodecxx . . $ AIPathMoveToPrevNode(211cadd9cc3984f1).(ai_path_infocxx . . $ ai_path_info# *aip) { |
| 291 | int c_path = aip->cur_pathcxx . . $ ai_path_info#cur_path.; |
| 292 | int c_node = aip->cur_nodecxx . . $ ai_path_info#cur_node.; |
| 293 | |
| 294 | c_node--; |
| 295 | |
| 296 | if (c_node >= 0) { |
| 297 | aip->cur_nodecxx . . $ ai_path_info#cur_node.--; |
| 298 | return true; |
| 299 | } |
| 300 | |
| 301 | c_path--; |
| 302 | |
| 303 | // We must want to check the next path |
| 304 | if (c_path > 0) { |
| 305 | aip->cur_pathcxx . . $ ai_path_info#cur_path.--; |
| 306 | |
| 307 | if (aip->path_typecxx . . $ ai_path_info#path_type.[c_path] == AIP_DYNAMICcxx . . $ `Descent3/aistruct.h:484:9`!) { |
| 308 | aip->cur_nodecxx . . $ ai_path_info#cur_node. = AIDynamicPathcxx . . $ AIDynamicPath.[aip->path_idcxx . . $ ai_path_info#path_id.[c_path]].num_nodescxx . . $ ai_dynamic_path#num_nodes. - 1; |
| 309 | } else if (aip->path_typecxx . . $ ai_path_info#path_type.[c_path] == AIP_STATICcxx . . $ `Descent3/aistruct.h:483:9`!) { |
| 310 | aip->cur_nodecxx . . $ ai_path_info#cur_node. = aip->path_end_nodecxx . . $ ai_path_info#path_end_node.[c_path]; |
| 311 | } |
| 312 | return true; |
| 313 | } |
| 314 | |
| 315 | return false; |
| 316 | } |
| 317 | |
| 318 | bool AIPathGetNextNodePoscxx . . $ AIPathGetNextNodePos(ea4bd046b9d29bc1).(ai_path_infocxx . . $ ai_path_info# *aip, vectorcxx . . $ vector# *pos, int *room) { |
| 319 | if (AIPathMoveToNextNodecxx . . $ AIPathMoveToNextNode(211cadd9cc3984f1).(aip)) { |
| 320 | AIPathGetCurrentNodePoscxx . . $ AIPathGetCurrentNodePos(ea4bd046b9d29bc1).(aip, pos, room); |
| 321 | AIPathMoveToPrevNodecxx . . $ AIPathMoveToPrevNode(211cadd9cc3984f1).(aip); |
| 322 | |
| 323 | return true; |
| 324 | } |
| 325 | |
| 326 | return false; |
| 327 | } |
| 328 | |
| 329 | bool AIPathGetPrevNodePoscxx . . $ AIPathGetPrevNodePos(ea4bd046b9d29bc1).(ai_path_infocxx . . $ ai_path_info# *aip, vectorcxx . . $ vector# *pos, int *room) { |
| 330 | if (AIPathMoveToPrevNodecxx . . $ AIPathMoveToPrevNode(211cadd9cc3984f1).(aip)) { |
| 331 | AIPathGetCurrentNodePoscxx . . $ AIPathGetCurrentNodePos(ea4bd046b9d29bc1).(aip, pos, room); |
| 332 | AIPathMoveToNextNodecxx . . $ AIPathMoveToNextNode(211cadd9cc3984f1).(aip); |
| 333 | |
| 334 | return true; |
| 335 | } |
| 336 | |
| 337 | return false; |
| 338 | } |
| 339 | |
| 340 | static void AIPathCompletecxx . . $ AIPathComplete(419c470199a90a97).(objectcxx . . $ object# *obj) { GoalPathCompletecxx . . $ GoalPathComplete(419c470199a90a97).(obj); } |
| 341 | |
| 342 | void AIPathMoveTurnTowardsNodecxx . . $ AIPathMoveTurnTowardsNode(682dd4424bca0090).(objectcxx . . $ object# *obj, vectorcxx . . $ vector# *mdir, bool *f_moved) { |
| 343 | ai_path_infocxx . . $ ai_path_info# *aip = &obj->ai_infocxx . . $ object#ai_info.->pathcxx . . $ ai_frame#path.; |
| 344 | goalcxx . . $ goal# *g_ptr = &obj->ai_infocxx . . $ object#ai_info.->goalscxx . . $ ai_frame#goals.[obj->ai_infocxx . . $ object#ai_info.->pathcxx . . $ ai_frame#path..goal_indexcxx . . $ ai_path_info#goal_index.]; |
| 345 | |
| 346 | bool f_too_far_from_end = false; |
| 347 | |
| 348 | // game_path *p = &GamePaths[path_info->path_id]; |
| 349 | int n = aip->cur_nodecxx . . $ ai_path_info#cur_node.; |
| 350 | int p = aip->cur_pathcxx . . $ ai_path_info#cur_path.; |
| 351 | |
| 352 | bool f_reverse = (g_ptr->flagscxx . . $ goal#flags. & GF_PATH_MOVE_REVERSE_DIRcxx . . $ `Descent3/aistruct_external.h:242:9`!) != 0; |
| 353 | |
| 354 | ai_framecxx . . $ ai_frame# *ai_info = obj->ai_infocxx . . $ object#ai_info.; |
| 355 | |
| 356 | vectorcxx . . $ vector# cur_pos; |
| 357 | |
| 358 | AIPathGetCurrentNodePoscxx . . $ AIPathGetCurrentNodePos(ea4bd046b9d29bc1).(aip, &cur_pos); |
| 359 | // mprintf(0, "Cur pos = %f,%f,%f\n", XYZ(&cur_pos)); |
| 360 | |
| 361 | // mprintf(0, "1 R %d, Goal p %d, n %d\n", f_reverse, p, n); |
| 362 | |
| 363 | // mprintf(0, "s %f, %f, %f\n", XYZ(&obj->pos)); |
| 364 | // mprintf(0, "l %f, %f, %f\n", XYZ(&obj->last_pos)); |
| 365 | |
| 366 | // mprintf(0, "%d is at Node %d\n", OBJNUM(obj), n); |
| 367 | |
| 368 | bool f_force_complete_stopping = false; |
| 369 | |
| 370 | if (((!f_reverse && AIPathAtEndcxx . . $ AIPathAtEnd(211cadd9cc3984f1).(aip)) || (f_reverse && AIPathAtStartcxx . . $ AIPathAtStart(211cadd9cc3984f1).(aip))) && |
| 371 | (((goalcxx . . $ goal# *)(&obj->ai_infocxx . . $ object#ai_info.->goalscxx . . $ ai_frame#goals.[aip->goal_indexcxx . . $ ai_path_info#goal_index.]))->circle_distancecxx . . $ goal#circle_distance. == 0.0f) && |
| 372 | obj->movement_typecxx . . $ object#movement_type. == MT_PHYSICScxx . . $ `Descent3/object_external.h:234:9`!) { |
| 373 | f_too_far_from_end = !AIMoveTowardsPositioncxx . . $ AIMoveTowardsPosition(e4ea9f4f5d132a1c).(obj, &cur_pos, 1.0, true, mdir, f_moved); |
| 374 | if (!f_too_far_from_end) { |
| 375 | f_force_complete_stopping = true; |
| 376 | } |
| 377 | } else { |
| 378 | vectorcxx . . $ vector# dir = cur_pos -cxx . . $ operator-(b77b703cd1e43e33). obj->poscxx . . $ object#pos.; |
| 379 | |
| 380 | if (obj->movement_typecxx . . $ object#movement_type. == MT_WALKINGcxx . . $ `Descent3/object_external.h:235:9`!) { |
| 381 | float dot = dir *cxx . . $ `operator*`(4a721543d64e126a). obj->orientcxx . . $ object#orient..uveccxx . . $ matrix#uvec.; |
| 382 | dir -=cxx . . $ `operator-=`(801a8d6f7ab7bef9). dot *cxx . . $ `operator*`(9d6577ff3e9faa29). obj->orientcxx . . $ object#orient..uveccxx . . $ matrix#uvec.; |
| 383 | } |
| 384 | vm_NormalizeVectorcxx . . $ vm_NormalizeVector(4939a7e530383cd4).(&dir); |
| 385 | |
| 386 | *mdir =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). dir; |
| 387 | *f_moved = false; |
| 388 | // AIMoveTowardsDir(obj, &dir); |
| 389 | } |
| 390 | // removed check if(f_reverse && (path_info->next_node < path_info->start_node)) |
| 391 | // removed check { |
| 392 | // removed check mprintf(0, "AI ERROR: Fixed a bad predefined path next_node to goal_node"); |
| 393 | // removed check path_info->next_node = path_info->start_node; |
| 394 | // removed check Int3(); |
| 395 | // removed check } |
| 396 | // removed check |
| 397 | // removed check if(!(f_reverse) && path_info->next_node > path_info->end_node) |
| 398 | // removed check { |
| 399 | // removed check mprintf(0, "AI ERROR: Fixed a bad predefined path next_node to goal_node"); |
| 400 | // removed check path_info->next_node = path_info->end_node; |
| 401 | // removed check Int3(); |
| 402 | // removed check } |
| 403 | |
| 404 | bool f_pass_node; |
| 405 | int last_n; |
| 406 | int last_p; |
| 407 | |
| 408 | pass_node: |
| 409 | |
| 410 | f_pass_node = false; |
| 411 | last_n = n; |
| 412 | last_p = p; |
| 413 | |
| 414 | if (obj->movement_typecxx . . $ object#movement_type. == MT_WALKINGcxx . . $ `Descent3/object_external.h:235:9`!) { |
| 415 | vectorcxx . . $ vector# dir = cur_pos -cxx . . $ operator-(b77b703cd1e43e33). obj->poscxx . . $ object#pos.; |
| 416 | |
| 417 | if (obj->movement_typecxx . . $ object#movement_type. == MT_WALKINGcxx . . $ `Descent3/object_external.h:235:9`!) { |
| 418 | float dot = dir *cxx . . $ `operator*`(4a721543d64e126a). obj->orientcxx . . $ object#orient..uveccxx . . $ matrix#uvec.; |
| 419 | dir -=cxx . . $ `operator-=`(801a8d6f7ab7bef9). dot *cxx . . $ `operator*`(9d6577ff3e9faa29). obj->orientcxx . . $ object#orient..uveccxx . . $ matrix#uvec.; |
| 420 | } |
| 421 | float dist = vm_GetMagnitudecxx . . $ vm_GetMagnitude(4939a7e530383cd4).(&dir); |
| 422 | |
| 423 | if (dist < 1.5f) { |
| 424 | f_pass_node = true; |
| 425 | } |
| 426 | } |
| 427 | |
| 428 | if (f_force_complete_stopping) { |
| 429 | f_pass_node = true; |
| 430 | } |
| 431 | |
| 432 | if (!f_pass_node) { |
| 433 | if (!f_reverse) { |
| 434 | if (AIPathAtStartcxx . . $ AIPathAtStart(211cadd9cc3984f1).(aip)) { |
| 435 | if (AIPathAtEndcxx . . $ AIPathAtEnd(211cadd9cc3984f1).(aip)) { |
| 436 | if ((obj->poscxx . . $ object#pos. -cxx . . $ operator-(b77b703cd1e43e33). cur_pos) *cxx . . $ `operator*`(4a721543d64e126a). (obj->last_poscxx . . $ object#last_pos. -cxx . . $ operator-(b77b703cd1e43e33). cur_pos) <= 0.0f && !f_too_far_from_end) |
| 437 | f_pass_node = true; |
| 438 | } else { |
| 439 | vectorcxx . . $ vector# next_pos; |
| 440 | AIPathGetNextNodePoscxx . . $ AIPathGetNextNodePos(ea4bd046b9d29bc1).(aip, &next_pos, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!); |
| 441 | |
| 442 | vectorcxx . . $ vector# proj_line = obj->poscxx . . $ object#pos. -cxx . . $ operator-(b77b703cd1e43e33). cur_pos; |
| 443 | vectorcxx . . $ vector# line = next_pos -cxx . . $ operator-(b77b703cd1e43e33). cur_pos; |
| 444 | float proj = proj_line *cxx . . $ `operator*`(4a721543d64e126a). line; |
| 445 | |
| 446 | if (proj >= 0.0f) |
| 447 | f_pass_node = true; |
| 448 | } |
| 449 | } else { |
| 450 | vectorcxx . . $ vector# prev_pos; |
| 451 | AIPathGetPrevNodePoscxx . . $ AIPathGetPrevNodePos(ea4bd046b9d29bc1).(aip, &prev_pos, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!); |
| 452 | |
| 453 | vectorcxx . . $ vector# proj = obj->poscxx . . $ object#pos. -cxx . . $ operator-(b77b703cd1e43e33). prev_pos; |
| 454 | vectorcxx . . $ vector# line = cur_pos -cxx . . $ operator-(b77b703cd1e43e33). prev_pos; |
| 455 | float line_len = vm_NormalizeVectorcxx . . $ vm_NormalizeVector(4939a7e530383cd4).(&line); |
| 456 | float proj_len = proj *cxx . . $ `operator*`(4a721543d64e126a). line; |
| 457 | |
| 458 | if (proj_len >= line_len) |
| 459 | f_pass_node = true; |
| 460 | } |
| 461 | } else { |
| 462 | if (AIPathAtEndcxx . . $ AIPathAtEnd(211cadd9cc3984f1).(aip)) { |
| 463 | if (AIPathAtStartcxx . . $ AIPathAtStart(211cadd9cc3984f1).(aip)) { |
| 464 | if ((obj->poscxx . . $ object#pos. -cxx . . $ operator-(b77b703cd1e43e33). cur_pos) *cxx . . $ `operator*`(4a721543d64e126a). (obj->last_poscxx . . $ object#last_pos. -cxx . . $ operator-(b77b703cd1e43e33). cur_pos) <= 0.0f && !f_too_far_from_end) |
| 465 | f_pass_node = true; |
| 466 | } else { |
| 467 | vectorcxx . . $ vector# prev_pos; |
| 468 | AIPathGetPrevNodePoscxx . . $ AIPathGetPrevNodePos(ea4bd046b9d29bc1).(aip, &prev_pos, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!); |
| 469 | |
| 470 | vectorcxx . . $ vector# proj_line = obj->poscxx . . $ object#pos. -cxx . . $ operator-(b77b703cd1e43e33). cur_pos; |
| 471 | vectorcxx . . $ vector# line = prev_pos -cxx . . $ operator-(b77b703cd1e43e33). cur_pos; |
| 472 | float proj = proj_line *cxx . . $ `operator*`(4a721543d64e126a). line; |
| 473 | |
| 474 | if (proj >= 0.0f) |
| 475 | f_pass_node = true; |
| 476 | } |
| 477 | } else { |
| 478 | vectorcxx . . $ vector# next_pos; |
| 479 | AIPathGetNextNodePoscxx . . $ AIPathGetNextNodePos(ea4bd046b9d29bc1).(aip, &next_pos, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!); |
| 480 | |
| 481 | vectorcxx . . $ vector# proj = obj->poscxx . . $ object#pos. -cxx . . $ operator-(b77b703cd1e43e33). next_pos; |
| 482 | vectorcxx . . $ vector# line = cur_pos -cxx . . $ operator-(b77b703cd1e43e33). next_pos; |
| 483 | float line_len = vm_NormalizeVectorcxx . . $ vm_NormalizeVector(4939a7e530383cd4).(&line); |
| 484 | float proj_len = proj *cxx . . $ `operator*`(4a721543d64e126a). line; |
| 485 | |
| 486 | if (proj_len >= line_len) |
| 487 | f_pass_node = true; |
| 488 | } |
| 489 | } |
| 490 | } |
| 491 | |
| 492 | if (f_pass_node) { |
| 493 | // mprintf(0, "f_pass_node\n"); |
| 494 | |
| 495 | if (((f_reverse) && AIPathAtStartcxx . . $ AIPathAtStart(211cadd9cc3984f1).(aip)) || ((!f_reverse) && AIPathAtEndcxx . . $ AIPathAtEnd(211cadd9cc3984f1).(aip))) { |
| 496 | // mprintf(0, "At end node: "); |
| 497 | |
| 498 | switch (g_ptr->flagscxx . . $ goal#flags. & GFM_END_OF_PATHcxx . . $ `Descent3/aistruct_external.h:241:9`!) { |
| 499 | case GF_PATH_REVERSE_AT_ENDcxx . . $ `Descent3/aistruct_external.h:239:9`!: |
| 500 | // mprintf(0, "End reverse dir\n"); |
| 501 | if (f_reverse) |
| 502 | g_ptr->flagscxx . . $ goal#flags. &= ~GF_PATH_MOVE_REVERSE_DIRcxx . . $ `Descent3/aistruct_external.h:242:9`!; |
| 503 | else |
| 504 | g_ptr->flagscxx . . $ goal#flags. |= GF_PATH_MOVE_REVERSE_DIRcxx . . $ `Descent3/aistruct_external.h:242:9`!; |
| 505 | return; |
| 506 | case GF_PATH_CIRCLE_AT_ENDcxx . . $ `Descent3/aistruct_external.h:240:9`!: |
| 507 | // mprintf(0, "End circle dir\n"); |
| 508 | if (f_reverse) |
| 509 | AIPathSetAtEndcxx . . $ AIPathSetAtEnd(8fcc2cafb3819f41).(aip); |
| 510 | else |
| 511 | AIPathSetAtStartcxx . . $ AIPathSetAtStart(8fcc2cafb3819f41).(aip); |
| 512 | return; |
| 513 | default: |
| 514 | // mprintf(0, "End kill goal\n"); |
| 515 | AIPathCompletecxx . . $ AIPathComplete(419c470199a90a97).(obj); |
| 516 | return; |
| 517 | } |
| 518 | } else { |
| 519 | // mprintf(0, "Passed node\n"); |
| 520 | if (g_ptr->flagscxx . . $ goal#flags. & GF_PATH_MOVE_REVERSE_DIRcxx . . $ `Descent3/aistruct_external.h:242:9`!) |
| 521 | AIPathMoveToPrevNodecxx . . $ AIPathMoveToPrevNode(211cadd9cc3984f1).(aip); |
| 522 | else |
| 523 | AIPathMoveToNextNodecxx . . $ AIPathMoveToNextNode(211cadd9cc3984f1).(aip); |
| 524 | } |
| 525 | |
| 526 | AIPathGetCurrentNodePoscxx . . $ AIPathGetCurrentNodePos(ea4bd046b9d29bc1).(aip, &cur_pos); |
| 527 | |
| 528 | n = aip->cur_nodecxx . . $ ai_path_info#cur_node.; |
| 529 | p = aip->cur_pathcxx . . $ ai_path_info#cur_path.; |
| 530 | |
| 531 | f_reverse = (g_ptr->flagscxx . . $ goal#flags. & GF_PATH_MOVE_REVERSE_DIRcxx . . $ `Descent3/aistruct_external.h:242:9`!) != 0; |
| 532 | |
| 533 | if (n != last_n || p != last_p) |
| 534 | goto pass_node; |
| 535 | } |
| 536 | } |
| 537 | |
| 538 | static bool AIPathFreeDPathSlotcxx . . $ AIPathFreeDPathSlot(83c267b20bac841a).(int slot) { |
| 539 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(AIDynamicPath[slot].use_count >= 0); |
| 540 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(slot >= 0 && slot < MAX_DYNAMIC_PATHScxx . . $ `Descent3/aipath.cpp:33:9`! && AIDynamicPath[slot].use_count != 0); |
| 541 | |
| 542 | AIDynamicPathcxx . . $ AIDynamicPath.[slot].use_countcxx . . $ ai_dynamic_path#use_count.--; |
| 543 | |
| 544 | if (!AIDynamicPathcxx . . $ AIDynamicPath.[slot].use_countcxx . . $ ai_dynamic_path#use_count.) { |
| 545 | AIDynamicPathcxx . . $ AIDynamicPath.[slot].num_nodescxx . . $ ai_dynamic_path#num_nodes. = 0; |
| 546 | AIDynamicPathcxx . . $ AIDynamicPath.[slot].owner_handlecxx . . $ ai_dynamic_path#owner_handle. = OBJECT_HANDLE_NONEcxx . . $ `Descent3/object_external.h:156:9`!; |
| 547 | } |
| 548 | |
| 549 | return true; |
| 550 | } |
| 551 | |
| 552 | static bool AIPathGetDPathSlotcxx . . $ AIPathGetDPathSlot(7ad6e86205318e69).(int *slot, int handle) { |
| 553 | int i; |
| 554 | |
| 555 | for (i = 0; i < MAX_DYNAMIC_PATHScxx . . $ `Descent3/aipath.cpp:33:9`!; i++) { |
| 556 | if (!AIDynamicPathcxx . . $ AIDynamicPath.[i].use_countcxx . . $ ai_dynamic_path#use_count.) { |
| 557 | AIDynamicPathcxx . . $ AIDynamicPath.[i].use_countcxx . . $ ai_dynamic_path#use_count.++; |
| 558 | *slot = i; |
| 559 | AIDynamicPathcxx . . $ AIDynamicPath.[i].owner_handlecxx . . $ ai_dynamic_path#owner_handle. = handle; |
| 560 | return true; |
| 561 | } else if (ObjGetcxx . . $ ObjGet(11672e354c0b263a).(AIDynamicPathcxx . . $ AIDynamicPath.[i].owner_handlecxx . . $ ai_dynamic_path#owner_handle.) == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! && AIDynamicPathcxx . . $ AIDynamicPath.[i].use_countcxx . . $ ai_dynamic_path#use_count. == 1) { |
| 562 | AIPathFreeDPathSlotcxx . . $ AIPathFreeDPathSlot(83c267b20bac841a).(i); |
| 563 | |
| 564 | AIDynamicPathcxx . . $ AIDynamicPath.[i].use_countcxx . . $ ai_dynamic_path#use_count.++; |
| 565 | *slot = i; |
| 566 | AIDynamicPathcxx . . $ AIDynamicPath.[i].owner_handlecxx . . $ ai_dynamic_path#owner_handle. = handle; |
| 567 | return true; |
| 568 | } |
| 569 | } |
| 570 | |
| 571 | mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Out of dynamic paths"); |
| 572 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(0); // -- get chris |
| 573 | return false; |
| 574 | } |
| 575 | |
| 576 | bool AIPathInitPathcxx . . $ AIPathInitPath(211cadd9cc3984f1).(ai_path_infocxx . . $ ai_path_info# *aip) { |
| 577 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(aip); |
| 578 | |
| 579 | aip->num_pathscxx . . $ ai_path_info#num_paths. = 0; |
| 580 | aip->cur_pathcxx . . $ ai_path_info#cur_path. = 0; |
| 581 | aip->cur_nodecxx . . $ ai_path_info#cur_node. = 0; |
| 582 | |
| 583 | aip->goal_indexcxx . . $ ai_path_info#goal_index. = -1; |
| 584 | aip->goal_uidcxx . . $ ai_path_info#goal_uid. = -1; |
| 585 | |
| 586 | return true; |
| 587 | } |
| 588 | |
| 589 | bool AIPathFreePathcxx . . $ AIPathFreePath(211cadd9cc3984f1).(ai_path_infocxx . . $ ai_path_info# *aip) { |
| 590 | int i; |
| 591 | |
| 592 | for (i = 0; i < aip->num_pathscxx . . $ ai_path_info#num_paths.; i++) { |
| 593 | if (aip->path_typecxx . . $ ai_path_info#path_type.[i] == AIP_DYNAMICcxx . . $ `Descent3/aistruct.h:484:9`!) { |
| 594 | AIPathFreeDPathSlotcxx . . $ AIPathFreeDPathSlot(83c267b20bac841a).(aip->path_idcxx . . $ ai_path_info#path_id.[i]); |
| 595 | } |
| 596 | } |
| 597 | |
| 598 | AIPathInitPathcxx . . $ AIPathInitPath(211cadd9cc3984f1).(aip); |
| 599 | |
| 600 | return true; |
| 601 | } |
| 602 | |
| 603 | static bool AIPathAddDPathcxx . . $ AIPathAddDPath(b6b555a4deffc6d9).(ai_path_infocxx . . $ ai_path_info# *aip, int handle) { |
| 604 | int slot; |
| 605 | bool status; |
| 606 | |
| 607 | if (aip->num_pathscxx . . $ ai_path_info#num_paths. >= MAX_JOINED_PATHScxx . . $ `Descent3/aistruct.h:479:9`!) { |
| 608 | mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "AI ERROR: Tried to join too many paths (Adding dpath)\n"); |
| 609 | return false; |
| 610 | } |
| 611 | |
| 612 | status = AIPathGetDPathSlotcxx . . $ AIPathGetDPathSlot(7ad6e86205318e69).(&slot, handle); |
| 613 | |
| 614 | if (status) { |
| 615 | aip->path_idcxx . . $ ai_path_info#path_id.[aip->num_pathscxx . . $ ai_path_info#num_paths.] = slot; |
| 616 | aip->path_typecxx . . $ ai_path_info#path_type.[aip->num_pathscxx . . $ ai_path_info#num_paths.] = AIP_DYNAMICcxx . . $ `Descent3/aistruct.h:484:9`!; |
| 617 | |
| 618 | aip->path_start_nodecxx . . $ ai_path_info#path_start_node.[aip->num_pathscxx . . $ ai_path_info#num_paths.] = 0; |
| 619 | aip->path_end_nodecxx . . $ ai_path_info#path_end_node.[aip->num_pathscxx . . $ ai_path_info#num_paths.] = 0; |
| 620 | |
| 621 | aip->path_flagscxx . . $ ai_path_info#path_flags.[aip->num_pathscxx . . $ ai_path_info#num_paths.] = 0; |
| 622 | |
| 623 | aip->num_pathscxx . . $ ai_path_info#num_paths.++; |
| 624 | } |
| 625 | |
| 626 | return status; |
| 627 | } |
| 628 | |
| 629 | static bool AIPathAddStaticPathcxx . . $ AIPathAddStaticPath(ad1202099d56ed20).(ai_path_infocxx . . $ ai_path_info# *aip, int path_id, int start_index, int end_index) { |
| 630 | // chrishack -- validation code is needed |
| 631 | |
| 632 | if (aip->num_pathscxx . . $ ai_path_info#num_paths. >= MAX_JOINED_PATHScxx . . $ `Descent3/aistruct.h:479:9`!) { |
| 633 | mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "AI ERROR: Tried to join too many paths (Adding spath)\n"); |
| 634 | return false; |
| 635 | } |
| 636 | |
| 637 | aip->path_idcxx . . $ ai_path_info#path_id.[aip->num_pathscxx . . $ ai_path_info#num_paths.] = path_id; |
| 638 | aip->path_typecxx . . $ ai_path_info#path_type.[aip->num_pathscxx . . $ ai_path_info#num_paths.] = AIP_STATICcxx . . $ `Descent3/aistruct.h:483:9`!; |
| 639 | aip->path_start_nodecxx . . $ ai_path_info#path_start_node.[aip->num_pathscxx . . $ ai_path_info#num_paths.] = start_index; |
| 640 | aip->path_end_nodecxx . . $ ai_path_info#path_end_node.[aip->num_pathscxx . . $ ai_path_info#num_paths.] = end_index; |
| 641 | |
| 642 | aip->num_pathscxx . . $ ai_path_info#num_paths.++; |
| 643 | |
| 644 | return true; |
| 645 | } |
| 646 | |
| 647 | static inline bool AIPathAddDPathNodecxx . . $ AIPathAddDPathNode(e36d515051d5afd1).(ai_path_infocxx . . $ ai_path_info# *aip, int *slot, int *cur_node, vectorcxx . . $ vector# *pos, int room, int handle) { |
| 648 | int status; |
| 649 | |
| 650 | if (*cur_node == MAX_NODEScxx . . $ `Descent3/aipath.cpp:34:9`!) { |
| 651 | status = AIPathAddDPathcxx . . $ AIPathAddDPath(b6b555a4deffc6d9).(aip, handle); |
| 652 | if (!status) |
| 653 | Int3cxx . . $ `misc/pserror.h:247:9`!(); // chrishack -- out of dynamic paths |
| 654 | |
| 655 | AIDynamicPathcxx . . $ AIDynamicPath.[*slot].num_nodescxx . . $ ai_dynamic_path#num_nodes. = MAX_NODEScxx . . $ `Descent3/aipath.cpp:34:9`!; |
| 656 | *cur_node = 0; |
| 657 | *slot = aip->path_idcxx . . $ ai_path_info#path_id.[aip->num_pathscxx . . $ ai_path_info#num_paths. - 1]; |
| 658 | } |
| 659 | |
| 660 | AIDynamicPathcxx . . $ AIDynamicPath.[*slot].poscxx . . $ ai_dynamic_path#pos.[*cur_node] =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). *pos; |
| 661 | AIDynamicPathcxx . . $ AIDynamicPath.[*slot].roomnumcxx . . $ ai_dynamic_path#roomnum.[(*cur_node)++] = room; |
| 662 | |
| 663 | aip->path_end_nodecxx . . $ ai_path_info#path_end_node.[aip->num_pathscxx . . $ ai_path_info#num_paths. - 1] = *cur_node - 1; |
| 664 | |
| 665 | return true; |
| 666 | } |
| 667 | |
| 668 | static bool AIGenerateAltBNodePathcxx . . $ AIGenerateAltBNodePath(959b8427c4b76a9f).(objectcxx . . $ object# *obj, vectorcxx . . $ vector# *start_pos, int *start_room, vectorcxx . . $ vector# *end_pos, int *end_room, |
| 669 | ai_path_infocxx . . $ ai_path_info# *aip, int *slot, int *cur_node, int handle) { |
| 670 | int x; |
| 671 | vectorcxx . . $ vector# *pos; |
| 672 | bool f_path_exists = true; |
| 673 | |
| 674 | bn_listcxx . . $ bn_list# *bnlist = BNode_GetBNListPtrcxx . . $ BNode_GetBNListPtr(a42128dcaf4239a4).(*start_room); |
| 675 | int last_node = BNode_FindDirLocalVisibleBNodecxx . . $ BNode_FindDirLocalVisibleBNode(d2d3175ccbf91b7d).(*start_room, start_pos, &obj->orientcxx . . $ object#orient..fveccxx . . $ matrix#fvec., obj->sizecxx . . $ object#size.); |
| 676 | if (last_node == -1) { |
| 677 | f_path_exists = false; |
| 678 | goto done; |
| 679 | } |
| 680 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(last_node >= 0); |
| 681 | |
| 682 | for (x = 0; x < AIAltPathNumNodescxx . . $ AIAltPathNumNodes. - 1 && f_path_exists; x++) { |
| 683 | int cur_room = BOA_INDEXcxx . . $ `Descent3/BOA.h:197:9`!(AIAltPath[x]); |
| 684 | int next_room = BOA_INDEXcxx . . $ `Descent3/BOA.h:197:9`!(AIAltPath[x + 1]); |
| 685 | |
| 686 | bnlist = BNode_GetBNListPtrcxx . . $ BNode_GetBNListPtr(a42128dcaf4239a4).(cur_room); |
| 687 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(bnlist); |
| 688 | |
| 689 | if (next_room != cur_room && next_room != BOA_NO_PATHcxx . . $ `Descent3/BOA.h:198:9`!) { |
| 690 | int portal = BOA_DetermineStartRoomPortalcxx . . $ BOA_DetermineStartRoomPortal(836cef11f1e7b2ee).(cur_room, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, next_room, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!); |
| 691 | if (portal == -1) { |
| 692 | f_path_exists = false; |
| 693 | } else { |
| 694 | int bnode = -1; |
| 695 | |
| 696 | if (cur_room >= 0 && cur_room <= Highest_room_indexcxx . . $ Highest_room_index.) { |
| 697 | bnode = Roomscxx . . $ Rooms.[cur_room].portalscxx . . $ room#portals.[portal].bnode_indexcxx . . $ portal#bnode_index.; |
| 698 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(bnode >= 0 && bnode < BNode_GetBNListPtr(cur_room)->num_nodes); |
| 699 | } else { |
| 700 | int croom = BOA_connectcxx . . $ BOA_connect.[cur_room - Highest_room_indexcxx . . $ Highest_room_index. - 1][portal].roomnumcxx . . $ connect_data#roomnum.; |
| 701 | int cportal = BOA_connectcxx . . $ BOA_connect.[cur_room - Highest_room_indexcxx . . $ Highest_room_index. - 1][portal].portalcxx . . $ connect_data#portal.; |
| 702 | |
| 703 | int r = Roomscxx . . $ Rooms.[croom].portalscxx . . $ room#portals.[cportal].croomcxx . . $ portal#croom.; |
| 704 | int p = Roomscxx . . $ Rooms.[croom].portalscxx . . $ room#portals.[cportal].cportalcxx . . $ portal#cportal.; |
| 705 | |
| 706 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(Rooms[r].used && (Rooms[r].flags & RF_EXTERNALcxx . . $ `Descent3/room_external.h:177:9`!)); |
| 707 | bnode = Roomscxx . . $ Rooms.[r].portalscxx . . $ room#portals.[p].bnode_indexcxx . . $ portal#bnode_index.; |
| 708 | // ASSERT(bnode >= 0 && bnode < BNode_GetBNListPtr(r)->num_nodes); |
| 709 | } |
| 710 | |
| 711 | // Add the last room... |
| 712 | bool f_ok = BNode_FindPathcxx . . $ BNode_FindPath(88bfc9447631a049).(cur_room, last_node, bnode, obj->sizecxx . . $ object#size.); |
| 713 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(f_ok); |
| 714 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(BNode_PathNumNodes); |
| 715 | |
| 716 | int i; |
| 717 | for (i = 0; i < BNode_PathNumNodescxx . . $ BNode_PathNumNodes.; i++) { |
| 718 | pos = &bnlist->nodescxx . . $ bn_list#nodes.[BNode_Pathcxx . . $ BNode_Path.[i]].poscxx . . $ bn_node#pos.; |
| 719 | AIPathAddDPathNodecxx . . $ AIPathAddDPathNode(e36d515051d5afd1).(aip, slot, cur_node, pos, cur_room, handle); |
| 720 | } |
| 721 | |
| 722 | int portal = BOA_DetermineStartRoomPortalcxx . . $ BOA_DetermineStartRoomPortal(836cef11f1e7b2ee).(next_room, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, cur_room, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!); |
| 723 | if (next_room <= Highest_room_indexcxx . . $ Highest_room_index.) { |
| 724 | bnode = Roomscxx . . $ Rooms.[next_room].portalscxx . . $ room#portals.[portal].bnode_indexcxx . . $ portal#bnode_index.; |
| 725 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(bnode >= 0); |
| 726 | } else { |
| 727 | int croom = BOA_connectcxx . . $ BOA_connect.[next_room - Highest_room_indexcxx . . $ Highest_room_index. - 1][portal].roomnumcxx . . $ connect_data#roomnum.; |
| 728 | int cportal = BOA_connectcxx . . $ BOA_connect.[next_room - Highest_room_indexcxx . . $ Highest_room_index. - 1][portal].portalcxx . . $ connect_data#portal.; |
| 729 | |
| 730 | int r = Roomscxx . . $ Rooms.[croom].portalscxx . . $ room#portals.[cportal].croomcxx . . $ portal#croom.; |
| 731 | int p = Roomscxx . . $ Rooms.[croom].portalscxx . . $ room#portals.[cportal].cportalcxx . . $ portal#cportal.; |
| 732 | |
| 733 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(Rooms[r].used && (Rooms[r].flags & RF_EXTERNALcxx . . $ `Descent3/room_external.h:177:9`!)); |
| 734 | bnode = Roomscxx . . $ Rooms.[r].portalscxx . . $ room#portals.[p].bnode_indexcxx . . $ portal#bnode_index.; |
| 735 | // ASSERT(bnode >= 0 && bnode < BNode_GetBNListPtr(r)->num_nodes); |
| 736 | } |
| 737 | |
| 738 | last_node = bnode; |
| 739 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(last_node >= 0); |
| 740 | } |
| 741 | } else { |
| 742 | if (next_room == BOA_NO_PATHcxx . . $ `Descent3/BOA.h:198:9`!) { |
| 743 | f_path_exists = false; |
| 744 | } |
| 745 | } |
| 746 | } |
| 747 | |
| 748 | if (f_path_exists) { |
| 749 | int bnode; |
| 750 | |
| 751 | bn_listcxx . . $ bn_list# *bnlist = BNode_GetBNListPtrcxx . . $ BNode_GetBNListPtr(a42128dcaf4239a4).(*end_room); |
| 752 | bnode = BNode_FindClosestLocalVisibleBNodecxx . . $ BNode_FindClosestLocalVisibleBNode(fadc9d1e831a2875).(*end_room, end_pos, obj->sizecxx . . $ object#size.); |
| 753 | if (bnode == -1) { |
| 754 | f_path_exists = false; |
| 755 | goto done; |
| 756 | } |
| 757 | |
| 758 | // Add the last room... |
| 759 | bool f_ok = BNode_FindPathcxx . . $ BNode_FindPath(88bfc9447631a049).(*end_room, last_node, bnode, obj->sizecxx . . $ object#size.); |
| 760 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(f_ok); |
| 761 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(BNode_PathNumNodes); |
| 762 | int i; |
| 763 | for (i = 0; i < BNode_PathNumNodescxx . . $ BNode_PathNumNodes.; i++) { |
| 764 | pos = &bnlist->nodescxx . . $ bn_list#nodes.[BNode_Pathcxx . . $ BNode_Path.[i]].poscxx . . $ bn_node#pos.; |
| 765 | AIPathAddDPathNodecxx . . $ AIPathAddDPathNode(e36d515051d5afd1).(aip, slot, cur_node, pos, *end_room, handle); |
| 766 | } |
| 767 | } |
| 768 | |
| 769 | done: |
| 770 | if (!f_path_exists) |
| 771 | AIPathFreePathcxx . . $ AIPathFreePath(211cadd9cc3984f1).(aip); |
| 772 | |
| 773 | return f_path_exists; |
| 774 | } |
| 775 | |
| 776 | static void AIGenerateAltBOAPathcxx . . $ AIGenerateAltBOAPath(de89b0408393e677).(vectorcxx . . $ vector# *start_pos, vectorcxx . . $ vector# *end_pos, ai_path_infocxx . . $ ai_path_info# *aip, int *slot, int *cur_node, |
| 777 | int handle) { |
| 778 | int x; |
| 779 | vectorcxx . . $ vector# *pos = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 780 | |
| 781 | for (x = 0; x < AIAltPathNumNodescxx . . $ AIAltPathNumNodes. - 1; x++) { |
| 782 | int cur_room = AIAltPathcxx . . $ AIAltPath.[x]; |
| 783 | int next_room = AIAltPathcxx . . $ AIAltPath.[x + 1]; |
| 784 | |
| 785 | int i; |
| 786 | |
| 787 | if (next_room >= 0 && next_room <= Highest_room_indexcxx . . $ Highest_room_index.) { |
| 788 | if (cur_room > Highest_room_indexcxx . . $ Highest_room_index.) { |
| 789 | i = BOA_DetermineStartRoomPortalcxx . . $ BOA_DetermineStartRoomPortal(836cef11f1e7b2ee).(next_room, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, cur_room, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, false, false, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!); |
| 790 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(i != -1); |
| 791 | pos = &Roomscxx . . $ Rooms.[next_room].portalscxx . . $ room#portals.[i].path_pntcxx . . $ portal#path_pnt.; |
| 792 | } else { |
| 793 | for (i = 0; i < Roomscxx . . $ Rooms.[next_room].num_portalscxx . . $ room#num_portals.; i++) { |
| 794 | if (cur_room <= Highest_room_indexcxx . . $ Highest_room_index. && Roomscxx . . $ Rooms.[next_room].portalscxx . . $ room#portals.[i].croomcxx . . $ portal#croom. == cur_room) { |
| 795 | pos = &Roomscxx . . $ Rooms.[next_room].portalscxx . . $ room#portals.[i].path_pntcxx . . $ portal#path_pnt.; |
| 796 | break; |
| 797 | } |
| 798 | } |
| 799 | } |
| 800 | |
| 801 | // Add the adjoining room's portal point |
| 802 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(i < Rooms[next_room].num_portals); |
| 803 | AIPathAddDPathNodecxx . . $ AIPathAddDPathNode(e36d515051d5afd1).(aip, slot, cur_node, pos, next_room, handle); |
| 804 | |
| 805 | // Add its center point |
| 806 | pos = &Roomscxx . . $ Rooms.[next_room].path_pntcxx . . $ room#path_pnt.; |
| 807 | AIPathAddDPathNodecxx . . $ AIPathAddDPathNode(e36d515051d5afd1).(aip, slot, cur_node, pos, next_room, handle); |
| 808 | } else { |
| 809 | if (BOA_INDEXcxx . . $ `Descent3/BOA.h:197:9`!(cur_room) <= Highest_room_indexcxx . . $ Highest_room_index. && cur_room != next_room) { |
| 810 | int p_index = BOA_DetermineStartRoomPortalcxx . . $ BOA_DetermineStartRoomPortal(836cef11f1e7b2ee).(cur_room, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, next_room, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!); |
| 811 | |
| 812 | if (p_index >= 0) { |
| 813 | pos = &Roomscxx . . $ Rooms.[cur_room].portalscxx . . $ room#portals.[p_index].path_pntcxx . . $ portal#path_pnt.; |
| 814 | AIPathAddDPathNodecxx . . $ AIPathAddDPathNode(e36d515051d5afd1).(aip, slot, cur_node, pos, cur_room, handle); |
| 815 | } |
| 816 | } |
| 817 | } |
| 818 | } |
| 819 | } |
| 820 | |
| 821 | // if(ROOMNUM_OUTSIDE(next_room) && ROOMNUM_OUTSIDE(*end_room) && (TERRAIN_REGION(next_room) == |
| 822 | // TERRAIN_REGION(*end_room) || TERRAIN_REGION(*end_room) == 0 || TERRAIN_REGION(next_room) == 0)) |
| 823 | // { |
| 824 | // next_room = *end_room; |
| 825 | // } |
| 826 | |
| 827 | static bool AIGenerateBNodePathcxx . . $ AIGenerateBNodePath(959b8427c4b76a9f).(objectcxx . . $ object# *obj, vectorcxx . . $ vector# *start_pos, int *start_room, vectorcxx . . $ vector# *end_pos, int *end_room, |
| 828 | ai_path_infocxx . . $ ai_path_info# *aip, int *slot, int *cur_node, int handle) { |
| 829 | int next_room = BOA_INDEXcxx . . $ `Descent3/BOA.h:197:9`!(*start_room); |
| 830 | bool f_path_exists = true; |
| 831 | vectorcxx . . $ vector# *pos; |
| 832 | |
| 833 | bn_listcxx . . $ bn_list# *bnlist; // = BNode_GetBNListPtr(*start_room); |
| 834 | int last_node = BNode_FindDirLocalVisibleBNodecxx . . $ BNode_FindDirLocalVisibleBNode(d2d3175ccbf91b7d).(*start_room, start_pos, &obj->orientcxx . . $ object#orient..fveccxx . . $ matrix#fvec., obj->sizecxx . . $ object#size.); |
| 835 | if (last_node == -1) { |
| 836 | f_path_exists = false; |
| 837 | goto done; |
| 838 | } |
| 839 | |
| 840 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(!(next_room >= 0 && next_room <= Highest_room_index && !Rooms[next_room].used)); |
| 841 | |
| 842 | // pos = &bnlist->nodes[last_node].pos; |
| 843 | // AIPathAddDPathNode(aip, slot, cur_node, pos, *start_room, handle); |
| 844 | |
| 845 | while ((BOA_INDEXcxx . . $ `Descent3/BOA.h:197:9`!(next_room) != BOA_GetNextRoomcxx . . $ BOA_GetNextRoom(9b79fb6aee4c0440).(next_room, *end_room)) && (next_room != BOA_NO_PATHcxx . . $ `Descent3/BOA.h:198:9`!) && |
| 846 | f_path_exists) { |
| 847 | int cur_room; |
| 848 | |
| 849 | cur_room = next_room; |
| 850 | next_room = BOA_GetNextRoomcxx . . $ BOA_GetNextRoom(9b79fb6aee4c0440).(next_room, *end_room); |
| 851 | bnlist = BNode_GetBNListPtrcxx . . $ BNode_GetBNListPtr(a42128dcaf4239a4).(cur_room); |
| 852 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(bnlist); |
| 853 | |
| 854 | if (next_room != cur_room && next_room != BOA_NO_PATHcxx . . $ `Descent3/BOA.h:198:9`!) { |
| 855 | int portal = BOA_DetermineStartRoomPortalcxx . . $ BOA_DetermineStartRoomPortal(836cef11f1e7b2ee).(cur_room, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, next_room, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!); |
| 856 | if (portal == -1) { |
| 857 | f_path_exists = false; |
| 858 | } else { |
| 859 | int bnode; |
| 860 | |
| 861 | if (cur_room <= Highest_room_indexcxx . . $ Highest_room_index.) { |
| 862 | bnode = Roomscxx . . $ Rooms.[cur_room].portalscxx . . $ room#portals.[portal].bnode_indexcxx . . $ portal#bnode_index.; |
| 863 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(bnode >= 0 && bnode < BNode_GetBNListPtr(cur_room)->num_nodes); |
| 864 | } else { |
| 865 | int croom = BOA_connectcxx . . $ BOA_connect.[cur_room - Highest_room_indexcxx . . $ Highest_room_index. - 1][portal].roomnumcxx . . $ connect_data#roomnum.; |
| 866 | int cportal = BOA_connectcxx . . $ BOA_connect.[cur_room - Highest_room_indexcxx . . $ Highest_room_index. - 1][portal].portalcxx . . $ connect_data#portal.; |
| 867 | |
| 868 | int r = Roomscxx . . $ Rooms.[croom].portalscxx . . $ room#portals.[cportal].croomcxx . . $ portal#croom.; |
| 869 | int p = Roomscxx . . $ Rooms.[croom].portalscxx . . $ room#portals.[cportal].cportalcxx . . $ portal#cportal.; |
| 870 | |
| 871 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(Rooms[r].used && (Rooms[r].flags & RF_EXTERNALcxx . . $ `Descent3/room_external.h:177:9`!)); |
| 872 | bnode = Roomscxx . . $ Rooms.[r].portalscxx . . $ room#portals.[p].bnode_indexcxx . . $ portal#bnode_index.; |
| 873 | // ASSERT(bnode >= 0 && bnode < BNode_GetBNListPtr(r)->num_nodes); |
| 874 | } |
| 875 | |
| 876 | // Add the last room... |
| 877 | bool f_ok = BNode_FindPathcxx . . $ BNode_FindPath(88bfc9447631a049).(cur_room, last_node, bnode, obj->sizecxx . . $ object#size.); |
| 878 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(f_ok); |
| 879 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(BNode_PathNumNodes); |
| 880 | |
| 881 | int i; |
| 882 | for (i = 0; i < BNode_PathNumNodescxx . . $ BNode_PathNumNodes.; i++) { |
| 883 | pos = &bnlist->nodescxx . . $ bn_list#nodes.[BNode_Pathcxx . . $ BNode_Path.[i]].poscxx . . $ bn_node#pos.; |
| 884 | AIPathAddDPathNodecxx . . $ AIPathAddDPathNode(e36d515051d5afd1).(aip, slot, cur_node, pos, cur_room, handle); |
| 885 | } |
| 886 | |
| 887 | int portal = BOA_DetermineStartRoomPortalcxx . . $ BOA_DetermineStartRoomPortal(836cef11f1e7b2ee).(next_room, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, cur_room, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!); |
| 888 | if (portal < 0) { |
| 889 | f_path_exists = false; |
| 890 | } else { |
| 891 | if (next_room <= Highest_room_indexcxx . . $ Highest_room_index.) { |
| 892 | last_node = Roomscxx . . $ Rooms.[next_room].portalscxx . . $ room#portals.[portal].bnode_indexcxx . . $ portal#bnode_index.; |
| 893 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(last_node >= 0 && last_node < BNode_GetBNListPtr(next_room)->num_nodes); |
| 894 | } else { |
| 895 | int croom = BOA_connectcxx . . $ BOA_connect.[next_room - Highest_room_indexcxx . . $ Highest_room_index. - 1][portal].roomnumcxx . . $ connect_data#roomnum.; |
| 896 | int cportal = BOA_connectcxx . . $ BOA_connect.[next_room - Highest_room_indexcxx . . $ Highest_room_index. - 1][portal].portalcxx . . $ connect_data#portal.; |
| 897 | |
| 898 | int r = Roomscxx . . $ Rooms.[croom].portalscxx . . $ room#portals.[cportal].croomcxx . . $ portal#croom.; |
| 899 | int p = Roomscxx . . $ Rooms.[croom].portalscxx . . $ room#portals.[cportal].cportalcxx . . $ portal#cportal.; |
| 900 | |
| 901 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(Rooms[r].used && (Rooms[r].flags & RF_EXTERNALcxx . . $ `Descent3/room_external.h:177:9`!)); |
| 902 | last_node = Roomscxx . . $ Rooms.[r].portalscxx . . $ room#portals.[p].bnode_indexcxx . . $ portal#bnode_index.; |
| 903 | // ASSERT(last_node >= 0 && last_node < BNode_GetBNListPtr(r)->num_nodes); |
| 904 | } |
| 905 | } |
| 906 | } |
| 907 | } else { |
| 908 | if (next_room == BOA_NO_PATHcxx . . $ `Descent3/BOA.h:198:9`!) { |
| 909 | f_path_exists = false; |
| 910 | } |
| 911 | } |
| 912 | } |
| 913 | |
| 914 | if (f_path_exists) { |
| 915 | int bnode; |
| 916 | |
| 917 | bn_listcxx . . $ bn_list# *bnlist = BNode_GetBNListPtrcxx . . $ BNode_GetBNListPtr(a42128dcaf4239a4).(*end_room); |
| 918 | bnode = BNode_FindClosestLocalVisibleBNodecxx . . $ BNode_FindClosestLocalVisibleBNode(fadc9d1e831a2875).(*end_room, end_pos, obj->sizecxx . . $ object#size.); |
| 919 | if (bnode == -1) { |
| 920 | f_path_exists = false; |
| 921 | goto done; |
| 922 | } |
| 923 | |
| 924 | // Add the last room... |
| 925 | bool f_ok = BNode_FindPathcxx . . $ BNode_FindPath(88bfc9447631a049).(*end_room, last_node, bnode, obj->sizecxx . . $ object#size.); |
| 926 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(f_ok); |
| 927 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(BNode_PathNumNodes); |
| 928 | int i; |
| 929 | for (i = 0; i < BNode_PathNumNodescxx . . $ BNode_PathNumNodes.; i++) { |
| 930 | pos = &bnlist->nodescxx . . $ bn_list#nodes.[BNode_Pathcxx . . $ BNode_Path.[i]].poscxx . . $ bn_node#pos.; |
| 931 | AIPathAddDPathNodecxx . . $ AIPathAddDPathNode(e36d515051d5afd1).(aip, slot, cur_node, pos, *end_room, handle); |
| 932 | } |
| 933 | } |
| 934 | |
| 935 | done: |
| 936 | if (!f_path_exists) |
| 937 | AIPathFreePathcxx . . $ AIPathFreePath(211cadd9cc3984f1).(aip); |
| 938 | |
| 939 | return f_path_exists; |
| 940 | } |
| 941 | |
| 942 | static bool AIGenerateBOAPathcxx . . $ AIGenerateBOAPath(8d18e519f8eea6bf).(vectorcxx . . $ vector# *start_pos, int *start_room, vectorcxx . . $ vector# *end_pos, int *end_room, ai_path_infocxx . . $ ai_path_info# *aip, |
| 943 | int *slot, int *cur_node, int handle) { |
| 944 | int next_room = *start_room; |
| 945 | bool f_path_exists = true; |
| 946 | vectorcxx . . $ vector# *pos; |
| 947 | |
| 948 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(ROOMNUM_OUTSIDEcxx . . $ `lib/object_external_struct.h:127:9`!(next_room) || (next_room >= 0 && next_room <= Highest_room_index && Rooms[next_room].used)); |
| 949 | |
| 950 | // Add in the center of the first room |
| 951 | if (!ROOMNUM_OUTSIDEcxx . . $ `lib/object_external_struct.h:127:9`!(next_room)) { |
| 952 | pos = &Roomscxx . . $ Rooms.[*start_room].path_pntcxx . . $ room#path_pnt.; |
| 953 | AIPathAddDPathNodecxx . . $ AIPathAddDPathNode(e36d515051d5afd1).(aip, slot, cur_node, pos, *start_room, handle); |
| 954 | } |
| 955 | |
| 956 | if (ROOMNUM_OUTSIDEcxx . . $ `lib/object_external_struct.h:127:9`!(next_room) && ROOMNUM_OUTSIDEcxx . . $ `lib/object_external_struct.h:127:9`!(*end_room) && |
| 957 | (TERRAIN_REGIONcxx . . $ TERRAIN_REGION(7864480464b09eea).(next_room) == TERRAIN_REGIONcxx . . $ TERRAIN_REGION(7864480464b09eea).(*end_room) || TERRAIN_REGIONcxx . . $ TERRAIN_REGION(7864480464b09eea).(*end_room) == 0 || |
| 958 | TERRAIN_REGIONcxx . . $ TERRAIN_REGION(7864480464b09eea).(next_room) == 0)) { |
| 959 | next_room = *end_room; |
| 960 | } |
| 961 | |
| 962 | while ((BOA_INDEXcxx . . $ `Descent3/BOA.h:197:9`!(next_room) != BOA_GetNextRoomcxx . . $ BOA_GetNextRoom(9b79fb6aee4c0440).(next_room, *end_room)) && (next_room != BOA_NO_PATHcxx . . $ `Descent3/BOA.h:198:9`!)) { |
| 963 | int cur_room; |
| 964 | |
| 965 | cur_room = next_room; |
| 966 | next_room = BOA_GetNextRoomcxx . . $ BOA_GetNextRoom(9b79fb6aee4c0440).(next_room, *end_room); |
| 967 | |
| 968 | if (next_room != cur_room && next_room != BOA_NO_PATHcxx . . $ `Descent3/BOA.h:198:9`! && BOA_INDEXcxx . . $ `Descent3/BOA.h:197:9`!(next_room) <= Highest_room_indexcxx . . $ Highest_room_index.) { |
| 969 | int i; |
| 970 | |
| 971 | for (i = 0; i < Roomscxx . . $ Rooms.[next_room].num_portalscxx . . $ room#num_portals.; i++) { |
| 972 | if (Roomscxx . . $ Rooms.[next_room].portalscxx . . $ room#portals.[i].croomcxx . . $ portal#croom. == cur_room) { |
| 973 | pos = &Roomscxx . . $ Rooms.[next_room].portalscxx . . $ room#portals.[i].path_pntcxx . . $ portal#path_pnt.; |
| 974 | break; |
| 975 | } |
| 976 | |
| 977 | if (Roomscxx . . $ Rooms.[Roomscxx . . $ Rooms.[next_room].portalscxx . . $ room#portals.[i].croomcxx . . $ portal#croom.].flagscxx . . $ room#flags. & RF_EXTERNALcxx . . $ `Descent3/room_external.h:177:9`!) { |
| 978 | int cell = GetTerrainCellFromPoscxx . . $ GetTerrainCellFromPos(177d9005acf670a0).(&Roomscxx . . $ Rooms.[next_room].portalscxx . . $ room#portals.[i].path_pntcxx . . $ portal#path_pnt.); |
| 979 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(cell != -1); // DAJ -1FIX |
| 980 | int region = TERRAIN_REGIONcxx . . $ TERRAIN_REGION(7864480464b09eea).(cell); |
| 981 | |
| 982 | if (Highest_room_indexcxx . . $ Highest_room_index. + region + 1 == BOA_INDEXcxx . . $ `Descent3/BOA.h:197:9`!(cur_room)) { |
| 983 | pos = &Roomscxx . . $ Rooms.[next_room].portalscxx . . $ room#portals.[i].path_pntcxx . . $ portal#path_pnt.; |
| 984 | break; |
| 985 | } |
| 986 | } |
| 987 | } |
| 988 | |
| 989 | // Add the adjoining room's portal point |
| 990 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(i < Rooms[next_room].num_portals); |
| 991 | AIPathAddDPathNodecxx . . $ AIPathAddDPathNode(e36d515051d5afd1).(aip, slot, cur_node, pos, next_room, handle); |
| 992 | |
| 993 | // Add its center point |
| 994 | pos = &Roomscxx . . $ Rooms.[next_room].path_pntcxx . . $ room#path_pnt.; |
| 995 | AIPathAddDPathNodecxx . . $ AIPathAddDPathNode(e36d515051d5afd1).(aip, slot, cur_node, pos, next_room, handle); |
| 996 | } else { |
| 997 | if (next_room == BOA_NO_PATHcxx . . $ `Descent3/BOA.h:198:9`!) { |
| 998 | f_path_exists = false; |
| 999 | } else if (BOA_INDEXcxx . . $ `Descent3/BOA.h:197:9`!(cur_room) <= Highest_room_indexcxx . . $ Highest_room_index. && cur_room != next_room) { |
| 1000 | int p_index = BOA_DetermineStartRoomPortalcxx . . $ BOA_DetermineStartRoomPortal(836cef11f1e7b2ee).(cur_room, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, next_room, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!); |
| 1001 | |
| 1002 | if (p_index >= 0) { |
| 1003 | pos = &Roomscxx . . $ Rooms.[cur_room].portalscxx . . $ room#portals.[p_index].path_pntcxx . . $ portal#path_pnt.; |
| 1004 | AIPathAddDPathNodecxx . . $ AIPathAddDPathNode(e36d515051d5afd1).(aip, slot, cur_node, pos, cur_room, handle); |
| 1005 | } |
| 1006 | } |
| 1007 | } |
| 1008 | } |
| 1009 | |
| 1010 | return f_path_exists; |
| 1011 | } |
| 1012 | |
| 1013 | bool AIPathAllocPathcxx . . $ AIPathAllocPath(896bfa3f698eea41).(objectcxx . . $ object# *obj, ai_framecxx . . $ ai_frame# *ai_info, void *goal_ptr, int *start_room, vectorcxx . . $ vector# *start_pos, int *end_room, |
| 1014 | vectorcxx . . $ vector# *end_pos, float rad, int flags, int handle, int ignore_obj) { |
| 1015 | bool status; |
| 1016 | bool f_path_exists = true; |
| 1017 | |
| 1018 | ai_path_infocxx . . $ ai_path_info# *aip = &ai_info->pathcxx . . $ ai_frame#path.; |
| 1019 | |
| 1020 | #ifdef _DEBUGcxx . . $ `<built-in>:482:9`! |
| 1021 | if (AI_debug_robot_docxx . . $ AI_debug_robot_do. && OBJNUMcxx . . $ `Descent3/object.h:700:9`!(obj) == AI_debug_robot_indexcxx . . $ AI_debug_robot_index.) { |
| 1022 | mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "AI Note: In free path\n"); |
| 1023 | } |
| 1024 | #endif |
| 1025 | AIPathFreePathcxx . . $ AIPathFreePath(211cadd9cc3984f1).(aip); |
| 1026 | |
| 1027 | // if(ai_info->awareness <= AWARE_NONE && !(ai_info->flags & AIF_PERSISTANT)) // chrishack -- scalar max_nodes in |
| 1028 | // path by awareness return false; |
| 1029 | |
| 1030 | aip->goal_indexcxx . . $ ai_path_info#goal_index. = (goalcxx . . $ goal# *)goal_ptr - ai_info->goalscxx . . $ ai_frame#goals.; |
| 1031 | aip->goal_uidcxx . . $ ai_path_info#goal_uid. = ((goalcxx . . $ goal# *)goal_ptr)->goal_uidcxx . . $ goal#goal_uid.; |
| 1032 | |
| 1033 | status = AIPathAddDPathcxx . . $ AIPathAddDPath(b6b555a4deffc6d9).(aip, handle); |
| 1034 | |
| 1035 | if (status) { |
| 1036 | int slot = aip->path_idcxx . . $ ai_path_info#path_id.[0]; |
| 1037 | int cur_node = 0; |
| 1038 | |
| 1039 | // Account for closed doors |
| 1040 | if (BOA_GetNextRoomcxx . . $ BOA_GetNextRoom(9b79fb6aee4c0440).(*start_room, *end_room) != BOA_NO_PATHcxx . . $ `Descent3/BOA.h:198:9`!) { |
| 1041 | bool f_make_alt = false; |
| 1042 | bool f_bline_ok = false; |
| 1043 | int last_room; |
| 1044 | fvi_querycxx . . $ fvi_query# fq; |
| 1045 | fvi_infocxx . . $ fvi_info# hit_info; |
| 1046 | |
| 1047 | fq.p0cxx . . $ fvi_query#p0. = start_pos; |
| 1048 | fq.startroomcxx . . $ fvi_query#startroom. = *start_room; |
| 1049 | fq.p1cxx . . $ fvi_query#p1. = end_pos; |
| 1050 | fq.radcxx . . $ fvi_query#rad. = obj->sizecxx . . $ object#size. - .1f; |
| 1051 | if (fq.radcxx . . $ fvi_query#rad. <= 0.0f) |
| 1052 | fq.radcxx . . $ fvi_query#rad. = .1f; |
| 1053 | fq.thisobjnumcxx . . $ fvi_query#thisobjnum. = OBJNUMcxx . . $ `Descent3/object.h:700:9`!(obj); |
| 1054 | fq.ignore_obj_listcxx . . $ fvi_query#ignore_obj_list. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 1055 | fq.flagscxx . . $ fvi_query#flags. = FQ_CHECK_OBJScxx . . $ `lib/findintersection_external.h:59:9`! | FQ_NO_RELINKcxx . . $ `lib/findintersection_external.h:73:9`! | FQ_IGNORE_WEAPONScxx . . $ `lib/findintersection_external.h:79:9`! | FQ_IGNORE_POWERUPScxx . . $ `lib/findintersection_external.h:62:9`!; |
| 1056 | |
| 1057 | int fate = fvi_FindIntersectioncxx . . $ fvi_FindIntersection(e1c4d7bd350effc8).(&fq, &hit_info); |
| 1058 | |
| 1059 | if (fate == HIT_NONEcxx . . $ `lib/findintersection_external.h:45:9`! || |
| 1060 | ((fate == HIT_OBJECTcxx . . $ `lib/findintersection_external.h:47:9`! || fate == HIT_SPHERE_2_POLY_OBJECTcxx . . $ `lib/findintersection_external.h:52:9`!) && hit_info.hit_objectcxx . . $ fvi_info#hit_object.[0] == ignore_obj)) { |
| 1061 | f_make_alt = false; |
| 1062 | f_bline_ok = true; |
| 1063 | } else if (BOA_Arraycxx . . $ BOA_Array.[BOA_INDEXcxx . . $ `Descent3/BOA.h:197:9`!(*start_room)][BOA_INDEXcxx . . $ `Descent3/BOA.h:197:9`!(*end_room)] & BOAF_TOO_SMALL_FOR_ROBOTcxx . . $ `Descent3/BOA.h:233:9`!) { |
| 1064 | f_make_alt = true; |
| 1065 | } else if (BOA_HasPossibleBlockagecxx . . $ BOA_HasPossibleBlockage(cf9ef193275fa6d8).(*start_room, *end_room)) { |
| 1066 | int next_room = BOA_INDEXcxx . . $ `Descent3/BOA.h:197:9`!(*start_room); |
| 1067 | |
| 1068 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(next_room >= 0 && next_room <= Highest_room_index + 8); |
| 1069 | |
| 1070 | do { |
| 1071 | if (next_room != BOA_INDEXcxx . . $ `Descent3/BOA.h:197:9`!(*start_room) && BOA_LockedDoorcxx . . $ BOA_LockedDoor(9985ed114f2bfc78).(obj, next_room)) { |
| 1072 | f_make_alt = true; |
| 1073 | break; |
| 1074 | } |
| 1075 | |
| 1076 | last_room = next_room; |
| 1077 | next_room = BOA_GetNextRoomcxx . . $ BOA_GetNextRoom(9b79fb6aee4c0440).(next_room, *end_room); |
| 1078 | |
| 1079 | if (BOA_INDEXcxx . . $ `Descent3/BOA.h:197:9`!(last_room) != BOA_INDEXcxx . . $ `Descent3/BOA.h:197:9`!(next_room) && next_room != BOA_NO_PATHcxx . . $ `Descent3/BOA.h:198:9`!) { |
| 1080 | if (BOA_DetermineStartRoomPortalcxx . . $ BOA_DetermineStartRoomPortal(836cef11f1e7b2ee).(last_room, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, next_room, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) == -1) { |
| 1081 | f_make_alt = true; |
| 1082 | break; |
| 1083 | } |
| 1084 | } |
| 1085 | } while (BOA_INDEXcxx . . $ `Descent3/BOA.h:197:9`!(next_room) != BOA_INDEXcxx . . $ `Descent3/BOA.h:197:9`!(*start_room) && (BOA_INDEXcxx . . $ `Descent3/BOA.h:197:9`!(next_room) != BOA_INDEXcxx . . $ `Descent3/BOA.h:197:9`!(*end_room)) && |
| 1086 | (next_room != BOA_NO_PATHcxx . . $ `Descent3/BOA.h:198:9`!)); |
| 1087 | } |
| 1088 | |
| 1089 | error_make_alt: |
| 1090 | |
| 1091 | if (f_make_alt) { |
| 1092 | f_path_exists = AIFindAltPathcxx . . $ AIFindAltPath(4c063a45e14c3cfe).(obj, *start_room, *end_room); |
| 1093 | |
| 1094 | if (f_path_exists) { |
| 1095 | bool f_bnode_ok = BNode_allocatedcxx . . $ BNode_allocated. && BNode_verifiedcxx . . $ BNode_verified. && |
| 1096 | !((ROOMNUM_OUTSIDEcxx . . $ `lib/object_external_struct.h:127:9`!(*start_room) && TERRAIN_REGIONcxx . . $ TERRAIN_REGION(7864480464b09eea).(*start_room) == 0) || |
| 1097 | (ROOMNUM_OUTSIDEcxx . . $ `lib/object_external_struct.h:127:9`!(*end_room) && TERRAIN_REGIONcxx . . $ TERRAIN_REGION(7864480464b09eea).(*end_room) == 0)) && |
| 1098 | !(ROOMNUM_OUTSIDEcxx . . $ `lib/object_external_struct.h:127:9`!(*start_room) && ROOMNUM_OUTSIDEcxx . . $ `lib/object_external_struct.h:127:9`!(*end_room) && |
| 1099 | TERRAIN_REGIONcxx . . $ TERRAIN_REGION(7864480464b09eea).(*start_room) != TERRAIN_REGIONcxx . . $ TERRAIN_REGION(7864480464b09eea).(*end_room)); |
| 1100 | |
| 1101 | if (f_bnode_ok) |
| 1102 | f_path_exists = |
| 1103 | AIGenerateAltBNodePathcxx . . $ AIGenerateAltBNodePath(959b8427c4b76a9f).(obj, start_pos, start_room, end_pos, end_room, aip, &slot, &cur_node, handle); |
| 1104 | else |
| 1105 | AIGenerateAltBOAPathcxx . . $ AIGenerateAltBOAPath(de89b0408393e677).(start_pos, end_pos, aip, &slot, &cur_node, handle); |
| 1106 | |
| 1107 | if (!f_path_exists) { |
| 1108 | mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Warning Alt path from %d to %d failed.\n", *start_room, *end_room); |
| 1109 | } |
| 1110 | } |
| 1111 | } else if (!f_bline_ok) { |
| 1112 | bool f_bnode_ok = BNode_allocatedcxx . . $ BNode_allocated. && BNode_verifiedcxx . . $ BNode_verified. && |
| 1113 | !((ROOMNUM_OUTSIDEcxx . . $ `lib/object_external_struct.h:127:9`!(*start_room) && TERRAIN_REGIONcxx . . $ TERRAIN_REGION(7864480464b09eea).(*start_room) == 0) || |
| 1114 | (ROOMNUM_OUTSIDEcxx . . $ `lib/object_external_struct.h:127:9`!(*end_room) && TERRAIN_REGIONcxx . . $ TERRAIN_REGION(7864480464b09eea).(*end_room) == 0)) && |
| 1115 | !(ROOMNUM_OUTSIDEcxx . . $ `lib/object_external_struct.h:127:9`!(*start_room) && ROOMNUM_OUTSIDEcxx . . $ `lib/object_external_struct.h:127:9`!(*end_room) && |
| 1116 | TERRAIN_REGIONcxx . . $ TERRAIN_REGION(7864480464b09eea).(*start_room) != TERRAIN_REGIONcxx . . $ TERRAIN_REGION(7864480464b09eea).(*end_room)); |
| 1117 | |
| 1118 | if (f_bnode_ok) |
| 1119 | f_path_exists = |
| 1120 | AIGenerateBNodePathcxx . . $ AIGenerateBNodePath(959b8427c4b76a9f).(obj, start_pos, start_room, end_pos, end_room, aip, &slot, &cur_node, handle); |
| 1121 | else |
| 1122 | f_path_exists = AIGenerateBOAPathcxx . . $ AIGenerateBOAPath(8d18e519f8eea6bf).(start_pos, start_room, end_pos, end_room, aip, &slot, &cur_node, handle); |
| 1123 | |
| 1124 | if (!f_path_exists) { |
| 1125 | f_make_alt = true; |
| 1126 | goto error_make_alt; |
| 1127 | } |
| 1128 | } |
| 1129 | |
| 1130 | if (f_path_exists) { |
| 1131 | // Add the end point |
| 1132 | AIPathAddDPathNodecxx . . $ AIPathAddDPathNode(e36d515051d5afd1).(aip, &slot, &cur_node, end_pos, *end_room, handle); |
| 1133 | |
| 1134 | // Makes sure that the last dynamic path |
| 1135 | AIDynamicPathcxx . . $ AIDynamicPath.[slot].num_nodescxx . . $ ai_dynamic_path#num_nodes. = cur_node; |
| 1136 | } |
| 1137 | } else { |
| 1138 | f_path_exists = false; |
| 1139 | // if(!(0x80000000 & *start_room) || !(0x80000000 & *end_room)) |
| 1140 | // mprintf(0, "No path available from %d to %d\n", *start_room, *end_room); |
| 1141 | |
| 1142 | #ifdef _DEBUGcxx . . $ `<built-in>:482:9`! |
| 1143 | if (AI_debug_robot_docxx . . $ AI_debug_robot_do. && OBJNUMcxx . . $ `Descent3/object.h:700:9`!(obj) == AI_debug_robot_indexcxx . . $ AI_debug_robot_index.) { |
| 1144 | mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "AI Note: In free path\n"); |
| 1145 | } |
| 1146 | #endif |
| 1147 | |
| 1148 | AIPathFreePathcxx . . $ AIPathFreePath(211cadd9cc3984f1).(aip); |
| 1149 | return false; |
| 1150 | } |
| 1151 | } else { |
| 1152 | f_path_exists = false; |
| 1153 | mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "No dynamic paths left\n"); |
| 1154 | } |
| 1155 | |
| 1156 | if (!f_path_exists) { |
| 1157 | #ifdef _DEBUGcxx . . $ `<built-in>:482:9`! |
| 1158 | if (AI_debug_robot_docxx . . $ AI_debug_robot_do. && OBJNUMcxx . . $ `Descent3/object.h:700:9`!(obj) == AI_debug_robot_indexcxx . . $ AI_debug_robot_index.) { |
| 1159 | mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "AI Note: In free path\n"); |
| 1160 | } |
| 1161 | #endif |
| 1162 | |
| 1163 | AIPathFreePathcxx . . $ AIPathFreePath(211cadd9cc3984f1).(aip); |
| 1164 | return false; |
| 1165 | } |
| 1166 | |
| 1167 | return true; |
| 1168 | } |
| 1169 | |
| 1170 | bool AIPathSetAsStaticPathcxx . . $ AIPathSetAsStaticPath(adaaf699fc2cec17).(objectcxx . . $ object# *obj, void *goal_ptr, int path_id, int start_node, int end_node, int cur_node) { |
| 1171 | bool status; |
| 1172 | ai_framecxx . . $ ai_frame# *ai_info = obj->ai_infocxx . . $ object#ai_info.; |
| 1173 | ai_path_infocxx . . $ ai_path_info# *aip = &ai_info->pathcxx . . $ ai_frame#path.; |
| 1174 | |
| 1175 | #ifdef _DEBUGcxx . . $ `<built-in>:482:9`! |
| 1176 | if (AI_debug_robot_docxx . . $ AI_debug_robot_do. && OBJNUMcxx . . $ `Descent3/object.h:700:9`!(obj) == AI_debug_robot_indexcxx . . $ AI_debug_robot_index.) { |
| 1177 | mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "AI Note: In free path\n"); |
| 1178 | } |
| 1179 | #endif |
| 1180 | AIPathFreePathcxx . . $ AIPathFreePath(211cadd9cc3984f1).(aip); |
| 1181 | |
| 1182 | aip->goal_indexcxx . . $ ai_path_info#goal_index. = (goalcxx . . $ goal# *)goal_ptr - ai_info->goalscxx . . $ ai_frame#goals.; |
| 1183 | aip->goal_uidcxx . . $ ai_path_info#goal_uid. = ((goalcxx . . $ goal# *)goal_ptr)->goal_uidcxx . . $ goal#goal_uid.; |
| 1184 | |
| 1185 | status = AIPathAddStaticPathcxx . . $ AIPathAddStaticPath(ad1202099d56ed20).(aip, path_id, start_node, end_node); |
| 1186 | |
| 1187 | if (status) { |
| 1188 | aip->cur_nodecxx . . $ ai_path_info#cur_node. = cur_node; |
| 1189 | } |
| 1190 | |
| 1191 | return status; |
| 1192 | } |
| 1193 | |
| 1194 | #ifdef _DEBUGcxx . . $ `<built-in>:482:9`! |
| 1195 | |
| 1196 | #include "hud.h"cxx . . $ `<file>/Descent3/hud.h`/ |
| 1197 | |
| 1198 | int AIPath_test_end_roomcxx . . $ AIPath_test_end_room. = 0; |
| 1199 | vectorcxx . . $ vector# AIPath_test_end_poscxx . . $ AIPath_test_end_pos. = {0, 0, 0}; |
| 1200 | |
| 1201 | bool MakeTestPathcxx . . $ MakeTestPath(26b728a3f807ec4f).(int *start_room, vectorcxx . . $ vector# *pos) { |
| 1202 | bool status; |
| 1203 | ai_framecxx . . $ ai_frame# ai_info; |
| 1204 | int count = 0; |
| 1205 | |
| 1206 | ai_info.awarenesscxx . . $ ai_frame#awareness. = AWARE_MOSTLYcxx . . $ `Descent3/aistruct_external.h:324:9`!; |
| 1207 | |
| 1208 | AIPathInitPathcxx . . $ AIPathInitPath(211cadd9cc3984f1).(&ai_info.pathcxx . . $ ai_frame#path.); |
| 1209 | |
| 1210 | status = AIPathAllocPathcxx . . $ AIPathAllocPath(896bfa3f698eea41).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, &ai_info, &ai_info.goalscxx . . $ ai_frame#goals.[0], start_room, pos, &AIPath_test_end_roomcxx . . $ AIPath_test_end_room., |
| 1211 | &AIPath_test_end_poscxx . . $ AIPath_test_end_pos., 0.0f, 0, 0); |
| 1212 | |
| 1213 | while (status) { |
| 1214 | vectorcxx . . $ vector# pos; |
| 1215 | int room; |
| 1216 | |
| 1217 | status = AIPathGetCurrentNodePoscxx . . $ AIPathGetCurrentNodePos(ea4bd046b9d29bc1).(&ai_info.pathcxx . . $ ai_frame#path., &pos, &room); |
| 1218 | |
| 1219 | if (status) { |
| 1220 | int id = FindObjectIDNamecxx . . $ FindObjectIDName(5c4306d8553b3696).("Shield"); |
| 1221 | ObjCreatecxx . . $ ObjCreate(849c3da80a4f387f).(OBJ_POWERUPcxx . . $ `Descent3/object_external.h:167:9`!, id, room, &pos, &Identity_matrixcxx . . $ Identity_matrix.); |
| 1222 | count++; |
| 1223 | } |
| 1224 | |
| 1225 | status = AIPathMoveToNextNodecxx . . $ AIPathMoveToNextNode(211cadd9cc3984f1).(&ai_info.pathcxx . . $ ai_frame#path.); |
| 1226 | } |
| 1227 | |
| 1228 | AddHUDMessagecxx . . $ AddHUDMessage(f90d95ab21fd6d97).("The test path has %d nodes.", count); |
| 1229 | |
| 1230 | // #ifdef _DEBUG |
| 1231 | // if(AI_debug_robot_do && OBJNUM(obj) == AI_debug_robot_index) |
| 1232 | // { |
| 1233 | // mprintf(0, "AI Note: In free path\n"); |
| 1234 | // } |
| 1235 | // #endif |
| 1236 | AIPathFreePathcxx . . $ AIPathFreePath(211cadd9cc3984f1).(&ai_info.pathcxx . . $ ai_frame#path.); |
| 1237 | |
| 1238 | return true; |
| 1239 | } |
| 1240 | |
| 1241 | #endif |