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

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 uint32_t CopyLump (const dBspHeader_t *header, int lumpIdx, void *dest, size_t size)
dMapTile_tLoadBSPFile (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.
static bool IsInvalidEntityToken (const char *token)
bool EpairCheckForDuplicate (const entity_t *ent, const epair_t *e)
epair_tAddEpair (const char *key, const char *value, int entNum)
epair_tParseEpair (int entNum)
 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

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 data, qFILE::f, lump_t::filelen, lump_t::fileofs, FS_Write(), len, LittleLong, dBspHeader_t::lumps, qFILE::name, and Sys_Error().

Referenced by 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 data.

Referenced by 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 dest, lump_t::filelen, lump_t::fileofs, length, dBspHeader_t::lumps, and Sys_Error().

Referenced by LoadBSPFile().

◆ EpairCheckForDuplicate()

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

Definition at line 418 of file bspfile.cpp.

References entity_t::epairs, epair_t::key, epair_t::next, and Q_streq.

Referenced by ParseMapEntity().

◆ FloatForKey()

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

Definition at line 566 of file bspfile.cpp.

References key, and ValueForKey().

Referenced by BuildLights().

◆ 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 GetVectorFromString(), key, and ValueForKey().

Referenced by BuildLights(), BuildPatches(), 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 Sys_Error(), VectorClear, and VectorSet.

Referenced by BuildLights(), and GetVectorForKey().

◆ IsInvalidEntityToken()

bool IsInvalidEntityToken ( const char * token)
inlinestatic

Definition at line 413 of file bspfile.cpp.

References Q_streq.

Referenced by AddEpair(), and UnparseEntities().

◆ LoadBSPFile()

◆ 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, num_entities, ParseEntity(), and ParseFromMemory().

Referenced by PrintBSPFileSizes().

◆ ParseEntity()

entity_t * ParseEntity ( void )
static

◆ 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(), key, Mem_StrDup, parsedToken, and StripTrailingWhitespaces().

Referenced by ParseEntity(), and ParseMapEntity().

◆ PrintBSPFileSizes()

void PrintBSPFileSizes ( void )

Dumps info about current file.

Definition at line 364 of file bspfile.cpp.

References Com_Printf(), curTile, num_entities, and ParseEntities().

Referenced by main().

◆ SetKeyValue()

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

Definition at line 546 of file bspfile.cpp.

References AddEpair(), entity_t::epairs, key, Mem_StrDup, epair_t::next, and Q_streq.

Referenced by CheckEntities(), ParseBrush(), and SetModelNumbers().

◆ 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.

Referenced by ParseEpair(), and UnparseEntities().

◆ SwapBSPFile()

◆ UnparseEntities()

const char * UnparseEntities ( void )

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

See also
ParseEntities

Definition at line 515 of file bspfile.cpp.

References curTile, entities, i, IsInvalidEntityToken(), epair_t::key, key, epair_t::next, num_entities, Q_strcat(), Q_strncpyz(), StripTrailingWhitespaces(), Sys_Error(), and epair_t::value.

Referenced by EndBSPFile(), and main().

◆ ValueForKey()

◆ WriteBSPFile()

Variable Documentation

◆ entities

◆ num_entities