1 /*
2 Copyright (C) 1997-2001 Id Software, Inc.
3 
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
8 
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 
13 See the GNU General Public License for more details.
14 
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 */
19 
20 #ifndef __FILES_H__
21 #define __FILES_H__
22 
23 //
24 // files.h: quake file formats
25 // This file must be identical in the quake and utils directories
26 //
27 
28 /*
29 =============================================================================
30 
31 	PAK FILE FORMAT
32 
33 	The .pak files are just a linear collapse of a directory tree
34 =============================================================================
35 */
36 
37 #define PAK_HEADER		(('K'<<24)+('C'<<16)+('A'<<8)+'P')	// little-endian "PACK"
38 #define PAK_HEADERSTR	"PACK"
39 
40 #define PAK_MAX_FILES	4096
41 
42 typedef struct dPackFile_s {
43 	char		name[56];
44 
45 	int			filePos;
46 	int			fileLen;
47 } dPackFile_t;
48 
49 typedef struct dPackHeader_s {
50 	int			ident;		// == PAK_HEADER
51 	int			dirOfs;
52 	int			dirLen;
53 } dPackHeader_t;
54 
55 /*
56 =============================================================================
57 
58 	PKZ FILE FORMAT
59 
60 	Essentially a zip file, PK2/PK3/PK4 are evidentally the same
61 =============================================================================
62 */
63 
64 #define PKZ_MAX_FILES	32768
65 
66 /*
67 =============================================================================
68 
69 	PCX IMAGE FILE FORMAT
70 
71 =============================================================================
72 */
73 
74 typedef struct pcxHeader_s {
75 	char				manufacturer;
76 	char				version;
77 	char				encoding;
78 	char				bitsPerPixel;
79 
80 	uint16				xMin, yMin, xMax, yMax;
81 	uint16				hRes, vRes;
82 	byte				palette[48];
83 
84 	char				reserved;
85 	char				colorPlanes;
86 
87 	uint16				bytesPerLine;
88 	uint16				paletteType;
89 
90 	char				filler[58];
91 
92 	byte				data;			// unbounded
93 } pcxHeader_t;
94 
95 /*
96 ==============================================================================
97 
98 	TGA IMAGE FILE FORMAT
99 
100 ==============================================================================
101 */
102 
103 typedef struct tgaHeader_s {
104 	byte	idLength;
105 	byte	colorMapType;
106 	byte	imageType;
107 
108 	uint16	colorMapIndex;
109 	uint16	colorMapLength;
110 	byte	colorMapSize;
111 
112 	uint16	xOrigin;
113 	uint16	yOrigin;
114 	uint16	width;
115 	uint16	height;
116 
117 	byte	pixelSize;
118 
119 	byte	attributes;
120 } tgaHeader_t;
121 
122 /*
123 ==============================================================================
124 
125 	WAL IMAGE FILE FORMAT
126 
127 ==============================================================================
128 */
129 
130 typedef struct walTex_s {
131 	char		name[32];
132 	uint32		width;
133 	uint32		height;
134 	uint32		offsets[4];				// four mip maps stored
135 	char		animName[32];			// next frame in animation chain
136 	int			flags;
137 	int			contents;
138 	int			value;
139 } walTex_t;
140 
141 /*
142 =============================================================================
143 
144 	MD2 MODEL FILE FORMAT
145 
146 =============================================================================
147 */
148 
149 #define MD2_HEADER		(('2'<<24)+('P'<<16)+('D'<<8)+'I')	// little-endian "IDP2"
150 #define MD2_HEADERSTR	"IDP2"
151 
152 #define MD2_MODEL_VERSION	8
153 
154 #define MD2_MAX_TRIANGLES	4096
155 #define MD2_MAX_VERTS		2048
156 #define MD2_MAX_FRAMES		512
157 #define MD2_MAX_SKINS		32
158 #define MD2_MAX_SKINNAME	64
159 
160 typedef struct dMd2Coord_s {
161 	int16			s;
162 	int16			t;
163 } dMd2Coord_t;
164 
165 typedef struct dMd2Triangle_s {
166 	int16			vertsIndex[3];
167 	int16			stIndex[3];
168 } dMd2Triangle_t;
169 
170 #define DTRIVERTX_V0   0
171 #define DTRIVERTX_V1   1
172 #define DTRIVERTX_V2   2
173 #define DTRIVERTX_LNI  3
174 #define DTRIVERTX_SIZE 4
175 
176 typedef struct dMd2TriVertX_s {
177 	byte			v[3];			// scaled byte to fit in frame mins/maxs
178 	byte			normalIndex;
179 } dMd2TriVertX_t;
180 
181 typedef struct dMd2Frame_s {
182 	float			scale[3];		// multiply byte verts by this
183 	float			translate[3];	// then add this
184 	char			name[16];		// frame name from grabbing
185 	dMd2TriVertX_t	verts[1];		// variable sized
186 } dMd2Frame_t;
187 
188 // the glcmd format:
189 // a positive integer starts a tristrip command, followed by that many
190 // vertex structures.
191 // a negative integer starts a trifan command, followed by -x vertexes
192 // a zero indicates the end of the command list.
193 // a vertex consists of a floating point s, a floating point t,
194 // and an integer vertex index.
195 
196 typedef struct dMd2Header_s {
197 	int				ident;
198 	int				version;
199 
200 	int				skinWidth;
201 	int				skinHeight;
202 	int				frameSize;		// byte size of each frame
203 
204 	int				numSkins;
205 	int				numVerts;
206 	int				numST;			// greater than numVerts for seams
207 	int				numTris;
208 	int				numGLCmds;		// dwords in strip/fan command list
209 	int				numFrames;
210 
211 	int				ofsSkins;		// each skin is a MD2_MAX_SKINNAME string
212 	int				ofsST;			// byte offset from start for stverts
213 	int				ofsTris;		// offset for dtriangles
214 	int				ofsFrames;		// offset for first frame
215 	int				ofsGLCmds;
216 	int				ofsEnd;			// end of file
217 } dMd2Header_t;
218 
219 /*
220 =============================================================================
221 
222 	MD3 MODEL FILE FORMAT
223 
224 =============================================================================
225 */
226 
227 #define MD3_HEADER		(('3'<<24)+('P'<<16)+('D'<<8)+'I')	// little-endian "IDP3"
228 #define MD3_HEADERSTR	"IDP3"
229 
230 #define MD3_MODEL_VERSION	15
231 
232 #define MD3_MAX_TRIANGLES	8192		// per mesh
233 #define MD3_MAX_VERTS		4096		// per mesh
234 #define MD3_MAX_SHADERS		256			// per mesh
235 #define MD3_MAX_FRAMES		1024		// per model
236 #define MD3_MAX_MESHES		32			// per model
237 #define MD3_MAX_TAGS		16			// per frame
238 
239 #define MD3_XYZ_SCALE		(1.0f/64)	// vertex scales
240 
241 typedef struct dMd3Coord_s {
242 	float			st[2];
243 } dMd3Coord_t;
244 
245 typedef struct dMd3Vertex_s {
246 	int16			point[3];
247 	byte			norm[2];
248 } dMd3Vertex_t;
249 
250 typedef struct dMd3Frame_s {
251 	vec3_t			mins;
252 	vec3_t			maxs;
253 
254 	vec3_t			translate;
255 	float			radius;
256 	char			creator[16];
257 } dMd3Frame_t;
258 
259 typedef struct dMd3Tag_s {
260 	char			tagName[MAX_QPATH];
261 	float			origin[3];
262 	float			axis[3][3];
263 } dMd3Tag_t;
264 
265 typedef struct dMd3Skin_s {
266 	char			name[MAX_QPATH];
267 	int				unused;					// shader
268 } dMd3Skin_t;
269 
270 typedef struct dMd3Mesh_s {
271 	char			ident[4];
272 
273 	char			meshName[MAX_QPATH];
274 
275 	int				flags;
276 
277 	int				numFrames;
278 	int				numSkins;
279 	int				numVerts;
280 	int				numTris;
281 
282 	int				ofsIndexes;
283 	int				ofsSkins;
284 	int				ofsTCs;
285 	int				ofsVerts;
286 
287 	int				meshSize;
288 } dMd3Mesh_t;
289 
290 typedef struct dMd3Header_s {
291 	int				ident;
292 	int				version;
293 
294 	char			fileName[MAX_QPATH];
295 
296 	int				flags;
297 
298 	int				numFrames;
299 	int				numTags;
300 	int				numMeshes;
301 	int				numSkins;
302 
303 	int				ofsFrames;
304 	int				ofsTags;
305 	int				ofsMeshes;
306 	int				ofsEnd;
307 } dMd3Header_t;
308 
309 /*
310 =============================================================================
311 
312 	SP2 SPRITE MODEL FILE FORMAT
313 
314 =============================================================================
315 */
316 
317 #define SP2_HEADER		(('2'<<24)+('S'<<16)+('D'<<8)+'I')	// little-endian "IDS2"
318 #define SP2_HEADERSTR	"IDS2"
319 
320 #define SP2_VERSION		2
321 
322 #define SP2_MAX_FRAMES	32
323 
324 typedef struct dSpriteFrame_s {
325 	int			width;
326 	int			height;
327 
328 	// raster coordinates inside pic
329 	int			originX;
330 	int			originY;
331 
332 	char		name[MAX_QPATH];			// name of pcx file
333 } dSpriteFrame_t;
334 
335 typedef struct dSpriteHeader_s {
336 	int				ident;
337 	int				version;
338 
339 	int				numFrames;
340 	dSpriteFrame_t	frames[SP2_MAX_FRAMES];	// variable sized
341 } dSpriteHeader_t;
342 
343 /*
344 =============================================================================
345 
346 	BSP FILE FORMAT COMMON
347 
348 =============================================================================
349 */
350 
351 // Key / value pair sizes
352 #define MAX_KEY					32
353 #define MAX_VALUE				1024
354 
355 /*
356 =============================================================================
357 
358 	QUAKE2 BSP FILE FORMAT
359 
360 =============================================================================
361 */
362 
363 // Header information
364 #define Q2BSP_HEADER	"IBSP"
365 #define Q2BSP_VERSION	38
366 
367 // Upper design bounds
368 // leaffaces, leafbrushes, planes, and verts are still bounded by 16 bit int16(short) limits
369 #define Q2BSP_MAX_MODELS		1024
370 #define Q2BSP_MAX_BRUSHES		8192
371 #define Q2BSP_MAX_ENTITIES		2048
372 #define Q2BSP_MAX_ENTSTRING		0x40000
373 #define Q2BSP_MAX_TEXINFO		8192
374 
375 #define Q2BSP_MAX_AREAPORTALS	1024
376 #define Q2BSP_MAX_PLANES		65536
377 #define Q2BSP_MAX_NODES			65536
378 #define Q2BSP_MAX_BRUSHSIDES	65536
379 #define Q2BSP_MAX_LEAFS			65536
380 #define Q2BSP_MAX_VERTS			65536
381 #define Q2BSP_MAX_FACES			65536
382 #define Q2BSP_MAX_LEAFFACES		65536
383 #define Q2BSP_MAX_LEAFBRUSHES	65536
384 #define Q2BSP_MAX_PORTALS		65536
385 #define Q2BSP_MAX_EDGES			128000
386 #define Q2BSP_MAX_SURFEDGES		256000
387 #define Q2BSP_MAX_LIGHTING		0x200000
388 #define Q2BSP_MAX_VISIBILITY	0x100000
389 
390 #define Q2BSP_MAX_VIS			8192	// (Q2BSP_MAX_LEAFS / 8)
391 #define Q2BSP_MAX_LIGHTMAPS		4
392 
393 // ==========================================================================
394 
395 #define Q2BSP_LUMP_ENTITIES		0
396 #define Q2BSP_LUMP_PLANES		1
397 #define Q2BSP_LUMP_VERTEXES		2
398 #define Q2BSP_LUMP_VISIBILITY	3
399 #define Q2BSP_LUMP_NODES		4
400 #define Q2BSP_LUMP_TEXINFO		5
401 #define Q2BSP_LUMP_FACES		6
402 #define Q2BSP_LUMP_LIGHTING		7
403 #define Q2BSP_LUMP_LEAFS		8
404 #define Q2BSP_LUMP_LEAFFACES	9
405 #define Q2BSP_LUMP_LEAFBRUSHES	10
406 #define Q2BSP_LUMP_EDGES		11
407 #define Q2BSP_LUMP_SURFEDGES	12
408 #define Q2BSP_LUMP_MODELS		13
409 #define Q2BSP_LUMP_BRUSHES		14
410 #define Q2BSP_LUMP_BRUSHSIDES	15
411 #define Q2BSP_LUMP_POP			16
412 #define Q2BSP_LUMP_AREAS		17
413 #define Q2BSP_LUMP_AREAPORTALS	18
414 #define Q2BSP_LUMP_TOTAL		19
415 
416 typedef struct dQ2BspLump_s {
417 	int				fileOfs;
418 	int				fileLen;
419 } dQ2BspLump_t;
420 
421 typedef struct dQ2BspHeader_s {
422 	int				ident;
423 	int				version;
424 
425 	dQ2BspLump_t	lumps[Q2BSP_LUMP_TOTAL];
426 } dQ2BspHeader_t;
427 
428 typedef struct dQ2BspModel_s {
429 	float			mins[3], maxs[3];
430 
431 	float			origin[3];		// for sounds or lights
432 
433 	int				headNode;
434 
435 	int				firstFace;	// submodels just draw faces
436 	int				numFaces;	// without walking the bsp tree
437 } dQ2BspModel_t;
438 
439 typedef struct dQ2BspVertex_s {
440 	float			point[3];
441 } dQ2BspVertex_t;
442 
443 // planes (x&~1) and (x&~1)+1 are always opposites
444 typedef struct dQ2BspPlane_s {
445 	float			normal[3];
446 	float			dist;
447 	int				type;		// PLANE_X - PLANE_ANYZ ?remove? trivial to regenerate
448 } dQ2BspPlane_t;
449 
450 typedef struct dQ2BspNode_s {
451 	int				planeNum;
452 	int				children[2];	// negative numbers are -(leafs+1), not nodes
453 	int16			mins[3];		// for frustom culling
454 	int16			maxs[3];
455 	uint16			firstFace;
456 	uint16			numFaces;	// counting both sides
457 } dQ2BspNode_t;
458 
459 typedef struct dQ2BspTexInfo_s {
460 	float			vecs[2][4];		// [s/t][xyz offset]
461 	int				flags;			// miptex flags + overrides
462 	int				value;			// light emission, etc
463 	char			texture[32];	// texture name (textures/*.wal)
464 	int				nextTexInfo;	// for animations, -1 = end of chain
465 } dQ2BspTexInfo_t;
466 
467 // note that edge 0 is never used, because negative edge nums are used for
468 // counterclockwise use of the edge in a face
469 typedef struct dQ2BspEdge_s {
470 	uint16			v[2];		// vertex numbers
471 } dQ2BspEdge_t;
472 
473 typedef struct dQ2BspSurface_s {
474 	uint16			planeNum;
475 	int16			side;
476 
477 	int				firstEdge;		// we must support > 64k edges
478 	int16			numEdges;
479 	int16			texInfo;
480 
481 	// lighting info
482 	byte			styles[Q2BSP_MAX_LIGHTMAPS];
483 	int				lightOfs;		// start of [numstyles*surfsize] samples
484 } dQ2BspSurface_t;
485 
486 typedef struct dQ2BspLeaf_s {
487 	int				contents;			// OR of all brushes (not needed?)
488 
489 	int16			cluster;
490 	int16			area;
491 
492 	int16			mins[3];			// for frustum culling
493 	int16			maxs[3];
494 
495 	uint16			firstLeafFace;
496 	uint16			numLeafFaces;
497 
498 	uint16			firstLeafBrush;
499 	uint16			numLeafBrushes;
500 } dQ2BspLeaf_t;
501 
502 typedef struct dQ2BspBrushSide_s {
503 	uint16			planeNum;		// facing out of the leaf
504 	int16			texInfo;
505 } dQ2BspBrushSide_t;
506 
507 typedef struct dQ2BspBrush_s {
508 	int				firstSide;
509 	int				numSides;
510 	int				contents;
511 } dQ2BspBrush_t;
512 
513 // the visibility lump consists of a header with a count, then byte offsets for
514 // the PVS and PHS of each cluster, then the raw compressed bit vectors
515 #define Q2BSP_VIS_PVS	0
516 #define Q2BSP_VIS_PHS	1
517 typedef struct dQ2BspVis_s {
518 	int				numClusters;
519 	int				bitOfs[8][2];	// bitofs[numclusters][2]
520 } dQ2BspVis_t;
521 
522 // each area has a list of portals that lead into other areas when portals are closed,
523 // other areas may not be visible or hearable even if the vis info says that it should be
524 typedef struct dQ2BspAreaPortal_s {
525 	int				portalNum;
526 	int				otherArea;
527 } dQ2BspAreaPortal_t;
528 
529 typedef struct dQ2BspArea_s {
530 	int				numAreaPortals;
531 	int				firstAreaPortal;
532 } dQ2BspArea_t;
533 
534 /*
535 =============================================================================
536 
537 	QUAKE3 BSP FILE FORMAT
538 
539 =============================================================================
540 */
541 
542 // Header information
543 #define Q3BSP_HEADER	"IBSP"
544 #define Q3BSP_VERSION	46
545 
546 // Lightmap information
547 #define Q3LIGHTMAP_WIDTH	128				// lightmaps are square
548 #define Q3LIGHTMAP_BYTES	3
549 #define Q3LIGHTMAP_SIZE		(Q3LIGHTMAP_WIDTH*Q3LIGHTMAP_WIDTH*3)
550 
551 // There shouldn't be any problem with increasing these values at the
552 // expense of more memory allocation in the utilities
553 #define Q3BSP_MAX_MODELS		0x400	// Same as Q2BSP_MAX_MODELS
554 #define Q3BSP_MAX_BRUSHES		0x8000
555 #define Q3BSP_MAX_ENTITIES		0x800
556 #define Q3BSP_MAX_ENTSTRING		0x40000
557 #define Q3BSP_MAX_SHADERS		0x400
558 
559 #define Q3BSP_MAX_AREAS			0x100
560 #define Q3BSP_MAX_FOGS			0x100
561 #define Q3BSP_MAX_PLANES		0x20000
562 #define Q3BSP_MAX_NODES			0x20000
563 #define Q3BSP_MAX_BRUSHSIDES	0x30000
564 #define Q3BSP_MAX_LEAFS			0x20000
565 #define Q3BSP_MAX_VERTEXES		0x80000
566 #define Q3BSP_MAX_FACES			0x20000
567 #define Q3BSP_MAX_LEAFFACES		0x40000	// Increased from 0x20000...
568 #define Q3BSP_MAX_LEAFBRUSHES	0x40000
569 #define Q3BSP_MAX_PORTALS		0x20000
570 #define Q3BSP_MAX_INDICES		0x80000
571 #define Q3BSP_MAX_LIGHTING		0x800000
572 #define Q3BSP_MAX_VISIBILITY	0x200000
573 
574 #define Q3BSP_MAX_VIS			(Q3BSP_MAX_LEAFS/8)
575 #define Q3BSP_MAX_LIGHTMAPS		4
576 
577 // ==========================================================================
578 
579 #define Q3BSP_LUMP_ENTITIES		0
580 #define Q3BSP_LUMP_SHADERREFS	1
581 #define Q3BSP_LUMP_PLANES		2
582 #define Q3BSP_LUMP_NODES		3
583 #define Q3BSP_LUMP_LEAFS		4
584 #define Q3BSP_LUMP_LEAFFACES	5
585 #define Q3BSP_LUMP_LEAFBRUSHES	6
586 #define Q3BSP_LUMP_MODELS		7
587 #define Q3BSP_LUMP_BRUSHES		8
588 #define Q3BSP_LUMP_BRUSHSIDES	9
589 #define Q3BSP_LUMP_VERTEXES		10
590 #define Q3BSP_LUMP_INDEXES		11
591 #define Q3BSP_LUMP_FOGS			12
592 #define Q3BSP_LUMP_FACES		13
593 #define Q3BSP_LUMP_LIGHTING		14
594 #define Q3BSP_LUMP_LIGHTGRID	15
595 #define Q3BSP_LUMP_VISIBILITY	16
596 #define Q3BSP_LUMP_LIGHTARRAY	17
597 #define Q3BSP_LUMP_TOTAL		17		// 16 for IDBSP
598 
599 typedef struct dQ3BspLump_s {
600 	int				fileOfs;
601 	int				fileLen;
602 } dQ3BspLump_t;
603 
604 typedef struct dQ3BspHeader_t {
605 	int				ident;
606 	int				version;
607 
608 	dQ3BspLump_t	lumps[Q3BSP_LUMP_TOTAL];
609 } dQ3BspHeader_t;
610 
611 typedef struct dQ3BspModel_s {
612 	float			mins[3], maxs[3];
613 	int				firstFace, numFaces;	// submodels just draw faces
614 											// without walking the bsp tree
615     int				firstBrush, numBrushes;
616 } dQ3BspModel_t;
617 
618 typedef struct dQ3BspVertex_s {
619 	float			point[3];
620     float			texCoords[2];		// texture coords
621 	float			lmCoords[2];		// lightmap texture coords
622     float			normal[3];			// normal
623     byte			color[4];			// color used for vertex lighting
624 } dQ3BspVertex_t;
625 
626 // planes (x&~1) and (x&~1)+1 are always opposites
627 typedef struct dQ3BspPlane_s {
628 	float	normal[3];
629 	float	dist;
630 } dQ3BspPlane_t;
631 
632 typedef struct dQ3BspNode_s {
633 	int				planeNum;
634 	int				children[2];	// negative numbers are -(leafs+1), not nodes
635 	int				mins[3];		// for frustum culling
636 	int				maxs[3];
637 } dQ3BspNode_t;
638 
639 typedef struct dQ3BspShaderRef_s {
640 	char			name[MAX_QPATH];
641 	int				flags;
642 	int				contents;
643 } dQ3BspShaderRef_t;
644 
645 enum {
646 	FACETYPE_PLANAR   = 1,
647 	FACETYPE_PATCH    = 2,
648 	FACETYPE_TRISURF  = 3,
649 	FACETYPE_FLARE    = 4
650 };
651 
652 typedef struct dQ3BspFace_s {
653 	int				shaderNum;
654 	int				fogNum;
655 	int				faceType;
656 
657     int				firstVert;
658 	int				numVerts;
659 	uint32			firstIndex;
660 	int				numIndexes;
661 
662     int				lmTexNum;		// lightmap info
663     int				lmOffset[2];
664     int				lmSize[2];
665 
666     float			origin[3];		// FACETYPE_FLARE only
667 
668     float			mins[3];
669     float			maxs[3];		// FACETYPE_PATCH and FACETYPE_TRISURF only
670     float			normal[3];		// FACETYPE_PLANAR only
671 
672     int				patch_cp[2];	// patch control point dimensions
673 } dQ3BspFace_t;
674 
675 typedef struct dQ3BspLeaf_s {
676 	int				cluster;
677 	int				area;
678 
679 	int				mins[3];
680 	int				maxs[3];
681 
682 	int				firstLeafFace;
683 	int				numLeafFaces;
684 
685 	int				firstLeafBrush;
686 	int				numLeafBrushes;
687 } dQ3BspLeaf_t;
688 
689 typedef struct dQ3BspBrushSide_s {
690 	int				planeNum;
691 	int				shaderNum;
692 } dQ3BspBrushSide_t;
693 
694 typedef struct dQ3BspBrush_s {
695 	int				firstSide;
696 	int				numSides;
697 	int				shaderNum;
698 } dQ3BspBrush_t;
699 
700 typedef struct dQ3BspFog_s {
701 	char			shader[MAX_QPATH];
702 	int				brushNum;
703 	int				visibleSide;
704 } dQ3BspFog_t;
705 
706 typedef struct dQ3BspVis_s {
707 	int				numClusters;
708 	int				rowSize;
709 	byte			data[1];
710 } dQ3BspVis_t;
711 
712 typedef struct dQ3BspGridLight_s {
713 	byte			ambient[3];
714 	byte			diffuse[3];
715 	byte			direction[2];
716 } dQ3BspGridLight_t;
717 
718 /*
719 =============================================================================
720 
721 	FUNCTIONS
722 
723 =============================================================================
724 */
725 
726 #define FS_FreeFile(buffer) _FS_FreeFile ((buffer),__FILE__,__LINE__)
727 #define FS_FreeFileList(list,num) _FS_FreeFileList ((list),(num),__FILE__,__LINE__)
728 
729 int			FS_ZLibDecompress (byte *in, int inlen, byte *out, int outlen, int wbits);
730 int			FS_ZLibCompressChunk (byte *in, int len_in, byte *out, int len_out, int method, int wbits);
731 
732 void		FS_CreatePath (char *path);
733 void		FS_CopyFile (char *src, char *dst);
734 
735 int			FS_FileLength (fileHandle_t fileNum);
736 int			FS_Tell (fileHandle_t fileNum);
737 
738 int			FS_Read (void *buffer, int len, fileHandle_t fileNum);
739 int			FS_Write (void *buffer, int size, fileHandle_t fileNum);
740 void		FS_Seek (fileHandle_t fileNum, int offset, fsSeekOrigin_t seekOrigin);
741 int			FS_OpenFile (char *fileName, fileHandle_t *fileNum, fsOpenMode_t openMode);
742 void		FS_CloseFile (fileHandle_t fileNum);
743 
744 int			FS_LoadFile (char *path, void **buffer, char *terminate);
745 void		_FS_FreeFile (void *buffer, const char *fileName, const int fileLine);
746 
747 int			FS_FileExists (char *path);
748 
749 char		*FS_Gamedir (void);
750 void		FS_SetGamedir (char *dir, qBool firstTime);
751 
752 void		FS_ExecAutoexec (void);
753 
754 int			FS_FindFiles (char *path, char *filter, char *extension, char **fileList, int maxFiles, qBool addGameDir, qBool recurse);
755 void		_FS_FreeFileList (char **list, int num, const char *fileName, const int fileLine);
756 
757 char		*FS_NextPath (char *prevPath);
758 
759 void		FS_Init (void);
760 
761 #endif // __FILES_H__
762