1 /* 2 =========================================================================== 3 Copyright (C) 1999-2005 Id Software, Inc. 4 5 This file is part of Quake III Arena source code. 6 7 Quake III Arena source code is free software; you can redistribute it 8 and/or modify it under the terms of the GNU General Public License as 9 published by the Free Software Foundation; either version 2 of the License, 10 or (at your option) any later version. 11 12 Quake III Arena source code is distributed in the hope that it will be 13 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 GNU General Public License for more details. 16 17 You should have received a copy of the GNU General Public License 18 along with Quake III Arena source code; if not, write to the Free Software 19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 =========================================================================== 21 */ 22 23 /***************************************************************************** 24 * name: be_aas_def.h 25 * 26 * desc: AAS 27 * 28 * $Archive: /source/code/botlib/be_aas_def.h $ 29 * 30 *****************************************************************************/ 31 32 //debugging on 33 #define AAS_DEBUG 34 35 #define MAX_CLIENTS 64 36 #define MAX_MODELS 256 // these are sent over the net as 8 bits 37 #define MAX_SOUNDS 256 // so they cannot be blindly increased 38 #define MAX_CONFIGSTRINGS 1024 39 40 #define CS_SCORES 32 41 #define CS_MODELS (CS_SCORES+MAX_CLIENTS) 42 #define CS_SOUNDS (CS_MODELS+MAX_MODELS) 43 44 #define DF_AASENTNUMBER(x) (x - aasworld.entities) 45 #define DF_NUMBERAASENT(x) (&aasworld.entities[x]) 46 #define DF_AASENTCLIENT(x) (x - aasworld.entities - 1) 47 #define DF_CLIENTAASENT(x) (&aasworld.entities[x + 1]) 48 49 #ifndef MAX_PATH 50 #define MAX_PATH MAX_QPATH 51 #endif 52 53 //string index (for model, sound and image index) 54 typedef struct aas_stringindex_s 55 { 56 int numindexes; 57 char **index; 58 } aas_stringindex_t; 59 60 //structure to link entities to areas and areas to entities 61 typedef struct aas_link_s 62 { 63 int entnum; 64 int areanum; 65 struct aas_link_s *next_ent, *prev_ent; 66 struct aas_link_s *next_area, *prev_area; 67 } aas_link_t; 68 69 //structure to link entities to leaves and leaves to entities 70 typedef struct bsp_link_s 71 { 72 int entnum; 73 int leafnum; 74 struct bsp_link_s *next_ent, *prev_ent; 75 struct bsp_link_s *next_leaf, *prev_leaf; 76 } bsp_link_t; 77 78 typedef struct bsp_entdata_s 79 { 80 vec3_t origin; 81 vec3_t angles; 82 vec3_t absmins; 83 vec3_t absmaxs; 84 int solid; 85 int modelnum; 86 } bsp_entdata_t; 87 88 //entity 89 typedef struct aas_entity_s 90 { 91 //entity info 92 aas_entityinfo_t i; 93 //links into the AAS areas 94 aas_link_t *areas; 95 //links into the BSP leaves 96 bsp_link_t *leaves; 97 } aas_entity_t; 98 99 typedef struct aas_settings_s 100 { 101 vec3_t phys_gravitydirection; 102 float phys_friction; 103 float phys_stopspeed; 104 float phys_gravity; 105 float phys_waterfriction; 106 float phys_watergravity; 107 float phys_maxvelocity; 108 float phys_maxwalkvelocity; 109 float phys_maxcrouchvelocity; 110 float phys_maxswimvelocity; 111 float phys_walkaccelerate; 112 float phys_airaccelerate; 113 float phys_swimaccelerate; 114 float phys_maxstep; 115 float phys_maxsteepness; 116 float phys_maxwaterjump; 117 float phys_maxbarrier; 118 float phys_jumpvel; 119 float phys_falldelta5; 120 float phys_falldelta10; 121 float rs_waterjump; 122 float rs_teleport; 123 float rs_barrierjump; 124 float rs_startcrouch; 125 float rs_startgrapple; 126 float rs_startwalkoffledge; 127 float rs_startjump; 128 float rs_rocketjump; 129 float rs_bfgjump; 130 float rs_jumppad; 131 float rs_aircontrolledjumppad; 132 float rs_funcbob; 133 float rs_startelevator; 134 float rs_falldamage5; 135 float rs_falldamage10; 136 float rs_maxfallheight; 137 float rs_maxjumpfallheight; 138 } aas_settings_t; 139 140 #define CACHETYPE_PORTAL 0 141 #define CACHETYPE_AREA 1 142 143 //routing cache 144 typedef struct aas_routingcache_s 145 { 146 byte type; //portal or area cache 147 float time; //last time accessed or updated 148 int size; //size of the routing cache 149 int cluster; //cluster the cache is for 150 int areanum; //area the cache is created for 151 vec3_t origin; //origin within the area 152 float starttraveltime; //travel time to start with 153 int travelflags; //combinations of the travel flags 154 struct aas_routingcache_s *prev, *next; 155 struct aas_routingcache_s *time_prev, *time_next; 156 unsigned char *reachabilities; //reachabilities used for routing 157 unsigned short int traveltimes[1]; //travel time for every area (variable sized) 158 } aas_routingcache_t; 159 160 //fields for the routing algorithm 161 typedef struct aas_routingupdate_s 162 { 163 int cluster; 164 int areanum; //area number of the update 165 vec3_t start; //start point the area was entered 166 unsigned short int tmptraveltime; //temporary travel time 167 unsigned short int *areatraveltimes; //travel times within the area 168 qboolean inlist; //true if the update is in the list 169 struct aas_routingupdate_s *next; 170 struct aas_routingupdate_s *prev; 171 } aas_routingupdate_t; 172 173 //reversed reachability link 174 typedef struct aas_reversedlink_s 175 { 176 int linknum; //the aas_areareachability_t 177 int areanum; //reachable from this area 178 struct aas_reversedlink_s *next; //next link 179 } aas_reversedlink_t; 180 181 //reversed area reachability 182 typedef struct aas_reversedreachability_s 183 { 184 int numlinks; 185 aas_reversedlink_t *first; 186 } aas_reversedreachability_t; 187 188 //areas a reachability goes through 189 typedef struct aas_reachabilityareas_s 190 { 191 int firstarea, numareas; 192 } aas_reachabilityareas_t; 193 194 typedef struct aas_s 195 { 196 int loaded; //true when an AAS file is loaded 197 int initialized; //true when AAS has been initialized 198 int savefile; //set true when file should be saved 199 int bspchecksum; 200 //current time 201 float time; 202 int numframes; 203 //name of the aas file 204 char filename[MAX_PATH]; 205 char mapname[MAX_PATH]; 206 //bounding boxes 207 int numbboxes; 208 aas_bbox_t *bboxes; 209 //vertexes 210 int numvertexes; 211 aas_vertex_t *vertexes; 212 //planes 213 int numplanes; 214 aas_plane_t *planes; 215 //edges 216 int numedges; 217 aas_edge_t *edges; 218 //edge index 219 int edgeindexsize; 220 aas_edgeindex_t *edgeindex; 221 //faces 222 int numfaces; 223 aas_face_t *faces; 224 //face index 225 int faceindexsize; 226 aas_faceindex_t *faceindex; 227 //convex areas 228 int numareas; 229 aas_area_t *areas; 230 //convex area settings 231 int numareasettings; 232 aas_areasettings_t *areasettings; 233 //reachablity list 234 int reachabilitysize; 235 aas_reachability_t *reachability; 236 //nodes of the bsp tree 237 int numnodes; 238 aas_node_t *nodes; 239 //cluster portals 240 int numportals; 241 aas_portal_t *portals; 242 //cluster portal index 243 int portalindexsize; 244 aas_portalindex_t *portalindex; 245 //clusters 246 int numclusters; 247 aas_cluster_t *clusters; 248 // 249 int numreachabilityareas; 250 float reachabilitytime; 251 //enities linked in the areas 252 aas_link_t *linkheap; //heap with link structures 253 int linkheapsize; //size of the link heap 254 aas_link_t *freelinks; //first free link 255 aas_link_t **arealinkedentities; //entities linked into areas 256 //entities 257 int maxentities; 258 int maxclients; 259 aas_entity_t *entities; 260 //string indexes 261 char *configstrings[MAX_CONFIGSTRINGS]; 262 int indexessetup; 263 //index to retrieve travel flag for a travel type 264 int travelflagfortype[MAX_TRAVELTYPES]; 265 //travel flags for each area based on contents 266 int *areacontentstravelflags; 267 //routing update 268 aas_routingupdate_t *areaupdate; 269 aas_routingupdate_t *portalupdate; 270 //number of routing updates during a frame (reset every frame) 271 int frameroutingupdates; 272 //reversed reachability links 273 aas_reversedreachability_t *reversedreachability; 274 //travel times within the areas 275 unsigned short ***areatraveltimes; 276 //array of size numclusters with cluster cache 277 aas_routingcache_t ***clusterareacache; 278 aas_routingcache_t **portalcache; 279 //cache list sorted on time 280 aas_routingcache_t *oldestcache; // start of cache list sorted on time 281 aas_routingcache_t *newestcache; // end of cache list sorted on time 282 //maximum travel time through portal areas 283 int *portalmaxtraveltimes; 284 //areas the reachabilities go through 285 int *reachabilityareaindex; 286 aas_reachabilityareas_t *reachabilityareas; 287 } aas_t; 288 289 #define AASINTERN 290 291 #ifndef BSPCINCLUDE 292 293 #include "be_aas_main.h" 294 #include "be_aas_entity.h" 295 #include "be_aas_sample.h" 296 #include "be_aas_cluster.h" 297 #include "be_aas_reach.h" 298 #include "be_aas_route.h" 299 #include "be_aas_routealt.h" 300 #include "be_aas_debug.h" 301 #include "be_aas_file.h" 302 #include "be_aas_optimize.h" 303 #include "be_aas_bsp.h" 304 #include "be_aas_move.h" 305 306 #endif //BSPCINCLUDE 307