30 #include "../shared/parse.h"
41 static int CMod_ValidateLump (
const lump_t* lump,
const char* functionName,
size_t elementSize,
const char* elementName,
int elementMaxCount)
45 if (lump->
filelen % elementSize)
52 if (count > elementMaxCount)
78 for (
int i = 0;
i <
count;
i++, in++, out++) {
108 for (
int i = 0;
i <
count;
i++, in++, out++) {
135 for (
int i = 0;
i <
count;
i++, out++, in++) {
137 out->
plane =
nullptr;
142 for (
int j = 0; j < 3; j++) {
147 for (
int j = 0; j < 2; j++) {
149 out->children[j] = child;
172 for (
int i = 0;
i <
count;
i++, out++, in++) {
197 for (
int i = 0;
i <
count;
i++, in++, out++) {
236 for (
int i = 0;
i <
count;
i++, in++, out++) {
241 for (
int j = 0; j < 3; j++) {
258 const unsigned short* in = (
const unsigned short*) (base + lump->
fileofs);
266 for (
int i = 0;
i <
count;
i++, in++, out++)
288 for (
int i = 0;
i <
count;
i++, in++, out++) {
306 byte* data_p = dataStart;
307 const byte* src = *source;
316 for (
int i = 0;
i < c + 2;
i++)
322 for (
int i = 0;
i < c;
i++)
330 return data_p - dataStart;
386 double start = time(
nullptr);
404 if (length != targetLength)
405 Com_Error(
ERR_DROP,
"CMod_LoadRouting: Map has BAD routing lump; expected %i got %i", targetLength, length);
408 for (
int i = 0;
i < 3;
i++) {
435 const int minX = std::max(tile.
wpMins[0], 0);
436 const int minY = std::max(tile.
wpMins[1], 0);
437 const int minZ = std::max(tile.
wpMins[2], 0);
442 assert(minX <= maxX);
443 assert(minY <= maxY);
444 assert(minZ <= maxZ);
446 Com_DPrintf(
DEBUG_ROUTING,
"Tile bounds: (%i, %i, %i) to (%i, %i, %i)\n", minX, minY, minZ, maxX, maxY, maxZ);
448 maxX - sX, maxY - sY, maxZ - sZ);
452 for (
int y = minY -
size; y <= maxY; y++)
453 for (
int x = minX -
size; x <= maxX; x++) {
457 for (
int z = minZ; z <= maxZ; z++) {
470 double end = time(
nullptr);
491 Com_Error(
ERR_DROP,
"CMod_LoadEntityString: No lump given (entitystring: '%s')", entityString ? entityString :
"none");
494 Com_Error(
ERR_DROP,
"CMod_LoadEntityString: Map has NO entity lump (offset: %u, length: %u, entitystring: '%s')", l->
fileofs, l->
filelen, entityString ? entityString :
"none");
497 Com_Error(
ERR_DROP,
"CMod_LoadEntityString: Map has too large entity lump (offset: %u, length: %u, entitystring: '%s')", l->
fileofs, l->
filelen, entityString ? entityString :
"none");
500 const char* es = (
const char*) (base + l->
fileofs);
531 Com_Error(
ERR_DROP,
"CMod_LoadEntityString: closing brace without data for keyname %s", keyname);
534 if (
Q_streq(keyname,
"origin")) {
537 if (sscanf(token,
"%f %f %f", &(v[0]), &(v[1]), &(v[2])) != 3)
538 Com_Error(
ERR_DROP,
"CMod_LoadEntityString: invalid origin token '%s' for keyname %s", token, keyname);
547 }
else if (
Q_streq(keyname,
"model") && token[0] ==
'*') {
549 int num = atoi(token + 1);
555 }
else if (
Q_streq(keyname,
"targetname") ||
Q_streq(keyname,
"target")) {
558 if (
Q_streq(keyname,
"classname") &&
Q_streq(token,
"worldspawn")) {
614 for (
int i = 0;
i < 6;
i++) {
615 const int side =
i & 1;
685 Com_sprintf(filename,
sizeof(filename),
"maps/%s.bsp", name);
699 const byte* base = (
const byte*) buf;
702 if (mapTiles->
numTiles >= MAX_MAPTILES)
750 const double start = time(
nullptr);
789 const int newZ =
RT_CheckCell(mapTiles, mapData->
routing, actorSize + 1, x, y, z,
nullptr);
802 const byte tile = mapData->
reroute[actorSize][y][x];
807 mapTiles->
getTilesAt(x ,y, fromTile1, fromTile2, fromTile3);
809 const int dx = x +
dvecs[dir][0];
810 const int dy = y + dvecs[dir][1];
814 const int tile2 = mapData->
reroute[actorSize][dy][dx];
817 #if 0 // this causes problems eg. at baseattack entrance (see bug 5292). Disabled until the underlying problem is found
821 mapTiles->
getTilesAt(dx ,dy, toTile1, toTile2, toTile3);
825 if (fromTile1 == toTile1) {
826 if (fromTile2 && toTile2) {
827 if (fromTile2 == toTile2) {
842 const double end = time(
nullptr);
843 Com_Printf(
"Rerouted %i cols for RMA in %5.1fs\n", cols, end - start);
884 if (token[0] ==
'-') {
892 Com_sprintf(name,
sizeof(name),
"%s%s", base, token + 1);
899 for (
int i = 0;
i < 3;
i++) {
911 CM_AddMapTile(name, entityString, day, sh[0], sh[1], sh[2], mapData, mapTiles);
914 CM_AddMapTile(name, entityString, day, 0, 0, 0, mapData, mapTiles);
932 if (!name || name[0] !=
'*')
935 int num = atoi(name + 1) - 1;
1004 Com_Printf(
"given point %i:%i:%i is not inside of any loaded tile\n", position[0], position[1], position[2]);
#define LUMP_LIGHTING_DAY
void CalculateMinsMaxs(const vec3_t angles, const AABB &relBox, const vec3_t origin, AABB &absBox)
Calculates the bounding box in absolute coordinates, also for rotating objects. WARNING: do not use t...
void getTileOverlap(const byte tile1, const byte tile2, int &minZ, int &maxZ)
static void CMod_LoadLeafs(MapTile &tile, const byte *base, const lump_t *lump)
static ipos3_t shift
The shift array is used for random map assemblies (RMA) to shift the mins/maxs and stuff like that...
#define VectorCopy(src, dest)
static void CMod_LoadNodes(MapTile &tile, const byte *base, const lump_t *lump, const vec3_t shift)
#define CONTENTS_WEAPONCLIP
#define VectorSet(v, x, y, z)
static cBspSurface_t nullSurface
static void CMod_LoadPlanes(MapTile &tile, const byte *base, const lump_t *lump, const vec3_t shift)
static int CMod_DeCompressRouting(const byte **source, byte *dataStart)
void CM_LoadBsp(MapTile &tile, const dBspHeader_t &header, const vec3_t shift, const byte *base)
bool Com_sprintf(char *dest, size_t size, const char *fmt,...)
copies formatted string with buffer-size checking
static void CM_InitBoxHull(MapTile &tile)
Set up the planes and nodes so that the six floats of a bounding box can just be stored out and get a...
const vec4_t dvecs[PATHFINDING_DIRECTIONS]
unsigned Com_BlockChecksum(const void *buffer, int length)
static void CMod_LoadLeafBrushes(MapTile &tile, const byte *base, const lump_t *lump)
Data for line tracing (?)
static void CMod_LoadLighting(MapTile &tile, const byte *base, const lump_t *lump)
Loads the lightmap for server side visibility lookup.
int FS_LoadFile(const char *path, byte **buffer)
Filenames are relative to the quake search path.
void Com_Printf(const char *const fmt,...)
static void CMod_LoadEntityString(MapTile &tile, const char *entityString, mapData_t *mapData, const byte *base, const lump_t *l, const vec3_t shift)
convex region of space in the BSP tree
unsigned short firstleafbrush
intptr_t thead[LEVEL_MAX]
#define Q_strvalid(string)
Directory of the different data blocks.
void Com_Error(int code, const char *fmt,...)
Stores the data of a map tile, mostly the BSP stuff.
void expand(const float byVal)
expand the box in all directions, but clip them to the maximum boundaries
byte reroute[ACTOR_MAX_SIZE][PATHFINDING_WIDTH][PATHFINDING_WIDTH]
Used to track where rerouting needs to occur.
void Q_strncpyz(char *dest, const char *src, size_t destsize)
Safe strncpy that ensures a trailing zero.
#define MAX_MAP_BRUSHSIDES
#define PATHFINDING_WIDTH
absolute max
#define LUMP_LIGHTING_NIGHT
void TR_BuildTracingNode_r(TR_TILE_TYPE *tile, tnode_t **tnode, int32_t nodenum, int level)
QGL_EXTERN GLuint GLsizei GLsizei * length
#define MAX_MAP_ENTSTRING
float CM_GetVisibility(const mapTiles_t *mapTiles, const pos3_t position)
Checks how well a position is visible.
#define NUM_REGULAR_MODELS
void CM_GetInlineModelAABB(mapTiles_t *mapTiles, const char *name, AABB &aabb)
This function calculates a model's aabb in world coordinates.
void Com_DPrintf(int level, const char *fmt,...)
A Com_Printf that only shows up if the "developer" cvar is set.
static void CM_AddMapTile(const char *name, const char *entityString, const bool day, const int sX, const int sY, const byte sZ, mapData_t *mapData, mapTiles_t *mapTiles)
Adds in a single map tile.
void getTilesAt(int x, int y, byte &fromTile1, byte &fromTile2, byte &fromTile3)
Header for various formats like pak, and model formats as well as bsp format.
void clipToMaxBoundaries()
static void CMod_LoadSurfaces(MapTile &tile, const byte *base, const lump_t *lump)
grid pathfinding and routing
#define Mem_FreePool(pool)
uint32_t brushContentFlags
cBspModel_t * CM_InlineModel(const mapTiles_t *mapTiles, const char *name)
Searches all inline models and return the cBspModel_t pointer for the given modelnumber or -name...
void setFromLittleFloat(const AABB &other)
void RT_UpdateConnectionColumn(mapTiles_t *mapTiles, Routing &routing, const int actorSize, const int x, const int y, const int dir, const char **list, const int minZ, const int maxZ)
Routing Function to update the connection between two fields.
static void CMod_RerouteMap(mapTiles_t *mapTiles, mapData_t *mapData)
Recalculate the seams of the tiles after an RMA.
#define Mem_PoolAllocTypeN(type, n, pool)
#define PATHFINDING_HEIGHT
15 max, adjusting above 8 will require a rewrite to the DV code
#define VectorAdd(a, b, dest)
const char * Com_Parse(const char *data_p[], char *target, size_t size, bool replaceWhitespaces)
Parse a token out of a string.
memPool_t * com_cmodelSysPool
TR_TILE_TYPE mapTiles[MAX_MAPTILES]
static void CMod_LoadBrushSides(MapTile &tile, const byte *base, const lump_t *lump)
void setConn(const int actorSize, const int x, const int y, const int z, const int dir, const int val)
void RT_GetMapSize(mapTiles_t *mapTiles, AABB &mapBox)
Calculate the map size via model data and store grid size in map_min and map_max. This is done with e...
QGL_EXTERN GLuint GLsizei GLsizei GLint GLenum GLchar * name
cBspBrushSide_t * brushsides
static void CM_MakeTracingNodes(MapTile &tile)
Use the bsp node structure to reconstruct efficient tracing structures that are used for fast visibil...
char mapEntityString[MAX_MAP_ENTSTRING]
cBspModel_t * CM_SetInlineModelOrientation(mapTiles_t *mapTiles, const char *name, const vec3_t origin, const vec3_t angles)
This function updates a model's orientation.
void Q_strcat(char *dest, size_t destsize, const char *format,...)
Safely (without overflowing the destination buffer) concatenates two strings.
int RT_CheckCell(mapTiles_t *mapTiles, Routing &routing, const int actorSize, const int x, const int y, const int z, const char **list)
This function looks to see if an actor of a given size can occupy a cell(s) and if so identifies the ...
unsigned short * leafbrushes
definitions common between client and server, but not game lib
void shift(const vec3_t shiftVec)
shove the whole box by the given vector
static int CMod_ValidateLump(const lump_t *lump, const char *functionName, size_t elementSize, const char *elementName, int elementMaxCount)
uint32_t brushContentFlags
#define MAX_MAP_LEAFBRUSHES
static void CMod_LoadRouting(MapTile &tile, mapData_t *mapData, const byte *base, const char *name, const lump_t *lump, const int sX, const int sY, const int sZ)
static void CMod_LoadBrushes(MapTile &tile, const byte *base, const lump_t *lump)
int theadlevel[LEVEL_MAX]
void copyPosData(const Routing &other, actorSizeEnum_t actorSize, const int x, const int y, const int z, const int sX, const int sY, const int sZ)
#define BSP_SwapHeader(header, name)
#define ROUTING_NOT_REACHABLE
QGL_EXTERN int GLboolean GLfloat * v
#define ACTOR_SIZE_INVALID
#define VectorSubtract(a, b, dest)
void CM_LoadMap(const char *tiles, bool day, const char *pos, const char *entityString, mapData_t *mapData, mapTiles_t *mapTiles)
Loads in the map and all submodels.
#define VectorInside(vec, mins, maxs)
unsigned short numleafbrushes
void FS_FreeFile(void *buffer)
static void CMod_LoadSubmodels(MapTile &tile, const byte *base, const lump_t *lump, const vec3_t shift)
Loads brush entities like func_door and func_breakable.