-/*\r
-Copyright (C) 1999-2007 id Software, Inc. and contributors.\r
-For a list of contributors, see the accompanying CONTRIBUTORS file.\r
-\r
-This file is part of GtkRadiant.\r
-\r
-GtkRadiant is free software; you can redistribute it and/or modify\r
-it under the terms of the GNU General Public License as published by\r
-the Free Software Foundation; either version 2 of the License, or\r
-(at your option) any later version.\r
-\r
-GtkRadiant is distributed in the hope that it will be useful,\r
-but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
-GNU General Public License for more details.\r
-\r
-You should have received a copy of the GNU General Public License\r
-along with GtkRadiant; if not, write to the Free Software\r
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA\r
-*/\r
-\r
-#ifndef _QFILES_H\r
-#define _QFILES_H\r
-\r
-#include "q_typedef.h"\r
-\r
-//\r
-// qfiles.h: quake file formats\r
-// This file must be identical in the quake and utils directories\r
-//\r
-\r
-/*\r
-========================================================================\r
-\r
-The .pak files are just a linear collapse of a directory tree\r
-\r
-========================================================================\r
-*/\r
-\r
-#define IDPAKHEADER (('K'<<24)+('C'<<16)+('A'<<8)+'P')\r
-\r
-typedef struct\r
-{\r
- char name[56];\r
- int filepos, filelen;\r
-} dpackfile_t;\r
-\r
-typedef struct\r
-{\r
- int ident; // == IDPAKHEADER\r
- int dirofs;\r
- int dirlen;\r
-} dpackheader_t;\r
-\r
-#define MAX_FILES_IN_PACK 4096\r
-\r
-\r
-/*\r
-========================================================================\r
-\r
-PCX files are used for as many images as possible\r
-\r
-========================================================================\r
-*/\r
-\r
-typedef struct\r
-{\r
- char manufacturer;\r
- char version;\r
- char encoding;\r
- char bits_per_pixel;\r
- unsigned short xmin,ymin,xmax,ymax;\r
- unsigned short hres,vres;\r
- unsigned char palette[48];\r
- char reserved;\r
- char color_planes;\r
- unsigned short bytes_per_line;\r
- unsigned short palette_type;\r
- char filler[58];\r
- unsigned char data; // unbounded\r
-} pcx_t;\r
-\r
-\r
-/*\r
-========================================================================\r
-\r
-.MD2 compressed triangle model file format\r
-\r
-========================================================================\r
-*/\r
-#define IDJOINTEDALIASHEADER (('2'<<24)+('J'<<16)+('D'<<8)+'I')\r
-\r
-/*\r
-========================================================================\r
-\r
-.MD2 triangle model file format\r
-\r
-========================================================================\r
-*/\r
-\r
-#define IDALIASHEADER (('2'<<24)+('P'<<16)+('D'<<8)+'I')\r
-#define ALIAS_VERSION 8\r
-\r
-#define MAX_TRIANGLES 2048\r
-#define MAX_VERTS 2048\r
-#define MAX_FRAMES 512\r
-#define MAX_MD2SKINS 64\r
-#define MAX_SKINNAME 64\r
-\r
-typedef struct\r
-{\r
- short s;\r
- short t;\r
-} dstvert_t;\r
-\r
-typedef struct \r
-{\r
- short index_xyz[3];\r
- short index_st[3];\r
-} dtriangle_t;\r
-\r
-typedef struct\r
-{\r
- byte v[3]; // scaled byte to fit in frame mins/maxs\r
- byte lightnormalindex;\r
-} dtrivertx_t;\r
-\r
-#define DTRIVERTX_V0 0\r
-#define DTRIVERTX_V1 1\r
-#define DTRIVERTX_V2 2\r
-#define DTRIVERTX_LNI 3\r
-#define DTRIVERTX_SIZE 4\r
-\r
-typedef struct\r
-{\r
- float scale[3]; // multiply byte verts by this\r
- float translate[3]; // then add this\r
- char name[16]; // frame name from grabbing\r
- dtrivertx_t verts[1]; // variable sized\r
-} daliasframe_t;\r
-\r
-\r
-// the glcmd format:\r
-// a positive integer starts a tristrip command, followed by that many\r
-// vertex structures.\r
-// a negative integer starts a trifan command, followed by -x vertexes\r
-// a zero indicates the end of the command list.\r
-// a vertex consists of a floating point s, a floating point t,\r
-// and an integer vertex index.\r
-\r
-\r
-typedef struct\r
-{\r
- int ident;\r
- int version;\r
-\r
- int skinwidth;\r
- int skinheight;\r
- int framesize; // byte size of each frame\r
-\r
- int num_skins;\r
- int num_xyz;\r
- int num_st; // greater than num_xyz for seams\r
- int num_tris;\r
- int num_glcmds; // dwords in strip/fan command list\r
- int num_frames;\r
-\r
- int ofs_skins; // each skin is a MAX_SKINNAME string\r
- int ofs_st; // byte offset from start for stverts\r
- int ofs_tris; // offset for dtriangles\r
- int ofs_frames; // offset for first frame\r
- int ofs_glcmds; \r
- int ofs_end; // end of file\r
-\r
-} dmdl_t;\r
-\r
-/*\r
-========================================================================\r
-\r
-.BK file format\r
-\r
-========================================================================\r
-*/\r
-\r
-#define IDBOOKHEADER (('K'<<24)+('O'<<16)+('O'<<8)+'B')\r
-#define BOOK_VERSION 2\r
-\r
-typedef struct bookframe_s\r
-{\r
- int x;\r
- int y;\r
- int w;\r
- int h;\r
- char name[MAX_SKINNAME]; // name of gfx file\r
-} bookframe_t;\r
-\r
-typedef struct bookheader_s\r
-{\r
- unsigned int ident;\r
- unsigned int version;\r
- int num_segments;\r
- int total_w;\r
- int total_h;\r
-} bookheader_t;\r
-\r
-typedef struct book_s\r
-{\r
- bookheader_t bheader;\r
- bookframe_t bframes[MAX_MD2SKINS];\r
-} book_t;\r
-\r
-/*\r
-========================================================================\r
-\r
-.SP2 sprite file format\r
-\r
-========================================================================\r
-*/\r
-\r
-#define IDSPRITEHEADER (('2'<<24)+('S'<<16)+('D'<<8)+'I')\r
- // little-endian "IDS2"\r
-#define SPRITE_VERSION 2\r
-\r
-typedef struct\r
-{\r
- int width, height;\r
- int origin_x, origin_y; // raster coordinates inside pic\r
- char name[MAX_SKINNAME]; // name of pcx file\r
-} dsprframe_t;\r
-\r
-typedef struct {\r
- int ident;\r
- int version;\r
- int numframes;\r
- dsprframe_t frames[1]; // variable sized\r
-} dsprite_t;\r
-\r
-/*\r
-==============================================================================\r
-\r
- .M8 texture file format\r
-\r
-==============================================================================\r
-*/\r
-\r
-typedef struct palette_s\r
-{\r
- union\r
- {\r
- struct\r
- {\r
- byte r,g,b;\r
- };\r
- };\r
-} palette_t;\r
-\r
-#define MIP_VERSION 2\r
-#define PAL_SIZE 256\r
-#define MIPLEVELS 16\r
-\r
-typedef struct miptex_s\r
-{\r
- int version;\r
- char name[32];\r
- unsigned width[MIPLEVELS], height[MIPLEVELS];\r
- unsigned offsets[MIPLEVELS]; // four mip maps stored\r
- char animname[32]; // next frame in animation chain\r
- palette_t palette[PAL_SIZE];\r
- int flags;\r
- int contents;\r
- int value;\r
-} miptex_t;\r
-\r
-\r
-#define MIP32_VERSION 4\r
-\r
-#define MIP32_NOMIP_FLAG2 0x00000001\r
-#define MIP32_DETAILER_FLAG2 0x00000002\r
-\r
-typedef struct miptex32_s\r
-{\r
- int version;\r
- char name[128];\r
- char altname[128]; // texture substitution\r
- char animname[128]; // next frame in animation chain\r
- char damagename[128]; // image that should be shown when damaged\r
- unsigned width[MIPLEVELS], height[MIPLEVELS];\r
- unsigned offsets[MIPLEVELS]; \r
- int flags;\r
- int contents;\r
- int value;\r
- float scale_x, scale_y;\r
- int mip_scale;\r
-\r
- // detail texturing info\r
- char dt_name[128]; // detailed texture name\r
- float dt_scale_x, dt_scale_y;\r
- float dt_u, dt_v;\r
- float dt_alpha;\r
- int dt_src_blend_mode, dt_dst_blend_mode;\r
-\r
- int flags2;\r
- int unused[19]; // future expansion to maintain compatibility with h2\r
-} miptex32_t;\r
-\r
-\r
-\r
-/*\r
-==============================================================================\r
-\r
- .BSP file format\r
-\r
-==============================================================================\r
-*/\r
-\r
-#define IDBSPHEADER (('P'<<24)+('S'<<16)+('B'<<8)+'I')\r
- // little-endian "IBSP"\r
-\r
-#define BSPVERSION 38\r
-\r
-\r
-// upper design bounds\r
-// leaffaces, leafbrushes, planes, and verts are still bounded by\r
-// 16 bit short limits\r
-#define MAX_MAP_MODELS 1024\r
-#define MAX_MAP_BRUSHES 8192\r
-#define MAX_MAP_ENTITIES 2048\r
-#define MAX_MAP_ENTSTRING 0x40000\r
-#define MAX_MAP_TEXINFO 8192\r
-\r
-#define MAX_MAP_AREAS 256\r
-#define MAX_MAP_AREAPORTALS 1024\r
-#define MAX_MAP_PLANES 65536\r
-#define MAX_MAP_NODES 65536\r
-#define MAX_MAP_BRUSHSIDES 65536\r
-#define MAX_MAP_LEAFS 65536\r
-#define MAX_MAP_VERTS 65536\r
-#define MAX_MAP_FACES 65536\r
-#define MAX_MAP_LEAFFACES 65536\r
-#define MAX_MAP_LEAFBRUSHES 65536\r
-#define MAX_MAP_PORTALS 65536\r
-#define MAX_MAP_EDGES 128000\r
-#define MAX_MAP_SURFEDGES 256000\r
-#define MAX_MAP_LIGHTING 0x200000\r
-#define MAX_MAP_VISIBILITY 0x180000\r
-\r
-// key / value pair sizes\r
-\r
-#define MAX_KEY 32\r
-#define MAX_VALUE 1024\r
-\r
-//=============================================================================\r
-\r
-typedef struct\r
-{\r
- int fileofs, filelen;\r
-} lump_t;\r
-\r
-#define LUMP_ENTITIES 0\r
-#define LUMP_PLANES 1\r
-#define LUMP_VERTEXES 2\r
-#define LUMP_VISIBILITY 3\r
-#define LUMP_NODES 4\r
-#define LUMP_TEXINFO 5\r
-#define LUMP_FACES 6\r
-#define LUMP_LIGHTING 7\r
-#define LUMP_LEAFS 8\r
-#define LUMP_LEAFFACES 9\r
-#define LUMP_LEAFBRUSHES 10\r
-#define LUMP_EDGES 11\r
-#define LUMP_SURFEDGES 12\r
-#define LUMP_MODELS 13\r
-#define LUMP_BRUSHES 14\r
-#define LUMP_BRUSHSIDES 15\r
-#define LUMP_POP 16\r
-#define LUMP_AREAS 17\r
-#define LUMP_AREAPORTALS 18\r
-#define HEADER_LUMPS 19\r
-\r
-typedef struct\r
-{\r
- int ident;\r
- int version; \r
- lump_t lumps[HEADER_LUMPS];\r
-} dheader_t;\r
-\r
-typedef struct\r
-{\r
- float mins[3], maxs[3];\r
- float origin[3]; // for sounds or lights\r
- int headnode;\r
- int firstface, numfaces; // submodels just draw faces\r
- // without walking the bsp tree\r
-} dmodel_t;\r
-\r
-\r
-typedef struct\r
-{\r
- float point[3];\r
-} dvertex_t;\r
-\r
-\r
-// 0-2 are axial planes\r
-#define PLANE_X 0\r
-#define PLANE_Y 1\r
-#define PLANE_Z 2\r
-\r
-// 3-5 are non-axial planes snapped to the nearest\r
-#define PLANE_ANYX 3\r
-#define PLANE_ANYY 4\r
-#define PLANE_ANYZ 5\r
-\r
-// planes (x&~1) and (x&~1)+1 are allways opposites\r
-\r
-typedef struct\r
-{\r
- float normal[3];\r
- float dist;\r
- int type; // PLANE_X - PLANE_ANYZ ?remove? trivial to regenerate\r
-} dplane_t;\r
-\r
-\r
-// contents flags are seperate bits\r
-// a given brush can contribute multiple content bits\r
-// multiple brushes can be in a single leaf\r
-\r
-// these definitions also need to be in q_shared.h!\r
-\r
-// lower bits are stronger, and will eat weaker brushes completely\r
-#define CONTENTS_SOLID 0x00000001 // an eye is never valid in a solid\r
-#define CONTENTS_WINDOW 0x00000002 // translucent, but not watery\r
-#define CONTENTS_PUSHPULL 0x00000004\r
-#define CONTENTS_LAVA 0x00000008\r
-#define CONTENTS_SLIME 0x00000010\r
-#define CONTENTS_WATER 0x00000020\r
-#define CONTENTS_MIST 0x00000040 // 64\r
-#define LAST_VISIBLE_CONTENTS 64 // this one worries me a bit JKH\r
-\r
-// remaining contents are non-visible, and don't eat brushes\r
-\r
-#define CONTENTS_AREAPORTAL 0x00008000\r
-\r
-#define CONTENTS_PLAYERCLIP 0x00010000\r
-#define CONTENTS_MONSTERCLIP 0x00020000\r
-\r
-// currents can be added to any other contents, and may be mixed\r
-#define CONTENTS_CURRENT_0 0x00040000\r
-#define CONTENTS_CURRENT_90 0x00080000\r
-#define CONTENTS_CURRENT_180 0x00100000\r
-#define CONTENTS_CURRENT_270 0x00200000\r
-#define CONTENTS_CURRENT_UP 0x00400000\r
-#define CONTENTS_CURRENT_DOWN 0x00800000\r
-\r
-#define CONTENTS_ORIGIN 0x01000000 // removed before bsping an entity\r
-\r
-#define CONTENTS_MONSTER 0x02000000 // should never be on a brush, only in game\r
-#define CONTENTS_DEADMONSTER 0x04000000\r
-#define CONTENTS_DETAIL 0x08000000 // brushes to be added after vis leafs\r
-#define CONTENTS_TRANSLUCENT 0x10000000 // auto set if any surface has trans\r
-#define CONTENTS_LADDER 0x20000000\r
-\r
-\r
-\r
-#define SURF_LIGHT 0x00000001 // value will hold the light strength\r
-\r
-#define SURF_SLICK 0x00000002 // effects game physics\r
-\r
-#define SURF_SKY 0x00000004 // don't draw, but add to skybox\r
-#define SURF_WARP 0x00000008 // turbulent water warp\r
-#define SURF_TRANS33 0x00000010\r
-#define SURF_TRANS66 0x00000020\r
-#define SURF_FLOWING 0x00000040 // scroll towards angle\r
-#define SURF_NODRAW 0x00000080 // don't bother referencing the texture\r
-\r
-#define SURF_HINT 0x00000100 // make a primary bsp splitter\r
-#define SURF_SKIP 0x00000200 // completely ignore, allowing non-closed brushes\r
-#define SURF_TALL_WALL 0x00000400 // face doesn't get broken up as normal\r
-\r
-#define SURF_ALPHA_TEXTURE 0x00000800 // texture has alpha in it, and should show through in bsp process\r
-#define SURF_ANIMSPEED 0x00001000 // value will hold the anim speed in fps\r
-\r
-#define SURF_UNDULATE 0x00002000 // rock surface up and down...\r
-#define SURF_SKYREFLECT 0x00004000 // liquid will somewhat reflect the sky - not quite finished....\r
-\r
-#define SURF_TYPE_GRAVEL 0x00000000\r
-#define SURF_TYPE_METAL 0x01000000\r
-#define SURF_TYPE_STONE 0x02000000\r
-#define SURF_TYPE_WOOD 0x03000000\r
-#define SURF_MATERIAL 0xFF000000\r
-\r
-\r
-\r
-typedef struct\r
-{\r
- int planenum;\r
- int children[2]; // negative numbers are -(leafs+1), not nodes\r
- short mins[3]; // for frustom culling\r
- short maxs[3];\r
- unsigned short firstface;\r
- unsigned short numfaces; // counting both sides\r
-} dnode_t;\r
-\r
-\r
-typedef struct texinfo_s\r
-{\r
- float vecs[2][4]; // [s/t][xyz offset]\r
- int flags; // miptex flags + overrides\r
- int value; // light emission, etc\r
- char texture[32]; // texture name (textures/*.wal)\r
- int nexttexinfo; // for animations, -1 = end of chain\r
-} texinfo_t;\r
-\r
-\r
-// note that edge 0 is never used, because negative edge nums are used for\r
-// counterclockwise use of the edge in a face\r
-typedef struct\r
-{\r
- unsigned short v[2]; // vertex numbers\r
-} dedge_t;\r
-\r
-#define MAXLIGHTMAPS 4\r
-typedef struct\r
-{\r
- unsigned short planenum;\r
- short side;\r
-\r
- int firstedge; // we must support > 64k edges\r
- short numedges; \r
- short texinfo;\r
-\r
-// lighting info\r
- union {\r
- byte styles[MAXLIGHTMAPS];\r
- paletteRGBA_t lighting;\r
- };\r
- int lightofs; // start of [numstyles*surfsize] samples\r
-} dface_t;\r
-\r
-typedef struct\r
-{\r
- int contents; // OR of all brushes (not needed?)\r
-\r
- short cluster;\r
- short area;\r
-\r
- short mins[3]; // for frustum culling\r
- short maxs[3];\r
-\r
- unsigned short firstleafface;\r
- unsigned short numleaffaces;\r
-\r
- unsigned short firstleafbrush;\r
- unsigned short numleafbrushes;\r
-} dleaf_t;\r
-\r
-typedef struct\r
-{\r
- unsigned short planenum; // facing out of the leaf\r
- short texinfo;\r
-} dbrushside_t;\r
-\r
-typedef struct\r
-{\r
- int firstside;\r
- int numsides;\r
- int contents;\r
-} dbrush_t;\r
-\r
-#define ANGLE_UP -1\r
-#define ANGLE_DOWN -2\r
-\r
-\r
-// the visibility lump consists of a header with a count, then\r
-// byte offsets for the PVS and PHS of each cluster, then the raw\r
-// compressed bit vectors\r
-#define DVIS_PVS 0\r
-#define DVIS_PHS 1\r
-typedef struct\r
-{\r
- int numclusters;\r
- int bitofs[8][2]; // bitofs[numclusters][2]\r
-} dvis_t;\r
-\r
-// each area has a list of portals that lead into other areas\r
-// when portals are closed, other areas may not be visible or\r
-// hearable even if the vis info says that it should be\r
-typedef struct\r
-{\r
- int portalnum;\r
- int otherarea;\r
-} dareaportal_t;\r
-\r
-\r
-typedef struct\r
-{\r
- int numareaportals;\r
- int firstareaportal;\r
-} darea_t;\r
-\r
-typedef struct\r
-{\r
- char *name;\r
- int value;\r
-} materialtype_t;\r
-\r
-enum\r
-{\r
- MATERIAL_GRAVEL,\r
- MATERIAL_METAL,\r
- MATERIAL_STONE,\r
- MATERIAL_WOOD,\r
-};\r
-\r
-materialtype_t *materialtypes;\r
-\r
-void QFile_ReadMaterialTypes(char* filename);\r
-\r
-\r
-#endif //_QFILES_H\r
+/*
+ Copyright (C) 1999-2007 id Software, Inc. and contributors.
+ For a list of contributors, see the accompanying CONTRIBUTORS file.
+
+ This file is part of GtkRadiant.
+
+ GtkRadiant is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ GtkRadiant is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GtkRadiant; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef _QFILES_H
+#define _QFILES_H
+
+#include "q_typedef.h"
+
+//
+// qfiles.h: quake file formats
+// This file must be identical in the quake and utils directories
+//
+
+/*
+ ========================================================================
+
+ The .pak files are just a linear collapse of a directory tree
+
+ ========================================================================
+ */
+
+#define IDPAKHEADER ( ( 'K' << 24 ) + ( 'C' << 16 ) + ( 'A' << 8 ) + 'P' )
+
+typedef struct
+{
+ char name[56];
+ int filepos, filelen;
+} dpackfile_t;
+
+typedef struct
+{
+ int ident; // == IDPAKHEADER
+ int dirofs;
+ int dirlen;
+} dpackheader_t;
+
+#define MAX_FILES_IN_PACK 4096
+
+
+/*
+ ========================================================================
+
+ PCX files are used for as many images as possible
+
+ ========================================================================
+ */
+
+typedef struct
+{
+ char manufacturer;
+ char version;
+ char encoding;
+ char bits_per_pixel;
+ unsigned short xmin,ymin,xmax,ymax;
+ unsigned short hres,vres;
+ unsigned char palette[48];
+ char reserved;
+ char color_planes;
+ unsigned short bytes_per_line;
+ unsigned short palette_type;
+ char filler[58];
+ unsigned char data; // unbounded
+} pcx_t;
+
+
+/*
+ ========================================================================
+
+ .MD2 compressed triangle model file format
+
+ ========================================================================
+ */
+#define IDJOINTEDALIASHEADER ( ( '2' << 24 ) + ( 'J' << 16 ) + ( 'D' << 8 ) + 'I' )
+
+/*
+ ========================================================================
+
+ .MD2 triangle model file format
+
+ ========================================================================
+ */
+
+#define IDALIASHEADER ( ( '2' << 24 ) + ( 'P' << 16 ) + ( 'D' << 8 ) + 'I' )
+#define ALIAS_VERSION 8
+
+#define MAX_TRIANGLES 2048
+#define MAX_VERTS 2048
+#define MAX_FRAMES 512
+#define MAX_MD2SKINS 64
+#define MAX_SKINNAME 64
+
+typedef struct
+{
+ short s;
+ short t;
+} dstvert_t;
+
+typedef struct
+{
+ short index_xyz[3];
+ short index_st[3];
+} dtriangle_t;
+
+typedef struct
+{
+ byte v[3]; // scaled byte to fit in frame mins/maxs
+ byte lightnormalindex;
+} dtrivertx_t;
+
+#define DTRIVERTX_V0 0
+#define DTRIVERTX_V1 1
+#define DTRIVERTX_V2 2
+#define DTRIVERTX_LNI 3
+#define DTRIVERTX_SIZE 4
+
+typedef struct
+{
+ float scale[3]; // multiply byte verts by this
+ float translate[3]; // then add this
+ char name[16]; // frame name from grabbing
+ dtrivertx_t verts[1]; // variable sized
+} daliasframe_t;
+
+
+// the glcmd format:
+// a positive integer starts a tristrip command, followed by that many
+// vertex structures.
+// a negative integer starts a trifan command, followed by -x vertexes
+// a zero indicates the end of the command list.
+// a vertex consists of a floating point s, a floating point t,
+// and an integer vertex index.
+
+
+typedef struct
+{
+ int ident;
+ int version;
+
+ int skinwidth;
+ int skinheight;
+ int framesize; // byte size of each frame
+
+ int num_skins;
+ int num_xyz;
+ int num_st; // greater than num_xyz for seams
+ int num_tris;
+ int num_glcmds; // dwords in strip/fan command list
+ int num_frames;
+
+ int ofs_skins; // each skin is a MAX_SKINNAME string
+ int ofs_st; // byte offset from start for stverts
+ int ofs_tris; // offset for dtriangles
+ int ofs_frames; // offset for first frame
+ int ofs_glcmds;
+ int ofs_end; // end of file
+
+} dmdl_t;
+
+/*
+ ========================================================================
+
+ .BK file format
+
+ ========================================================================
+ */
+
+#define IDBOOKHEADER ( ( 'K' << 24 ) + ( 'O' << 16 ) + ( 'O' << 8 ) + 'B' )
+#define BOOK_VERSION 2
+
+typedef struct bookframe_s
+{
+ int x;
+ int y;
+ int w;
+ int h;
+ char name[MAX_SKINNAME]; // name of gfx file
+} bookframe_t;
+
+typedef struct bookheader_s
+{
+ unsigned int ident;
+ unsigned int version;
+ int num_segments;
+ int total_w;
+ int total_h;
+} bookheader_t;
+
+typedef struct book_s
+{
+ bookheader_t bheader;
+ bookframe_t bframes[MAX_MD2SKINS];
+} book_t;
+
+/*
+ ========================================================================
+
+ .SP2 sprite file format
+
+ ========================================================================
+ */
+
+#define IDSPRITEHEADER ( ( '2' << 24 ) + ( 'S' << 16 ) + ( 'D' << 8 ) + 'I' )
+// little-endian "IDS2"
+#define SPRITE_VERSION 2
+
+typedef struct
+{
+ int width, height;
+ int origin_x, origin_y; // raster coordinates inside pic
+ char name[MAX_SKINNAME]; // name of pcx file
+} dsprframe_t;
+
+typedef struct {
+ int ident;
+ int version;
+ int numframes;
+ dsprframe_t frames[1]; // variable sized
+} dsprite_t;
+
+/*
+ ==============================================================================
+
+ .M8 texture file format
+
+ ==============================================================================
+ */
+
+typedef struct palette_s
+{
+ union
+ {
+ struct
+ {
+ byte r,g,b;
+ };
+ };
+} palette_t;
+
+#define MIP_VERSION 2
+#define PAL_SIZE 256
+#define MIPLEVELS 16
+
+typedef struct miptex_s
+{
+ int version;
+ char name[32];
+ unsigned width[MIPLEVELS], height[MIPLEVELS];
+ unsigned offsets[MIPLEVELS]; // four mip maps stored
+ char animname[32]; // next frame in animation chain
+ palette_t palette[PAL_SIZE];
+ int flags;
+ int contents;
+ int value;
+} miptex_t;
+
+
+#define MIP32_VERSION 4
+
+#define MIP32_NOMIP_FLAG2 0x00000001
+#define MIP32_DETAILER_FLAG2 0x00000002
+
+typedef struct miptex32_s
+{
+ int version;
+ char name[128];
+ char altname[128]; // texture substitution
+ char animname[128]; // next frame in animation chain
+ char damagename[128]; // image that should be shown when damaged
+ unsigned width[MIPLEVELS], height[MIPLEVELS];
+ unsigned offsets[MIPLEVELS];
+ int flags;
+ int contents;
+ int value;
+ float scale_x, scale_y;
+ int mip_scale;
+
+ // detail texturing info
+ char dt_name[128]; // detailed texture name
+ float dt_scale_x, dt_scale_y;
+ float dt_u, dt_v;
+ float dt_alpha;
+ int dt_src_blend_mode, dt_dst_blend_mode;
+
+ int flags2;
+ int unused[19]; // future expansion to maintain compatibility with h2
+} miptex32_t;
+
+
+
+/*
+ ==============================================================================
+
+ .BSP file format
+
+ ==============================================================================
+ */
+
+#define IDBSPHEADER ( ( 'P' << 24 ) + ( 'S' << 16 ) + ( 'B' << 8 ) + 'I' )
+// little-endian "IBSP"
+
+#define BSPVERSION 38
+
+
+// upper design bounds
+// leaffaces, leafbrushes, planes, and verts are still bounded by
+// 16 bit short limits
+#define MAX_MAP_MODELS 1024
+#define MAX_MAP_BRUSHES 8192
+#define MAX_MAP_ENTITIES 2048
+#define MAX_MAP_ENTSTRING 0x40000
+#define MAX_MAP_TEXINFO 8192
+
+#define MAX_MAP_AREAS 256
+#define MAX_MAP_AREAPORTALS 1024
+#define MAX_MAP_PLANES 65536
+#define MAX_MAP_NODES 65536
+#define MAX_MAP_BRUSHSIDES 65536
+#define MAX_MAP_LEAFS 65536
+#define MAX_MAP_VERTS 65536
+#define MAX_MAP_FACES 65536
+#define MAX_MAP_LEAFFACES 65536
+#define MAX_MAP_LEAFBRUSHES 65536
+#define MAX_MAP_PORTALS 65536
+#define MAX_MAP_EDGES 128000
+#define MAX_MAP_SURFEDGES 256000
+#define MAX_MAP_LIGHTING 0x200000
+#define MAX_MAP_VISIBILITY 0x180000
+
+// key / value pair sizes
+
+#define MAX_KEY 32
+#define MAX_VALUE 1024
+
+//=============================================================================
+
+typedef struct
+{
+ int fileofs, filelen;
+} lump_t;
+
+#define LUMP_ENTITIES 0
+#define LUMP_PLANES 1
+#define LUMP_VERTEXES 2
+#define LUMP_VISIBILITY 3
+#define LUMP_NODES 4
+#define LUMP_TEXINFO 5
+#define LUMP_FACES 6
+#define LUMP_LIGHTING 7
+#define LUMP_LEAFS 8
+#define LUMP_LEAFFACES 9
+#define LUMP_LEAFBRUSHES 10
+#define LUMP_EDGES 11
+#define LUMP_SURFEDGES 12
+#define LUMP_MODELS 13
+#define LUMP_BRUSHES 14
+#define LUMP_BRUSHSIDES 15
+#define LUMP_POP 16
+#define LUMP_AREAS 17
+#define LUMP_AREAPORTALS 18
+#define HEADER_LUMPS 19
+
+typedef struct
+{
+ int ident;
+ int version;
+ lump_t lumps[HEADER_LUMPS];
+} dheader_t;
+
+typedef struct
+{
+ float mins[3], maxs[3];
+ float origin[3]; // for sounds or lights
+ int headnode;
+ int firstface, numfaces; // submodels just draw faces
+ // without walking the bsp tree
+} dmodel_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
+
+// planes (x&~1) and (x&~1)+1 are allways opposites
+
+typedef struct
+{
+ float normal[3];
+ float dist;
+ int type; // PLANE_X - PLANE_ANYZ ?remove? trivial to regenerate
+} dplane_t;
+
+
+// contents flags are seperate bits
+// a given brush can contribute multiple content bits
+// multiple brushes can be in a single leaf
+
+// these definitions also need to be in q_shared.h!
+
+// lower bits are stronger, and will eat weaker brushes completely
+#define CONTENTS_SOLID 0x00000001 // an eye is never valid in a solid
+#define CONTENTS_WINDOW 0x00000002 // translucent, but not watery
+#define CONTENTS_PUSHPULL 0x00000004
+#define CONTENTS_LAVA 0x00000008
+#define CONTENTS_SLIME 0x00000010
+#define CONTENTS_WATER 0x00000020
+#define CONTENTS_MIST 0x00000040 // 64
+#define LAST_VISIBLE_CONTENTS 64 // this one worries me a bit JKH
+
+// remaining contents are non-visible, and don't eat brushes
+
+#define CONTENTS_AREAPORTAL 0x00008000
+
+#define CONTENTS_PLAYERCLIP 0x00010000
+#define CONTENTS_MONSTERCLIP 0x00020000
+
+// currents can be added to any other contents, and may be mixed
+#define CONTENTS_CURRENT_0 0x00040000
+#define CONTENTS_CURRENT_90 0x00080000
+#define CONTENTS_CURRENT_180 0x00100000
+#define CONTENTS_CURRENT_270 0x00200000
+#define CONTENTS_CURRENT_UP 0x00400000
+#define CONTENTS_CURRENT_DOWN 0x00800000
+
+#define CONTENTS_ORIGIN 0x01000000 // removed before bsping an entity
+
+#define CONTENTS_MONSTER 0x02000000 // should never be on a brush, only in game
+#define CONTENTS_DEADMONSTER 0x04000000
+#define CONTENTS_DETAIL 0x08000000 // brushes to be added after vis leafs
+#define CONTENTS_TRANSLUCENT 0x10000000 // auto set if any surface has trans
+#define CONTENTS_LADDER 0x20000000
+
+
+
+#define SURF_LIGHT 0x00000001 // value will hold the light strength
+
+#define SURF_SLICK 0x00000002 // effects game physics
+
+#define SURF_SKY 0x00000004 // don't draw, but add to skybox
+#define SURF_WARP 0x00000008 // turbulent water warp
+#define SURF_TRANS33 0x00000010
+#define SURF_TRANS66 0x00000020
+#define SURF_FLOWING 0x00000040 // scroll towards angle
+#define SURF_NODRAW 0x00000080 // don't bother referencing the texture
+
+#define SURF_HINT 0x00000100 // make a primary bsp splitter
+#define SURF_SKIP 0x00000200 // completely ignore, allowing non-closed brushes
+#define SURF_TALL_WALL 0x00000400 // face doesn't get broken up as normal
+
+#define SURF_ALPHA_TEXTURE 0x00000800 // texture has alpha in it, and should show through in bsp process
+#define SURF_ANIMSPEED 0x00001000 // value will hold the anim speed in fps
+
+#define SURF_UNDULATE 0x00002000 // rock surface up and down...
+#define SURF_SKYREFLECT 0x00004000 // liquid will somewhat reflect the sky - not quite finished....
+
+#define SURF_TYPE_GRAVEL 0x00000000
+#define SURF_TYPE_METAL 0x01000000
+#define SURF_TYPE_STONE 0x02000000
+#define SURF_TYPE_WOOD 0x03000000
+#define SURF_MATERIAL 0xFF000000
+
+
+
+typedef struct
+{
+ int planenum;
+ int children[2]; // negative numbers are -(leafs+1), not nodes
+ short mins[3]; // for frustom culling
+ short maxs[3];
+ unsigned short firstface;
+ unsigned short numfaces; // counting both sides
+} dnode_t;
+
+
+typedef struct texinfo_s
+{
+ float vecs[2][4]; // [s/t][xyz offset]
+ int flags; // miptex flags + overrides
+ int value; // light emission, etc
+ char texture[32]; // texture name (textures/*.wal)
+ int nexttexinfo; // for animations, -1 = end of chain
+} texinfo_t;
+
+
+// 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
+{
+ unsigned short planenum;
+ short side;
+
+ int firstedge; // we must support > 64k edges
+ short numedges;
+ short texinfo;
+
+// lighting info
+ union {
+ byte styles[MAXLIGHTMAPS];
+ paletteRGBA_t lighting;
+ };
+ int lightofs; // start of [numstyles*surfsize] samples
+} dface_t;
+
+typedef struct
+{
+ int contents; // OR of all brushes (not needed?)
+
+ short cluster;
+ short area;
+
+ short mins[3]; // for frustum culling
+ short maxs[3];
+
+ unsigned short firstleafface;
+ unsigned short numleaffaces;
+
+ unsigned short firstleafbrush;
+ unsigned short numleafbrushes;
+} dleaf_t;
+
+typedef struct
+{
+ unsigned short planenum; // facing out of the leaf
+ short texinfo;
+} dbrushside_t;
+
+typedef struct
+{
+ int firstside;
+ int numsides;
+ int contents;
+} dbrush_t;
+
+#define ANGLE_UP -1
+#define ANGLE_DOWN -2
+
+
+// the visibility lump consists of a header with a count, then
+// byte offsets for the PVS and PHS of each cluster, then the raw
+// compressed bit vectors
+#define DVIS_PVS 0
+#define DVIS_PHS 1
+typedef struct
+{
+ int numclusters;
+ int bitofs[8][2]; // bitofs[numclusters][2]
+} dvis_t;
+
+// each area has a list of portals that lead into other areas
+// when portals are closed, other areas may not be visible or
+// hearable even if the vis info says that it should be
+typedef struct
+{
+ int portalnum;
+ int otherarea;
+} dareaportal_t;
+
+
+typedef struct
+{
+ int numareaportals;
+ int firstareaportal;
+} darea_t;
+
+typedef struct
+{
+ char *name;
+ int value;
+} materialtype_t;
+
+enum
+{
+ MATERIAL_GRAVEL,
+ MATERIAL_METAL,
+ MATERIAL_STONE,
+ MATERIAL_WOOD,
+};
+
+materialtype_t *materialtypes;
+
+void QFile_ReadMaterialTypes( char* filename );
+
+
+#endif //_QFILES_H