This graph shows which files directly or indirectly include this file:

Go to the source code of this file.
Functions | |
| qboolean | AAS_LoadAASFile (char *filename, int fpoffset, int fplength) |
| qboolean | AAS_WriteAASFile (char *filename) |
|
||||||||||||||||
|
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:

|
Here is the call graph for this function:

1.3.9.1