bspfile.c File Reference

#include "shared.h"
#include "bspfile.h"
#include "scriplib.h"
#include "../bsp.h"
Include dependency graph for bspfile.c:

Go to the source code of this file.

Functions

byteCompressRouting (byte *dataStart, byte *destStart, int l)
 Compress the routing data of a map.
static void SwapBSPFile (void)
 Byte swaps all data in a bsp file.
static int CopyLump (int lump, void *dest, int size)
void LoadBSPFile (const char *filename)
static void AddLump (qFILE *bspfile, dBspHeader_t *header, int lumpnum, void *data, int len)
long WriteBSPFile (const char *filename)
 Swaps the bsp file in place, so it should not be referenced again.
void PrintBSPFileSizes (void)
 Dumps info about current file.
static void StripTrailingWhitespaces (char *str)
 Removes trailing whitespaces from the given string.
epair_tParseEpair (void)
 Parses one key and value for an entity from the current tokens.
static entity_tParseEntity (void)
void ParseEntities (void)
 Parses the curTile->entdata string into entities.
const char * UnparseEntities (void)
 Generates the curTile->entdata string from all the entities.
void SetKeyValue (entity_t *ent, const char *key, const char *value)
const char * ValueForKey (const entity_t *ent, const char *key)
vec_t FloatForKey (const entity_t *ent, const char *key)
void GetVectorFromString (const char *value, vec3_t vec)
 Converts a string into a vec3_t.
void GetVectorForKey (const entity_t *ent, const char *key, vec3_t vec)
 Converts the value of a entity parameter into a vec3_t.

Variables

static dBspHeader_theader
int num_entities
entity_t entities [MAX_MAP_ENTITIES]

Detailed Description

Definition in file bspfile.c.


Function Documentation

static void AddLump ( qFILE bspfile,
dBspHeader_t header,
int  lumpnum,
void *  data,
int  len 
) [inline, static]
See also:
WriteBSPFile
Todo:
Implement this without the ftell stuff - don't write the bsp file twice

Definition at line 283 of file bspfile.c.

References qFILE_s::f, lump_t::filelen, lump_t::fileofs, FS_Write(), LittleLong(), and dBspHeader_t::lumps.

Referenced by WriteBSPFile().

byte* CompressRouting ( byte dataStart,
byte destStart,
int  l 
)

Compress the routing data of a map.

See also:
CMod_DeCompressRouting
CMod_LoadRouting

Definition at line 36 of file bspfile.c.

References byte, and data.

Referenced by DoRouting().

static int CopyLump ( int  lump,
void *  dest,
int  size 
) [static]

Definition at line 203 of file bspfile.c.

References byte, lump_t::filelen, lump_t::fileofs, dBspHeader_t::lumps, ofs, and Sys_Error().

Referenced by LoadBSPFile().

vec_t FloatForKey ( const entity_t ent,
const char *  key 
)

Definition at line 545 of file bspfile.c.

References ValueForKey().

Referenced by BuildLights().

void GetVectorForKey ( const entity_t ent,
const char *  key,
vec3_t  vec 
)

Converts the value of a entity parameter into a vec3_t.

Definition at line 574 of file bspfile.c.

References GetVectorFromString(), and ValueForKey().

Referenced by BuildLights(), BuildPatches(), and ParseMapEntity().

void GetVectorFromString ( const char *  value,
vec3_t  vec 
)

Converts a string into a vec3_t.

Definition at line 556 of file bspfile.c.

References VectorClear.

Referenced by BuildLights(), and GetVectorForKey().

void LoadBSPFile ( const char *  filename  ) 
void ParseEntities ( void   ) 

Parses the curTile->entdata string into entities.

See also:
UnparseEntities
ParseEntity

Definition at line 466 of file bspfile.c.

References config, curTile, dMapTile_t::entdata, dMapTile_t::entdatasize, num_entities, ParseEntity(), ParseFromMemory(), ValueForKey(), VERB_EXTRA, and Verb_Printf().

Referenced by PrintBSPFileSizes().

static entity_t* ParseEntity ( void   )  [static]
epair_t* ParseEpair ( void   ) 

Parses one key and value for an entity from the current tokens.

See also:
parsedToken
GetToken
ParseEntity
ParseMapEntity

Definition at line 405 of file bspfile.c.

References GetToken(), epair_s::key, MAX_KEY, MAX_VALUE, Mem_Alloc, Mem_StrDup, parsedToken, qfalse, StripTrailingWhitespaces(), Sys_Error(), and epair_s::value.

Referenced by ParseEntity(), and ParseMapEntity().

void PrintBSPFileSizes ( void   ) 
void SetKeyValue ( entity_t ent,
const char *  key,
const char *  value 
)
static void StripTrailingWhitespaces ( char *  str  )  [static]

Removes trailing whitespaces from the given string.

Parameters:
[in,out] str The string to clean up
Note:
Whitespaces are converted to \0

Definition at line 387 of file bspfile.c.

Referenced by ParseEpair(), and UnparseEntities().

static void SwapBSPFile ( void   )  [static]

Byte swaps all data in a bsp file.

Definition at line 85 of file bspfile.c.

References dBspLeaf_t::area, dMapTile_t::brushes, dMapTile_t::brushsides, dBspNode_t::children, cBspBrush_s::contentFlags, dBspBrush_t::contentFlags, dBspLeaf_t::contentFlags, curTile, dMapTile_t::dbrushes, dBspPlane_t::dist, dMapTile_t::edges, dMapTile_t::faces, cBspBrush_s::firstbrushside, dBspBrush_t::firstbrushside, dBspSurface_t::firstedge, dBspNode_t::firstface, dBspModel_t::firstface, dBspLeaf_t::firstleafbrush, dBspModel_t::headnode, i, dMapTile_t::leafbrushes, dMapTile_t::leafs, LIGHTMAP_MAX, dBspSurface_t::lightofs, LittleFloat(), LittleLong(), LittleShort(), dBspLeaf_t::maxs, dBspNode_t::maxs, dBspModel_t::maxs, dBspLeaf_t::mins, dBspNode_t::mins, dBspModel_t::mins, dMapTile_t::models, dMapTile_t::nodes, dBspPlane_t::normal, dMapTile_t::numbrushes, dMapTile_t::numbrushsides, dMapTile_t::numedges, dBspSurface_t::numedges, dBspNode_t::numfaces, dMapTile_t::numfaces, dBspModel_t::numfaces, dMapTile_t::numleafbrushes, dBspLeaf_t::numleafbrushes, dMapTile_t::numleafs, dMapTile_t::nummodels, dMapTile_t::numnodes, dMapTile_t::numplanes, cBspBrush_s::numsides, dBspBrush_t::numsides, dMapTile_t::numsurfedges, dMapTile_t::numtexinfo, dMapTile_t::numvertexes, dBspModel_t::origin, dBspBrushSide_t::planenum, dBspNode_t::planenum, dBspSurface_t::planenum, dMapTile_t::planes, dBspVertex_t::point, dBspSurface_t::side, texinfo_s::surfaceFlags, dMapTile_t::surfedges, dBspBrushSide_t::texinfo, dBspSurface_t::texinfo, dMapTile_t::texinfo, dBspPlane_t::type, dBspEdge_t::v, texinfo_s::value, texinfo_s::vecs, and dMapTile_t::vertexes.

Referenced by LoadBSPFile(), and WriteBSPFile().

const char* UnparseEntities ( void   ) 

Generates the curTile->entdata string from all the entities.

See also:
ParseEntities

Definition at line 488 of file bspfile.c.

References Com_sprintf(), curTile, dMapTile_t::entdata, dMapTile_t::entdatasize, entity_t::epairs, i, epair_s::key, key, epair_s::next, num_entities, Q_strcat(), Q_strncpyz(), StripTrailingWhitespaces(), and epair_s::value.

Referenced by EndBSPFile(), and main().

const char* ValueForKey ( const entity_t ent,
const char *  key 
)
long WriteBSPFile ( const char *  filename  ) 

Variable Documentation

entity_t entities[MAX_MAP_ENTITIES]
dBspHeader_t* header [static]

Generated by  doxygen 1.6.2