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

BSPFILE.H File Reference

Go to the source code of this file.

Data Structures

struct  dbrush_t
struct  dbrushside_t
struct  dedge_t
struct  dface_t
struct  dheader_t
struct  dleaf_t
struct  dmiptexlump_t
struct  dmodel_t
struct  dnode_t
struct  dpath_t
struct  dplane_t
struct  dvertex_t
struct  entity_t
struct  epair_s
struct  lump_t
struct  miptex_s
struct  texinfo_s

Defines

#define ANGLE_DOWN   -2
#define ANGLE_UP   -1
#define BSPVERSION   34
#define CONTENTS_CURRENT_0   1024
#define CONTENTS_CURRENT_180   4096
#define CONTENTS_CURRENT_270   8192
#define CONTENTS_CURRENT_90   2048
#define CONTENTS_CURRENT_DOWN   32768
#define CONTENTS_CURRENT_UP   16384
#define CONTENTS_LAVA   8
#define CONTENTS_MONSTER   128
#define CONTENTS_MONSTERCLIP   512
#define CONTENTS_ORIGIN   65536
#define CONTENTS_PLAYERCLIP   256
#define CONTENTS_SLIME   16
#define CONTENTS_SOLID   1
#define CONTENTS_THINWATER   64
#define CONTENTS_WATER   32
#define CONTENTS_WINDOW   2
#define HEADER_LUMPS   18
#define LAST_VISIBLE_CONTENTS   64
#define LUMP_BRUSHES   16
#define LUMP_BRUSHSIDES   17
#define LUMP_EDGES   12
#define LUMP_ENTITIES   0
#define LUMP_FACES   7
#define LUMP_LEAFBRUSHES   11
#define LUMP_LEAFFACES   10
#define LUMP_LEAFS   9
#define LUMP_LIGHTING   8
#define LUMP_MODELS   14
#define LUMP_NODES   5
#define LUMP_PATHS   15
#define LUMP_PLANES   1
#define LUMP_POP   18
#define LUMP_SURFEDGES   13
#define LUMP_TEXINFO   6
#define LUMP_TEXTURES   2
#define LUMP_VERTEXES   3
#define LUMP_VISIBILITY   4
#define MAX_KEY   32
#define MAX_MAP_BRUSHES   8192
#define MAX_MAP_BRUSHSIDES   65536
#define MAX_MAP_EDGES   128000
#define MAX_MAP_ENTITIES   2048
#define MAX_MAP_ENTSTRING   0x20000
#define MAX_MAP_FACES   65536
#define MAX_MAP_LEAFBRUSHES   65536
#define MAX_MAP_LEAFFACES   65536
#define MAX_MAP_LEAFS   65536
#define MAX_MAP_LIGHTING   0x200000
#define MAX_MAP_MIPTEX   0x200000
#define MAX_MAP_MODELS   1024
#define MAX_MAP_NODES   65536
#define MAX_MAP_PATHS   2048
#define MAX_MAP_PLANES   65536
#define MAX_MAP_PORTALS   65536
#define MAX_MAP_SURFEDGES   256000
#define MAX_MAP_TEXINFO   8192
#define MAX_MAP_TEXTURES   1024
#define MAX_MAP_VERTS   65536
#define MAX_MAP_VISIBILITY   0x100000
#define MAX_VALUE   1024
#define MAXLIGHTMAPS   4
#define MIPLEVELS   4
#define PLANE_ANYX   3
#define PLANE_ANYY   4
#define PLANE_ANYZ   5
#define PLANE_X   0
#define PLANE_Y   1
#define PLANE_Z   2
#define SURF_LAVA   16
#define SURF_LIGHT   2
#define SURF_MIRROR   128
#define SURF_SKY   64
#define SURF_SLIME   8
#define SURF_SLIPPERY   256
#define SURF_WATER   4
#define SURF_WINDOW   32
#define TEX_SPECIAL   1

Typedefs

typedef epair_s epair_t
typedef miptex_s miptex_t
typedef texinfo_s texinfo_t

Functions

int CompressVis (byte *vis, byte *dest)
void DecompressVis (byte *in, byte *decompressed)
vec_t FloatForKey (entity_t *ent, char *key)
void GetVectorForKey (entity_t *ent, char *key, vec3_t vec)
void LoadBSPFile (char *filename)
void ParseEntities (void)
epair_tParseEpair (void)
void PrintBSPFileSizes (void)
void PrintEntity (entity_t *ent)
void SetKeyValue (entity_t *ent, char *key, char *value)
void UnparseEntities (void)
char * ValueForKey (entity_t *ent, char *key)
void WriteBSPFile (char *filename)

Variables

dbrush_t dbrushes [MAX_MAP_BRUSHES]
dbrushside_t dbrushsides [MAX_MAP_BRUSHSIDES]
dedge_t dedges [MAX_MAP_EDGES]
char dentdata [MAX_MAP_ENTSTRING]
dface_t dfaces [MAX_MAP_FACES]
unsigned short dleafbrushes [MAX_MAP_LEAFBRUSHES]
unsigned short dleaffaces [MAX_MAP_LEAFFACES]
dleaf_t dleafs [MAX_MAP_LEAFS]
byte dlightdata [MAX_MAP_LIGHTING]
dmodel_t dmodels [MAX_MAP_MODELS]
dnode_t dnodes [MAX_MAP_NODES]
dpath_t dpaths [MAX_MAP_PATHS]
dplane_t dplanes [MAX_MAP_PLANES]
int dsurfedges [MAX_MAP_SURFEDGES]
byte dtexdata [MAX_MAP_MIPTEX]
dvertex_t dvertexes [MAX_MAP_VERTS]
byte dvisdata [MAX_MAP_VISIBILITY]
int entdatasize
entity_t entities [MAX_MAP_ENTITIES]
int lightdatasize
int num_entities
int numbrushes
int numbrushsides
int numedges
int numfaces
int numleafbrushes
int numleaffaces
int numleafs
int nummodels
int numnodes
int numpaths
int numplanes
int numsurfedges
int numtexinfo
int numvertexes
int r_leaftovis [MAX_MAP_LEAFS]
int r_numvisleafs
int r_vistoleaf [MAX_MAP_LEAFS]
int texdatasize
texinfo_t texinfo [MAX_MAP_TEXINFO]
int visdatasize


Define Documentation

#define ANGLE_DOWN   -2
 

Definition at line 273 of file BSPFILE.H.

#define ANGLE_UP   -1
 

Definition at line 272 of file BSPFILE.H.

#define BSPVERSION   34
 

Definition at line 57 of file BSPFILE.H.

#define CONTENTS_CURRENT_0   1024
 

Definition at line 165 of file BSPFILE.H.

#define CONTENTS_CURRENT_180   4096
 

Definition at line 167 of file BSPFILE.H.

#define CONTENTS_CURRENT_270   8192
 

Definition at line 168 of file BSPFILE.H.

#define CONTENTS_CURRENT_90   2048
 

Definition at line 166 of file BSPFILE.H.

#define CONTENTS_CURRENT_DOWN   32768
 

Definition at line 170 of file BSPFILE.H.

#define CONTENTS_CURRENT_UP   16384
 

Definition at line 169 of file BSPFILE.H.

#define CONTENTS_LAVA   8
 

Definition at line 151 of file BSPFILE.H.

#define CONTENTS_MONSTER   128
 

Definition at line 159 of file BSPFILE.H.

#define CONTENTS_MONSTERCLIP   512
 

Definition at line 161 of file BSPFILE.H.

#define CONTENTS_ORIGIN   65536
 

Definition at line 172 of file BSPFILE.H.

#define CONTENTS_PLAYERCLIP   256
 

Definition at line 160 of file BSPFILE.H.

#define CONTENTS_SLIME   16
 

Definition at line 152 of file BSPFILE.H.

#define CONTENTS_SOLID   1
 

Definition at line 149 of file BSPFILE.H.

#define CONTENTS_THINWATER   64
 

Definition at line 154 of file BSPFILE.H.

#define CONTENTS_WATER   32
 

Definition at line 153 of file BSPFILE.H.

#define CONTENTS_WINDOW   2
 

Definition at line 150 of file BSPFILE.H.

#define HEADER_LUMPS   18
 

Definition at line 84 of file BSPFILE.H.

#define LAST_VISIBLE_CONTENTS   64
 

Definition at line 156 of file BSPFILE.H.

#define LUMP_BRUSHES   16
 

Definition at line 80 of file BSPFILE.H.

#define LUMP_BRUSHSIDES   17
 

Definition at line 81 of file BSPFILE.H.

#define LUMP_EDGES   12
 

Definition at line 76 of file BSPFILE.H.

#define LUMP_ENTITIES   0
 

Definition at line 64 of file BSPFILE.H.

#define LUMP_FACES   7
 

Definition at line 71 of file BSPFILE.H.

#define LUMP_LEAFBRUSHES   11
 

Definition at line 75 of file BSPFILE.H.

#define LUMP_LEAFFACES   10
 

Definition at line 74 of file BSPFILE.H.

#define LUMP_LEAFS   9
 

Definition at line 73 of file BSPFILE.H.

#define LUMP_LIGHTING   8
 

Definition at line 72 of file BSPFILE.H.

#define LUMP_MODELS   14
 

Definition at line 78 of file BSPFILE.H.

#define LUMP_NODES   5
 

Definition at line 69 of file BSPFILE.H.

#define LUMP_PATHS   15
 

Definition at line 79 of file BSPFILE.H.

#define LUMP_PLANES   1
 

Definition at line 65 of file BSPFILE.H.

#define LUMP_POP   18
 

Definition at line 82 of file BSPFILE.H.

#define LUMP_SURFEDGES   13
 

Definition at line 77 of file BSPFILE.H.

#define LUMP_TEXINFO   6
 

Definition at line 70 of file BSPFILE.H.

#define LUMP_TEXTURES   2
 

Definition at line 66 of file BSPFILE.H.

#define LUMP_VERTEXES   3
 

Definition at line 67 of file BSPFILE.H.

#define LUMP_VISIBILITY   4
 

Definition at line 68 of file BSPFILE.H.

#define MAX_KEY   32
 

Definition at line 52 of file BSPFILE.H.

#define MAX_MAP_BRUSHES   8192
 

Definition at line 28 of file BSPFILE.H.

#define MAX_MAP_BRUSHSIDES   65536
 

Definition at line 37 of file BSPFILE.H.

#define MAX_MAP_EDGES   128000
 

Definition at line 44 of file BSPFILE.H.

#define MAX_MAP_ENTITIES   2048
 

Definition at line 29 of file BSPFILE.H.

#define MAX_MAP_ENTSTRING   0x20000
 

Definition at line 31 of file BSPFILE.H.

#define MAX_MAP_FACES   65536
 

Definition at line 40 of file BSPFILE.H.

#define MAX_MAP_LEAFBRUSHES   65536
 

Definition at line 42 of file BSPFILE.H.

#define MAX_MAP_LEAFFACES   65536
 

Definition at line 41 of file BSPFILE.H.

#define MAX_MAP_LEAFS   65536
 

Definition at line 38 of file BSPFILE.H.

#define MAX_MAP_LIGHTING   0x200000
 

Definition at line 47 of file BSPFILE.H.

#define MAX_MAP_MIPTEX   0x200000
 

Definition at line 46 of file BSPFILE.H.

#define MAX_MAP_MODELS   1024
 

Definition at line 27 of file BSPFILE.H.

#define MAX_MAP_NODES   65536
 

Definition at line 36 of file BSPFILE.H.

#define MAX_MAP_PATHS   2048
 

Definition at line 30 of file BSPFILE.H.

#define MAX_MAP_PLANES   65536
 

Definition at line 35 of file BSPFILE.H.

#define MAX_MAP_PORTALS   65536
 

Definition at line 43 of file BSPFILE.H.

#define MAX_MAP_SURFEDGES   256000
 

Definition at line 45 of file BSPFILE.H.

#define MAX_MAP_TEXINFO   8192
 

Definition at line 33 of file BSPFILE.H.

#define MAX_MAP_TEXTURES   1024
 

Definition at line 32 of file BSPFILE.H.

#define MAX_MAP_VERTS   65536
 

Definition at line 39 of file BSPFILE.H.

#define MAX_MAP_VISIBILITY   0x100000
 

Definition at line 48 of file BSPFILE.H.

#define MAX_VALUE   1024
 

Definition at line 53 of file BSPFILE.H.

#define MAXLIGHTMAPS   4
 

Definition at line 215 of file BSPFILE.H.

#define MIPLEVELS   4
 

Definition at line 107 of file BSPFILE.H.

#define PLANE_ANYX   3
 

Definition at line 130 of file BSPFILE.H.

#define PLANE_ANYY   4
 

Definition at line 131 of file BSPFILE.H.

#define PLANE_ANYZ   5
 

Definition at line 132 of file BSPFILE.H.

#define PLANE_X   0
 

Definition at line 125 of file BSPFILE.H.

#define PLANE_Y   1
 

Definition at line 126 of file BSPFILE.H.

#define PLANE_Z   2
 

Definition at line 127 of file BSPFILE.H.

#define SURF_LAVA   16
 

Definition at line 200 of file BSPFILE.H.

#define SURF_LIGHT   2
 

Definition at line 196 of file BSPFILE.H.

#define SURF_MIRROR   128
 

Definition at line 204 of file BSPFILE.H.

#define SURF_SKY   64
 

Definition at line 203 of file BSPFILE.H.

#define SURF_SLIME   8
 

Definition at line 199 of file BSPFILE.H.

#define SURF_SLIPPERY   256
 

Definition at line 206 of file BSPFILE.H.

#define SURF_WATER   4
 

Definition at line 198 of file BSPFILE.H.

#define SURF_WINDOW   32
 

Definition at line 201 of file BSPFILE.H.

#define TEX_SPECIAL   1
 

Definition at line 195 of file BSPFILE.H.


Typedef Documentation

typedef struct epair_s epair_t
 

typedef struct miptex_s miptex_t
 

typedef struct texinfo_s texinfo_t
 


Function Documentation

int CompressVis byte vis,
byte dest
 

void DecompressVis byte in,
byte decompressed
 

vec_t FloatForKey entity_t ent,
char *  key
 

Definition at line 158 of file l_bsp_ent.c.

References atof(), k, ValueForKey(), and vec_t.

00159 {
00160     char    *k;
00161     
00162     k = ValueForKey (ent, key);
00163     return atof(k);
00164 }

Here is the call graph for this function:

void GetVectorForKey entity_t ent,
char *  key,
vec3_t  vec
 

Definition at line 166 of file l_bsp_ent.c.

References k, sscanf(), v1, v2, and ValueForKey().

00167 {
00168     char    *k;
00169     double  v1, v2, v3;
00170 
00171     k = ValueForKey (ent, key);
00172 // scanf into doubles, then assign, so it is vec_t size independent
00173     v1 = v2 = v3 = 0;
00174     sscanf (k, "%lf %lf %lf", &v1, &v2, &v3);
00175     vec[0] = v1;
00176     vec[1] = v2;
00177     vec[2] = v3;
00178 }

Here is the call graph for this function:

void LoadBSPFile char *  filename  ) 
 

Referenced by Bspinfo(), LightMain(), OnlyEnts(), OnlyTextures(), VisMain(), VLightMain(), and VSoundMain().

void ParseEntities void   ) 
 

Definition at line 447 of file bspfile.c.

References dentdata, entdatasize, num_entities, ParseEntity(), and ParseFromMemory().

Referenced by LightMain(), PrintBSPFileSizes(), VLightMain(), and VSoundMain().

00447                            {
00448     num_entities = 0;
00449     ParseFromMemory( dentdata, entdatasize );
00450 
00451     while ( ParseEntity () ) {
00452     }   
00453 }

Here is the call graph for this function:

epair_t* ParseEpair void   ) 
 

Definition at line 378 of file bspfile.c.

00378                             {
00379     epair_t *e;
00380 
00381     e = malloc( sizeof(epair_t) );
00382     memset( e, 0, sizeof(epair_t) );
00383     
00384     if ( strlen(token) >= MAX_KEY-1 ) {
00385         Error ("ParseEpar: token too long");
00386     }
00387     e->key = copystring( token );
00388     GetToken( qfalse );
00389     if ( strlen(token) >= MAX_VALUE-1 ) {
00390         Error ("ParseEpar: token too long");
00391     }
00392     e->value = copystring( token );
00393 
00394     // strip trailing spaces that sometimes get accidentally
00395     // added in the editor
00396     StripTrailing( e->key );
00397     StripTrailing( e->value );
00398 
00399     return e;
00400 }

void PrintBSPFileSizes void   ) 
 

Definition at line 314 of file bspfile.c.

References dleafbrushes, dleafsurfaces, drawIndexes, drawSurfaces, drawVerts, entdatasize, LIGHTMAP_HEIGHT, LIGHTMAP_WIDTH, num_entities, numbrushes, numbrushsides, numDrawIndexes, numDrawSurfaces, numDrawVerts, numFogs, numleafbrushes, numleafs, numleafsurfaces, numLightBytes, nummodels, numnodes, numplanes, numShaders, numVisBytes, ParseEntities(), and printf().

Referenced by Bspinfo().

00314                                {
00315     if ( !num_entities ) {
00316         ParseEntities();
00317     }
00318 
00319     printf ("%6i models       %7i\n"
00320         ,nummodels, (int)(nummodels*sizeof(dmodel_t)));
00321     printf ("%6i shaders      %7i\n"
00322         ,numShaders, (int)(numShaders*sizeof(dshader_t)));
00323     printf ("%6i brushes      %7i\n"
00324         ,numbrushes, (int)(numbrushes*sizeof(dbrush_t)));
00325     printf ("%6i brushsides   %7i\n"
00326         ,numbrushsides, (int)(numbrushsides*sizeof(dbrushside_t)));
00327     printf ("%6i fogs         %7i\n"
00328         ,numFogs, (int)(numFogs*sizeof(dfog_t)));
00329     printf ("%6i planes       %7i\n"
00330         ,numplanes, (int)(numplanes*sizeof(dplane_t)));
00331     printf ("%6i entdata      %7i\n", num_entities, entdatasize);
00332 
00333     printf ("\n");
00334 
00335     printf ("%6i nodes        %7i\n"
00336         ,numnodes, (int)(numnodes*sizeof(dnode_t)));
00337     printf ("%6i leafs        %7i\n"
00338         ,numleafs, (int)(numleafs*sizeof(dleaf_t)));
00339     printf ("%6i leafsurfaces %7i\n"
00340         ,numleafsurfaces, (int)(numleafsurfaces*sizeof(dleafsurfaces[0])));
00341     printf ("%6i leafbrushes  %7i\n"
00342         ,numleafbrushes, (int)(numleafbrushes*sizeof(dleafbrushes[0])));
00343     printf ("%6i drawverts    %7i\n"
00344         ,numDrawVerts, (int)(numDrawVerts*sizeof(drawVerts[0])));
00345     printf ("%6i drawindexes  %7i\n"
00346         ,numDrawIndexes, (int)(numDrawIndexes*sizeof(drawIndexes[0])));
00347     printf ("%6i drawsurfaces %7i\n"
00348         ,numDrawSurfaces, (int)(numDrawSurfaces*sizeof(drawSurfaces[0])));
00349 
00350     printf ("%6i lightmaps    %7i\n"
00351         ,numLightBytes / (LIGHTMAP_WIDTH*LIGHTMAP_HEIGHT*3), numLightBytes );
00352     printf ("       visibility   %7i\n"
00353         , numVisBytes );
00354 }

Here is the call graph for this function:

void PrintEntity entity_t ent  ) 
 

Definition at line 118 of file l_bsp_ent.c.

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

00119 {
00120     epair_t *ep;
00121     
00122     printf ("------- entity %p -------\n", ent);
00123     for (ep=ent->epairs ; ep ; ep=ep->next)
00124     {
00125         printf ("%s = %s\n", ep->key, ep->value);
00126     }
00127 
00128 }

Here is the call graph for this function:

void SetKeyValue entity_t ent,
char *  key,
char *  value
 

Definition at line 130 of file l_bsp_ent.c.

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

00131 {
00132     epair_t *ep;
00133     
00134     for (ep=ent->epairs ; ep ; ep=ep->next)
00135         if (!strcmp (ep->key, key) )
00136         {
00137             FreeMemory(ep->value);
00138             ep->value = copystring(value);
00139             return;
00140         }
00141     ep = GetMemory(sizeof(*ep));
00142     ep->next = ent->epairs;
00143     ent->epairs = ep;
00144     ep->key = copystring(key);
00145     ep->value = copystring(value);
00146 }

Here is the call graph for this function:

void UnparseEntities void   ) 
 

Definition at line 465 of file bspfile.c.

References entdatasize, entities, epair_t, entity_t::epairs, Error(), i, epair_s::key, line, epair_s::next, sprintf(), strcat(), strcpy(), StripTrailing(), strlen(), epair_s::value, and value.

Referenced by EndBSPFile(), and OnlyEnts().

00465                              {
00466     char    *buf, *end;
00467     epair_t *ep;
00468     char    line[2048];
00469     int     i;
00470     char    key[1024], value[1024];
00471 
00472     buf = dentdata;
00473     end = buf;
00474     *end = 0;
00475     
00476     for (i=0 ; i<num_entities ; i++) {
00477         ep = entities[i].epairs;
00478         if ( !ep ) {
00479             continue;   // ent got removed
00480         }
00481         
00482         strcat (end,"{\n");
00483         end += 2;
00484                 
00485         for ( ep = entities[i].epairs ; ep ; ep=ep->next ) {
00486             strcpy (key, ep->key);
00487             StripTrailing (key);
00488             strcpy (value, ep->value);
00489             StripTrailing (value);
00490                 
00491             sprintf (line, "\"%s\" \"%s\"\n", key, value);
00492             strcat (end, line);
00493             end += strlen(line);
00494         }
00495         strcat (end,"}\n");
00496         end += 2;
00497 
00498         if (end > buf + MAX_MAP_ENTSTRING) {
00499             Error ("Entity text too long");
00500         }
00501     }
00502     entdatasize = end - buf + 1;
00503 }

Here is the call graph for this function: