Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

aas_file.c File Reference

#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:

Include dependency graph

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)


Define Documentation

#define AAS_Error   Error
 

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().


Function Documentation

void AAS_DData unsigned char *  data,
int  size
 

Definition at line 230 of file aas_file.c.

References data, and i.

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

void AAS_DumpAASData void   ) 
 

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

qboolean AAS_LoadAASFile char *  filename,
int  fpoffset,
int  fplength
 

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:

char* AAS_LoadAASLump FILE fp,
int  offset,
int  length,
void *  buf
 

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:

void AAS_ShowNumReachabilities int  tt,
char *  name
 

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:

void AAS_ShowTotals void   ) 
 

Definition at line 440 of file aas_file.c.

References AAS_ShowNumReachabilities(), aasworld, aas_s::edgeindexsize, aas_s::faceindexsize, Log_Print(), aas_s::numareas, aas_s::numareasettings, aas_s::numclusters, aas_s::numedges, aas_s::numfaces, aas_s::numnodes, aas_s::numplanes, aas_s::numportals, aas_s::numvertexes, aas_s::portalindexsize, aas_s::reachabilitysize, TRAVEL_BARRIERJUMP, TRAVEL_BFGJUMP, TRAVEL_CROUCH, TRAVEL_DOUBLEJUMP, TRAVEL_ELEVATOR, TRAVEL_FUNCBOB, TRAVEL_GRAPPLEHOOK, TRAVEL_JUMP, TRAVEL_JUMPPAD, TRAVEL_LADDER, TRAVEL_RAMPJUMP, TRAVEL_ROCKETJUMP, TRAVEL_STRAFEJUMP, TRAVEL_SWIM, TRAVEL_TELEPORT, TRAVEL_WALK, TRAVEL_WALKOFFLEDGE, and TRAVEL_WATERJUMP.

Referenced by AAS_WriteAASFile(), and main().

00441 {
00442     Log_Print("numvertexes = %d\r\n", aasworld.numvertexes);
00443     Log_Print("numplanes = %d\r\n", aasworld.numplanes);
00444     Log_Print("numedges = %d\r\n", aasworld.numedges);
00445     Log_Print("edgeindexsize = %d\r\n", aasworld.edgeindexsize);
00446     Log_Print("numfaces = %d\r\n", aasworld.numfaces);
00447     Log_Print("faceindexsize = %d\r\n", aasworld.faceindexsize);
00448     Log_Print("numareas = %d\r\n", aasworld.numareas);
00449     Log_Print("numareasettings = %d\r\n", aasworld.numareasettings);
00450     Log_Print("reachabilitysize = %d\r\n", aasworld.reachabilitysize);
00451     Log_Print("numnodes = %d\r\n", aasworld.numnodes);
00452     Log_Print("numportals = %d\r\n", aasworld.numportals);
00453     Log_Print("portalindexsize = %d\r\n", aasworld.portalindexsize);
00454     Log_Print("numclusters = %d\r\n", aasworld.numclusters);
00455     AAS_ShowNumReachabilities(TRAVEL_WALK, "walk");
00456     AAS_ShowNumReachabilities(TRAVEL_CROUCH, "crouch");
00457     AAS_ShowNumReachabilities(TRAVEL_BARRIERJUMP, "barrier jump");
00458     AAS_ShowNumReachabilities(TRAVEL_JUMP, "jump");
00459     AAS_ShowNumReachabilities(TRAVEL_LADDER, "ladder");
00460     AAS_ShowNumReachabilities(TRAVEL_WALKOFFLEDGE, "walk off ledge");
00461     AAS_ShowNumReachabilities(TRAVEL_SWIM, "swim");
00462     AAS_ShowNumReachabilities(TRAVEL_WATERJUMP, "water jump");
00463     AAS_ShowNumReachabilities(TRAVEL_TELEPORT, "teleport");
00464     AAS_ShowNumReachabilities(TRAVEL_ELEVATOR, "elevator");
00465     AAS_ShowNumReachabilities(TRAVEL_ROCKETJUMP, "rocket jump");
00466     AAS_ShowNumReachabilities(TRAVEL_BFGJUMP, "bfg jump");
00467     AAS_ShowNumReachabilities(TRAVEL_GRAPPLEHOOK, "grapple hook");
00468     AAS_ShowNumReachabilities(TRAVEL_DOUBLEJUMP, "double jump");
00469     AAS_ShowNumReachabilities(TRAVEL_RAMPJUMP, "ramp jump");
00470     AAS_ShowNumReachabilities(TRAVEL_STRAFEJUMP, "strafe jump");
00471     AAS_ShowNumReachabilities(TRAVEL_JUMPPAD, "jump pad");
00472     AAS_ShowNumReachabilities(TRAVEL_FUNCBOB, "func bob");
00473 } //end of the function AAS_ShowTotals

Here is the call graph for this function:

void AAS_SwapAASData void   ) 
 

Definition at line 37 of file aas_file.c.

References aasworld, aas_areasettings_s::areaflags, aas_portal_s::areanum, aas_reachability_s::areanum, aas_area_s::areanum, aas_s::areas, aas_s::areasettings, aas_face_s::backarea, aas_portal_s::backcluster, aas_s::bboxes, aas_area_s::center, aas_node_s::children, aas_areasettings_s::cluster, aas_portal_s::clusterareanum, aas_areasettings_s::clusterareanum, aas_s::clusters, aas_areasettings_s::contents, aas_plane_s::dist, aas_s::edgeindex, aas_s::edgeindexsize, aas_reachability_s::edgenum, aas_s::edges, aas_reachability_s::end, aas_face_s::faceflags, aas_s::faceindex, aas_s::faceindexsize, aas_reachability_s::facenum, aas_s::faces, aas_face_s::firstedge, aas_area_s::firstface, aas_cluster_s::firstportal, aas_areasettings_s::firstreachablearea, aas_bbox_s::flags, aas_face_s::frontarea, aas_portal_s::frontcluster, i, j, LittleFloat(), LittleLong(), LittleShort(), aas_area_s::maxs, aas_bbox_s::maxs, aas_area_s::mins, aas_bbox_s::mins, aas_s::nodes, aas_plane_s::normal, aas_cluster_s::numareas, aas_s::numareas, aas_s::numareasettings, aas_s::numbboxes, aas_s::numclusters, aas_face_s::numedges, aas_s::numedges, aas_area_s::numfaces, aas_s::numfaces, aas_s::numnodes, aas_s::numplanes, aas_cluster_s::numportals, aas_s::numportals, aas_areasettings_s::numreachableareas, aas_s::numvertexes, aas_node_s::planenum, aas_face_s::planenum, aas_s::planes, aas_s::portalindex, aas_s::portalindexsize, aas_s::portals, aas_areasettings_s::presencetype, aas_bbox_s::presencetype, aas_s::reachability, aas_s::reachabilitysize, aas_reachability_s::start, aas_reachability_s::traveltime, aas_reachability_s::traveltype, aas_plane_s::type, aas_edge_s::v, and aas_s::vertexes.

00038 {
00039     int i, j;
00040     //bounding boxes
00041     for (i = 0; i < aasworld.numbboxes; i++)
00042     {
00043         aasworld.bboxes[i].presencetype = LittleLong(aasworld.bboxes[i].presencetype);
00044         aasworld.bboxes[i].flags = LittleLong(aasworld.bboxes[i].flags);
00045         for (j = 0; j < 3; j++)
00046         {
00047             aasworld.bboxes[i].mins[j] = LittleLong(aasworld.bboxes[i].mins[j]);
00048             aasworld.bboxes[i].maxs[j] = LittleLong(aasworld.bboxes[i].maxs[j]);
00049         } //end for
00050     } //end for
00051     //vertexes
00052     for (i = 0; i < aasworld.numvertexes; i++)
00053     {
00054         for (j = 0; j < 3; j++)
00055             aasworld.vertexes[i][j] = LittleFloat(aasworld.vertexes[i][j]);
00056     } //end for
00057     //planes
00058     for (i = 0; i < aasworld.numplanes; i++)
00059     {
00060         for (j = 0; j < 3; j++)
00061             aasworld.planes[i].normal[j] = LittleFloat(aasworld.planes[i].normal[j]);
00062         aasworld.planes[i].dist = LittleFloat(aasworld.planes[i].dist);
00063         aasworld.planes[i].type = LittleLong(aasworld.planes[i].type);
00064     } //end for
00065     //edges
00066     for (i = 0; i < aasworld.numedges; i++)
00067     {
00068         aasworld.edges[i].v[0] = LittleLong(aasworld.edges[i].v[0]);
00069         aasworld.edges[i].v[1] = LittleLong(aasworld.edges[i].v[1]);
00070     } //end for
00071     //edgeindex
00072     for (i = 0; i < aasworld.edgeindexsize; i++)
00073     {
00074         aasworld.edgeindex[i] = LittleLong(aasworld.edgeindex[i]);
00075     } //end for
00076     //faces
00077     for (i = 0; i < aasworld.numfaces; i++)
00078     {
00079         aasworld.faces[i].planenum = LittleLong(aasworld.faces[i].planenum);
00080         aasworld.faces[i].faceflags = LittleLong(aasworld.faces[i].faceflags);
00081         aasworld.faces[i].numedges = LittleLong(aasworld.faces[i].numedges);
00082         aasworld.faces[i].firstedge = LittleLong(aasworld.faces[i].firstedge);
00083         aasworld.faces[i].frontarea = LittleLong(aasworld.faces[i].frontarea);
00084         aasworld.faces[i].backarea = LittleLong(aasworld.faces[i].backarea);
00085     } //end for
00086     //face index
00087     for (i = 0; i < aasworld.faceindexsize; i++)
00088     {
00089         aasworld.faceindex[i] = LittleLong(aasworld.faceindex[i]);
00090     } //end for
00091     //convex areas
00092     for (i = 0; i < aasworld.numareas; i++)
00093     {
00094         aasworld.areas[i].areanum = LittleLong(aasworld.areas[i].areanum);
00095         aasworld.areas[i].numfaces = LittleLong(aasworld.areas[i].numfaces);
00096         aasworld.areas[i].firstface = LittleLong(aasworld.areas[i].firstface);
00097         for (j = 0; j < 3; j++)
00098         {
00099             aasworld.areas[i].mins[j] = LittleFloat(aasworld.areas[i].mins[j]);
00100             aasworld.areas[i].maxs[j] = LittleFloat(aasworld.areas[i].maxs[j]);
00101             aasworld.areas[i].center[j] = LittleFloat(aasworld.areas[i].center[j]);
00102         } //end for
00103     } //end for
00104     //area settings
00105     for (i = 0; i < aasworld.numareasettings; i++)
00106     {
00107         aasworld.areasettings[i].contents = LittleLong(aasworld.areasettings[i].contents);
00108         aasworld.areasettings[i].areaflags = LittleLong(aasworld.areasettings[i].areaflags);
00109         aasworld.areasettings[i].presencetype = LittleLong(aasworld.areasettings[i].presencetype);
00110         aasworld.areasettings[i].cluster = LittleLong(aasworld.areasettings[i].cluster);
00111         aasworld.areasettings[i].clusterareanum = LittleLong(aasworld.areasettings[i].clusterareanum);
00112         aasworld.areasettings[i].numreachableareas = LittleLong(aasworld.areasettings[i].numreachableareas);
00113         aasworld.areasettings[i].firstreachablearea = LittleLong(aasworld.areasettings[i].firstreachablearea);
00114     } //end for
00115     //area reachability
00116     for (i = 0; i < aasworld.reachabilitysize; i++)
00117     {
00118         aasworld.reachability[i].areanum = LittleLong(aasworld.reachability[i].areanum);
00119         aasworld.reachability[i].facenum = LittleLong(aasworld.reachability[i].facenum);
00120         aasworld.reachability[i].edgenum = LittleLong(aasworld.reachability[i].edgenum);
00121         for (j = 0; j < 3; j++)
00122         {
00123             aasworld.reachability[i].start[j] = LittleFloat(aasworld.reachability[i].start[j]);
00124             aasworld.reachability[i].end[j] = LittleFloat(aasworld.reachability[i].end[j]);
00125         } //end for
00126         aasworld.reachability[i].traveltype = LittleLong(aasworld.reachability[i].traveltype);
00127         aasworld.reachability[i].traveltime = LittleShort(aasworld.reachability[i].traveltime);
00128     } //end for
00129     //nodes
00130     for (i = 0; i < aasworld.numnodes; i++)
00131     {
00132         aasworld.nodes[i].planenum = LittleLong(aasworld.nodes[i].planenum);
00133         aasworld.nodes[i].children[0] = LittleLong(aasworld.nodes[i].children[0]);
00134         aasworld.nodes[i].children[1] = LittleLong(aasworld.nodes[i].children[1]);
00135     } //end for
00136     //cluster portals
00137     for (i = 0; i < aasworld.numportals; i++)
00138     {
00139         aasworld.portals[i].areanum = LittleLong(aasworld.portals[i].areanum);
00140         aasworld.portals[i].frontcluster = LittleLong(aasworld.portals[i].frontcluster);
00141         aasworld.portals[i].backcluster = LittleLong(aasworld.portals[i].backcluster);
00142         aasworld.portals[i].clusterareanum[0] = LittleLong(aasworld.portals[i].clusterareanum[0]);
00143         aasworld.portals[i].clusterareanum[1] = LittleLong(aasworld.portals[i].clusterareanum[1]);
00144     } //end for
00145     //cluster portal index
00146     for (i = 0; i < aasworld.portalindexsize; i++)
00147     {
00148         aasworld.portalindex[i] = LittleLong(aasworld.portalindex[i]);
00149     } //end for
00150     //cluster
00151     for (i = 0; i < aasworld.numclusters; i++)
00152     {
00153         aasworld.clusters[i].numareas = LittleLong(aasworld.clusters[i].numareas);
00154         aasworld.clusters[i].numportals = LittleLong(aasworld.clusters[i].numportals);
00155         aasworld.clusters[i].firstportal = LittleLong(aasworld.clusters[i].firstportal);
00156     } //end for
00157 } //end of the function AAS_SwapAASData

Here is the call graph for this function:

qboolean AAS_WriteAASFile char *  filename  ) 
 

Definition at line 481 of file aas_file.c.

References aas_area_t, aas_areasettings_t, aas_bbox_t, aas_cluster_t, AAS_DData(), aas_edge_t, aas_edgeindex_t, aas_face_t, aas_faceindex_t, aas_header_t, aas_node_t, aas_plane_t, aas_portal_t, aas_portalindex_t, aas_reachability_t, AAS_ShowTotals(), AAS_SwapAASData(), aas_vertex_t, AAS_WriteAASLump(), AAS_WriteAASLump_offset, AASID, 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, aasworld, aas_s::areas, aas_s::areasettings, aas_s::bboxes, botimport, aas_s::bspchecksum, aas_s::clusters, Com_Memset(), aas_s::edgeindex, aas_s::edgeindexsize, aas_s::edges, aas_s::faceindex, aas_s::faceindexsize, aas_s::faces, fclose(), fileHandle_t, fopen(), fp, botlib_import_s::FS_FCloseFile, botlib_import_s::FS_FOpenFile, botlib_import_s::FS_Seek, FS_SEEK_SET, FS_WRITE, botlib_import_s::FS_Write, fseek(), fwrite(), header, dheader_t::ident, LittleLong(), Log_Print(), memset(), 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, aas_s::planes, aas_s::portalindex, aas_s::portalindexsize, aas_s::portals, PRT_ERROR, PRT_MESSAGE, qboolean, aas_s::reachability, aas_s::reachabilitysize, SEEK_SET, dheader_t::version, and aas_s::vertexes.

Referenced by AAS_ContinueInit(), and main().

00482 {
00483     aas_header_t header;
00484     FILE *fp;
00485 
00486     Log_Print("writing %s\n", filename);
00487     AAS_ShowTotals();
00488     //swap the aas data
00489     AAS_SwapAASData();
00490     //initialize the file header
00491     memset(&header, 0, sizeof(aas_header_t));
00492     header.ident = LittleLong(AASID);
00493     header.version = LittleLong(AASVERSION);
00494     header.bspchecksum = LittleLong(aasworld.bspchecksum);
00495     //open a new file
00496     fp = fopen(filename, "wb");
00497     if (!fp)
00498     {
00499         Log_Print("error opening %s\n", filename);
00500         return false;
00501     } //end if
00502     //write the header
00503     if (fwrite(&header, sizeof(aas_header_t), 1, fp) < 1)
00504     {
00505         fclose(fp);
00506         return false;
00507     } //end if
00508     //add the data lumps to the file
00509     if (!AAS_WriteAASLump(fp, &header, AASLUMP_BBOXES, aasworld.bboxes,
00510         aasworld.numbboxes * sizeof(aas_bbox_t))) return false;
00511     if (!AAS_WriteAASLump(fp, &header, AASLUMP_VERTEXES, aasworld.vertexes,
00512         aasworld.numvertexes * sizeof(aas_vertex_t))) return false;
00513     if (!AAS_WriteAASLump(fp, &header, AASLUMP_PLANES, aasworld.planes,
00514         aasworld.numplanes * sizeof(aas_plane_t))) return false;
00515     if (!AAS_WriteAASLump(fp, &header, AASLUMP_EDGES, aasworld.edges,
00516         aasworld.numedges * sizeof(aas_edge_t))) return false;
00517     if (!AAS_WriteAASLump(fp, &header, AASLUMP_EDGEINDEX, aasworld.edgeindex,
00518         aasworld.edgeindexsize * sizeof(aas_edgeindex_t))) return false;
00519     if (!AAS_WriteAASLump(fp, &header, AASLUMP_FACES, aasworld.faces,
00520         aasworld.numfaces * sizeof(aas_face_t))) return false;
00521     if (!AAS_WriteAASLump(fp, &header, AASLUMP_FACEINDEX, aasworld.faceindex,
00522         aasworld.faceindexsize *