]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - libs/pakstuff.h
get the basics of a new scons build system together
[xonotic/netradiant.git] / libs / pakstuff.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 #ifndef _PAKSTUFF_H_\r
23 #define _PAKSTUFF_H_\r
24 \r
25 #ifndef _WIN32\r
26 #define WINAPI\r
27 #else\r
28 #include <windows.h>\r
29 #endif\r
30 \r
31 #ifndef __cplusplus\r
32 typedef int bool; // leo\r
33 #endif\r
34 \r
35 #ifdef __cplusplus\r
36 extern "C"\r
37 {\r
38 #endif\r
39 \r
40 typedef char           Int8;\r
41 typedef short          Int16;\r
42 typedef long           Int32;\r
43 typedef unsigned char  UInt8;\r
44 typedef unsigned short UInt16;\r
45 typedef unsigned long  UInt32;\r
46 typedef float          Float32;\r
47 typedef double         Float64;\r
48 #define MAX(a, b)              (((a) > (b)) ? (a) : (b))\r
49 #define MIN(a, b)              (((a) < (b)) ? (a) : (b))\r
50 #define RANDOM(x)              (random() % (x))\r
51 #define RANDOMIZE()             srand((int) time(NULL))\r
52 \r
53 #define FTYPE_UNKNOWN 0\r
54 #define FTYPE_IWAD    1    /* .wad  "IWAD" */\r
55 #define FTYPE_PWAD    2    /* .wad  "PWAD" */\r
56 #define FTYPE_PACK    3    /* .pak  "PACK" */\r
57 #define FTYPE_WAD2    4    /* .wad  "WAD2" */\r
58 #define FTYPE_BSP     10   /* .bsp  (0x17 0x00 0x00 0x00) */\r
59 #define FTYPE_MODEL   11   /* .mdl  "IDPO" */\r
60 #define FTYPE_SPRITE  12   /* .spr  "IDSP" */\r
61 #define FTYPE_WAV     20   /* .wav  "RIFF" */\r
62 #define FTYPE_AU      21   /* .au   ".snd" */\r
63 #define FTYPE_VOC     22   /* .voc  ?      */\r
64 #define FTYPE_PBM_ASC 30   /* .pbm  "P1"   */\r
65 #define FTYPE_PGM_ASC 31   /* .pgm  "P2"   */\r
66 #define FTYPE_PPM_ASC 32   /* .ppm  "P3"   */\r
67 #define FTYPE_PBM_RAW 33   /* .pbm  "P4"   */\r
68 #define FTYPE_PGM_RAW 34   /* .pgm  "P5"   */\r
69 #define FTYPE_PPM_RAW 35   /* .ppm  "P6"   */\r
70 #define FTYPE_BMP     36   /* .bmp  "BM"   */\r
71 #define FTYPE_GIF     37   /* .gif  "GIF8" */\r
72 #define FTYPE_PCX     38   /* .pcx  (0x0a 0x05 0x01 0x08) */\r
73 #define FTYPE_ERROR   -1\r
74 \r
75 #ifdef FAT_ENDIAN\r
76 Bool    ReadInt16               (FILE *file, UInt16 huge *x);\r
77 Bool    ReadInt32               (FILE *file, UInt32 huge *x);\r
78 Bool    ReadFloat32             (FILE *file, Float32 huge *x);\r
79 Bool    WriteInt16              (FILE *file, UInt16 huge *x);\r
80 Bool    WriteInt32              (FILE *file, UInt32 huge *x);\r
81 Bool    WriteFloat32    (FILE *file, Float32 huge *x);\r
82 UInt16  SwapInt16               (UInt16 x);\r
83 UInt32  SwapInt32               (UInt32 x);\r
84 Float32 SwapFloat32             (Float32 x);\r
85 #else\r
86 #define ReadInt16(f, p)         ReadBytes((f), (p), 2L)\r
87 #define ReadInt32(f, p)         ReadBytes((f), (p), 4L)\r
88 #define ReadFloat32(f, p)       ReadBytes((f), (p), 4L)\r
89 #define WriteInt16(f, p)        WriteBytes((f), (p), 2L)\r
90 #define WriteInt32(f, p)        WriteBytes((f), (p), 4L)\r
91 #define WriteFloat32(f, p)      WriteBytes((f), (p), 4L)\r
92 #define SwapInt16(x)            (x)\r
93 #define SwapInt32(x)            (x)\r
94 #define SwapFloat32(x)          (x)\r
95 #endif /* FAT_ENDIAN */\r
96 \r
97 #define FROMDISK        -1\r
98 struct PACKDirectory\r
99 {\r
100    char   name[56];             /* name of file */\r
101    UInt32 offset;               /* offset to start of data */\r
102    UInt32 size;                 /* byte size of data */\r
103 };\r
104 typedef struct PACKDirectory *PACKDirPtr;\r
105 \r
106 typedef struct DirListStruct\r
107 {\r
108         char                                    dirname[1024];\r
109         int                                             from;\r
110         struct  DirListStruct   *next;\r
111 } DIRLIST;\r
112 \r
113 typedef struct FileListStruct\r
114 {\r
115         char                                    filename[1024];\r
116         UInt32                                  offset;\r
117         UInt32                                  size;\r
118         struct  FileListStruct  *next;\r
119 } FILELIST;\r
120 \r
121 typedef struct DirStruct\r
122 {\r
123         char                            name[1024];\r
124         FILELIST                        *files;\r
125         struct DirStruct        *next;\r
126 } DIRECTORY;\r
127 \r
128 \r
129 extern int m_nPAKIndex;\r
130 extern FILE* pakfile[16];\r
131 extern bool pakopen;\r
132 extern DIRECTORY        *paktextures;\r
133 \r
134 void ClearFileList                              (FILELIST **);\r
135 void ClearDirList                               (DIRLIST **);\r
136 bool GetPackFileList                            (FILELIST **, char *);\r
137 bool GetPackTextureDirs                 (DIRLIST **);\r
138 bool AddToDirListAlphabetized   (DIRLIST **, char *, int);\r
139 bool AddToFileListAlphabetized  (FILELIST **t, char *, UInt32, UInt32, bool);\r
140 bool PakLoadFile                                        (const char *, void **);\r
141 void OpenPakFile                                        (const char *);\r
142 void ClosePakFile                               (void);\r
143 int  PakLoadAnyFile(const char *filename, void **bufferptr);\r
144 void WINAPI InitPakFile(const char * pBasePath, const char *pName);\r
145 \r
146 #ifdef __cplusplus\r
147 }\r
148 #endif\r
149 \r
150 #endif\r