pakstuff.h (4596B)
1 /* 2 =========================================================================== 3 Copyright (C) 1999-2005 Id Software, Inc. 4 5 This file is part of Quake III Arena source code. 6 7 Quake III Arena source code is free software; you can redistribute it 8 and/or modify it under the terms of the GNU General Public License as 9 published by the Free Software Foundation; either version 2 of the License, 10 or (at your option) any later version. 11 12 Quake III Arena source code is distributed in the hope that it will be 13 useful, 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. 16 17 You should have received a copy of the GNU General Public License 18 along with Foobar; if not, write to the Free Software 19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 =========================================================================== 21 */ 22 #ifndef _PAKSTUFF_H_ 23 #define _PAKSTUFF_H_ 24 25 #include <windows.h> 26 #ifdef __cplusplus 27 extern "C" 28 { 29 #endif 30 31 typedef char Int8; 32 typedef short Int16; 33 typedef long Int32; 34 typedef unsigned char UInt8; 35 typedef unsigned short UInt16; 36 typedef unsigned long UInt32; 37 typedef float Float32; 38 typedef double Float64; 39 #define MAX(a, b) (((a) > (b)) ? (a) : (b)) 40 #define MIN(a, b) (((a) < (b)) ? (a) : (b)) 41 #define RANDOM(x) (random() % (x)) 42 #define RANDOMIZE() srand((int) time(NULL)) 43 44 #define FTYPE_UNKNOWN 0 45 #define FTYPE_IWAD 1 /* .wad "IWAD" */ 46 #define FTYPE_PWAD 2 /* .wad "PWAD" */ 47 #define FTYPE_PACK 3 /* .pak "PACK" */ 48 #define FTYPE_WAD2 4 /* .wad "WAD2" */ 49 #define FTYPE_BSP 10 /* .bsp (0x17 0x00 0x00 0x00) */ 50 #define FTYPE_MODEL 11 /* .mdl "IDPO" */ 51 #define FTYPE_SPRITE 12 /* .spr "IDSP" */ 52 #define FTYPE_WAV 20 /* .wav "RIFF" */ 53 #define FTYPE_AU 21 /* .au ".snd" */ 54 #define FTYPE_VOC 22 /* .voc ? */ 55 #define FTYPE_PBM_ASC 30 /* .pbm "P1" */ 56 #define FTYPE_PGM_ASC 31 /* .pgm "P2" */ 57 #define FTYPE_PPM_ASC 32 /* .ppm "P3" */ 58 #define FTYPE_PBM_RAW 33 /* .pbm "P4" */ 59 #define FTYPE_PGM_RAW 34 /* .pgm "P5" */ 60 #define FTYPE_PPM_RAW 35 /* .ppm "P6" */ 61 #define FTYPE_BMP 36 /* .bmp "BM" */ 62 #define FTYPE_GIF 37 /* .gif "GIF8" */ 63 #define FTYPE_PCX 38 /* .pcx (0x0a 0x05 0x01 0x08) */ 64 #define FTYPE_ERROR -1 65 66 #ifdef FAT_ENDIAN 67 Bool ReadInt16 (FILE *file, UInt16 huge *x); 68 Bool ReadInt32 (FILE *file, UInt32 huge *x); 69 Bool ReadFloat32 (FILE *file, Float32 huge *x); 70 Bool WriteInt16 (FILE *file, UInt16 huge *x); 71 Bool WriteInt32 (FILE *file, UInt32 huge *x); 72 Bool WriteFloat32 (FILE *file, Float32 huge *x); 73 UInt16 SwapInt16 (UInt16 x); 74 UInt32 SwapInt32 (UInt32 x); 75 Float32 SwapFloat32 (Float32 x); 76 #else 77 #define ReadInt16(f, p) ReadBytes((f), (p), 2L) 78 #define ReadInt32(f, p) ReadBytes((f), (p), 4L) 79 #define ReadFloat32(f, p) ReadBytes((f), (p), 4L) 80 #define WriteInt16(f, p) WriteBytes((f), (p), 2L) 81 #define WriteInt32(f, p) WriteBytes((f), (p), 4L) 82 #define WriteFloat32(f, p) WriteBytes((f), (p), 4L) 83 #define SwapInt16(x) (x) 84 #define SwapInt32(x) (x) 85 #define SwapFloat32(x) (x) 86 #endif /* FAT_ENDIAN */ 87 88 #define FROMDISK -1 89 struct PACKDirectory 90 { 91 char name[56]; /* name of file */ 92 UInt32 offset; /* offset to start of data */ 93 UInt32 size; /* byte size of data */ 94 }; 95 typedef struct PACKDirectory *PACKDirPtr; 96 97 typedef struct DirListStruct 98 { 99 char dirname[1024]; 100 int from; 101 struct DirListStruct *next; 102 } DIRLIST; 103 104 typedef struct FileListStruct 105 { 106 char filename[1024]; 107 UInt32 offset; 108 UInt32 size; 109 struct FileListStruct *next; 110 } FILELIST; 111 112 typedef struct DirStruct 113 { 114 char name[1024]; 115 FILELIST *files; 116 struct DirStruct *next; 117 } DIRECTORY; 118 119 120 extern int m_nPAKIndex; 121 extern FILE* pakfile[16]; 122 extern boolean pakopen; 123 extern DIRECTORY *paktextures; 124 125 void ClearFileList (FILELIST **); 126 void ClearDirList (DIRLIST **); 127 boolean GetPackFileList (FILELIST **, char *); 128 boolean GetPackTextureDirs (DIRLIST **); 129 boolean AddToDirListAlphabetized (DIRLIST **, char *, int); 130 boolean AddToFileListAlphabetized (FILELIST **t, char *, UInt32, UInt32, boolean); 131 boolean PakLoadFile (const char *, void **); 132 void OpenPakFile (const char *); 133 void ClosePakFile (void); 134 int PakLoadAnyFile(const char *filename, void **bufferptr); 135 void WINAPI InitPakFile(const char * pBasePath, const char *pName); 136 137 #ifdef __cplusplus 138 } 139 #endif 140 141 #endif