41static 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++) {
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);
398 const byte* source = base + lump->
fileofs;
404 if (
length != targetLength)
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++) {
458 mapData->routing.copyPosData(*tempMap,
size + 1, x, y, z, sX, sY, sZ);
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;
699 const byte* base = (
const byte*)
buf;
702 if (
mapTiles->numTiles >= MAX_MAPTILES)
739 mapData->mapChecksum += checksum;
750 const double start = time(
nullptr);
761 mapData->routing.setConn(actorSize, x, y, z, 6, 0);
762 mapData->routing.setConn(actorSize, x, y, z, 1, 0);
763 mapData->routing.setConn(actorSize, x, y, z, 5, 0);
765 mapData->routing.setConn(actorSize, x, y, z, 4, 0);
766 mapData->routing.setConn(actorSize, x, y, z, 0, 0);
767 mapData->routing.setConn(actorSize, x, y, z, 7, 0);
771 mapData->routing.setConn(actorSize, x, y, z, 5, 0);
772 mapData->routing.setConn(actorSize, x, y, z, 3, 0);
773 mapData->routing.setConn(actorSize, x, y, z, 7, 0);
775 mapData->routing.setConn(actorSize, x, y, z, 6, 0);
776 mapData->routing.setConn(actorSize, x, y, z, 2, 0);
777 mapData->routing.setConn(actorSize, x, y, z, 4, 0);
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];
821 mapTiles->getTilesAt(dx ,dy, toTile1, toTile2, toTile3);
825 if (fromTile1 == toTile1) {
826 if (fromTile2 && toTile2) {
827 if (fromTile2 == toTile2) {
828 mapTiles->getTileOverlap(toTile1, toTile2, minZ, maxZ);
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] ==
'-') {
899 for (
int i = 0;
i < 3;
i++) {
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]);
void setFromLittleFloat(const AABB &other)
void shift(const vec3_t shiftVec)
shove the whole box by the given vector
void expand(const float byVal)
expand the box in all directions, but clip them to the maximum boundaries
void clipToMaxBoundaries()
Stores the data of a map tile, mostly the BSP stuff.
int theadlevel[LEVEL_MAX]
intptr_t thead[LEVEL_MAX]
unsigned short * leafbrushes
cBspBrushSide_t * brushsides
static void CMod_LoadBrushSides(MapTile &tile, const byte *base, const lump_t *lump)
void CM_GetInlineModelAABB(mapTiles_t *mapTiles, const char *name, AABB &aabb)
This function calculates a model's aabb in world coordinates.
static void CMod_LoadLeafBrushes(MapTile &tile, const byte *base, const lump_t *lump)
static void CMod_LoadPlanes(MapTile &tile, const byte *base, const lump_t *lump, const vec3_t shift)
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.
static void CMod_LoadSurfaces(MapTile &tile, const byte *base, const lump_t *lump)
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.
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_LoadLighting(MapTile &tile, const byte *base, const lump_t *lump)
Loads the lightmap for server side visibility lookup.
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.
static void CM_MakeTracingNodes(MapTile &tile)
Use the bsp node structure to reconstruct efficient tracing structures that are used for fast visibil...
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.
static void CMod_LoadEntityString(MapTile &tile, const char *entityString, mapData_t *mapData, const byte *base, const lump_t *l, const vec3_t shift)
static int CMod_DeCompressRouting(const byte **source, byte *dataStart)
float CM_GetVisibility(const mapTiles_t *mapTiles, const pos3_t position)
Checks how well a position is visible.
static void CMod_LoadBrushes(MapTile &tile, const byte *base, const lump_t *lump)
void CM_LoadBsp(MapTile &tile, const dBspHeader_t &header, const vec3_t shift, const byte *base)
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.
static void CMod_RerouteMap(mapTiles_t *mapTiles, mapData_t *mapData)
Recalculate the seams of the tiles after an RMA.
static void CMod_LoadLeafs(MapTile &tile, const byte *base, const lump_t *lump)
static void CMod_LoadNodes(MapTile &tile, const byte *base, const lump_t *lump, const vec3_t shift)
static int CMod_ValidateLump(const lump_t *lump, const char *functionName, size_t elementSize, const char *elementName, int elementMaxCount)
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...
static cBspSurface_t nullSurface
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...
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 ...
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.
void Com_DPrintf(int level, const char *fmt,...)
A Com_Printf that only shows up if the "developer" cvar is set.
void Com_Error(int code, const char *fmt,...)
void Com_Printf(const char *const fmt,...)
memPool_t * com_cmodelSysPool
definitions common between client and server, but not game lib
#define CONTENTS_WEAPONCLIP
#define ROUTING_NOT_REACHABLE
#define LUMP_LIGHTING_NIGHT
#define MAX_MAP_BRUSHSIDES
#define PATHFINDING_WIDTH
absolute max
#define MAX_MAP_ENTSTRING
#define NUM_REGULAR_MODELS
#define LUMP_LIGHTING_DAY
#define MAX_MAP_LEAFBRUSHES
#define PATHFINDING_HEIGHT
15 max, adjusting above 8 will require a rewrite to the DV code
#define ACTOR_SIZE_INVALID
int FS_LoadFile(const char *path, byte **buffer)
Filenames are relative to the quake search path.
void FS_FreeFile(void *buffer)
const vec4_t dvecs[PATHFINDING_DIRECTIONS]
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...
unsigned Com_BlockChecksum(const void *buffer, int length)
#define Mem_FreePool(pool)
#define Mem_PoolAllocTypeN(type, n, pool)
const char * Com_Parse(const char *data_p[], char *target, size_t size, bool replaceWhitespaces)
Parse a token out of a string.
Shared parsing functions.
Header for various formats like pak, and model formats as well as bsp format.
#define BSP_SwapHeader(header, name)
QGL_EXTERN int GLboolean GLfloat * v
QGL_EXTERN GLuint GLsizei GLsizei * length
QGL_EXTERN GLuint GLsizei GLsizei GLint GLenum GLchar * name
static ipos3_t shift
The shift array is used for random map assemblies (RMA) to shift the mins/maxs and stuff like that.
grid pathfinding and routing
#define Q_strvalid(string)
void Q_strncpyz(char *dest, const char *src, size_t destsize)
Safe strncpy that ensures a trailing zero.
void Q_strcat(char *dest, size_t destsize, const char *format,...)
Safely (without overflowing the destination buffer) concatenates two strings.
bool Com_sprintf(char *dest, size_t size, const char *fmt,...)
copies formatted string with buffer-size checking
uint32_t brushContentFlags
unsigned short firstleafbrush
unsigned short numleafbrushes
uint32_t brushContentFlags
convex region of space in the BSP tree
Directory of the different data blocks.
Data for line tracing (?).
static mapTiles_t mapTiles
void TR_BuildTracingNode_r(TR_TILE_TYPE *tile, tnode_t **tnode, int32_t nodenum, int level)
#define VectorSubtract(a, b, dest)
#define VectorInside(vec, mins, maxs)
#define VectorCopy(src, dest)
#define VectorAdd(a, b, dest)
#define VectorSet(v, x, y, z)