| 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 | --- HISTORICAL COMMENTS FOLLOW --- |
| 19 | |
| 20 | * $Logfile: /DescentIII/main/BOA.h $ |
| 21 | * $Revision: 34 $ |
| 22 | * $Date: 4/30/99 5:40p $ |
| 23 | * $Author: Jason $ |
| 24 | * |
| 25 | * BOA Header |
| 26 | * |
| 27 | * $Log: /DescentIII/main/BOA.h $ |
| 28 | * |
| 29 | * 34 4/30/99 5:40p Jason |
| 30 | * fixed some issues with release builds |
| 31 | * |
| 32 | * 33 4/29/99 5:43p Chris |
| 33 | * Added the check for bad center points |
| 34 | * |
| 35 | * 32 4/26/99 11:11a Chris |
| 36 | * Updated Bnode system |
| 37 | * |
| 38 | * 31 4/20/99 8:55p Chris |
| 39 | * Fixed problem with robots not being able to open locked doors that a |
| 40 | * player has the key for. |
| 41 | * |
| 42 | * 30 4/18/99 5:39a Chris |
| 43 | * Vastly improved the path node system |
| 44 | * |
| 45 | * 29 2/25/99 5:43p Chris |
| 46 | * Massive improvement to BOA and AI (again) |
| 47 | * |
| 48 | * 28 2/24/99 12:27p Chris |
| 49 | * Fixed problems with GB finding robots/room he couldn't get to. Fixed |
| 50 | * problems with forcefields(sound prop. and path finding). Fixed |
| 51 | * problems with small portals. |
| 52 | * |
| 53 | * 27 2/12/99 11:22a Chris |
| 54 | * Updated what BOA uses for BOA_cost_array. It is not just the distance |
| 55 | * from the center of the room to the center of the portal. It was this + |
| 56 | * the dist to the next room's center. The reason for this change was it |
| 57 | * makes it easier to compute the exact BOA_DIST for sounds. This is |
| 58 | * because the two distances are seperated (so from the start pos, we do a |
| 59 | * vm_Vect dist from the start point to the portal)... Hmmm.... |
| 60 | * |
| 61 | * 26 2/09/99 12:41p Chris |
| 62 | * |
| 63 | * 25 2/09/99 12:40p Chris |
| 64 | * More aipath stuff has been merged with the new BOA |
| 65 | * |
| 66 | * 24 2/09/99 12:17p Chris |
| 67 | * |
| 68 | * 23 2/09/99 9:58a Chris |
| 69 | * Massive BOA update :) Terrain happy now. Vis happy now. Sound happy |
| 70 | * now. |
| 71 | * |
| 72 | * 22 1/11/99 2:14p Chris |
| 73 | * Massive work on OSIRIS and AI |
| 74 | * |
| 75 | * 21 12/11/98 1:55p Chris |
| 76 | * Reduced BOA's size and changed how it works with no path situations |
| 77 | * |
| 78 | * 20 12/09/98 10:41a Jason |
| 79 | * fixed BOA problems with lighting |
| 80 | * |
| 81 | * 19 9/16/98 12:07p Chris |
| 82 | * Improved BOA AABB computation with room checksums |
| 83 | * |
| 84 | * 18 8/04/98 2:32p Chris |
| 85 | * Improved attach code added more fixes to the AABB partial computation |
| 86 | * patch |
| 87 | * |
| 88 | * 17 8/03/98 5:47p Chris |
| 89 | * Improved the partial AABB computation |
| 90 | * |
| 91 | * 16 7/21/98 2:14p Chris |
| 92 | * Some FVI speedups - not done |
| 93 | * |
| 94 | * 15 7/20/98 5:39p Jason |
| 95 | * fixed MACRO bug |
| 96 | * |
| 97 | * 14 7/20/98 4:45p Jason |
| 98 | * added BOA vis table stuff |
| 99 | * |
| 100 | * 13 7/16/98 8:29p Chris |
| 101 | * Intermediate checkin |
| 102 | * |
| 103 | * 12 7/16/98 8:29p Chris |
| 104 | * Partial implementation of the new collide code |
| 105 | * |
| 106 | * 11 5/03/98 8:36p Chris |
| 107 | * Additional debug info |
| 108 | * |
| 109 | * 10 4/28/98 12:01p Matt |
| 110 | * Dropped MAX_PATH_PORTALS from 100 down to 40. |
| 111 | * |
| 112 | * 9 4/22/98 6:38p Matt |
| 113 | * Added SourceSafe header |
| 114 | * |
| 115 | */ |
| 116 | |
| 117 | #ifndef _BOA_H__ |
| 118 | #define _BOA_H__cxx . . $ `Descent3/BOA.h:118:9`! |
| 119 | |
| 120 | #include "room.h"cxx . . $ `<file>/Descent3/room.h`/ |
| 121 | #include "terrain.h"cxx . . $ `<file>/Descent3/terrain.h`/ |
| 122 | |
| 123 | #define MAX_PATH_PORTALScxx . . $ `Descent3/BOA.h:123:9`! 40 |
| 124 | #define MAX_BOA_TERRAIN_REGIONScxx . . $ `Descent3/BOA.h:124:9`! 8 |
| 125 | |
| 126 | extern float BOA_cost_arraycxx . . $ BOA_cost_array.[MAX_ROOMScxx . . $ `Descent3/room.h:377:9`! + MAX_BOA_TERRAIN_REGIONScxx . . $ `Descent3/BOA.h:124:9`!][MAX_PATH_PORTALScxx . . $ `Descent3/BOA.h:123:9`!]; |
| 127 | extern uint16_tcxx . . $ uint16_t# BOA_Arraycxx . . $ BOA_Array.[MAX_ROOMScxx . . $ `Descent3/room.h:377:9`! + MAX_BOA_TERRAIN_REGIONScxx . . $ `Descent3/BOA.h:124:9`!][MAX_ROOMScxx . . $ `Descent3/room.h:377:9`! + MAX_BOA_TERRAIN_REGIONScxx . . $ `Descent3/BOA.h:124:9`!]; |
| 128 | extern int BOA_mine_checksumcxx . . $ BOA_mine_checksum.; |
| 129 | extern int BOA_AABB_checksumcxx . . $ BOA_AABB_checksum.; |
| 130 | extern int BOA_vis_checksumcxx . . $ BOA_vis_checksum.; |
| 131 | extern bool BOA_vis_validcxx . . $ BOA_vis_valid.; |
| 132 | extern int BOA_AABB_ROOM_checksumcxx . . $ BOA_AABB_ROOM_checksum.[MAX_ROOMScxx . . $ `Descent3/room.h:377:9`! + MAX_BOA_TERRAIN_REGIONScxx . . $ `Descent3/BOA.h:124:9`!]; |
| 133 | |
| 134 | //-- Priority Queue |
| 135 | class q_itemcxx . . $ q_item# { |
| 136 | public: |
| 137 | q_itemcxx . . $ q_item#q_item(c2f439e40e2f19ed).(int room_index, int par, float n_cost) { |
| 138 | roomnumcxx . . $ q_item#roomnum. = room_index; |
| 139 | parentcxx . . $ q_item#parent. = par; |
| 140 | costcxx . . $ q_item#cost. = n_cost; |
| 141 | nextcxx . . $ q_item#next. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 142 | } |
| 143 | |
| 144 | int roomnumcxx . . $ q_item#roomnum.; |
| 145 | int parentcxx . . $ q_item#parent.; |
| 146 | float costcxx . . $ q_item#cost.; |
| 147 | |
| 148 | q_itemcxx . . $ q_item# *nextcxx . . $ q_item#next.; |
| 149 | }; |
| 150 | |
| 151 | class pqcxx . . $ pq# { |
| 152 | q_itemcxx . . $ q_item# *q_headcxx . . $ pq#q_head.; |
| 153 | |
| 154 | public: |
| 155 | pqcxx . . $ pq#pq(49f6e7a06ebc5aa8).() { q_headcxx . . $ pq#q_head. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; } |
| 156 | |
| 157 | void pushcxx . . $ pq#push(240407348a0b1927).(q_itemcxx . . $ q_item# *new_node) { |
| 158 | new_node->nextcxx . . $ q_item#next. = q_headcxx . . $ pq#q_head.; |
| 159 | q_headcxx . . $ pq#q_head. = new_node; |
| 160 | } |
| 161 | |
| 162 | q_itemcxx . . $ q_item# *popcxx . . $ pq#pop(df628bf610f7b0b3).() { |
| 163 | q_itemcxx . . $ q_item# *cur_item = q_headcxx . . $ pq#q_head.; |
| 164 | q_itemcxx . . $ q_item# *prev_item = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 165 | q_itemcxx . . $ q_item# *best_item = q_headcxx . . $ pq#q_head.; |
| 166 | q_itemcxx . . $ q_item# *best_prev_item = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 167 | |
| 168 | if (q_headcxx . . $ pq#q_head. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) |
| 169 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 170 | |
| 171 | while (cur_item != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) { |
| 172 | if (cur_item->costcxx . . $ q_item#cost. < best_item->costcxx . . $ q_item#cost.) { |
| 173 | |
| 174 | best_prev_item = prev_item; |
| 175 | best_item = cur_item; |
| 176 | } |
| 177 | |
| 178 | prev_item = cur_item; |
| 179 | cur_item = cur_item->nextcxx . . $ q_item#next.; |
| 180 | } |
| 181 | |
| 182 | // Actually remove this item from the list |
| 183 | if (best_item == q_headcxx . . $ pq#q_head.) { |
| 184 | q_headcxx . . $ pq#q_head. = best_item->nextcxx . . $ q_item#next.; |
| 185 | } else { |
| 186 | best_prev_item->nextcxx . . $ q_item#next. = best_item->nextcxx . . $ q_item#next.; |
| 187 | } |
| 188 | |
| 189 | return best_item; |
| 190 | } |
| 191 | }; |
| 192 | |
| 193 | // Next Segment Info |
| 194 | #define BOA_ROOM_MASKcxx . . $ `Descent3/BOA.h:194:9`! 0x03FF |
| 195 | |
| 196 | #define BOA_TERRAIN_INDEXcxx . . $ `Descent3/BOA.h:196:9`! (Highest_room_index + 1) |
| 197 | #define BOA_INDEXcxx . . $ `Descent3/BOA.h:197:9`!(x) ((ROOMNUM_OUTSIDEcxx . . $ `lib/object_external_struct.h:127:9`!(x) ? (TERRAIN_REGION(x) + Highest_room_index + 1) : x)) |
| 198 | #define BOA_NO_PATHcxx . . $ `Descent3/BOA.h:198:9`! (Highest_room_index + 9) |
| 199 | |
| 200 | #define BOA_NEXT_ROOMcxx . . $ `Descent3/BOA.h:200:9`!(a, b) (BOA_Array[a][b] & BOA_ROOM_MASKcxx . . $ `Descent3/BOA.h:194:9`!) |
| 201 | |
| 202 | // Visability Info |
| 203 | |
| 204 | #define BOAF_VIScxx . . $ `Descent3/BOA.h:204:9`! 0x0400 |
| 205 | |
| 206 | #define BOA_GET_VIScxx . . $ `Descent3/BOA.h:206:9`!(a, b) (BOA_vis_valid ? ((BOA_Array[a][b] & BOAF_VIS) != 0) : 1) |
| 207 | |
| 208 | // Set if a sound could prop between these to areas |
| 209 | #define BOA_SOUND_PROPcxx . . $ `Descent3/BOA.h:209:9`! 0x0800 |
| 210 | |
| 211 | // Distance from segment to segment Info |
| 212 | |
| 213 | #define BOA_DIST_MASKcxx . . $ `Descent3/BOA.h:213:9`! 0x3000 |
| 214 | |
| 215 | #define BOA_VNEAR_DISTcxx . . $ `Descent3/BOA.h:215:9`! 0.0 |
| 216 | #define BOA_NEAR_DISTcxx . . $ `Descent3/BOA.h:216:9`! 100.0 |
| 217 | #define BOA_FAR_DISTcxx . . $ `Descent3/BOA.h:217:9`! 200.0 |
| 218 | #define BOA_VFAR_DISTcxx . . $ `Descent3/BOA.h:218:9`! 300.0 |
| 219 | |
| 220 | #define BOAF_VNEAR_DISTcxx . . $ `Descent3/BOA.h:220:9`! 0x0000 // 0.0 to 100.0 |
| 221 | #define BOAF_NEAR_DISTcxx . . $ `Descent3/BOA.h:221:9`! 0x1000 // 100.0 to 200.0 |
| 222 | #define BOAF_FAR_DISTcxx . . $ `Descent3/BOA.h:222:9`! 0x2000 // 200.0 to 300.0 |
| 223 | #define BOAF_VFAR_DISTcxx . . $ `Descent3/BOA.h:223:9`! 0x3000 // 300.0+ |
| 224 | |
| 225 | #define BOA_GET_DISTcxx . . $ `Descent3/BOA.h:225:9`!(a, b) ((BOA_Array[a][b] & BOA_DIST_MASK) != 0) |
| 226 | |
| 227 | // Possible Blockage Info |
| 228 | |
| 229 | #define BOAF_BLOCKAGEcxx . . $ `Descent3/BOA.h:229:9`! 0x4000 |
| 230 | #define BOA_HAS_POSSIBLE_BLOCKAGEcxx . . $ `Descent3/BOA.h:230:9`!(a, b) ((BOA_Array[a][b] & BOAF_BLOCKAGE) != 0) |
| 231 | |
| 232 | // Path have a sport in it that is too small for a robot to get through |
| 233 | #define BOAF_TOO_SMALL_FOR_ROBOTcxx . . $ `Descent3/BOA.h:233:9`! 0x8000 |
| 234 | #define BOA_TOO_SMALL_FOR_ROBOTcxx . . $ `Descent3/BOA.h:234:9`!(a, b) ((BOA_Array[a][b] & BOAF_TOO_SMALL_FOR_ROBOT) != 0) |
| 235 | |
| 236 | struct connect_datacxx . . $ connect_data# { |
| 237 | int roomnumcxx . . $ connect_data#roomnum.; |
| 238 | int portalcxx . . $ connect_data#portal.; |
| 239 | }; |
| 240 | |
| 241 | extern int BOA_num_minescxx . . $ BOA_num_mines.; |
| 242 | extern int BOA_num_terrain_regionscxx . . $ BOA_num_terrain_regions.; |
| 243 | extern int BOA_num_connectcxx . . $ BOA_num_connect.[MAX_BOA_TERRAIN_REGIONScxx . . $ `Descent3/BOA.h:124:9`!]; |
| 244 | extern connect_datacxx . . $ connect_data# BOA_connectcxx . . $ BOA_connect.[MAX_BOA_TERRAIN_REGIONScxx . . $ `Descent3/BOA.h:124:9`!][MAX_PATH_PORTALScxx . . $ `Descent3/BOA.h:123:9`!]; |
| 245 | |
| 246 | void MakeBOAcxx . . $ MakeBOA(49f6e7a06ebc5aa8).(void); |
| 247 | |
| 248 | // Goes through all the rooms and determines their visibility in relation to one another |
| 249 | void MakeBOAVisTablecxx . . $ MakeBOAVisTable(b45ddcbc8423892c).(bool from_lighting = 0); |
| 250 | |
| 251 | // Computes the AABBs for the level |
| 252 | void ComputeAABBcxx . . $ ComputeAABB(b45ddcbc8423892c).(bool f_full); |
| 253 | |
| 254 | bool BOA_ComputeMinDistcxx . . $ BOA_ComputeMinDist(d76bc30baaf01f3b).(int start_room, int end_room, float max_check_dist, float *dist, int *num_blockages = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!); |
| 255 | bool BOA_ComputePropDistcxx . . $ BOA_ComputePropDist(37445a109bcb590f).(int start_room, vectorcxx . . $ vector# *start_pos, int end_room, vectorcxx . . $ vector# *end_pos, float *dist, |
| 256 | int *num_blockages); |
| 257 | bool BOA_IsSoundAudiblecxx . . $ BOA_IsSoundAudible(cf9ef193275fa6d8).(int start_room, int end_room); |
| 258 | bool BOA_IsVisiblecxx . . $ BOA_IsVisible(cf9ef193275fa6d8).(int start_room, int end_room); |
| 259 | bool BOA_HasPossibleBlockagecxx . . $ BOA_HasPossibleBlockage(cf9ef193275fa6d8).(int start_room, int end_room); |
| 260 | int BOA_GetNextRoomcxx . . $ BOA_GetNextRoom(9b79fb6aee4c0440).(int start_room, int end_room); |
| 261 | int BOA_DetermineStartRoomPortalcxx . . $ BOA_DetermineStartRoomPortal(836cef11f1e7b2ee).(int start_room, vectorcxx . . $ vector# *start_pos, int end_room, vectorcxx . . $ vector# *end_pos, |
| 262 | bool f_for_sound = false, bool f_making_robot_path_invalid_list = false, |
| 263 | int *blocked_portal = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!); |
| 264 | bool BOA_PassablePortalcxx . . $ BOA_PassablePortal(1c87feb9d04b51db).(int room, int portal_index, bool f_for_sound = false, |
| 265 | bool f_making_robot_path_invalid_list = false); |
| 266 | bool BOA_LockedDoorcxx . . $ BOA_LockedDoor(9985ed114f2bfc78).(objectcxx . . $ object# *obj, int roomnum); |
| 267 | void BOA_ComputePathPointscxx . . $ BOA_ComputePathPoints(a07d8cccb7673f5a).(char *message = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, int len = 0); |
| 268 | int BOAGetMineChecksumcxx . . $ BOAGetMineChecksum(b126dc7c1de90089).(); |
| 269 | |
| 270 | #endif |