]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - tools/quake2/common/qfiles.h
transfer from internal tree r5311 branches/1.4-gpl
[xonotic/netradiant.git] / tools / quake2 / common / qfiles.h
1 /*\r
2 Copyright (C) 1999-2007 id Software, Inc. and contributors.\r
3 For a list of contributors, see the accompanying CONTRIBUTORS file.\r
4 \r
5 This file is part of GtkRadiant.\r
6 \r
7 GtkRadiant is free software; you can redistribute it and/or modify\r
8 it under the terms of the GNU General Public License as published by\r
9 the Free Software Foundation; either version 2 of the License, or\r
10 (at your option) any later version.\r
11 \r
12 GtkRadiant is distributed in the hope that it will be useful,\r
13 but WITHOUT ANY WARRANTY; without even the implied warranty of\r
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
15 GNU General Public License for more details.\r
16 \r
17 You should have received a copy of the GNU General Public License\r
18 along with GtkRadiant; if not, write to the Free Software\r
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\r
20 */\r
21 \r
22 //\r
23 // qfiles.h: quake file formats\r
24 // This file must be identical in the quake and utils directories\r
25 //\r
26 \r
27 /*\r
28 ========================================================================\r
29 \r
30 The .pak files are just a linear collapse of a directory tree\r
31 \r
32 ========================================================================\r
33 */\r
34 \r
35 #ifdef _WIN32\r
36         #ifdef NDEBUG                                                   // Don't show in a Release build\r
37                 #pragma warning(disable : 4305)     // truncate from double to float\r
38                 #pragma warning(disable : 4244)     // conversion from double to float\r
39                 #pragma warning(disable : 4018)     // signed/unsigned mismatch\r
40         #endif\r
41 #endif\r
42 \r
43 #define IDPAKHEADER             (('K'<<24)+('C'<<16)+('A'<<8)+'P')\r
44 \r
45 typedef struct\r
46 {\r
47         char    name[56];\r
48         int             filepos, filelen;\r
49 } dpackfile_t;\r
50 \r
51 typedef struct\r
52 {\r
53         int             ident;          // == IDPAKHEADER\r
54         int             dirofs;\r
55         int             dirlen;\r
56 } dpackheader_t;\r
57 \r
58 #define MAX_FILES_IN_PACK       4096\r
59 \r
60 \r
61 /*\r
62 ========================================================================\r
63 \r
64 PCX files are used for as many images as possible\r
65 \r
66 ========================================================================\r
67 */\r
68 \r
69 typedef struct\r
70 {\r
71     char        manufacturer;\r
72     char        version;\r
73     char        encoding;\r
74     char        bits_per_pixel;\r
75     unsigned short      xmin,ymin,xmax,ymax;\r
76     unsigned short      hres,vres;\r
77     unsigned char       palette[48];\r
78     char        reserved;\r
79     char        color_planes;\r
80     unsigned short      bytes_per_line;\r
81     unsigned short      palette_type;\r
82     char        filler[58];\r
83     unsigned char       data;                   // unbounded\r
84 } pcx_t;\r
85 \r
86 \r
87 /*\r
88 ========================================================================\r
89 \r
90 .MD2 triangle model file format\r
91 \r
92 ========================================================================\r
93 */\r
94 \r
95 #define IDALIASHEADER           (('2'<<24)+('P'<<16)+('D'<<8)+'I')\r
96 #define ALIAS_VERSION   8\r
97 \r
98 #define MAX_TRIANGLES   4096\r
99 #define MAX_VERTS               2048\r
100 #define MAX_FRAMES              512\r
101 #define MAX_MD2SKINS    32\r
102 #define MAX_SKINNAME    64\r
103 \r
104 typedef struct\r
105 {\r
106         short   s;\r
107         short   t;\r
108 } dstvert_t;\r
109 \r
110 typedef struct \r
111 {\r
112         short   index_xyz[3];\r
113         short   index_st[3];\r
114 } dtriangle_t;\r
115 \r
116 typedef struct\r
117 {\r
118         byte    v[3];                   // scaled byte to fit in frame mins/maxs\r
119         byte    lightnormalindex;\r
120 } dtrivertx_t;\r
121 \r
122 #define DTRIVERTX_V0   0\r
123 #define DTRIVERTX_V1   1\r
124 #define DTRIVERTX_V2   2\r
125 #define DTRIVERTX_LNI  3\r
126 #define DTRIVERTX_SIZE 4\r
127 \r
128 typedef struct\r
129 {\r
130         float           scale[3];       // multiply byte verts by this\r
131         float           translate[3];   // then add this\r
132         char            name[16];       // frame name from grabbing\r
133         dtrivertx_t     verts[1];       // variable sized\r
134 } daliasframe_t;\r
135 \r
136 \r
137 // the glcmd format:\r
138 // a positive integer starts a tristrip command, followed by that many\r
139 // vertex structures.\r
140 // a negative integer starts a trifan command, followed by -x vertexes\r
141 // a zero indicates the end of the command list.\r
142 // a vertex consists of a floating point s, a floating point t,\r
143 // and an integer vertex index.\r
144 \r
145 \r
146 typedef struct\r
147 {\r
148         int                     ident;\r
149         int                     version;\r
150 \r
151         int                     skinwidth;\r
152         int                     skinheight;\r
153         int                     framesize;              // byte size of each frame\r
154 \r
155         int                     num_skins;\r
156         int                     num_xyz;\r
157         int                     num_st;                 // greater than num_xyz for seams\r
158         int                     num_tris;\r
159         int                     num_glcmds;             // dwords in strip/fan command list\r
160         int                     num_frames;\r
161 \r
162         int                     ofs_skins;              // each skin is a MAX_SKINNAME string\r
163         int                     ofs_st;                 // byte offset from start for stverts\r
164         int                     ofs_tris;               // offset for dtriangles\r
165         int                     ofs_frames;             // offset for first frame\r
166         int                     ofs_glcmds;     \r
167         int                     ofs_end;                // end of file\r
168 \r
169 } dmdl_t;\r
170 \r
171 /*\r
172 ========================================================================\r
173 \r
174 .SP2 sprite file format\r
175 \r
176 ========================================================================\r
177 */\r
178 \r
179 #define IDSPRITEHEADER  (('2'<<24)+('S'<<16)+('D'<<8)+'I')\r
180                 // little-endian "IDS2"\r
181 #define SPRITE_VERSION  2\r
182 \r
183 typedef struct\r
184 {\r
185         int             width, height;\r
186         int             origin_x, origin_y;             // raster coordinates inside pic\r
187         char    name[MAX_SKINNAME];             // name of pcx file\r
188 } dsprframe_t;\r
189 \r
190 typedef struct {\r
191         int                     ident;\r
192         int                     version;\r
193         int                     numframes;\r
194         dsprframe_t     frames[1];                      // variable sized\r
195 } dsprite_t;\r
196 \r
197 /*\r
198 ==============================================================================\r
199 \r
200   .WAL texture file format\r
201 \r
202 ==============================================================================\r
203 */\r
204 \r
205 \r
206 #define MIPLEVELS       4\r
207 typedef struct miptex_s\r
208 {\r
209         char            name[32];\r
210         unsigned        width, height;\r
211         unsigned        offsets[MIPLEVELS];             // four mip maps stored\r
212         char            animname[32];                   // next frame in animation chain\r
213         int                     flags;\r
214         int                     contents;\r
215         int                     value;\r
216 } miptex_t;\r
217 \r
218  /*\r
219  ==============================================================================\r
220  \r
221 -  .WAL texture file format\r
222 +  .M8 texture file format\r
223  \r
224  ==============================================================================\r
225  */\r
226  \r
227 typedef struct palette_s\r
228 {\r
229         union\r
230         {\r
231                 struct\r
232                 {\r
233                         byte r,g,b;\r
234                 };\r
235         };\r
236 } palette_t;\r
237 \r
238 #define MIP_VERSION             2\r
239 #define PAL_SIZE                256\r
240 #define H2_MIPLEVELS            16\r
241  \r
242  typedef struct miptex_m8_s\r
243  {\r
244         int             version;\r
245         char            name[32];\r
246         unsigned        width[H2_MIPLEVELS], height[H2_MIPLEVELS];\r
247         unsigned        offsets[H2_MIPLEVELS];          // four mip maps stored\r
248         char            animname[32];                   // next frame in animation chain\r
249         palette_t       palette[PAL_SIZE];\r
250         int             flags;\r
251         int             contents;\r
252         int             value;\r
253  } miptex_m8_t;\r
254  \r
255  \r
256 #define MIP32_VERSION   4\r
257 \r
258 #define MIP32_NOMIP_FLAG2               0x00000001\r
259 #define MIP32_DETAILER_FLAG2            0x00000002\r
260 \r
261 typedef struct miptex_m32_s\r
262 {\r
263         int                     version;\r
264         char            name[128];\r
265         char            altname[128];                   // texture substitution\r
266         char            animname[128];                  // next frame in animation chain\r
267         char            damagename[128];                // image that should be shown when damaged\r
268         unsigned        width[H2_MIPLEVELS], height[H2_MIPLEVELS];\r
269         unsigned        offsets[H2_MIPLEVELS];          \r
270         int                     flags;\r
271         int                     contents;\r
272         int                     value;\r
273         float           scale_x, scale_y;\r
274         int                     mip_scale;\r
275 \r
276         // detail texturing info\r
277         char            dt_name[128];           // detailed texture name\r
278         float           dt_scale_x, dt_scale_y;\r
279         float           dt_u, dt_v;\r
280         float           dt_alpha;\r
281         int                     dt_src_blend_mode, dt_dst_blend_mode;\r
282 \r
283         int                     flags2;\r
284         int                     unused[19];                             // future expansion to maintain compatibility with h2\r
285 } miptex_m32_t;\r
286 \r
287 \r
288 \r
289 \r
290 /*\r
291 ==============================================================================\r
292 \r
293   .BSP file format\r
294 \r
295 ==============================================================================\r
296 */\r
297 \r
298 #define IDBSPHEADER     (('P'<<24)+('S'<<16)+('B'<<8)+'I')\r
299                 // little-endian "IBSP"\r
300 \r
301 #define BSPVERSION      38\r
302 \r
303 \r
304 // upper design bounds\r
305 // leaffaces, leafbrushes, planes, and verts are still bounded by\r
306 // 16 bit short limits\r
307 #define MAX_MAP_MODELS          1024\r
308 #define MAX_MAP_BRUSHES         8192\r
309 #define MAX_MAP_ENTITIES        2048\r
310 #define MAX_MAP_ENTSTRING       0x40000\r
311 #define MAX_MAP_TEXINFO         8192\r
312 \r
313 #define MAX_MAP_AREAS           256\r
314 #define MAX_MAP_AREAPORTALS     1024\r
315 #define MAX_MAP_PLANES          65536\r
316 #define MAX_MAP_NODES           65536\r
317 #define MAX_MAP_BRUSHSIDES      65536\r
318 #define MAX_MAP_LEAFS           65536\r
319 #define MAX_MAP_VERTS           65536\r
320 #define MAX_MAP_FACES           65536\r
321 #define MAX_MAP_LEAFFACES       65536\r
322 #define MAX_MAP_LEAFBRUSHES 65536\r
323 #define MAX_MAP_PORTALS         65536\r
324 #define MAX_MAP_EDGES           128000\r
325 #define MAX_MAP_SURFEDGES       256000\r
326 #define MAX_MAP_LIGHTING        0x200000\r
327 #define MAX_MAP_VISIBILITY      0x100000\r
328 \r
329 // key / value pair sizes\r
330 \r
331 #define MAX_KEY         32\r
332 #define MAX_VALUE       1024\r
333 \r
334 //=============================================================================\r
335 \r
336 typedef struct\r
337 {\r
338         int             fileofs, filelen;\r
339 } lump_t;\r
340 \r
341 #define LUMP_ENTITIES           0\r
342 #define LUMP_PLANES                     1\r
343 #define LUMP_VERTEXES           2\r
344 #define LUMP_VISIBILITY         3\r
345 #define LUMP_NODES                      4\r
346 #define LUMP_TEXINFO            5\r
347 #define LUMP_FACES                      6\r
348 #define LUMP_LIGHTING           7\r
349 #define LUMP_LEAFS                      8\r
350 #define LUMP_LEAFFACES          9\r
351 #define LUMP_LEAFBRUSHES        10\r
352 #define LUMP_EDGES                      11\r
353 #define LUMP_SURFEDGES          12\r
354 #define LUMP_MODELS                     13\r
355 #define LUMP_BRUSHES            14\r
356 #define LUMP_BRUSHSIDES         15\r
357 #define LUMP_POP                        16\r
358 #define LUMP_AREAS                      17\r
359 #define LUMP_AREAPORTALS        18\r
360 #define HEADER_LUMPS            19\r
361 \r
362 typedef struct\r
363 {\r
364         int                     ident;\r
365         int                     version;        \r
366         lump_t          lumps[HEADER_LUMPS];\r
367 } dheader_t;\r
368 \r
369 typedef struct\r
370 {\r
371         float           mins[3], maxs[3];\r
372         float           origin[3];              // for sounds or lights\r
373         int                     headnode;\r
374         int                     firstface, numfaces;    // submodels just draw faces\r
375                                                                                 // without walking the bsp tree\r
376 } dmodel_t;\r
377 \r
378 \r
379 typedef struct\r
380 {\r
381         float   point[3];\r
382 } dvertex_t;\r
383 \r
384 \r
385 // 0-2 are axial planes\r
386 #define PLANE_X                 0\r
387 #define PLANE_Y                 1\r
388 #define PLANE_Z                 2\r
389 \r
390 // 3-5 are non-axial planes snapped to the nearest\r
391 #define PLANE_ANYX              3\r
392 #define PLANE_ANYY              4\r
393 #define PLANE_ANYZ              5\r
394 \r
395 // planes (x&~1) and (x&~1)+1 are allways opposites\r
396 \r
397 typedef struct\r
398 {\r
399         float   normal[3];\r
400         float   dist;\r
401         int             type;           // PLANE_X - PLANE_ANYZ ?remove? trivial to regenerate\r
402 } dplane_t;\r
403 \r
404 \r
405 // contents flags are seperate bits\r
406 // a given brush can contribute multiple content bits\r
407 // multiple brushes can be in a single leaf\r
408 \r
409 // these definitions also need to be in q_shared.h!\r
410 \r
411 // lower bits are stronger, and will eat weaker brushes completely\r
412 #define CONTENTS_SOLID                  1               // an eye is never valid in a solid\r
413 #define CONTENTS_WINDOW                 2               // translucent, but not watery\r
414 #define CONTENTS_AUX                    4\r
415 #define CONTENTS_LAVA                   8\r
416 #define CONTENTS_SLIME                  16\r
417 #define CONTENTS_WATER                  32\r
418 #define CONTENTS_MIST                   64\r
419 #define LAST_VISIBLE_CONTENTS   64\r
420 \r
421 // remaining contents are non-visible, and don't eat brushes\r
422 \r
423 #define CONTENTS_AREAPORTAL             0x8000\r
424 \r
425 #define CONTENTS_PLAYERCLIP             0x10000\r
426 #define CONTENTS_MONSTERCLIP    0x20000\r
427 \r
428 // currents can be added to any other contents, and may be mixed\r
429 #define CONTENTS_CURRENT_0              0x40000\r
430 #define CONTENTS_CURRENT_90             0x80000\r
431 #define CONTENTS_CURRENT_180    0x100000\r
432 #define CONTENTS_CURRENT_270    0x200000\r
433 #define CONTENTS_CURRENT_UP             0x400000\r
434 #define CONTENTS_CURRENT_DOWN   0x800000\r
435 \r
436 #define CONTENTS_ORIGIN                 0x1000000       // removed before bsping an entity\r
437 \r
438 #define CONTENTS_MONSTER                0x2000000       // should never be on a brush, only in game\r
439 #define CONTENTS_DEADMONSTER    0x4000000\r
440 #define CONTENTS_DETAIL                 0x8000000       // brushes to be added after vis leafs\r
441 #define CONTENTS_TRANSLUCENT    0x10000000      // auto set if any surface has trans\r
442 #define CONTENTS_LADDER                 0x20000000\r
443 \r
444 \r
445 \r
446 #define SURF_LIGHT              0x1             // value will hold the light strength\r
447 \r
448 #define SURF_SLICK              0x2             // effects game physics\r
449 \r
450 #define SURF_SKY                0x4             // don't draw, but add to skybox\r
451 #define SURF_WARP               0x8             // turbulent water warp\r
452 #define SURF_TRANS33    0x10\r
453 #define SURF_TRANS66    0x20\r
454 #define SURF_FLOWING    0x40    // scroll towards angle\r
455 #define SURF_NODRAW             0x80    // don't bother referencing the texture\r
456 \r
457 #define SURF_HINT               0x100   // make a primary bsp splitter\r
458 #define SURF_SKIP               0x200   // completely ignore, allowing non-closed brushes\r
459 \r
460 \r
461 \r
462 typedef struct\r
463 {\r
464         int                     planenum;\r
465         int                     children[2];    // negative numbers are -(leafs+1), not nodes\r
466         short           mins[3];                // for frustom culling\r
467         short           maxs[3];\r
468         unsigned short  firstface;\r
469         unsigned short  numfaces;       // counting both sides\r
470 } dnode_t;\r
471 \r
472 \r
473 typedef struct texinfo_s\r
474 {\r
475         float           vecs[2][4];             // [s/t][xyz offset]\r
476         int                     flags;                  // miptex flags + overrides\r
477         int                     value;                  // light emission, etc\r
478         char            texture[32];    // texture name (textures/*.wal)\r
479         int                     nexttexinfo;    // for animations, -1 = end of chain\r
480 } texinfo_t;\r
481 \r
482 \r
483 // note that edge 0 is never used, because negative edge nums are used for\r
484 // counterclockwise use of the edge in a face\r
485 typedef struct\r
486 {\r
487         unsigned short  v[2];           // vertex numbers\r
488 } dedge_t;\r
489 \r
490 #define MAXLIGHTMAPS    4\r
491 typedef struct\r
492 {\r
493         unsigned short  planenum;\r
494         short           side;\r
495 \r
496         int                     firstedge;              // we must support > 64k edges\r
497         short           numedges;       \r
498         short           texinfo;\r
499 \r
500 // lighting info\r
501         byte            styles[MAXLIGHTMAPS];\r
502         int                     lightofs;               // start of [numstyles*surfsize] samples\r
503 } dface_t;\r
504 \r
505 typedef struct\r
506 {\r
507         int                             contents;                       // OR of all brushes (not needed?)\r
508 \r
509         short                   cluster;\r
510         short                   area;\r
511 \r
512         short                   mins[3];                        // for frustum culling\r
513         short                   maxs[3];\r
514 \r
515         unsigned short  firstleafface;\r
516         unsigned short  numleaffaces;\r
517 \r
518         unsigned short  firstleafbrush;\r
519         unsigned short  numleafbrushes;\r
520 } dleaf_t;\r
521 \r
522 typedef struct\r
523 {\r
524         unsigned short  planenum;               // facing out of the leaf\r
525         short   texinfo;\r
526 } dbrushside_t;\r
527 \r
528 typedef struct\r
529 {\r
530         int                     firstside;\r
531         int                     numsides;\r
532         int                     contents;\r
533 } dbrush_t;\r
534 \r
535 #define ANGLE_UP        -1\r
536 #define ANGLE_DOWN      -2\r
537 \r
538 \r
539 // the visibility lump consists of a header with a count, then\r
540 // byte offsets for the PVS and PHS of each cluster, then the raw\r
541 // compressed bit vectors\r
542 #define DVIS_PVS        0\r
543 #define DVIS_PHS        1\r
544 typedef struct\r
545 {\r
546         int                     numclusters;\r
547         int                     bitofs[8][2];   // bitofs[numclusters][2]\r
548 } dvis_t;\r
549 \r
550 // each area has a list of portals that lead into other areas\r
551 // when portals are closed, other areas may not be visible or\r
552 // hearable even if the vis info says that it should be\r
553 typedef struct\r
554 {\r
555         int             portalnum;\r
556         int             otherarea;\r
557 } dareaportal_t;\r
558 \r
559 typedef struct\r
560 {\r
561         int             numareaportals;\r
562         int             firstareaportal;\r
563 } darea_t;\r