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