]> icculus.org git repositories - divverent/netradiant.git/blob - plugins/archivewad/wad.h
initial
[divverent/netradiant.git] / plugins / archivewad / wad.h
1 /*
2 Copyright (C) 2001-2006, William Joseph.
3 All Rights Reserved.
4
5 This file is part of GtkRadiant.
6
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.
11
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.
16
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
20 */
21
22 #if !defined(INCLUDED_WAD_H)
23 #define INCLUDED_WAD_H
24
25 #include "bytestreamutils.h"
26 #include "idatastream.h"
27
28 #define CMP_NONE                0
29 #define CMP_LZSS                1
30
31 #define TYP_NONE                0
32 #define TYP_LABEL               1
33
34 #define TYP_LUMPY               64                              // 64 + grab command number
35 #define TYP_PALETTE             64
36 #define TYP_QTEX                65
37 #define TYP_QPIC                66
38 #define TYP_SOUND               67
39 #define TYP_MIPTEX              68
40
41 typedef struct
42 {
43         char identification[4];         // should be WAD2 or 2DAW
44         int                     numlumps;
45         int                     infotableofs;
46 } wadinfo_t;
47
48 typedef struct
49 {
50         int                     filepos;
51         int                     disksize;
52         int                     size;                                   // uncompressed
53         char            type;
54         char            compression;
55         char            pad1, pad2;
56         char            name[16];                               // must be null terminated
57 } lumpinfo_t;
58
59 inline void istream_read_wadinfo(InputStream& istream, wadinfo_t& wadinfo)
60 {
61   istream.read(reinterpret_cast<InputStream::byte_type*>(wadinfo.identification), 4);
62   wadinfo.numlumps = istream_read_int32_le(istream);
63   wadinfo.infotableofs = istream_read_int32_le(istream);
64 }
65
66 inline void istream_read_lumpinfo(InputStream& istream, lumpinfo_t& lumpinfo)
67 {
68         lumpinfo.filepos = istream_read_int32_le(istream);
69         lumpinfo.disksize = istream_read_int32_le(istream);
70         lumpinfo.size = istream_read_int32_le(istream);
71         lumpinfo.type = istream_read_byte(istream);
72         lumpinfo.compression = istream_read_byte(istream);
73         lumpinfo.pad1 = istream_read_byte(istream);
74   lumpinfo.pad2 = istream_read_byte(istream);
75   istream.read(reinterpret_cast<InputStream::byte_type*>(lumpinfo.name), 16);
76 }
77
78 #endif