#include "shared.h"
#include "bspfile.h"
#include "scriplib.h"
#include "../bsp.h"
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 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_t * | ParseEpair (void) |
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 | |
static dBspHeader_t * | header |
int | num_entities |
entity_t | entities [MAX_MAP_ENTITIES] |
Definition in file bspfile.c.
static void AddLump | ( | qFILE * | bspfile, | |
dBspHeader_t * | header, | |||
int | lumpnum, | |||
void * | data, | |||
int | len | |||
) | [inline, static] |
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().
Compress the routing data of a map.
Definition at line 36 of file bspfile.c.
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().
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 | ) |
Definition at line 221 of file bspfile.c.
References dMapTile_t::brushes, dMapTile_t::brushsides, BSPVERSION, byte, dBspBrush_t::contentFlags, cBspBrush_s::contentFlags, CopyLump(), curTile, dMapTile_t::dbrushes, dMapTile_t::edges, dMapTile_t::entdata, dMapTile_t::entdatasize, dMapTile_t::faces, dBspBrush_t::firstbrushside, cBspBrush_s::firstbrushside, FS_FreeFile(), FS_LoadFile(), i, IDBSPHEADER, dMapTile_t::leafbrushes, dMapTile_t::leafs, dMapTile_t::lightdata, dMapTile_t::lightdatasize, LIGHTMAP_DAY, LIGHTMAP_NIGHT, LittleLong(), 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_t::mapTiles, mapTiles, MAX_MAP_BRUSHES, 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, dBspBrush_t::numsides, cBspBrush_s::numsides, dMapTile_t::numsurfedges, dMapTile_t::numtexinfo, mapTiles_t::numTiles, dMapTile_t::numvertexes, dMapTile_t::planes, dMapTile_t::routedata, dMapTile_t::routedatasize, dMapTile_t::surfedges, SwapBSPFile(), Sys_Error(), dMapTile_t::texinfo, and dMapTile_t::vertexes.
Referenced by main().
void ParseEntities | ( | void | ) |
Parses the curTile->entdata string into entities.
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] |
Definition at line 430 of file bspfile.c.
References entity_t::epairs, GetToken(), MAX_MAP_ENTITIES, epair_s::next, num_entities, parsedToken, ParseEpair(), qtrue, and Sys_Error().
Referenced by ParseEntities().
epair_t* ParseEpair | ( | void | ) |
Parses one key and value for an entity from the current tokens.
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 | ) |
Dumps info about current file.
Definition at line 349 of file bspfile.c.
References Com_Printf(), curTile, dMapTile_t::entdatasize, dMapTile_t::leafbrushes, dMapTile_t::lightdatasize, num_entities, 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, dMapTile_t::numsurfedges, dMapTile_t::numtexinfo, dMapTile_t::numvertexes, ParseEntities(), dMapTile_t::routedatasize, and dMapTile_t::surfedges.
Referenced by main().
void SetKeyValue | ( | entity_t * | ent, | |
const char * | key, | |||
const char * | value | |||
) |
Definition at line 518 of file bspfile.c.
References entity_t::epairs, epair_s::key, Mem_Alloc, Mem_Free, Mem_StrDup, epair_s::next, and epair_s::value.
Referenced by CheckEntities(), ParseBrush(), and SetModelNumbers().
static void StripTrailingWhitespaces | ( | char * | str | ) | [static] |
Removes trailing whitespaces from the given string.
[in,out] | str | The string to clean up |
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.
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 | |||
) |
Definition at line 535 of file bspfile.c.
References entity_t::epairs, epair_s::key, epair_s::next, and epair_s::value.
Referenced by BuildLights(), Check_ExtraBrushesForWorldspawn(), Check_IsOptimisable(), Check_Stats(), Check_TargetExists(), CheckEntities(), EntityForModel(), FaceFromPortal(), FindTargetEntity(), FloatForKey(), GetVectorForKey(), LoadMapFile(), ParseEntities(), ParseMapEntity(), and ProcessSubModel().
long WriteBSPFile | ( | const char * | filename | ) |
Swaps the bsp file in place, so it should not be referenced again.
Definition at line 299 of file bspfile.c.
References AddLump(), dMapTile_t::brushsides, BSPVERSION, curTile, dMapTile_t::dbrushes, dMapTile_t::edges, dMapTile_t::entdata, dMapTile_t::entdatasize, qFILE_s::f, dMapTile_t::faces, FILE_WRITE, FS_CloseFile(), FS_OpenFile(), FS_Write(), IDBSPHEADER, dBspHeader_t::ident, dMapTile_t::leafbrushes, dMapTile_t::leafs, dMapTile_t::lightdata, dMapTile_t::lightdatasize, LittleLong(), 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, 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, dMapTile_t::numsurfedges, dMapTile_t::numtexinfo, dMapTile_t::numvertexes, dMapTile_t::planes, dMapTile_t::routedata, dMapTile_t::routedatasize, SEEK_SET, dMapTile_t::surfedges, SwapBSPFile(), Sys_Error(), dMapTile_t::texinfo, dBspHeader_t::version, and dMapTile_t::vertexes.
Referenced by EndBSPFile(), and main().
Definition at line 380 of file bspfile.c.
Referenced by _mxml_entity_cb(), BeginModel(), BuildLights(), Check_ExtraBrushesForWorldspawn(), Check_IsOptimisable(), Check_Stats(), Check_TargetExists(), CheckEntities(), EntityForModel(), FaceFromPortal(), FindTargetEntity(), LoadMapFile(), MoveBrushesToWorld(), ParseBrush(), ParseMapEntity(), ProcessModels(), ProcessSubModel(), ProcessWorldModel(), SetModelNumbers(), and WriteMapFile().
dBspHeader_t* header [static] |
Definition at line 201 of file bspfile.c.
Referenced by CheckBSPFile(), CIN_ROQ_PlayCinematic(), CM_AddMapTile(), MP_LoadTeamMultiplayer(), MP_MultiplayerTeamSlotComments_f(), MP_SaveTeamMultiplayer(), R_ModAddMapTile(), R_WriteCompressedTGA(), SAV_GameLoad(), SAV_GameReadGameComment(), SAV_GameSave(), and SAV_GameSaveNameCleanup_f().
int num_entities |
Definition at line 379 of file bspfile.c.
Referenced by BuildLights(), Check_ExtraBrushesForWorldspawn(), Check_Stats(), Check_TargetExists(), CheckEntities(), EntityForModel(), FindTargetEntity(), LoadMapFile(), main(), MoveBrushesToWorld(), ParseBrush(), ParseEntities(), ParseEntity(), ParseMapEntity(), PrintBSPFileSizes(), ProcessModels(), SetModelNumbers(), UnparseEntities(), and WriteMapFile().