49 if (data + 1 < dend && *data == *(data + 1)) {
55 while (data + 1 < dend && val == *(data)) {
62 *dest_p++ = (
byte)(c) | 0x80;
68 while ((data + 1 < dend && *data != *(data + 1)) || data == dend - 1) {
99 for (j = 0; j < 3; j++) {
109 for (j = 0; j < 3; j++)
116 for (j = 0; j < 3; j++)
125 for (j = 0; j < 2; j++)
126 for (
int k = 0; k < 4; k++)
149 for (j = 0; j < 3; j++) {
164 for (j = 0; j < 3; j++) {
216 const uint32_t ofs = lump->
fileofs;
223 memcpy(dest, (
const byte*)header + ofs, length);
225 return length /
size;
243 Sys_Error(
"'%s' doesn't exist", filename);
249 Sys_Error(
"%s is not a IBSP file", filename);
300 lump = &header->
lumps[lumpnum];
302 offset = ftell(bspfile->
f);
304 Sys_Error(
"Overflow in AddLump for lump %i (%s) %s", lumpnum, bspfile->
name, strerror(errno));
309 FS_Write(data, (len + 3) &~ 3, bspfile);
332 FS_Write(&outheader,
sizeof(outheader), &bspfile);
351 size = ftell(bspfile.
getFile());
354 FS_Write(&outheader,
sizeof(outheader), &bspfile);
370 Com_Printf(
"================================\n");
406 s = str + strlen(str) - 1;
407 while (s >= str && *s <=
' ') {
433 Sys_Error(
"Invalid entity %i found with key '%s' and value '%s'", entNum, key, value);
435 if (strlen(key) >=
MAX_KEY - 1)
460 return AddEpair(key, value, entNum);
484 Sys_Error(
"ParseEntity: EOF without closing brace");
529 for (ep = entities[
i].epairs; ep; ep = ep->
next) {
536 Sys_Error(
"Invalid entity %i found with key '%s' and value '%s'",
i, key, value);
577 if (value[0] !=
'\0') {
582 if (sscanf(value,
"%lf %lf %lf", &v1, &v2, &v3) != 3)
583 Sys_Error(
"invalid vector statement given: '%s'", value);
bool Q_strnull(const char *string)
#define LUMP_LIGHTING_DAY
void PrintBSPFileSizes(void)
Dumps info about current file.
dBspEdge_t edges[MAX_MAP_EDGES]
void Sys_Error(const char *error,...)
#define VectorSet(v, x, y, z)
int FS_OpenFile(const char *filename, qFILE *file, filemode_t mode)
Finds and opens the file in the search path.
static uint32_t CopyLump(const dBspHeader_t *header, int lumpIdx, void *dest, size_t size)
byte routedata[MAX_MAP_ROUTING]
char entdata[MAX_MAP_ENTSTRING]
bool EpairCheckForDuplicate(const entity_t *ent, const epair_t *e)
dBspModel_t models[MAX_MAP_MODELS]
dBspNode_t nodes[MAX_MAP_NODES]
int FS_LoadFile(const char *path, byte **buffer)
Filenames are relative to the quake search path.
static void SwapBSPFile(void)
Byte swaps all data in a bsp file.
void Com_Printf(const char *const fmt,...)
entity_t entities[MAX_MAP_ENTITIES]
convex region of space in the BSP tree
Directory of the different data blocks.
epair_t * ParseEpair(int entNum)
Parses one key and value for an entity from the current tokens.
static void AddLump(qFILE *bspfile, dBspHeader_t *header, int lumpnum, void *data, int len)
dBspBrushSide_t brushsides[MAX_MAP_BRUSHSIDES]
cBspBrush_t brushes[MAX_MAP_BRUSHES]
dBspTexinfo_t texinfo[MAX_MAP_TEXINFO]
void Q_strncpyz(char *dest, const char *src, size_t destsize)
Safe strncpy that ensures a trailing zero.
void SetKeyValue(entity_t *ent, const char *key, const char *value)
void GetVectorForKey(const entity_t *ent, const char *key, vec3_t vec)
Converts the value of a entity parameter into a vec3_t.
#define LUMP_LIGHTING_NIGHT
dBspSurface_t faces[MAX_MAP_FACES]
static void StripTrailingWhitespaces(char *str)
Removes trailing whitespaces from the given string.
byte lightdata[LIGHTMAP_MAX][MAX_MAP_LIGHTING]
QGL_EXTERN GLuint GLsizei GLsizei * length
void ParseEntities(void)
Parses the curTile->entdata string into entities.
dMapTile_t * LoadBSPFile(const char *filename)
byte * CompressRouting(byte *dataStart, byte *destStart, int l)
Compress the routing data of a map.
dBspPlane_t planes[MAX_MAP_PLANES]
void GetVectorFromString(const char *value, vec3_t vec)
Converts a string into a vec3_t.
int lightdatasize[LIGHTMAP_MAX]
QGL_EXTERN GLenum GLuint * dest
char parsedToken[MAX_TOKEN_CHARS]
uint32_t brushContentFlags
dBspLeaf_t leafs[MAX_MAP_LEAFS]
static bool IsInvalidEntityToken(const char *token)
const char * UnparseEntities(void)
Generates the curTile->entdata string from all the entities.
unsigned short leafbrushes[MAX_MAP_LEAFBRUSHES]
TR_TILE_TYPE mapTiles[MAX_MAPTILES]
QGL_EXTERN GLuint GLchar GLuint * len
vec_t FloatForKey(const entity_t *ent, const char *key)
int surfedges[MAX_MAP_SURFEDGES]
void Q_strcat(char *dest, size_t destsize, const char *format,...)
Safely (without overflowing the destination buffer) concatenates two strings.
long WriteBSPFile(const char *filename)
Swaps the bsp file in place, so it should not be referenced again.
int lightofs[LIGHTMAP_MAX]
const char * GetToken()
Parses the next token from the current script on the stack and store the result in parsedToken...
#define Mem_AllocType(type)
static entity_t * ParseEntity(void)
uint32_t brushContentFlags
GLsizei const GLvoid * data
dBspVertex_t vertexes[MAX_MAP_VERTS]
const char * ValueForKey(const entity_t *ent, const char *key)
#define BSP_SwapHeader(header, name)
epair_t * AddEpair(const char *key, const char *value, int entNum)
void ParseFromMemory(char *buffer, int size)
Parses e.g. the entity string that is already stored in memory.
dBspBrush_t dbrushes[MAX_MAP_BRUSHES]
static mapTiles_t mapTiles
dBspNormal_t normals[MAX_MAP_VERTS]
void FS_FreeFile(void *buffer)
int FS_Write(const void *buffer, int len, qFILE *f)
Properly handles partial writes.