UFO: Alien Invasion
Loading...
Searching...
No Matches
bspfile.cpp File Reference
#include "shared.h"
#include "bspfile.h"
#include "scriplib.h"
#include "../bsp.h"
#include <errno.h>
Include dependency graph for bspfile.cpp:

Go to the source code of this file.

Functions

byte * CompressRouting (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 uint32_t CopyLump (const dBspHeader_t *header, int lumpIdx, void *dest, size_t sizesize)
dMapTile_t * LoadBSPFile (const char *filenamefilename)
static void AddLump (qFILE *bspfile, dBspHeader_t *header, int lumpnum, void *data, int len)
long WriteBSPFile (const char *filenamefilename)
 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.
static bool IsInvalidEntityToken (const char *token)
bool EpairCheckForDuplicate (const entity_t *ent, const epair_t *e)
epair_t * AddEpair (const char *key, const char *value, int entNum)
epair_t * ParseEpair (int entNum)
 Parses one key and value for an entity from the current tokens.
static entity_t * ParseEntity (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

int num_entities
entity_t entities [MAX_MAP_ENTITIES]

Function Documentation

◆ AddEpair()

epair_t * AddEpair ( const char * key,
const char * value,
int entNum )

◆ AddLump()

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

Definition at line 295 of file bspfile.cpp.

References AddLump(), data, qFILE::f, lump_t::filelen, lump_t::fileofs, FS_Write(), len, LittleLong, dBspHeader_t::lumps, qFILE::name, and Sys_Error().

Referenced by AddLump(), and WriteBSPFile().

◆ CompressRouting()

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

Compress the routing data of a map.

See also
CMod_DeCompressRouting
CMod_LoadRouting

Definition at line 37 of file bspfile.cpp.

References CompressRouting(), and data.

Referenced by CompressRouting(), and DoRouting().

◆ CopyLump()

uint32_t CopyLump ( const dBspHeader_t * header,
int lumpIdx,
void * dest,
size_t size )
static

Definition at line 212 of file bspfile.cpp.

References CopyLump(), dest, lump_t::filelen, lump_t::fileofs, length, dBspHeader_t::lumps, and Sys_Error().

Referenced by CopyLump(), and LoadBSPFile().

◆ EpairCheckForDuplicate()

bool EpairCheckForDuplicate ( const entity_t * ent,
const epair_t * e )

◆ FloatForKey()

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

Definition at line 566 of file bspfile.cpp.

References FloatForKey(), and ValueForKey().

Referenced by BuildLights(), and FloatForKey().

◆ GetVectorForKey()

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 592 of file bspfile.cpp.

References GetVectorForKey(), GetVectorFromString(), and ValueForKey().

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

◆ GetVectorFromString()

void GetVectorFromString ( const char * value,
vec3_t vec )

Converts a string into a vec3_t.

Definition at line 575 of file bspfile.cpp.

References GetVectorFromString(), Sys_Error(), VectorClear, and VectorSet.

Referenced by BuildLights(), GetVectorForKey(), and GetVectorFromString().

◆ IsInvalidEntityToken()

bool IsInvalidEntityToken ( const char * token)
inlinestatic

Definition at line 413 of file bspfile.cpp.

References IsInvalidEntityToken(), and Q_streq.

Referenced by AddEpair(), IsInvalidEntityToken(), and UnparseEntities().

◆ LoadBSPFile()

dMapTile_t * LoadBSPFile ( const char * filename)
See also
WriteBSPFile

Definition at line 231 of file bspfile.cpp.

References cBspBrush_t::brushContentFlags, dBspBrush_t::brushContentFlags, dMapTile_t::brushes, dMapTile_t::brushsides, BSP_SwapHeader, BSPVERSION, CopyLump(), curTile, dMapTile_t::dbrushes, dMapTile_t::edges, dMapTile_t::entdata, dMapTile_t::entdatasize, dMapTile_t::faces, cBspBrush_t::firstbrushside, dBspBrush_t::firstbrushside, FS_FreeFile(), FS_LoadFile(), i, IDBSPHEADER, dBspHeader_t::ident, dMapTile_t::leafbrushes, dMapTile_t::leafs, dMapTile_t::lightdata, dMapTile_t::lightdatasize, LIGHTMAP_DAY, LIGHTMAP_NIGHT, LoadBSPFile(), LUMP_BRUSHES, LUMP_BRUSHSIDES, LUMP_EDGES, LUMP_ENTITIES, LUMP_FACES, LUMP_LEAFBRUSHES, LUMP_LEAFS, LUMP_LIGHTING_DAY, LUMP_LIGHTING_NIGHT, LUMP_MODELS, LUMP_NODES, LUMP_NORMALS, LUMP_PLANES, LUMP_ROUTING, LUMP_SURFEDGES, LUMP_TEXINFO, LUMP_VERTEXES, mapTiles, mapTiles_t::mapTiles, dMapTile_t::models, dMapTile_t::nodes, dMapTile_t::normals, dMapTile_t::numbrushes, dMapTile_t::numbrushsides, dMapTile_t::numedges, dMapTile_t::numfaces, dMapTile_t::numleafbrushes, dMapTile_t::numleafs, dMapTile_t::nummodels, dMapTile_t::numnodes, dMapTile_t::numnormals, dMapTile_t::numplanes, cBspBrush_t::numsides, dBspBrush_t::numsides, dMapTile_t::numsurfedges, dMapTile_t::numtexinfo, mapTiles_t::numTiles, dMapTile_t::numvertexes, OBJZERO, dMapTile_t::planes, dMapTile_t::routedata, dMapTile_t::routedatasize, dMapTile_t::surfedges, SwapBSPFile(), Sys_Error(), dMapTile_t::texinfo, dBspHeader_t::version, and dMapTile_t::vertexes.

Referenced by LoadBSPFile(), and main().

◆ ParseEntities()

void ParseEntities ( void )

Parses the curTile->entdata string into entities.

See also
UnparseEntities
ParseEntity

Definition at line 502 of file bspfile.cpp.

References curTile, dMapTile_t::entdata, dMapTile_t::entdatasize, num_entities, ParseEntities(), ParseEntity(), and ParseFromMemory().

Referenced by ParseEntities(), and PrintBSPFileSizes().

◆ ParseEntity()

◆ ParseEpair()

epair_t * ParseEpair ( int entNum)

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

See also
parsedToken
GetToken
ParseEntity
ParseMapEntity

Definition at line 453 of file bspfile.cpp.

References AddEpair(), GetToken(), Mem_StrDup, parsedToken, ParseEpair(), and StripTrailingWhitespaces().

Referenced by ParseEntity(), ParseEpair(), and ParseMapEntity().

◆ PrintBSPFileSizes()

◆ SetKeyValue()

void SetKeyValue ( entity_t * ent,
const char * key,
const char * value )

◆ StripTrailingWhitespaces()

void StripTrailingWhitespaces ( char * str)
static

Removes trailing whitespaces from the given string.

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

Definition at line 402 of file bspfile.cpp.

References StripTrailingWhitespaces().

Referenced by ParseEpair(), StripTrailingWhitespaces(), and UnparseEntities().

◆ SwapBSPFile()

void SwapBSPFile ( void )
static

Byte swaps all data in a bsp file.

Definition at line 87 of file bspfile.cpp.

References dBspLeaf_t::area, cBspBrush_t::brushContentFlags, dBspBrush_t::brushContentFlags, dMapTile_t::brushes, dMapTile_t::brushsides, dBspNode_t::children, dBspLeaf_t::contentFlags, curTile, dBspModel_t::dbmBox, dMapTile_t::dbrushes, dBspPlane_t::dist, dMapTile_t::edges, dMapTile_t::faces, cBspBrush_t::firstbrushside, dBspBrush_t::firstbrushside, dBspSurface_t::firstedge, dBspModel_t::firstface, dBspNode_t::firstface, dBspLeaf_t::firstleafbrush, dBspModel_t::headnode, i, dMapTile_t::leafbrushes, dMapTile_t::leafs, LIGHTMAP_MAX, dBspSurface_t::lightofs, LittleFloat, LittleLong, LittleShort, AABB::maxs, dBspLeaf_t::maxs, dBspNode_t::maxs, AABB::mins, dBspLeaf_t::mins, dBspNode_t::mins, dMapTile_t::models, dMapTile_t::nodes, dBspPlane_t::normal, dMapTile_t::numbrushes, dMapTile_t::numbrushsides, dBspSurface_t::numedges, dMapTile_t::numedges, dBspModel_t::numfaces, dBspNode_t::numfaces, dMapTile_t::numfaces, dBspLeaf_t::numleafbrushes, dMapTile_t::numleafbrushes, dMapTile_t::numleafs, dMapTile_t::nummodels, dMapTile_t::numnodes, dMapTile_t::numplanes, cBspBrush_t::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, dBspTexinfo_t::surfaceFlags, dMapTile_t::surfedges, SwapBSPFile(), dBspBrushSide_t::texinfo, dBspSurface_t::texinfo, dMapTile_t::texinfo, dBspPlane_t::type, dBspEdge_t::v, dBspTexinfo_t::value, dBspTexinfo_t::vecs, and dMapTile_t::vertexes.

Referenced by LoadBSPFile(), SwapBSPFile(), and WriteBSPFile().

◆ UnparseEntities()

const char * UnparseEntities ( void )

◆ ValueForKey()

◆ WriteBSPFile()

Variable Documentation

◆ entities

◆ num_entities