1 /* 2 =========================================================================== 3 4 Return to Castle Wolfenstein multiplayer GPL Source Code 5 Copyright (C) 1999-2010 id Software LLC, a ZeniMax Media company. 6 7 This file is part of the Return to Castle Wolfenstein multiplayer GPL Source Code (RTCW MP Source Code). 8 9 RTCW MP Source Code is free software: you can redistribute it and/or modify 10 it under the terms of the GNU General Public License as published by 11 the Free Software Foundation, either version 3 of the License, or 12 (at your option) any later version. 13 14 RTCW MP Source Code is distributed in the hope that it will be useful, 15 but WITHOUT ANY WARRANTY; without even the implied warranty of 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 GNU General Public License for more details. 18 19 You should have received a copy of the GNU General Public License 20 along with RTCW MP Source Code. If not, see <http://www.gnu.org/licenses/>. 21 22 In addition, the RTCW MP Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the RTCW MP Source Code. If not, please request a copy in writing from id Software at the address below. 23 24 If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA. 25 26 =========================================================================== 27 */ 28 29 30 /***************************************************************************** 31 * name: be_aas_def.h 32 * 33 * desc: AAS 34 * 35 * 36 *****************************************************************************/ 37 38 #include "../qcommon/q_shared.h" 39 40 //debugging on 41 #define AAS_DEBUG 42 43 #define MAX_CONFIGSTRINGS 2048 //----(SA) upped 44 45 #define DF_AASENTNUMBER( x ) ( x - ( *aasworlds ).entities ) 46 #define DF_NUMBERAASENT( x ) ( &( *aasworlds ).entities[x] ) 47 #define DF_AASENTCLIENT( x ) ( x - ( *aasworlds ).entities - 1 ) 48 #define DF_CLIENTAASENT( x ) ( &( *aasworlds ).entities[x + 1] ) 49 50 //string index (for model, sound and image index) 51 typedef struct aas_stringindex_s 52 { 53 int numindexes; 54 char **index; 55 } aas_stringindex_t; 56 57 //structure to link entities to areas and areas to entities 58 typedef struct aas_link_s 59 { 60 int entnum; 61 int areanum; 62 struct aas_link_s *next_ent, *prev_ent; 63 struct aas_link_s *next_area, *prev_area; 64 } aas_link_t; 65 66 //structure to link entities to leaves and leaves to entities 67 typedef struct bsp_link_s 68 { 69 int entnum; 70 int leafnum; 71 struct bsp_link_s *next_ent, *prev_ent; 72 struct bsp_link_s *next_leaf, *prev_leaf; 73 } bsp_link_t; 74 75 typedef struct bsp_entdata_s 76 { 77 vec3_t origin; 78 vec3_t angles; 79 vec3_t absmins; 80 vec3_t absmaxs; 81 int solid; 82 int modelnum; 83 } bsp_entdata_t; 84 85 //entity 86 typedef struct aas_entity_s 87 { 88 //entity info 89 aas_entityinfo_t i; 90 //links into the AAS areas 91 aas_link_t *areas; 92 //links into the BSP leaves 93 bsp_link_t *leaves; 94 } aas_entity_t; 95 96 typedef struct aas_settings_s 97 { 98 float sv_friction; 99 float sv_stopspeed; 100 float sv_gravity; 101 float sv_waterfriction; 102 float sv_watergravity; 103 float sv_maxvelocity; 104 float sv_maxwalkvelocity; 105 float sv_maxcrouchvelocity; 106 float sv_maxswimvelocity; 107 float sv_walkaccelerate; 108 float sv_airaccelerate; 109 float sv_swimaccelerate; 110 float sv_maxstep; 111 float sv_maxsteepness; 112 float sv_maxwaterjump; 113 float sv_maxbarrier; 114 float sv_jumpvel; 115 } aas_settings_t; 116 117 //routing cache 118 typedef struct aas_routingcache_s 119 { 120 int size; //size of the routing cache 121 float time; //last time accessed or updated 122 int cluster; //cluster the cache is for 123 int areanum; //area the cache is created for 124 vec3_t origin; //origin within the area 125 float starttraveltime; //travel time to start with 126 int travelflags; //combinations of the travel flags 127 struct aas_routingcache_s *prev, *next; 128 unsigned char *reachabilities; //reachabilities used for routing 129 unsigned short int traveltimes[1]; //travel time for every area (variable sized) 130 } aas_routingcache_t; 131 132 //32bit values for pointers to allow loading cache on non-32 bit platforms 133 typedef struct 134 { 135 int size; //size of the routing cache 136 float time; //last time accessed or updated 137 int cluster; //cluster the cache is for 138 int areanum; //area the cache is created for 139 vec3_t origin; //origin within the area 140 float starttraveltime; //travel time to start with 141 int travelflags; //combinations of the travel flags 142 int prev_, next_; 143 int reachabilities_; //reachabilities used for routing 144 unsigned short int traveltimes[1]; //travel time for every area (variable sized) 145 } aas_routingcache_32_t; 146 147 //fields for the routing algorithm 148 typedef struct aas_routingupdate_s 149 { 150 int cluster; 151 int areanum; //area number of the update 152 vec3_t start; //start point the area was entered 153 unsigned short int tmptraveltime; //temporary travel time 154 unsigned short int *areatraveltimes; //travel times within the area 155 qboolean inlist; //true if the update is in the list 156 struct aas_routingupdate_s *next; 157 struct aas_routingupdate_s *prev; 158 } aas_routingupdate_t; 159 160 //reversed reachability link 161 typedef struct aas_reversedlink_s 162 { 163 int linknum; //the aas_areareachability_t 164 int areanum; //reachable from this area 165 struct aas_reversedlink_s *next; //next link 166 } aas_reversedlink_t; 167 168 //reversed area reachability 169 typedef struct aas_reversedreachability_s 170 { 171 int numlinks; 172 aas_reversedlink_t *first; 173 } aas_reversedreachability_t; 174 175 // Ridah, route-tables 176 #include "be_aas_routetable.h" 177 // done. 178 179 typedef struct aas_s 180 { 181 int loaded; //true when an AAS file is loaded 182 int initialized; //true when AAS has been initialized 183 int savefile; //set true when file should be saved 184 int bspchecksum; 185 //current time 186 float time; 187 int numframes; 188 //name of the aas file 189 char filename[MAX_QPATH]; 190 char mapname[MAX_QPATH]; 191 //bounding boxes 192 int numbboxes; 193 aas_bbox_t *bboxes; 194 //vertexes 195 int numvertexes; 196 aas_vertex_t *vertexes; 197 //planes 198 int numplanes; 199 aas_plane_t *planes; 200 //edges 201 int numedges; 202 aas_edge_t *edges; 203 //edge index 204 int edgeindexsize; 205 aas_edgeindex_t *edgeindex; 206 //faces 207 int numfaces; 208 aas_face_t *faces; 209 //face index 210 int faceindexsize; 211 aas_faceindex_t *faceindex; 212 //convex areas 213 int numareas; 214 aas_area_t *areas; 215 //convex area settings 216 int numareasettings; 217 aas_areasettings_t *areasettings; 218 //reachablity list 219 int reachabilitysize; 220 aas_reachability_t *reachability; 221 //nodes of the bsp tree 222 int numnodes; 223 aas_node_t *nodes; 224 //cluster portals 225 int numportals; 226 aas_portal_t *portals; 227 //cluster portal index 228 int portalindexsize; 229 aas_portalindex_t *portalindex; 230 //clusters 231 int numclusters; 232 aas_cluster_t *clusters; 233 // 234 int reachabilityareas; 235 float reachabilitytime; 236 //enities linked in the areas 237 aas_link_t *linkheap; //heap with link structures 238 int linkheapsize; //size of the link heap 239 aas_link_t *freelinks; //first free link 240 aas_link_t **arealinkedentities; //entities linked into areas 241 //entities 242 int maxentities; 243 int maxclients; 244 aas_entity_t *entities; 245 //string indexes 246 char *configstrings[MAX_CONFIGSTRINGS]; 247 int indexessetup; 248 //index to retrieve travel flag for a travel type 249 int travelflagfortype[MAX_TRAVELTYPES]; 250 //routing update 251 aas_routingupdate_t *areaupdate; 252 aas_routingupdate_t *portalupdate; 253 //number of routing updates during a frame (reset every frame) 254 int frameroutingupdates; 255 //reversed reachability links 256 aas_reversedreachability_t *reversedreachability; 257 //travel times within the areas 258 unsigned short ***areatraveltimes; 259 //array of size numclusters with cluster cache 260 aas_routingcache_t ***clusterareacache; 261 aas_routingcache_t **portalcache; 262 //maximum travel time through portals 263 int *portalmaxtraveltimes; 264 // Ridah, pointer to Route-Table information 265 aas_rt_t *routetable; 266 //hide travel times 267 unsigned short int *hidetraveltimes; 268 //vis data 269 byte *decompressedvis; 270 int decompressedvisarea; 271 byte **areavisibility; 272 // done. 273 // Ridah, store the area's waypoint for hidepos calculations (center traced downwards) 274 vec3_t *areawaypoints; 275 // Ridah, so we can cache the areas that have already been tested for visibility/attackability 276 byte *visCache; 277 } aas_t; 278 279 #define AASINTERN 280 281 #ifndef BSPCINCLUDE 282 283 #include "be_aas_main.h" 284 #include "be_aas_entity.h" 285 #include "be_aas_sample.h" 286 #include "be_aas_cluster.h" 287 #include "be_aas_reach.h" 288 #include "be_aas_route.h" 289 #include "be_aas_routealt.h" 290 #include "be_aas_debug.h" 291 #include "be_aas_file.h" 292 #include "be_aas_optimize.h" 293 #include "be_aas_bsp.h" 294 #include "be_aas_move.h" 295 296 // Ridah, route-tables 297 #include "be_aas_routetable.h" 298 299 #endif //BSPCINCLUDE 300