ScummVM API documentation
clickteam.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program 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 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef COMMON_CLICKTEAM_H
23 #define COMMON_CLICKTEAM_H
24 
25 #include "common/archive.h"
26 #include "common/fs.h"
27 #include "common/ptr.h"
28 #include "common/stream.h"
29 #include "common/hashmap.h"
30 #include "common/hash-str.h"
31 
32 namespace Common {
34 public:
35  enum class ClickteamTagId : uint16 {
36  BANNER_IMAGE = 0x1235,
37  FILE_LIST = 0x123a,
38  STRINGS = 0x123e,
39  UNINSTALLER = 0x123f,
40  FILE_PATCHING_LIST = 0x1242,
41  };
42 
44  protected:
45  ClickteamTag(uint16 tagId, byte *contents, uint32 size) : _tagId(tagId), _contents(contents), _size(size) {
46  }
47  friend class ClickteamInstaller;
48  public:
49  uint16 _tagId;
50  byte *_contents;
51  uint32 _size;
52 
53  ~ClickteamTag() {
54  delete[] _contents;
55  }
56  };
57 
58  bool hasFile(const Common::Path &path) const override;
59  int listMembers(Common::ArchiveMemberList&) const override;
60  const ArchiveMemberPtr getMember(const Common::Path &path) const override;
61  Common::SharedArchiveContents readContentsForPath(const Common::Path &translated) const override;
62 
63  ClickteamTag* getTag(ClickteamTagId tagId) const;
64 
65  static ClickteamInstaller* openPatch(Common::SeekableReadStream *stream, bool verifyOriginal = true, bool verifyAllowSkip = true,
66  Common::Archive *reference = &SearchMan, DisposeAfterUse::Flag dispose = DisposeAfterUse::NO);
67  static ClickteamInstaller* open(Common::SeekableReadStream *stream, DisposeAfterUse::Flag dispose = DisposeAfterUse::NO);
68  static ClickteamInstaller* open(const Common::FSNode &node);
69 
70 private:
71  struct ClickteamPatchDescriptor {
72  uint32 _originalCRC;
73  uint32 _originalSize;
74  uint32 _patchDataOffset;
75  uint32 _patchSize;
76  };
77  class ClickteamFileDescriptor {
78  private:
79  Common::Path _fileName;
80 
81  // Offset of the file contents relative to the beginning of block3
82  uint32 _fileDataOffset;
83  // Offset of file descriptor
84  uint32 _fileDescriptorOffset;
85  uint32 _compressedSize;
86  uint32 _uncompressedSize;
87  uint32 _expectedCRC;
88  bool _supported;
89  bool _isPatchFile;
90  bool _crcIsXorred;
91  bool _isReferenceMissing;
92  //uint16 _field1c;
94 
95  ClickteamFileDescriptor(const ClickteamTag& contentsTag, uint32 off);
96  friend class ClickteamInstaller;
97  public:
98  // It's public for hashmap
99  ClickteamFileDescriptor() : _fileDataOffset(0), _fileDescriptorOffset(0), _compressedSize(0), _uncompressedSize(0) {}
100  };
101 
104  uint32 crcXor, uint32 block3Offset, uint32 block3Size, Common::SeekableReadStream *stream,
105  Common::Archive *reference,
106  DisposeAfterUse::Flag dispose)
107  : _files(files), _tags(tags), _crcXor(crcXor), _block3Offset(block3Offset), /*_block3Size(block3Size), */_stream(stream, dispose),
108  _reference(reference) {
109  }
110 
111  static int findPatchIdx(const ClickteamFileDescriptor &desc, Common::SeekableReadStream *refStream, const Common::Path &fileName,
112  uint32 crcXor, bool doWarn);
116  uint32 _crcXor, _block3Offset/*, _block3Size*/;
117  Common::Archive *_reference;
118 };
119 }
120 #endif
const ArchiveMemberPtr getMember(const Common::Path &path) const override
Definition: list.h:44
Definition: path.h:52
Definition: stream.h:745
Definition: archive.h:141
Definition: noncopyable.h:39
int listMembers(Common::ArchiveMemberList &) const override
bool hasFile(const Common::Path &path) const override
#define SearchMan
Definition: archive.h:476
Definition: clickteam.h:33
Definition: algorithm.h:29
Definition: fs.h:69
Definition: archive.h:224