]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - plugins/archivewad/wad.h
reformat code! now the code is only ugly on the *inside*
[xonotic/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     char identification[4];     // should be WAD2 or 2DAW
43     int numlumps;
44     int infotableofs;
45 } wadinfo_t;
46
47 typedef struct {
48     int filepos;
49     int disksize;
50     int size;                           // uncompressed
51     char type;
52     char compression;
53     char pad1, pad2;
54     char name[16];                      // must be null terminated
55 } lumpinfo_t;
56
57 inline void istream_read_wadinfo(InputStream &istream, wadinfo_t &wadinfo)
58 {
59     istream.read(reinterpret_cast<InputStream::byte_type *>( wadinfo.identification ), 4);
60     wadinfo.numlumps = istream_read_int32_le(istream);
61     wadinfo.infotableofs = istream_read_int32_le(istream);
62 }
63
64 inline void istream_read_lumpinfo(InputStream &istream, lumpinfo_t &lumpinfo)
65 {
66     lumpinfo.filepos = istream_read_int32_le(istream);
67     lumpinfo.disksize = istream_read_int32_le(istream);
68     lumpinfo.size = istream_read_int32_le(istream);
69     lumpinfo.type = istream_read_byte(istream);
70     lumpinfo.compression = istream_read_byte(istream);
71     lumpinfo.pad1 = istream_read_byte(istream);
72     lumpinfo.pad2 = istream_read_byte(istream);
73     istream.read(reinterpret_cast<InputStream::byte_type *>( lumpinfo.name ), 16);
74 }
75
76 #endif