aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/others/irrlicht-1.8.1/source/Irrlicht/CWADReader.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/others/irrlicht-1.8.1/source/Irrlicht/CWADReader.h')
-rw-r--r--src/others/irrlicht-1.8.1/source/Irrlicht/CWADReader.h177
1 files changed, 177 insertions, 0 deletions
diff --git a/src/others/irrlicht-1.8.1/source/Irrlicht/CWADReader.h b/src/others/irrlicht-1.8.1/source/Irrlicht/CWADReader.h
new file mode 100644
index 0000000..2d51902
--- /dev/null
+++ b/src/others/irrlicht-1.8.1/source/Irrlicht/CWADReader.h
@@ -0,0 +1,177 @@
1// Copyright (C) 2002-2012 Thomas Alten
2// This file is part of the "Irrlicht Engine".
3// For conditions of distribution and use, see copyright notice in irrlicht.h
4
5#ifndef __C_WAD_READER_H_INCLUDED__
6#define __C_WAD_READER_H_INCLUDED__
7
8#include "IrrCompileConfig.h"
9#ifdef __IRR_COMPILE_WITH_WAD_ARCHIVE_LOADER_
10
11#include "IReferenceCounted.h"
12#include "IReadFile.h"
13#include "irrArray.h"
14#include "irrString.h"
15#include "IFileSystem.h"
16#include "CFileList.h"
17
18
19namespace irr
20{
21namespace io
22{
23
24 enum eWADFileTypes
25 {
26 WAD_FORMAT_UNKNOWN = 0,
27 WAD_FORMAT_QUAKE2 = 1,
28 WAD_FORMAT_HALFLIFE = 2,
29
30 WAD_CMP_NONE = 0,
31 WAD_CMP_LZSS = 1,
32
33 WAD_TYP_NONE = 0,
34 WAD_TYP_LABEL = 1,
35
36 WAD_TYP_LUMPY = 64, // 64 + grab command number
37 WAD_TYP_PALETTE = 64,
38 WAD_TYP_QTEX = 65,
39 WAD_TYP_QPIC = 66,
40 WAD_TYP_SOUND = 67,
41 WAD_TYP_MIPTEX = 68,
42 WAD_TYP_MIPTEX_HALFLIFE = 67,
43 WAD_TYP_FONT = 70,
44 };
45
46// byte-align structures
47#include "irrpack.h"
48
49 struct SWADFileHeader
50 {
51 c8 tag[4]; // type of WAD format WAD2 = quake2, WAD3 = halflife
52 u32 numlumps;
53 u32 infotableofs;
54 } PACK_STRUCT;
55
56 struct SWADFileEntryOriginal
57 {
58 u32 filepos;
59 u32 disksize;
60 u32 size; // uncompressed
61 u8 type;
62 u8 compression;
63 u8 pad[2];
64 u8 name[16]; // must be null terminated
65 } PACK_STRUCT;
66
67// Default alignment
68#include "irrunpack.h"
69
70 struct SWADFileEntry
71 {
72 io::path simpleFileName;
73 bool operator < (const SWADFileEntry& other) const
74 {
75 return simpleFileName < other.simpleFileName;
76 }
77
78 io::path wadFileName;
79 SWADFileEntryOriginal header;
80 };
81
82 //! Archiveloader capable of loading WAD Archives
83 class CArchiveLoaderWAD : public IArchiveLoader
84 {
85 public:
86
87 //! Constructor
88 CArchiveLoaderWAD(io::IFileSystem* fs);
89
90 //! returns true if the file maybe is able to be loaded by this class
91 //! based on the file extension (e.g. ".zip")
92 virtual bool isALoadableFileFormat(const io::path& filename) const;
93
94 //! Check if the file might be loaded by this class
95 /** Check might look into the file.
96 \param file File handle to check.
97 \return True if file seems to be loadable. */
98 virtual bool isALoadableFileFormat(io::IReadFile* file) const;
99
100 //! Check to see if the loader can create archives of this type.
101 /** Check based on the archive type.
102 \param fileType The archive type to check.
103 \return True if the archile loader supports this type, false if not */
104 virtual bool isALoadableFileFormat(E_FILE_ARCHIVE_TYPE fileType) const;
105
106 //! Creates an archive from the filename
107 /** \param file File handle to check.
108 \return Pointer to newly created archive, or 0 upon error. */
109 virtual IFileArchive* createArchive(const io::path& filename, bool ignoreCase, bool ignorePaths) const;
110
111 //! creates/loads an archive from the file.
112 //! \return Pointer to the created archive. Returns 0 if loading failed.
113 virtual io::IFileArchive* createArchive(io::IReadFile* file, bool ignoreCase, bool ignorePaths) const;
114
115 private:
116 io::IFileSystem* FileSystem;
117 };
118
119
120 //! reads from WAD
121 class CWADReader : public IFileArchive, virtual CFileList
122 {
123 public:
124
125 CWADReader(IReadFile* file, bool ignoreCase, bool ignorePaths);
126 virtual ~CWADReader();
127
128 // file archive methods
129
130 //! return the id of the file Archive
131 virtual const io::path& getArchiveName() const;
132
133 //! opens a file by file name
134 virtual IReadFile* createAndOpenFile(const io::path& filename);
135
136 //! opens a file by index
137 virtual IReadFile* createAndOpenFile(u32 index);
138
139 //! returns the list of files
140 virtual const IFileList* getFileList() const;
141
142 //! get the class Type
143 virtual E_FILE_ARCHIVE_TYPE getType() const { return EFAT_WAD; }
144
145
146 private:
147
148 io::path Type;
149
150 //! scans for a local header, returns false if there is no more local file header.
151 bool scanLocalHeader();
152
153 //! splits filename from zip file into useful filenames and paths
154 void extractFilename(SWADFileEntry* entry);
155
156
157 io::path Base;
158 io::path MountPoint;
159
160 IReadFile* File;
161
162 eWADFileTypes WadType;
163 SWADFileHeader Header;
164
165 //core::array<SWADFileEntry> FileInfo;
166
167 io::IFileSystem* FileSystem;
168 };
169
170} // end namespace io
171} // end namespace irr
172
173#endif
174
175
176#endif // #ifdef __IRR_COMPILE_WITH_WAD_ARCHIVE_LOADER_
177