1 /*
2 ===========================================================================
3 
4 Return to Castle Wolfenstein single player 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 single player GPL Source Code (“RTCW SP Source Code”).
8 
9 RTCW SP 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 SP 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 SP Source Code.  If not, see <http://www.gnu.org/licenses/>.
21 
22 In addition, the RTCW SP 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 SP 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 //NOTE:	int = default signed
32 //					default long
33 
34 #define AASID                       ( ( 'S' << 24 ) + ( 'A' << 16 ) + ( 'A' << 8 ) + 'E' )
35 #define AASVERSION                  8
36 
37 //presence types
38 #define PRESENCE_NONE               1
39 #define PRESENCE_NORMAL             2
40 #define PRESENCE_CROUCH             4
41 
42 //travel types
43 #define MAX_TRAVELTYPES             32
44 #define TRAVEL_INVALID              1       //temporary not possible
45 #define TRAVEL_WALK                 2       //walking
46 #define TRAVEL_CROUCH               3       //crouching
47 #define TRAVEL_BARRIERJUMP          4       //jumping onto a barrier
48 #define TRAVEL_JUMP                 5       //jumping
49 #define TRAVEL_LADDER               6       //climbing a ladder
50 #define TRAVEL_WALKOFFLEDGE         7       //walking of a ledge
51 #define TRAVEL_SWIM                 8       //swimming
52 #define TRAVEL_WATERJUMP            9       //jump out of the water
53 #define TRAVEL_TELEPORT             10      //teleportation
54 #define TRAVEL_ELEVATOR             11      //travel by elevator
55 #define TRAVEL_ROCKETJUMP           12      //rocket jumping required for travel
56 #define TRAVEL_BFGJUMP              13      //bfg jumping required for travel
57 #define TRAVEL_GRAPPLEHOOK          14      //grappling hook required for travel
58 #define TRAVEL_DOUBLEJUMP           15      //double jump
59 #define TRAVEL_RAMPJUMP             16      //ramp jump
60 #define TRAVEL_STRAFEJUMP           17      //strafe jump
61 #define TRAVEL_JUMPPAD              18      //jump pad
62 #define TRAVEL_FUNCBOB              19      //func bob
63 
64 //additional travel flags
65 #define TRAVELTYPE_MASK             0xFFFFFF
66 #define TRAVELFLAG_NOTTEAM1         ( 1 << 24 )
67 #define TRAVELFLAG_NOTTEAM2         ( 2 << 24 )
68 
69 //face flags
70 #define FACE_SOLID                  1       //just solid at the other side
71 #define FACE_LADDER                 2       //ladder
72 #define FACE_GROUND                 4       //standing on ground when in this face
73 #define FACE_GAP                    8       //gap in the ground
74 #define FACE_LIQUID                 16
75 #define FACE_LIQUIDSURFACE          32
76 
77 //area contents
78 #define AREACONTENTS_WATER              1
79 #define AREACONTENTS_LAVA               2
80 #define AREACONTENTS_SLIME              4
81 #define AREACONTENTS_CLUSTERPORTAL      8
82 #define AREACONTENTS_TELEPORTAL         16
83 #define AREACONTENTS_ROUTEPORTAL        32
84 #define AREACONTENTS_TELEPORTER         64
85 #define AREACONTENTS_JUMPPAD            128
86 #define AREACONTENTS_DONOTENTER         256
87 #define AREACONTENTS_VIEWPORTAL         512
88 // Rafael - nopass
89 #define AREACONTENTS_DONOTENTER_LARGE   1024
90 #define AREACONTENTS_MOVER              2048
91 
92 //number of model of the mover inside this area
93 #define AREACONTENTS_MODELNUMSHIFT      24
94 #define AREACONTENTS_MAXMODELNUM        0xFF
95 #define AREACONTENTS_MODELNUM           ( AREACONTENTS_MAXMODELNUM << AREACONTENTS_MODELNUMSHIFT )
96 
97 //area flags
98 #define AREA_GROUNDED               1       //bot can stand on the ground
99 #define AREA_LADDER                 2       //area contains one or more ladder faces
100 #define AREA_LIQUID                 4       //area contains a liquid
101 // Ridah
102 #define AREA_DISABLED               8
103 #define AREA_USEFORROUTING          1024
104 
105 //aas file header lumps
106 #define AAS_LUMPS                   14
107 #define AASLUMP_BBOXES              0
108 #define AASLUMP_VERTEXES            1
109 #define AASLUMP_PLANES              2
110 #define AASLUMP_EDGES               3
111 #define AASLUMP_EDGEINDEX           4
112 #define AASLUMP_FACES               5
113 #define AASLUMP_FACEINDEX           6
114 #define AASLUMP_AREAS               7
115 #define AASLUMP_AREASETTINGS        8
116 #define AASLUMP_REACHABILITY        9
117 #define AASLUMP_NODES               10
118 #define AASLUMP_PORTALS             11
119 #define AASLUMP_PORTALINDEX         12
120 #define AASLUMP_CLUSTERS            13
121 
122 //========== bounding box =========
123 
124 //bounding box
125 typedef struct aas_bbox_s
126 {
127 	int presencetype;
128 	int flags;
129 	vec3_t mins, maxs;
130 } aas_bbox_t;
131 
132 //============ settings ===========
133 
134 //reachability to another area
135 typedef struct aas_reachability_s
136 {
137 	int areanum;                        //number of the reachable area
138 	int facenum;                        //number of the face towards the other area
139 	int edgenum;                        //number of the edge towards the other area
140 	vec3_t start;                       //start point of inter area movement
141 	vec3_t end;                         //end point of inter area movement
142 	int traveltype;                 //type of travel required to get to the area
143 	unsigned short int traveltime; //travel time of the inter area movement
144 } aas_reachability_t;
145 
146 //area settings
147 typedef struct aas_areasettings_s
148 {
149 	//could also add all kind of statistic fields
150 	int contents;                       //contents of the convex area
151 	int areaflags;                      //several area flags
152 	int presencetype;                   //how a bot can be present in this convex area
153 	int cluster;                        //cluster the area belongs to, if negative it's a portal
154 	int clusterareanum;             //number of the area in the cluster
155 	int numreachableareas;          //number of reachable areas from this one
156 	int firstreachablearea;         //first reachable area in the reachable area index
157 	// Ridah, add a ground steepness stat, so we can avoid terrain when we can take a close-by flat route
158 	float groundsteepness;          // 0 = flat, 1 = steep
159 } aas_areasettings_t;
160 
161 //cluster portal
162 typedef struct aas_portal_s
163 {
164 	int areanum;                        //area that is the actual portal
165 	int frontcluster;                   //cluster at front of portal
166 	int backcluster;                    //cluster at back of portal
167 	int clusterareanum[2];          //number of the area in the front and back cluster
168 } aas_portal_t;
169 
170 //cluster portal index
171 typedef int aas_portalindex_t;
172 
173 //cluster
174 typedef struct aas_cluster_s
175 {
176 	int numareas;                       //number of areas in the cluster
177 	int numreachabilityareas;           //number of areas with reachabilities
178 	int numportals;                     //number of cluster portals
179 	int firstportal;                    //first cluster portal in the index
180 } aas_cluster_t;
181 
182 //============ 3d definition ============
183 
184 typedef vec3_t aas_vertex_t;
185 
186 //just a plane in the third dimension
187 typedef struct aas_plane_s
188 {
189 	vec3_t normal;                      //normal vector of the plane
190 	float dist;                         //distance of the plane (normal vector * distance = point in plane)
191 	int type;
192 } aas_plane_t;
193 
194 //edge
195 typedef struct aas_edge_s
196 {
197 	int v[2];                           //numbers of the vertexes of this edge
198 } aas_edge_t;
199 
200 //edge index, negative if vertexes are reversed
201 typedef int aas_edgeindex_t;
202 
203 //a face bounds a convex area, often it will also seperate two convex areas
204 typedef struct aas_face_s
205 {
206 	int planenum;                       //number of the plane this face is in
207 	int faceflags;                      //face flags (no use to create face settings for just this field)
208 	int numedges;                       //number of edges in the boundary of the face
209 	int firstedge;                      //first edge in the edge index
210 	int frontarea;                      //convex area at the front of this face
211 	int backarea;                       //convex area at the back of this face
212 } aas_face_t;
213 
214 //face index, stores a negative index if backside of face
215 typedef int aas_faceindex_t;
216 
217 //convex area with a boundary of faces
218 typedef struct aas_area_s
219 {
220 	int areanum;                        //number of this area
221 	//3d definition
222 	int numfaces;                       //number of faces used for the boundary of the convex area
223 	int firstface;                      //first face in the face index used for the boundary of the convex area
224 	vec3_t mins;                        //mins of the convex area
225 	vec3_t maxs;                        //maxs of the convex area
226 	vec3_t center;                      //'center' of the convex area
227 } aas_area_t;
228 
229 //nodes of the bsp tree
230 typedef struct aas_node_s
231 {
232 	int planenum;
233 	int children[2];                    //child nodes of this node, or convex areas as leaves when negative
234 										//when a child is zero it's a solid leaf
235 } aas_node_t;
236 
237 //=========== aas file ===============
238 
239 //header lump
240 typedef struct
241 {
242 	int fileofs;
243 	int filelen;
244 } aas_lump_t;
245 
246 //aas file header
247 typedef struct aas_header_s
248 {
249 	int ident;
250 	int version;
251 	int bspchecksum;
252 	//data entries
253 	aas_lump_t lumps[AAS_LUMPS];
254 } aas_header_t;
255 
256 
257 //====== additional information ======
258 /*
259 
260 -	when a node child is a solid leaf the node child number is zero
261 -	two adjacent areas (sharing a plane at opposite sides) share a face
262 	this face is a portal between the areas
263 -	when an area uses a face from the faceindex with a positive index
264 	then the face plane normal points into the area
265 -	the face edges are stored counter clockwise using the edgeindex
266 -	two adjacent convex areas (sharing a face) only share One face
267 	this is a simple result of the areas being convex
268 -	the convex areas can't have a mixture of ground and gap faces
269 	other mixtures of faces in one area are allowed
270 -	areas with the AREACONTENTS_CLUSTERPORTAL in the settings have
271 	cluster number zero
272 -	edge zero is a dummy
273 -	face zero is a dummy
274 -	area zero is a dummy
275 -	node zero is a dummy
276 */
277