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

l_bsp_sin.c File Reference

#include "l_cmd.h"
#include "l_math.h"
#include "l_mem.h"
#include "l_log.h"
#include "l_poly.h"
#include "../botlib/l_script.h"
#include "l_bsp_ent.h"
#include "l_bsp_sin.h"

Include dependency graph for l_bsp_sin.c:

Include dependency graph

Go to the source code of this file.

Defines

#define WCONVEX_EPSILON   0.5

Functions

void FreeValueKeys (entity_t *ent)
void GetLeafNums (void)
void Sin_AddLump (int lumpnum, void *data, int len, int size, int maxsize)
void Sin_AllocMaxBSP (void)
winding_tSin_BrushSideWinding (sin_dbrush_t *brush, sin_dbrushside_t *baseside)
int Sin_CompressVis (byte *vis, byte *dest)
int Sin_CopyLump (int lump, void *dest, int size, int maxsize)
void Sin_DecompressVis (byte *in, byte *decompressed)
float Sin_FaceOnWinding (sin_dface_t *face, winding_t *winding)
void Sin_FixTextureReferences (void)
void Sin_FreeMaxBSP (void)
int Sin_HintSkipBrush (sin_dbrush_t *brush)
void Sin_LoadBSPFile (char *filename, int offset, int length)
void Sin_LoadBSPFileTexinfo (char *filename)
void Sin_ParseEntities (void)
void Sin_PrintBSPFileSizes (void)
void Sin_SwapBSPFile (qboolean todisk)
void Sin_UnparseEntities (void)
void Sin_WriteBSPFile (char *filename)
qboolean WindingIsTiny (winding_t *w)

Variables

sin_dheader_theader
sin_dheader_t outheader
int sin_allocatedbspmem = 0
int sin_bspallocated = false
sin_dareaportal_tsin_dareaportals
sin_darea_tsin_dareas
sin_dbrush_tsin_dbrushes
sin_dbrushside_tsin_dbrushsides
char sin_dbrushsidetextured [SIN_MAX_MAP_BRUSHSIDES]
sin_dedge_tsin_dedges
char * sin_dentdata
sin_dface_tsin_dfaces
unsigned short * sin_dleafbrushes
unsigned short * sin_dleaffaces
sin_dleaf_tsin_dleafs
bytesin_dlightdata
sin_dmodel_tsin_dmodels
sin_dnode_tsin_dnodes
sin_dplane_tsin_dplanes
byte sin_dpop [256]
int * sin_dsurfedges
sin_dvertex_tsin_dvertexes
sin_dvis_tsin_dvis
bytesin_dvisdata
int sin_entdatasize
int sin_lightdatasize
sin_lightvalue_tsin_lightinfo
int sin_numareaportals
int sin_numareas
int sin_numbrushes
int sin_numbrushsides
int sin_numedges
int sin_numfaces
int sin_numleafbrushes
int sin_numleaffaces
int sin_numleafs
int sin_numlightinfo
int sin_nummodels
int sin_numnodes
int sin_numplanes
int sin_numsurfedges
int sin_numtexinfo
int sin_numvertexes
sin_texinfo_tsin_texinfo
int sin_visdatasize
FILEwadfile


Define Documentation

#define WCONVEX_EPSILON   0.5
 

Definition at line 272 of file l_bsp_sin.c.


Function Documentation

void FreeValueKeys entity_t ent  ) 
 

Definition at line 1123 of file l_bsp_sin.c.

References epair_t, entity_t::epairs, FreeMemory(), epair_s::key, epair_s::next, next, and epair_s::value.

01124 {
01125     epair_t *ep,*next;
01126 
01127     for (ep=ent->epairs ; ep ; ep=next)
01128     {
01129         next = ep->next;
01130         FreeMemory(ep->value);
01131         FreeMemory(ep->key);
01132         FreeMemory(ep);
01133     }
01134     ent->epairs = NULL;
01135 }

Here is the call graph for this function:

void GetLeafNums void   ) 
 

void Sin_AddLump int  lumpnum,
void *  data,
int  len,
int  size,
int  maxsize
 

Definition at line 947 of file l_bsp_sin.c.

References data, Error(), sin_lump_t::filelen, sin_lump_t::fileofs, ftell(), header, LittleLong(), dheader_t::lumps, SafeWrite(), and wadfile.

Referenced by Sin_WriteBSPFile().

00948 {
00949     sin_lump_t *lump;
00950     int totallength;
00951 
00952     totallength = len*size;
00953 
00954     if (len > maxsize)
00955         Error ("Sin_WriteBSPFile: exceeded max size for lump %d size %d > maxsize %d\n", lumpnum, len, maxsize );
00956 
00957     lump = &header->lumps[lumpnum];
00958     
00959     lump->fileofs = LittleLong( ftell(wadfile) );
00960     lump->filelen = LittleLong(totallength);
00961     SafeWrite (wadfile, data, (totallength+3)&~3);
00962 }

Here is the call graph for this function:

void Sin_AllocMaxBSP void   ) 
 

Definition at line 101 of file l_bsp_sin.c.

References byte, GetClearedMemory(), Log_Print(), PrintMemorySize(), sin_allocatedbspmem, sin_dareaportals, sin_dareas, sin_dbrushes, sin_dbrushsides, sin_dedges, sin_dentdata, sin_dfaces, sin_dleafbrushes, sin_dleaffaces, sin_dleafs, sin_dlightdata, sin_dmodels, sin_dnodes, sin_dplanes, sin_dsurfedges, sin_dvertexes, sin_dvis, sin_dvisdata, sin_entdatasize, sin_lightdatasize, sin_lightinfo, sin_lightvalue_t, SIN_MAX_MAP_AREAPORTALS, SIN_MAX_MAP_AREAS, SIN_MAX_MAP_BRUSHES, SIN_MAX_MAP_BRUSHSIDES, SIN_MAX_MAP_EDGES, SIN_MAX_MAP_ENTSTRING, SIN_MAX_MAP_FACES, SIN_MAX_MAP_LEAFBRUSHES, SIN_MAX_MAP_LEAFFACES, SIN_MAX_MAP_LEAFS, SIN_MAX_MAP_LIGHTINFO, SIN_MAX_MAP_LIGHTING, SIN_MAX_MAP_MODELS, SIN_MAX_MAP_NODES, SIN_MAX_MAP_PLANES, SIN_MAX_MAP_SURFEDGES, SIN_MAX_MAP_TEXINFO, SIN_MAX_MAP_VERTS, SIN_MAX_MAP_VISIBILITY, sin_numareaportals, sin_numareas, sin_numbrushes, sin_numbrushsides, sin_numedges, sin_numfaces, sin_numleafbrushes, sin_numleaffaces, sin_numleafs, sin_numlightinfo, sin_nummodels, sin_numnodes, sin_numplanes, sin_numsurfedges, sin_numtexinfo, sin_numvertexes, sin_texinfo, sin_texinfo_t, and sin_visdatasize.

Referenced by LoadMapFromBSP().

00102 {
00103     //models
00104     sin_nummodels = 0;
00105     sin_dmodels = (sin_dmodel_t *) GetClearedMemory(SIN_MAX_MAP_MODELS * sizeof(sin_dmodel_t));
00106     sin_allocatedbspmem += SIN_MAX_MAP_MODELS * sizeof(sin_dmodel_t);
00107     //vis data
00108     sin_visdatasize = 0;
00109     sin_dvisdata = (byte *) GetClearedMemory(SIN_MAX_MAP_VISIBILITY * sizeof(byte));
00110     sin_dvis = (sin_dvis_t *) sin_dvisdata;
00111     sin_allocatedbspmem += SIN_MAX_MAP_VISIBILITY * sizeof(byte);
00112     //light data
00113     sin_lightdatasize = 0;
00114     sin_dlightdata = (byte *) GetClearedMemory(SIN_MAX_MAP_LIGHTING * sizeof(byte));
00115     sin_allocatedbspmem += SIN_MAX_MAP_LIGHTING * sizeof(byte);
00116     //entity data
00117     sin_entdatasize = 0;
00118     sin_dentdata = (char *) GetClearedMemory(SIN_MAX_MAP_ENTSTRING * sizeof(char));
00119     sin_allocatedbspmem += SIN_MAX_MAP_ENTSTRING * sizeof(char);
00120     //leafs
00121     sin_numleafs = 0;
00122     sin_dleafs = (sin_dleaf_t *) GetClearedMemory(SIN_MAX_MAP_LEAFS * sizeof(sin_dleaf_t));
00123     sin_allocatedbspmem += SIN_MAX_MAP_LEAFS * sizeof(sin_dleaf_t);
00124     //planes
00125     sin_numplanes = 0;
00126     sin_dplanes = (sin_dplane_t *) GetClearedMemory(SIN_MAX_MAP_PLANES * sizeof(sin_dplane_t));
00127     sin_allocatedbspmem += SIN_MAX_MAP_PLANES * sizeof(sin_dplane_t);
00128     //vertexes
00129     sin_numvertexes = 0;
00130     sin_dvertexes = (sin_dvertex_t *) GetClearedMemory(SIN_MAX_MAP_VERTS * sizeof(sin_dvertex_t));
00131     sin_allocatedbspmem += SIN_MAX_MAP_VERTS * sizeof(sin_dvertex_t);
00132     //nodes
00133     sin_numnodes = 0;
00134     sin_dnodes = (sin_dnode_t *) GetClearedMemory(SIN_MAX_MAP_NODES * sizeof(sin_dnode_t));
00135     sin_allocatedbspmem += SIN_MAX_MAP_NODES * sizeof(sin_dnode_t);
00136     //texture info
00137     sin_numtexinfo = 0;
00138     sin_texinfo = (sin_texinfo_t *) GetClearedMemory(SIN_MAX_MAP_TEXINFO * sizeof(sin_texinfo_t));
00139     sin_allocatedbspmem += SIN_MAX_MAP_TEXINFO * sizeof(sin_texinfo_t);
00140     //faces
00141     sin_numfaces = 0;
00142     sin_dfaces = (sin_dface_t *) GetClearedMemory(SIN_MAX_MAP_FACES * sizeof(sin_dface_t));
00143     sin_allocatedbspmem += SIN_MAX_MAP_FACES * sizeof(sin_dface_t);
00144     //edges
00145     sin_numedges = 0;
00146     sin_dedges = (sin_dedge_t *) GetClearedMemory(SIN_MAX_MAP_EDGES * sizeof(sin_dedge_t));
00147     sin_allocatedbspmem += SIN_MAX_MAP_EDGES * sizeof(sin_dedge_t);
00148     //leaf faces
00149     sin_numleaffaces = 0;
00150     sin_dleaffaces = (unsigned short *) GetClearedMemory(SIN_MAX_MAP_LEAFFACES * sizeof(unsigned short));
00151     sin_allocatedbspmem += SIN_MAX_MAP_LEAFFACES * sizeof(unsigned short);
00152     //leaf brushes
00153     sin_numleafbrushes = 0;
00154     sin_dleafbrushes = (unsigned short *) GetClearedMemory(SIN_MAX_MAP_LEAFBRUSHES * sizeof(unsigned short));
00155     sin_allocatedbspmem += SIN_MAX_MAP_LEAFBRUSHES * sizeof(unsigned short);
00156     //surface edges
00157     sin_numsurfedges = 0;
00158     sin_dsurfedges = (int *) GetClearedMemory(SIN_MAX_MAP_SURFEDGES * sizeof(int));
00159     sin_allocatedbspmem += SIN_MAX_MAP_SURFEDGES * sizeof(int);
00160     //brushes
00161     sin_numbrushes = 0;
00162     sin_dbrushes = (sin_dbrush_t *) GetClearedMemory(SIN_MAX_MAP_BRUSHES * sizeof(sin_dbrush_t));
00163     sin_allocatedbspmem += SIN_MAX_MAP_BRUSHES * sizeof(sin_dbrush_t);
00164     //brushsides
00165     sin_numbrushsides = 0;
00166     sin_dbrushsides = (sin_dbrushside_t *) GetClearedMemory(SIN_MAX_MAP_BRUSHSIDES * sizeof(sin_dbrushside_t));
00167     sin_allocatedbspmem += SIN_MAX_MAP_BRUSHSIDES * sizeof(sin_dbrushside_t);
00168     //areas
00169     sin_numareas = 0;
00170     sin_dareas = (sin_darea_t *) GetClearedMemory(SIN_MAX_MAP_AREAS * sizeof(sin_darea_t));
00171     sin_allocatedbspmem += SIN_MAX_MAP_AREAS * sizeof(sin_darea_t);
00172     //area portals
00173     sin_numareaportals = 0;
00174     sin_dareaportals = (sin_dareaportal_t *) GetClearedMemory(SIN_MAX_MAP_AREAPORTALS * sizeof(sin_dareaportal_t));
00175     sin_allocatedbspmem += SIN_MAX_MAP_AREAPORTALS * sizeof(sin_dareaportal_t);
00176     //light info
00177     sin_numlightinfo = 0;
00178     sin_lightinfo = (sin_lightvalue_t *) GetClearedMemory(SIN_MAX_MAP_LIGHTINFO * sizeof(sin_lightvalue_t));
00179     sin_allocatedbspmem += SIN_MAX_MAP_LIGHTINFO * sizeof(sin_lightvalue_t);
00180     //print allocated memory
00181     Log_Print("allocated ");
00182     PrintMemorySize(sin_allocatedbspmem);
00183     Log_Print(" of BSP memory\n");
00184 } //end of the function Sin_AllocMaxBSP

Here is the call graph for this function:

winding_t* Sin_BrushSideWinding sin_dbrush_t brush,
sin_dbrushside_t baseside
 

Definition at line 331 of file l_bsp_sin.c.

References BaseWindingForPlane(), ChopWindingInPlace(), sin_dplane_t::dist, DotProduct, fabs(), sin_dbrush_t::firstside, i, sin_dplane_t::normal, sin_dbrush_t::numsides, sin_dbrushside_t::planenum, sin_dbrushsides, sin_dplanes, and w.

Referenced by Sin_FixTextureReferences().

00332 {
00333     int i;
00334     sin_dplane_t *baseplane, *plane;
00335     sin_dbrushside_t *side;
00336     winding_t *w;
00337     
00338     //create a winding for the brush side with the given planenumber
00339     baseplane = &sin_dplanes[baseside->planenum];
00340     w = BaseWindingForPlane(baseplane->normal, baseplane->dist);
00341     for (i = 0; i < brush->numsides && w; i++)
00342     {
00343         side = &sin_dbrushsides[brush->firstside + i];
00344         //don't chop with the base plane
00345         if (side->planenum == baseside->planenum) continue;
00346         //also don't use planes that are almost equal
00347         plane = &sin_dplanes[side->planenum];
00348         if (DotProduct(baseplane->normal, plane->normal) > 0.999
00349                 && fabs(baseplane->dist - plane->dist) < 0.01) continue;
00350         //
00351         plane = &sin_dplanes[side->planenum^1];
00352         ChopWindingInPlace(&w, plane->normal, plane->dist, 0); //CLIP_EPSILON);
00353     } //end for
00354     return w;
00355 } //end of the function Sin_BrushSideWinding

Here is the call graph for this function:

int Sin_CompressVis byte vis,
byte dest
 

Definition at line 468 of file l_bsp_sin.c.

References byte, j, sin_dvis_t::numclusters, and sin_dvis.

00469 {
00470     int     j;
00471     int     rep;
00472     int     visrow;
00473     byte    *dest_p;
00474     
00475     dest_p = dest;
00476 //  visrow = (r_numvisleafs + 7)>>3;
00477     visrow = (sin_dvis->numclusters + 7)>>3;
00478     
00479     for (j=0 ; j<visrow ; j++)
00480     {
00481         *dest_p++ = vis[j];
00482         if (vis[j])
00483             continue;
00484 
00485         rep = 1;
00486         for ( j++; j<visrow ; j++)
00487             if (vis[j] || rep == 255)
00488                 break;
00489             else
00490                 rep++;
00491         *dest_p++ = rep;
00492         j--;
00493     }
00494     
00495     return dest_p - dest;
00496 } //end of the function Sin_CompressVis

int Sin_CopyLump int  lump,
void *  dest,
int  size,
int  maxsize
 

Definition at line 786 of file l_bsp_sin.c.

References byte, Error(), lump_t::filelen, lump_t::fileofs, header, length(), dheader_t::lumps, and memcpy().

Referenced by Sin_LoadBSPFile().

00787 {
00788     int     length, ofs;
00789 
00790     length = header->lumps[lump].filelen;
00791     ofs = header->lumps[lump].fileofs;
00792     
00793     if (length % size)
00794         Error ("Sin_LoadBSPFile: odd lump size");
00795 
00796    if ((length/size) > maxsize)
00797       Error ("Sin_LoadBSPFile: exceeded max size for lump %d size %d > maxsize %d\n", lump, (length/size), maxsize );
00798     
00799     memcpy (dest, (byte *)header + ofs, length);
00800 
00801     return length / size;
00802 }

Here is the call graph for this function:

void Sin_DecompressVis byte in,
byte decompressed
 

Definition at line 504 of file l_bsp_sin.c.

References byte, c, Error(), in, sin_dvis_t::numclusters, and sin_dvis.

00505 {
00506     int     c;
00507     byte    *out;
00508     int     row;
00509 
00510 //  row = (r_numvisleafs+7)>>3; 
00511     row = (sin_dvis->numclusters+7)>>3; 
00512     out = decompressed;
00513 
00514     do
00515     {
00516         if (*in)
00517         {
00518             *out++ = *in++;
00519             continue;
00520         }
00521     
00522         c = in[1];
00523         if (!c)
00524             Error ("DecompressVis: 0 repeat");
00525         in += 2;
00526         while (c)
00527         {
00528             *out++ = 0;
00529             c--;
00530         }
00531     } while (out - decompressed < row);
00532 } //end of the function Sin_DecompressVis

Here is the call graph for this function:

float Sin_FaceOnWinding sin_dface_t face,
winding_t winding
 

Definition at line 281 of file l_bsp_sin.c.

References abs(), ChopWindingInPlace(), CopyWinding(), CrossProduct(), sin_dplane_t::dist, DotProduct, sin_dface_t::firstedge, FreeWinding(), i, memcpy(), sin_dplane_t::normal, sin_dface_t::numedges, sin_dface_t::planenum, sin_dvertex_t::point, sin_dface_t::side, sin_dedges, sin_dplanes, sin_dsurfedges, sin_dvertexes, sin_dedge_t::v, v1, v2, vec3_t, vec_t, VectorNegate, VectorNormalize(), VectorSubtract, w, and WindingArea().

Referenced by Sin_FixTextureReferences().

00282 {
00283     int i, edgenum, side;
00284     float dist, area;
00285     sin_dplane_t plane;
00286     vec_t *v1, *v2;
00287     vec3_t normal, edgevec;
00288     winding_t *w;
00289 
00290     //
00291     w = CopyWinding(winding);
00292     memcpy(&plane, &sin_dplanes[face->planenum], sizeof(sin_dplane_t));
00293     //check on which side of the plane the face is
00294     if (face->side)
00295     {
00296         VectorNegate(plane.normal, plane.normal);
00297         plane.dist = -plane.dist;
00298     } //end if
00299     for (i = 0; i < face->numedges && w; i++)
00300     {
00301         //get the first and second vertex of the edge
00302         edgenum = sin_dsurfedges[face->firstedge + i];
00303         side = edgenum > 0;
00304         //if the face plane is flipped
00305         v1 = sin_dvertexes[sin_dedges[abs(edgenum)].v[side]].point;
00306         v2 = sin_dvertexes[sin_dedges[abs(edgenum)].v[!side]].point;
00307         //create a plane through the edge vector, orthogonal to the face plane
00308         //and with the normal vector pointing out of the face
00309         VectorSubtract(v1, v2, edgevec);
00310         CrossProduct(edgevec, plane.normal, normal);
00311         VectorNormalize(normal);
00312         dist = DotProduct(normal, v1);
00313         //
00314         ChopWindingInPlace(&w, normal, dist, 0.9); //CLIP_EPSILON
00315     } //end for
00316     if (w)
00317     {
00318         area = WindingArea(w);
00319         FreeWinding(w);
00320         return area;
00321     } //end if
00322     return 0;
00323 } //end of the function Sin_FaceOnWinding

Here is the call graph for this function:

void Sin_FixTextureReferences void   ) 
 

Definition at line 389 of file l_bsp_sin.c.

References sin_dbrush_t::firstside, FreeWinding(), i, j, k, memset(), sin_dbrush_t::numsides, sin_dbrushside_t::planenum, sin_dface_t::planenum, Sin_BrushSideWinding(), sin_dbrushes, sin_dbrushsides, sin_dbrushsidetextured, sin_dfaces, Sin_FaceOnWinding(), Sin_HintSkipBrush(), SIN_MAX_MAP_BRUSHSIDES, sin_dface_t::texinfo, sin_dbrushside_t::texinfo, w, WE_NOTENOUGHPOINTS, WE_POINTBOGUSRANGE, WE_SMALLAREA, WindingArea(), WindingError(), and WindingIsTiny().

00390 {
00391     int i, j, k, we;
00392     sin_dbrushside_t *brushside;
00393     sin_dbrush_t *brush;
00394     sin_dface_t *face;
00395     winding_t *w;
00396 
00397     memset(sin_dbrushsidetextured, false, SIN_MAX_MAP_BRUSHSIDES);
00398     //go over all the brushes
00399    for (i = 0; i < sin_numbrushes; i++)
00400    {
00401         brush = &sin_dbrushes[i];
00402         //hint brushes are not textured
00403         if (Sin_HintSkipBrush(brush)) continue;
00404         //go over all the sides of the brush
00405         for (j = 0; j < brush->numsides; j++)
00406         {
00407             brushside = &sin_dbrushsides[brush->firstside + j];
00408             //
00409             w = Sin_BrushSideWinding(brush, brushside);
00410             if (!w)
00411             {
00412                 sin_dbrushsidetextured[brush->firstside + j] = true;
00413                 continue;
00414             } //end if
00415             else
00416             {
00417                 //RemoveEqualPoints(w, 0.2);
00418                 if (WindingIsTiny(w))
00419                 {
00420                     FreeWinding(w);
00421                     sin_dbrushsidetextured[brush->firstside + j] = true;
00422                     continue;
00423                 } //end if
00424                 else
00425                 {
00426                     we = WindingError(w);
00427                     if (we == WE_NOTENOUGHPOINTS
00428                         || we == WE_SMALLAREA
00429                         || we == WE_POINTBOGUSRANGE
00430 //                      || we == WE_NONCONVEX
00431                         )
00432                     {
00433                         FreeWinding(w);
00434                         sin_dbrushsidetextured[brush->firstside + j] = true;
00435                         continue;
00436                     } //end if
00437                 } //end else
00438             } //end else
00439             if (WindingArea(w) < 20)
00440             {
00441                 sin_dbrushsidetextured[brush->firstside + j] = true;
00442             } //end if
00443             //find a face for texturing this brush
00444             for (k = 0; k < sin_numfaces; k++)
00445             {
00446                 face = &sin_dfaces[k];
00447                 //if the face is in the same plane as the brush side
00448                 if ((face->planenum&~1) != (brushside->planenum&~1)) continue;
00449                 //if the face is partly or totally on the brush side
00450                 if (Sin_FaceOnWinding(face, w))
00451                 {
00452                     brushside->texinfo = face->texinfo;
00453                     sin_dbrushsidetextured[brush->firstside + j] = true;
00454                     break;
00455                 } //end if
00456             } //end for
00457             FreeWinding(w);
00458         } //end for
00459     } //end for
00460 } //end of the function Sin_FixTextureReferences*/

Here is the call graph for this function:

void Sin_FreeMaxBSP void   ) 
 

Definition at line 186 of file l_bsp_sin.c.

References FreeMemory(), Log_Print(), PrintMemorySize(), sin_allocatedbspmem, sin_dareaportals, sin_dareas, sin_dbrushes, sin_dbrushsides, sin_dedges, sin_dentdata, sin_dfaces, sin_dleafbrushes, sin_dleaffaces, sin_dleafs, sin_dlightdata, sin_dmodels, sin_dnodes, sin_dplanes, sin_dsurfedges, sin_dvertexes, sin_dvis, sin_dvisdata, sin_entdatasize, sin_lightdatasize, sin_lightinfo, sin_numareaportals, sin_numareas, sin_numbrushes, sin_numbrushsides, sin_numedges, sin_numfaces, sin_numleafbrushes, sin_numleaffaces, sin_numleafs, sin_numlightinfo, sin_nummodels, sin_numnodes, sin_numplanes, sin_numsurfedges, sin_numtexinfo, sin_numvertexes, sin_texinfo, and sin_visdatasize.

Referenced by LoadMapFromBSP().

00187 {
00188     //models
00189     sin_nummodels = 0;
00190     FreeMemory(sin_dmodels);
00191     sin_dmodels = NULL;
00192     //vis data
00193     sin_visdatasize = 0;
00194     FreeMemory(sin_dvisdata);
00195     sin_dvisdata = NULL;
00196     sin_dvis = NULL;
00197     //light data
00198     sin_lightdatasize = 0;
00199     FreeMemory(sin_dlightdata);
00200     sin_dlightdata = NULL;
00201     //entity data
00202     sin_entdatasize = 0;
00203     FreeMemory(sin_dentdata);
00204     sin_dentdata = NULL;
00205     //leafs
00206     sin_numleafs = 0;
00207     FreeMemory(sin_dleafs);
00208     sin_dleafs = NULL;
00209     //planes
00210     sin_numplanes = 0;
00211     FreeMemory(sin_dplanes);
00212     sin_dplanes = NULL;
00213     //vertexes
00214     sin_numvertexes = 0;
00215     FreeMemory(sin_dvertexes);
00216     sin_dvertexes = NULL;
00217     //nodes
00218     sin_numnodes = 0;
00219     FreeMemory(sin_dnodes);
00220     sin_dnodes = NULL;
00221     //texture info
00222     sin_numtexinfo = 0;
00223     FreeMemory(sin_texinfo);
00224     sin_texinfo = NULL;
00225     //faces
00226     sin_numfaces = 0;
00227     FreeMemory(sin_dfaces);
00228     sin_dfaces = NULL;
00229     //edges
00230     sin_numedges = 0;
00231     FreeMemory(sin_dedges);
00232     sin_dedges = NULL;
00233     //leaf faces
00234     sin_numleaffaces = 0;
00235     FreeMemory(sin_dleaffaces);
00236     sin_dleaffaces = NULL;
00237     //leaf brushes
00238     sin_numleafbrushes = 0;
00239     FreeMemory(sin_dleafbrushes);
00240     sin_dleafbrushes = NULL;
00241     //surface edges
00242     sin_numsurfedges = 0;
00243     FreeMemory(sin_dsurfedges);
00244     sin_dsurfedges = NULL;
00245     //brushes
00246     sin_numbrushes = 0;
00247     FreeMemory(sin_dbrushes);
00248     sin_dbrushes = NULL;
00249     //brushsides
00250     sin_numbrushsides = 0;
00251     FreeMemory(sin_dbrushsides);
00252     sin_dbrushsides = NULL;
00253     //areas
00254     sin_numareas = 0;
00255     FreeMemory(sin_dareas);
00256     sin_dareas = NULL;
00257     //area portals
00258     sin_numareaportals = 0;
00259     FreeMemory(sin_dareaportals);
00260     sin_dareaportals = NULL;
00261     //light info
00262     sin_numlightinfo = 0;
00263     FreeMemory(sin_lightinfo);
00264     sin_lightinfo = NULL;
00265     //
00266     Log_Print("freed ");
00267     PrintMemorySize(sin_allocatedbspmem);
00268     Log_Print(" of BSP memory\n");
00269     sin_allocatedbspmem = 0;
00270 } //end of the function Sin_FreeMaxBSP

Here is the call graph for this function:

int Sin_HintSkipBrush sin_dbrush_t brush  ) 
 

Definition at line 362 of file l_bsp_sin.c.

References sin_dbrush_t::firstside, sin_texinfo_s::flags, j, sin_dbrush_t::numsides, sin_dbrushsides, sin_texinfo, SURF_SKIP, and sin_dbrushside_t::texinfo.

Referenced by Sin_FixTextureReferences().

00363 {
00364     int j;
00365     sin_dbrushside_t *brushside;
00366 
00367     for (j = 0; j < brush->numsides; j++)
00368     {
00369         brushside = &sin_dbrushsides[brush->firstside + j];
00370         if (brushside->texinfo > 0)
00371         {
00372             if (sin_texinfo[brushside->texinfo].flags & (SURF_SKIP|SURF_HINT))
00373             {
00374                 return true;
00375             } //end if
00376         } //end if
00377     } //end for
00378     return false;
00379 } //end of the function Sin_HintSkipBrush

void Sin_LoadBSPFile char *  filename,
int  offset,
int  length
 

Definition at line 825 of file l_bsp_sin.c.

References Error(), FreeMemory(), header, i, dheader_t::ident, length(), LittleLong(), LoadFile(), offset, SIN_BSPHEADER, SIN_BSPVERSION, Sin_CopyLump(), sin_dareaportals, sin_dareas, sin_dbrushes, sin_dbrushsides, sin_dedges, sin_dentdata, sin_dfaces, sin_dleafbrushes, sin_dleaffaces, sin_dleafs, sin_dlightdata, sin_dmodels, sin_dnodes, sin_dplanes, sin_dpop, sin_dsurfedges, sin_dvertexes, sin_dvisdata, sin_entdatasize, sin_lightdatasize, sin_lightinfo, sin_lightvalue_t, SIN_LUMP_AREAPORTALS, SIN_LUMP_AREAS, SIN_LUMP_BRUSHES, SIN_LUMP_BRUSHSIDES, SIN_LUMP_EDGES, SIN_LUMP_ENTITIES, SIN_LUMP_FACES, SIN_LUMP_LEAFBRUSHES, SIN_LUMP_LEAFFACES, SIN_LUMP_LEAFS, SIN_LUMP_LIGHTINFO, SIN_LUMP_LIGHTING, SIN_LUMP_MODELS, SIN_LUMP_NODES, SIN_LUMP_PLANES, SIN_LUMP_POP, SIN_LUMP_SURFEDGES, SIN_LUMP_TEXINFO, SIN_LUMP_VERTEXES, SIN_LUMP_VISIBILITY, SIN_MAX_MAP_AREAPORTALS, SIN_MAX_MAP_AREAS, SIN_MAX_MAP_BRUSHES, SIN_MAX_MAP_BRUSHSIDES, SIN_MAX_MAP_EDGES, SIN_MAX_MAP_ENTSTRING, SIN_MAX_MAP_FACES, SIN_MAX_MAP_LEAFBRUSHES, SIN_MAX_MAP_LEAFFACES, SIN_MAX_MAP_LEAFS, SIN_MAX_MAP_LIGHTINFO, SIN_MAX_MAP_LIGHTING, SIN_MAX_MAP_MODELS, SIN_MAX_MAP_NODES, SIN_MAX_MAP_PLANES, SIN_MAX_MAP_SURFEDGES, SIN_MAX_MAP_TEXINFO, SIN_MAX_MAP_VERTS, SIN_MAX_MAP_VISIBILITY, sin_numareaportals, sin_numareas, sin_numbrushes, sin_numbrushsides, sin_numedges, sin_numfaces, sin_numleafbrushes, sin_numleaffaces, sin_numleafs, sin_numlightinfo, sin_nummodels, sin_numnodes, sin_numplanes, sin_numsurfedges, sin_numtexinfo, sin_numvertexes, Sin_SwapBSPFile(), sin_texinfo, sin_texinfo_t, sin_visdatasize, and dheader_t::version.

Referenced by Sin_LoadMapFromBSP().

00826 {
00827     int         i;
00828     
00829 //
00830 // load the file header
00831 //
00832     LoadFile (filename, (void **)&header, offset, length);
00833 
00834 // swap the header
00835     for (i=0 ; i< sizeof(sin_dheader_t)/4 ; i++)
00836         ((int *)header)[i] = LittleLong ( ((int *)header)[i]);
00837 
00838     if (header->ident != SIN_BSPHEADER && header->ident != SINGAME_BSPHEADER)
00839         Error ("%s is not a IBSP file", filename);
00840     if (header->version != SIN_BSPVERSION && header->version != SINGAME_BSPVERSION)
00841         Error ("%s is version %i, not %i", filename, header->version, SIN_BSPVERSION);
00842 
00843 #ifdef SIN
00844     sin_nummodels = Sin_CopyLump (SIN_LUMP_MODELS, sin_dmodels, sizeof(sin_dmodel_t), SIN_MAX_MAP_MODELS);
00845     sin_numvertexes = Sin_CopyLump (SIN_LUMP_VERTEXES, sin_dvertexes, sizeof(sin_dvertex_t), SIN_MAX_MAP_VERTS);
00846     sin_numplanes = Sin_CopyLump (SIN_LUMP_PLANES, sin_dplanes, sizeof(sin_dplane_t), SIN_MAX_MAP_PLANES);
00847     sin_numleafs = Sin_CopyLump (SIN_LUMP_LEAFS, sin_dleafs, sizeof(sin_dleaf_t), SIN_MAX_MAP_LEAFS);
00848     sin_numnodes = Sin_CopyLump (SIN_LUMP_NODES, sin_dnodes, sizeof(sin_dnode_t), SIN_MAX_MAP_NODES);
00849     sin_numtexinfo = Sin_CopyLump (SIN_LUMP_TEXINFO, sin_texinfo, sizeof(sin_texinfo_t), SIN_MAX_MAP_TEXINFO);
00850     sin_numfaces = Sin_CopyLump (SIN_LUMP_FACES, sin_dfaces, sizeof(sin_dface_t), SIN_MAX_MAP_FACES);
00851     sin_numleaffaces = Sin_CopyLump (SIN_LUMP_LEAFFACES, sin_dleaffaces, sizeof(sin_dleaffaces[0]), SIN_MAX_MAP_LEAFFACES);
00852     sin_numleafbrushes = Sin_CopyLump (SIN_LUMP_LEAFBRUSHES, sin_dleafbrushes, sizeof(sin_dleafbrushes[0]), SIN_MAX_MAP_LEAFBRUSHES);
00853     sin_numsurfedges = Sin_CopyLump (SIN_LUMP_SURFEDGES, sin_dsurfedges, sizeof(sin_dsurfedges[0]), SIN_MAX_MAP_SURFEDGES);
00854     sin_numedges = Sin_CopyLump (SIN_LUMP_EDGES, sin_dedges, sizeof(sin_dedge_t), SIN_MAX_MAP_EDGES);
00855     sin_numbrushes = Sin_CopyLump (SIN_LUMP_BRUSHES, sin_dbrushes, sizeof(sin_dbrush_t), SIN_MAX_MAP_BRUSHES);
00856     sin_numbrushsides = Sin_CopyLump (SIN_LUMP_BRUSHSIDES, sin_dbrushsides, sizeof(sin_dbrushside_t), SIN_MAX_MAP_BRUSHSIDES);
00857     sin_numareas = Sin_CopyLump (SIN_LUMP_AREAS, sin_dareas, sizeof(sin_darea_t), SIN_MAX_MAP_AREAS);
00858     sin_numareaportals = Sin_CopyLump (SIN_LUMP_AREAPORTALS, sin_dareaportals, sizeof(sin_dareaportal_t), SIN_MAX_MAP_AREAPORTALS);
00859     sin_numlightinfo = Sin_CopyLump (SIN_LUMP_LIGHTINFO, sin_lightinfo, sizeof(sin_lightvalue_t), SIN_MAX_MAP_LIGHTINFO);
00860 
00861     sin_visdatasize = Sin_CopyLump (SIN_LUMP_VISIBILITY, sin_dvisdata, 1, SIN_MAX_MAP_VISIBILITY);
00862     sin_lightdatasize = Sin_CopyLump (SIN_LUMP_LIGHTING, sin_dlightdata, 1, SIN_MAX_MAP_LIGHTING);
00863     sin_entdatasize = Sin_CopyLump (SIN_LUMP_ENTITIES, sin_dentdata, 1, SIN_MAX_MAP_ENTSTRING);
00864 
00865     Sin_CopyLump (SIN_LUMP_POP, sin_dpop, 1, sizeof(sin_dpop));
00866 #else
00867     sin_nummodels = Sin_CopyLump (SIN_LUMP_MODELS, sin_dmodels, sizeof(sin_dmodel_t));
00868     sin_numvertexes = Sin_CopyLump (SIN_LUMP_VERTEXES, sin_dvertexes, sizeof(sin_dvertex_t));
00869     sin_numplanes = Sin_CopyLump (SIN_LUMP_PLANES, sin_dplanes, sizeof(sin_dplane_t));
00870     sin_numleafs = Sin_CopyLump (SIN_LUMP_LEAFS, sin_dleafs, sizeof(sin_dleaf_t));
00871     sin_numnodes = Sin_CopyLump (SIN_LUMP_NODES, sin_dnodes, sizeof(sin_dnode_t));
00872     sin_numtexinfo = Sin_CopyLump (SIN_LUMP_TEXINFO, sin_texinfo, sizeof(sin_texinfo_t));
00873     sin_numfaces = Sin_CopyLump (SIN_LUMP_FACES, sin_dfaces, sizeof(sin_dface_t));
00874     sin_numleaffaces = Sin_CopyLump (SIN_LUMP_LEAFFACES, sin_dleaffaces, sizeof(sin_dleaffaces[0]));
00875     sin_numleafbrushes = Sin_CopyLump (SIN_LUMP_LEAFBRUSHES, sin_dleafbrushes, sizeof(sin_dleafbrushes[0]));
00876     sin_numsurfedges = Sin_CopyLump (SIN_LUMP_SURFEDGES, sin_dsurfedges, sizeof(sin_dsurfedges[0]));
00877     sin_numedges = Sin_CopyLump (SIN_LUMP_EDGES, sin_dedges, sizeof(sin_dedge_t));
00878     sin_numbrushes = Sin_CopyLump (SIN_LUMP_BRUSHES, sin_dbrushes, sizeof(sin_dbrush_t));
00879     sin_numbrushsides = Sin_CopyLump (SIN_LUMP_BRUSHSIDES, sin_dbrushsides, sizeof(sin_dbrushside_t));
00880     sin_numareas = Sin_CopyLump (SIN_LUMP_AREAS, sin_dareas, sizeof(sin_darea_t));
00881     sin_numareaportals = Sin_CopyLump (SIN_LUMP_AREAPORTALS, sin_dareaportals, sizeof(sin_dareaportal_t));
00882 
00883     sin_visdatasize = Sin_CopyLump (SIN_LUMP_VISIBILITY, sin_dvisdata, 1);
00884     sin_lightdatasize = Sin_CopyLump (SIN_LUMP_LIGHTING, sin_dlightdata, 1);
00885     sin_entdatasize = Sin_CopyLump (SIN_LUMP_ENTITIES, sin_dentdata, 1);
00886 
00887     Sin_CopyLump (SIN_LUMP_POP, sin_dpop, 1);
00888 #endif
00889 
00890     FreeMemory(header);     // everything has been copied out
00891         
00892 //
00893 // swap everything
00894