252 lines
5.1 KiB
C
252 lines
5.1 KiB
C
|
|
|
|
// upper design bounds
|
|
|
|
#define max_map_hulls 4
|
|
|
|
#define max_map_models 256
|
|
#define max_map_brushes 4096
|
|
#define max_map_entities 1024
|
|
//#define max_map_entstring 65536
|
|
#define max_map_entstring 131072
|
|
|
|
#define max_map_planes 8192
|
|
#define max_map_nodes 32767 // because negative shorts are contents
|
|
#define max_map_clipnodes 32767 //
|
|
#define max_map_leafs 32767 //
|
|
#define max_map_verts 65535
|
|
#define max_map_faces 65535
|
|
#define max_map_marksurfaces 65535
|
|
#define max_map_texinfo 4096
|
|
#define max_map_edges 256000
|
|
#define max_map_surfedges 512000
|
|
#define max_map_miptex 0x200000
|
|
#define max_map_lighting 0x100000
|
|
#define max_map_visibility 0x100000
|
|
|
|
// key / value pair sizes
|
|
|
|
#define max_key 32
|
|
#define max_value 1024
|
|
|
|
//=============================================================================
|
|
|
|
|
|
#define bspversion 29
|
|
|
|
typedef struct
|
|
{
|
|
int fileofs, filelen;
|
|
} lump_t;
|
|
|
|
#define lump_entities 0
|
|
#define lump_planes 1
|
|
#define lump_textures 2
|
|
#define lump_vertexes 3
|
|
#define lump_visibility 4
|
|
#define lump_nodes 5
|
|
#define lump_texinfo 6
|
|
#define lump_faces 7
|
|
#define lump_lighting 8
|
|
#define lump_clipnodes 9
|
|
#define lump_leafs 10
|
|
#define lump_marksurfaces 11
|
|
#define lump_edges 12
|
|
#define lump_surfedges 13
|
|
#define lump_models 14
|
|
|
|
#define header_lumps 15
|
|
|
|
typedef struct
|
|
{
|
|
float mins[3], maxs[3];
|
|
float origin[3];
|
|
int headnode[max_map_hulls];
|
|
int visleafs; // not including the solid leaf 0
|
|
int firstface, numfaces;
|
|
} dmodel_t;
|
|
|
|
typedef struct
|
|
{
|
|
int version;
|
|
lump_t lumps[header_lumps];
|
|
} dheader_t;
|
|
|
|
typedef struct
|
|
{
|
|
int nummiptex;
|
|
int dataofs[4]; // [nummiptex]
|
|
} dmiptexlump_t;
|
|
|
|
#define miplevels 4
|
|
typedef struct miptex_s
|
|
{
|
|
char name[16];
|
|
unsigned width, height;
|
|
unsigned offsets[miplevels]; // four mip maps stored
|
|
} miptex_t;
|
|
|
|
|
|
typedef struct
|
|
{
|
|
float point[3];
|
|
} dvertex_t;
|
|
|
|
|
|
// 0-2 are axial planes
|
|
#define plane_x 0
|
|
#define plane_y 1
|
|
#define plane_z 2
|
|
|
|
// 3-5 are non-axial planes snapped to the nearest
|
|
#define plane_anyx 3
|
|
#define plane_anyy 4
|
|
#define plane_anyz 5
|
|
|
|
typedef struct
|
|
{
|
|
float normal[3];
|
|
float dist;
|
|
int type; // plane_x - plane_anyz ?remove? trivial to regenerate
|
|
} dplane_t;
|
|
|
|
|
|
|
|
#define contents_empty -1
|
|
#define contents_solid -2
|
|
#define contents_water -3
|
|
#define contents_slime -4
|
|
#define contents_lava -5
|
|
#define contents_sky -6
|
|
|
|
// !!! if this is changed, it must be changed in asm_i386.h too !!!
|
|
typedef struct
|
|
{
|
|
int planenum;
|
|
short children[2]; // negative numbers are -(leafs+1), not nodes
|
|
short mins[3]; // for sphere culling
|
|
short maxs[3];
|
|
unsigned short firstface;
|
|
unsigned short numfaces; // counting both sides
|
|
} dnode_t;
|
|
|
|
typedef struct
|
|
{
|
|
int planenum;
|
|
short children[2]; // negative numbers are contents
|
|
} dclipnode_t;
|
|
|
|
|
|
typedef struct texinfo_s
|
|
{
|
|
float vecs[2][4]; // [s/t][xyz offset]
|
|
int miptex;
|
|
int flags;
|
|
} texinfo_t;
|
|
#define tex_special 1 // sky or slime, no lightmap or 256 subdivision
|
|
|
|
// note that edge 0 is never used, because negative edge nums are used for
|
|
// counterclockwise use of the edge in a face
|
|
typedef struct
|
|
{
|
|
unsigned short v[2]; // vertex numbers
|
|
} dedge_t;
|
|
|
|
#define maxlightmaps 4
|
|
typedef struct
|
|
{
|
|
short planenum;
|
|
short side;
|
|
|
|
int firstedge; // we must support > 64k edges
|
|
short numedges;
|
|
short texinfo;
|
|
|
|
// lighting info
|
|
byte styles[maxlightmaps];
|
|
int lightofs; // start of [numstyles*surfsize] samples
|
|
} dface_t;
|
|
|
|
|
|
|
|
#define ambient_water 0
|
|
#define ambient_sky 1
|
|
#define ambient_slime 2
|
|
#define ambient_lava 3
|
|
|
|
#define num_ambients 4 // automatic ambient sounds
|
|
|
|
// leaf 0 is the generic contents_solid leaf, used for all solid areas
|
|
// all other leafs need visibility info
|
|
typedef struct
|
|
{
|
|
int contents;
|
|
int visofs; // -1 = no visibility info
|
|
|
|
short mins[3]; // for frustum culling
|
|
short maxs[3];
|
|
|
|
unsigned short firstmarksurface;
|
|
unsigned short nummarksurfaces;
|
|
|
|
byte ambient_level[num_ambients];
|
|
} dleaf_t;
|
|
|
|
//============================================================================
|
|
|
|
#ifndef quake_game
|
|
|
|
// the utilities get to be lazy and just use large static arrays
|
|
|
|
extern int nummodels;
|
|
extern dmodel_t dmodels[max_map_models];
|
|
|
|
extern int visdatasize;
|
|
extern byte dvisdata[max_map_visibility];
|
|
|
|
extern int lightdatasize;
|
|
extern byte dlightdata[max_map_lighting];
|
|
|
|
extern int texdatasize;
|
|
extern byte dtexdata[max_map_miptex]; // (dmiptexlump_t)
|
|
|
|
extern int entdatasize;
|
|
extern char dentdata[max_map_entstring];
|
|
|
|
extern int numleafs;
|
|
extern dleaf_t dleafs[max_map_leafs];
|
|
|
|
extern int numplanes;
|
|
extern dplane_t dplanes[max_map_planes];
|
|
|
|
extern int numvertexes;
|
|
extern dvertex_t dvertexes[max_map_verts];
|
|
|
|
extern int numnodes;
|
|
extern dnode_t dnodes[max_map_nodes];
|
|
|
|
extern int numtexinfo;
|
|
extern texinfo_t texinfo[max_map_texinfo];
|
|
|
|
extern int numfaces;
|
|
extern dface_t dfaces[max_map_faces];
|
|
|
|
extern int numclipnodes;
|
|
extern dclipnode_t dclipnodes[max_map_clipnodes];
|
|
|
|
extern int numedges;
|
|
extern dedge_t dedges[max_map_edges];
|
|
|
|
extern int nummarksurfaces;
|
|
extern unsigned short dmarksurfaces[max_map_marksurfaces];
|
|
|
|
extern int numsurfedges;
|
|
extern int dsurfedges[max_map_surfedges];
|
|
|
|
|
|
|
|
void loadbspfile (char *filename);
|
|
void writebspfile (char *filename);
|
|
void printbspfilesizes (void);
|
|
|
|
#endif
|