2 Copyright (C) 1999-2007 id Software, Inc. and contributors.
3 For a list of contributors, see the accompanying CONTRIBUTORS file.
5 This file is part of GtkRadiant.
7 GtkRadiant is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 GtkRadiant is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GtkRadiant; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
32 typedef int bool; // leo
43 typedef unsigned char UInt8;
44 typedef unsigned short UInt16;
45 typedef unsigned long UInt32;
46 typedef float Float32;
47 typedef double Float64;
48 #define MAX(a, b) (((a) > (b)) ? (a) : (b))
49 #define MIN(a, b) (((a) < (b)) ? (a) : (b))
50 #define RANDOM(x) (random() % (x))
51 #define RANDOMIZE() srand((int) time(NULL))
53 #define FTYPE_UNKNOWN 0
54 #define FTYPE_IWAD 1 /* .wad "IWAD" */
55 #define FTYPE_PWAD 2 /* .wad "PWAD" */
56 #define FTYPE_PACK 3 /* .pak "PACK" */
57 #define FTYPE_WAD2 4 /* .wad "WAD2" */
58 #define FTYPE_BSP 10 /* .bsp (0x17 0x00 0x00 0x00) */
59 #define FTYPE_MODEL 11 /* .mdl "IDPO" */
60 #define FTYPE_SPRITE 12 /* .spr "IDSP" */
61 #define FTYPE_WAV 20 /* .wav "RIFF" */
62 #define FTYPE_AU 21 /* .au ".snd" */
63 #define FTYPE_VOC 22 /* .voc ? */
64 #define FTYPE_PBM_ASC 30 /* .pbm "P1" */
65 #define FTYPE_PGM_ASC 31 /* .pgm "P2" */
66 #define FTYPE_PPM_ASC 32 /* .ppm "P3" */
67 #define FTYPE_PBM_RAW 33 /* .pbm "P4" */
68 #define FTYPE_PGM_RAW 34 /* .pgm "P5" */
69 #define FTYPE_PPM_RAW 35 /* .ppm "P6" */
70 #define FTYPE_BMP 36 /* .bmp "BM" */
71 #define FTYPE_GIF 37 /* .gif "GIF8" */
72 #define FTYPE_PCX 38 /* .pcx (0x0a 0x05 0x01 0x08) */
73 #define FTYPE_ERROR -1
76 Bool ReadInt16 (FILE *file, UInt16 huge *x);
77 Bool ReadInt32 (FILE *file, UInt32 huge *x);
78 Bool ReadFloat32 (FILE *file, Float32 huge *x);
79 Bool WriteInt16 (FILE *file, UInt16 huge *x);
80 Bool WriteInt32 (FILE *file, UInt32 huge *x);
81 Bool WriteFloat32 (FILE *file, Float32 huge *x);
82 UInt16 SwapInt16 (UInt16 x);
83 UInt32 SwapInt32 (UInt32 x);
84 Float32 SwapFloat32 (Float32 x);
86 #define ReadInt16(f, p) ReadBytes((f), (p), 2L)
87 #define ReadInt32(f, p) ReadBytes((f), (p), 4L)
88 #define ReadFloat32(f, p) ReadBytes((f), (p), 4L)
89 #define WriteInt16(f, p) WriteBytes((f), (p), 2L)
90 #define WriteInt32(f, p) WriteBytes((f), (p), 4L)
91 #define WriteFloat32(f, p) WriteBytes((f), (p), 4L)
92 #define SwapInt16(x) (x)
93 #define SwapInt32(x) (x)
94 #define SwapFloat32(x) (x)
95 #endif /* FAT_ENDIAN */
100 char name[56]; /* name of file */
101 UInt32 offset; /* offset to start of data */
102 UInt32 size; /* byte size of data */
104 typedef struct PACKDirectory *PACKDirPtr;
106 typedef struct DirListStruct
110 struct DirListStruct *next;
113 typedef struct FileListStruct
118 struct FileListStruct *next;
121 typedef struct DirStruct
125 struct DirStruct *next;
129 extern int m_nPAKIndex;
130 extern FILE* pakfile[16];
132 extern DIRECTORY *paktextures;
134 void ClearFileList (FILELIST **);
135 void ClearDirList (DIRLIST **);
136 bool GetPackFileList (FILELIST **, char *);
137 bool GetPackTextureDirs (DIRLIST **);
138 bool AddToDirListAlphabetized (DIRLIST **, char *, int);
139 bool AddToFileListAlphabetized (FILELIST **t, char *, UInt32, UInt32, bool);
140 bool PakLoadFile (const char *, void **);
141 void OpenPakFile (const char *);
142 void ClosePakFile (void);
143 int PakLoadAnyFile(const char *filename, void **bufferptr);
144 void WINAPI InitPakFile(const char * pBasePath, const char *pName);