#include "qbsp.h"
#include "../botlib/aasfile.h"
#include "aas_file.h"
#include "aas_store.h"
#include "aas_create.h"
Include dependency graph for aas_file.c:

Go to the source code of this file.
Defines | |
| #define | AAS_Error Error |
Functions | |
| void | AAS_DData (unsigned char *data, int size) |
| void | AAS_DumpAASData (void) |
| qboolean | AAS_LoadAASFile (char *filename, int fpoffset, int fplength) |
| char * | AAS_LoadAASLump (FILE *fp, int offset, int length, void *buf) |
| void | AAS_ShowNumReachabilities (int tt, char *name) |
| void | AAS_ShowTotals (void) |
| void | AAS_SwapAASData (void) |
| qboolean | AAS_WriteAASFile (char *filename) |
| int | AAS_WriteAASLump (FILE *fp, aas_header_t *h, int lumpnum, void *data, int length) |
|
|
Definition at line 29 of file aas_file.c. Referenced by AAS_AllocReachability(), AAS_AreaReachability(), AAS_CreatePortals(), AAS_FindClusters(), AAS_FloodClusterAreas_r(), AAS_GetAdjacentAreasWithLessPresenceTypes_r(), AAS_LoadAASFile(), AAS_LoadAASLump(), AAS_ReadRouteCache(), AAS_UpdatePortal(), and AAS_WriteRouteCache(). |
|
||||||||||||
|
Definition at line 230 of file aas_file.c. Referenced by AAS_LoadAASFile(), and AAS_WriteAASFile(). 00231 {
00232 int i;
00233
00234 for (i = 0; i < size; i++)
00235 {
00236 data[i] ^= (unsigned char) i * 119;
00237 } //end for
00238 } //end of the function AAS_DData
|
|
|
Definition at line 165 of file aas_file.c. References aasworld, and aas_s::loaded. 00166 {
00167 /*
00168 if (aasworld.vertexes) FreeMemory(aasworld.vertexes);
00169 aasworld.vertexes = NULL;
00170 if (aasworld.planes) FreeMemory(aasworld.planes);
00171 aasworld.planes = NULL;
00172 if (aasworld.edges) FreeMemory(aasworld.edges);
00173 aasworld.edges = NULL;
00174 if (aasworld.edgeindex) FreeMemory(aasworld.edgeindex);
00175 aasworld.edgeindex = NULL;
00176 if (aasworld.faces) FreeMemory(aasworld.faces);
00177 aasworld.faces = NULL;
00178 if (aasworld.faceindex) FreeMemory(aasworld.faceindex);
00179 aasworld.faceindex = NULL;
00180 if (aasworld.areas) FreeMemory(aasworld.areas);
00181 aasworld.areas = NULL;
00182 if (aasworld.areasettings) FreeMemory(aasworld.areasettings);
00183 aasworld.areasettings = NULL;
00184 if (aasworld.reachability) FreeMemory(aasworld.reachability);
00185 aasworld.reachability = NULL;
00186 */
00187 aasworld.loaded = false;
00188 } //end of the function AAS_DumpAASData
|
|
||||||||||||||||
|
Definition at line 246 of file aas_file.c. References aas_area_t, aas_areasettings_t, aas_bbox_t, aas_cluster_t, AAS_DData(), AAS_DumpAASData(), aas_edge_t, aas_edgeindex_t, AAS_Error, aas_face_t, aas_faceindex_t, aas_header_t, AAS_LoadAASLump(), aas_node_t, aas_plane_t, aas_portal_t, aas_portalindex_t, aas_reachability_t, AAS_SwapAASData(), aas_vertex_t, AASLUMP_AREAS, AASLUMP_AREASETTINGS, AASLUMP_BBOXES, AASLUMP_CLUSTERS, AASLUMP_EDGEINDEX, AASLUMP_EDGES, AASLUMP_FACEINDEX, AASLUMP_FACES, AASLUMP_NODES, AASLUMP_PLANES, AASLUMP_PORTALINDEX, AASLUMP_PORTALS, AASLUMP_REACHABILITY, AASLUMP_VERTEXES, AASVERSION, AASVERSION_OLD, aasworld, aas_s::areas, aas_s::areasettings, aas_s::bboxes, aas_s::bspchecksum, aas_s::clusters, aas_s::edgeindex, aas_s::edgeindexsize, aas_s::edges, aas_s::faceindex, aas_s::faceindexsize, aas_s::faces, fclose(), lump_t::filelen, lump_t::fileofs, fopen(), fp, fread(), fseek(), header, dheader_t::ident, length(), LittleLong(), aas_s::loaded, dheader_t::lumps, aas_s::nodes, aas_s::numareas, aas_s::numareasettings, aas_s::numbboxes, aas_s::numclusters, aas_s::numedges, aas_s::numfaces, aas_s::numnodes, aas_s::numplanes, aas_s::numportals, aas_s::numvertexes, offset, aas_s::planes, aas_s::portalindex, aas_s::portalindexsize, aas_s::portals, qboolean, aas_s::reachability, aas_s::reachabilitysize, SEEK_SET, dheader_t::version, and aas_s::vertexes. Referenced by AAS_LoadFiles(), main(), and TH_AASToTetrahedrons(). 00247 {
00248 FILE *fp;
00249 aas_header_t header;
00250 int offset, length;
00251
00252 //dump current loaded aas file
00253 AAS_DumpAASData();
00254 //open the file
00255 fp = fopen(filename, "rb");
00256 if (!fp)
00257 {
00258 AAS_Error("can't open %s\n", filename);
00259 return false;
00260 } //end if
00261 //seek to the correct position (in the pak file)
00262 if (fseek(fp, fpoffset, SEEK_SET))
00263 {
00264 AAS_Error("can't seek to file %s\n");
00265 fclose(fp);
00266 return false;
00267 } //end if
00268 //read the header
00269 if (fread(&header, sizeof(aas_header_t), 1, fp) != 1)
00270 {
00271 AAS_Error("can't read header of file %s\n", filename);
00272 fclose(fp);
00273 return false;
00274 } //end if
00275 //check header identification
00276 header.ident = LittleLong(header.ident);
00277 if (header.ident != AASID)
00278 {
00279 AAS_Error("%s is not an AAS file\n", filename);
00280 fclose(fp);
00281 return false;
00282 } //end if
00283 //check the version
00284 header.version = LittleLong(header.version);
00285 if (header.version != AASVERSION_OLD && header.version != AASVERSION)
00286 {
00287 AAS_Error("%s is version %i, not %i\n", filename, header.version, AASVERSION);
00288 fclose(fp);
00289 return false;
00290 } //end if
00291 //
00292 if (header.version == AASVERSION)
00293 {
00294 AAS_DData((unsigned char *) &header + 8, sizeof(aas_header_t) - 8);
00295 } //end if
00296 aasworld.bspchecksum = LittleLong(header.bspchecksum);
00297 //load the lumps:
00298 //bounding boxes
00299 offset = fpoffset + LittleLong(header.lumps[AASLUMP_BBOXES].fileofs);
00300 length = LittleLong(header.lumps[AASLUMP_BBOXES].filelen);
00301 aasworld.bboxes = (aas_bbox_t *) AAS_LoadAASLump(fp, offset, length, aasworld.bboxes);
00302 if (!aasworld.bboxes) return false;
00303 aasworld.numbboxes = length / sizeof(aas_bbox_t);
00304 //vertexes
00305 offset = fpoffset + LittleLong(header.lumps[AASLUMP_VERTEXES].fileofs);
00306 length = LittleLong(header.lumps[AASLUMP_VERTEXES].filelen);
00307 aasworld.vertexes = (aas_vertex_t *) AAS_LoadAASLump(fp, offset, length, aasworld.vertexes);
00308 if (!aasworld.vertexes) return false;
00309 aasworld.numvertexes = length / sizeof(aas_vertex_t);
00310 //planes
00311 offset = fpoffset + LittleLong(header.lumps[AASLUMP_PLANES].fileofs);
00312 length = LittleLong(header.lumps[AASLUMP_PLANES].filelen);
00313 aasworld.planes = (aas_plane_t *) AAS_LoadAASLump(fp, offset, length, aasworld.planes);
00314 if (!aasworld.planes) return false;
00315 aasworld.numplanes = length / sizeof(aas_plane_t);
00316 //edges
00317 offset = fpoffset + LittleLong(header.lumps[AASLUMP_EDGES].fileofs);
00318 length = LittleLong(header.lumps[AASLUMP_EDGES].filelen);
00319 aasworld.edges = (aas_edge_t *) AAS_LoadAASLump(fp, offset, length, aasworld.edges);
00320 if (!aasworld.edges) return false;
00321 aasworld.numedges = length / sizeof(aas_edge_t);
00322 //edgeindex
00323 offset = fpoffset + LittleLong(header.lumps[AASLUMP_EDGEINDEX].fileofs);
00324 length = LittleLong(header.lumps[AASLUMP_EDGEINDEX].filelen);
00325 aasworld.edgeindex = (aas_edgeindex_t *) AAS_LoadAASLump(fp, offset, length, aasworld.edgeindex);
00326 if (!aasworld.edgeindex) return false;
00327 aasworld.edgeindexsize = length / sizeof(aas_edgeindex_t);
00328 //faces
00329 offset = fpoffset + LittleLong(header.lumps[AASLUMP_FACES].fileofs);
00330 length = LittleLong(header.lumps[AASLUMP_FACES].filelen);
00331 aasworld.faces = (aas_face_t *) AAS_LoadAASLump(fp, offset, length, aasworld.faces);
00332 if (!aasworld.faces) return false;
00333 aasworld.numfaces = length / sizeof(aas_face_t);
00334 //faceindex
00335 offset = fpoffset + LittleLong(header.lumps[AASLUMP_FACEINDEX].fileofs);
00336 length = LittleLong(header.lumps[AASLUMP_FACEINDEX].filelen);
00337 aasworld.faceindex = (aas_faceindex_t *) AAS_LoadAASLump(fp, offset, length, aasworld.faceindex);
00338 if (!aasworld.faceindex) return false;
00339 aasworld.faceindexsize = length / sizeof(int);
00340 //convex areas
00341 offset = fpoffset + LittleLong(header.lumps[AASLUMP_AREAS].fileofs);
00342 length = LittleLong(header.lumps[AASLUMP_AREAS].filelen);
00343 aasworld.areas = (aas_area_t *) AAS_LoadAASLump(fp, offset, length, aasworld.areas);
00344 if (!aasworld.areas) return false;
00345 aasworld.numareas = length / sizeof(aas_area_t);
00346 //area settings
00347 offset = fpoffset + LittleLong(header.lumps[AASLUMP_AREASETTINGS].fileofs);
00348 length = LittleLong(header.lumps[AASLUMP_AREASETTINGS].filelen);
00349 aasworld.areasettings = (aas_areasettings_t *) AAS_LoadAASLump(fp, offset, length, aasworld.areasettings);
00350 if (!aasworld.areasettings) return false;
00351 aasworld.numareasettings = length / sizeof(aas_areasettings_t);
00352 //reachability list
00353 offset = fpoffset + LittleLong(header.lumps[AASLUMP_REACHABILITY].fileofs);
00354 length = LittleLong(header.lumps[AASLUMP_REACHABILITY].filelen);
00355 aasworld.reachability = (aas_reachability_t *) AAS_LoadAASLump(fp, offset, length, aasworld.reachability);
00356 if (length && !aasworld.reachability) return false;
00357 aasworld.reachabilitysize = length / sizeof(aas_reachability_t);
00358 //nodes
00359 offset = fpoffset + LittleLong(header.lumps[AASLUMP_NODES].fileofs);
00360 length = LittleLong(header.lumps[AASLUMP_NODES].filelen);
00361 aasworld.nodes = (aas_node_t *) AAS_LoadAASLump(fp, offset, length, aasworld.nodes);
00362 if (!aasworld.nodes) return false;
00363 aasworld.numnodes = length / sizeof(aas_node_t);
00364 //cluster portals
00365 offset = fpoffset + LittleLong(header.lumps[AASLUMP_PORTALS].fileofs);
00366 length = LittleLong(header.lumps[AASLUMP_PORTALS].filelen);
00367 aasworld.portals = (aas_portal_t *) AAS_LoadAASLump(fp, offset, length, aasworld.portals);
00368 if (length && !aasworld.portals) return false;
00369 aasworld.numportals = length / sizeof(aas_portal_t);
00370 //cluster portal index
00371 offset = fpoffset + LittleLong(header.lumps[AASLUMP_PORTALINDEX].fileofs);
00372 length = LittleLong(header.lumps[AASLUMP_PORTALINDEX].filelen);
00373 aasworld.portalindex = (aas_portalindex_t *) AAS_LoadAASLump(fp, offset, length, aasworld.portalindex);
00374 if (length && !aasworld.portalindex) return false;
00375 aasworld.portalindexsize = length / sizeof(aas_portalindex_t);
00376 //clusters
00377 offset = fpoffset + LittleLong(header.lumps[AASLUMP_CLUSTERS].fileofs);
00378 length = LittleLong(header.lumps[AASLUMP_CLUSTERS].filelen);
00379 aasworld.clusters = (aas_cluster_t *) AAS_LoadAASLump(fp, offset, length, aasworld.clusters);
00380 if (length && !aasworld.clusters) return false;
00381 aasworld.numclusters = length / sizeof(aas_cluster_t);
00382 //swap everything
00383 AAS_SwapAASData();
00384 //aas file is loaded
00385 aasworld.loaded = true;
00386 //close the file
00387 fclose(fp);
00388 return true;
00389 } //end of the function AAS_LoadAASFile
|
Here is the call graph for this function:

|
||||||||||||||||||||
|
Definition at line 196 of file aas_file.c. References AAS_DumpAASData(), AAS_Error, fclose(), fp, fread(), FreeMemory(), fseek(), GetClearedMemory(), length(), offset, printf(), and SEEK_SET. Referenced by AAS_LoadAASFile(). 00197 {
00198 if (!length)
00199 {
00200 printf("lump size 0\n");
00201 return buf;
00202 } //end if
00203 //seek to the data
00204 if (fseek(fp, offset, SEEK_SET))
00205 {
00206 AAS_Error("can't seek to lump\n");
00207 AAS_DumpAASData();
00208 fclose(fp);
00209 return 0;
00210 } //end if
00211 //allocate memory
00212 if (!buf) buf = (void *) GetClearedMemory(length);
00213 //read the data
00214 if (fread((char *) buf, 1, length, fp) != length)
00215 {
00216 AAS_Error("can't read lump\n");
00217 FreeMemory(buf);
00218 AAS_DumpAASData();
00219 fclose(fp);
00220 return NULL;
00221 } //end if
00222 return buf;
00223 } //end of the function AAS_LoadAASLump
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 422 of file aas_file.c. References aasworld, i, Log_Print(), name, aas_s::reachability, aas_s::reachabilitysize, and aas_reachability_s::traveltype. Referenced by AAS_ShowTotals(). 00423 {
00424 int i, num;
00425
00426 num = 0;
00427 for (i = 0; i < aasworld.reachabilitysize; i++)
00428 {
00429 if ((aasworld.reachability[i].traveltype & TRAVELTYPE_MASK) == tt)
00430 num++;
00431 } //end for
00432 Log_Print("%6d %s\n", num, name);
00433 } //end of the function AAS_ShowNumReachabilities
|
Here is the call graph for this function:

|
Here is the call graph for this function:

|
Here is the call graph for this function:

|