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/ptr.h"
27 #include "common/stream.h"
28 #include "common/hashmap.h"
29 #include "common/hash-str.h"
30 
31 namespace Common {
33 public:
34  enum class ClickteamTagId : uint16 {
35  BANNER_IMAGE = 0x1235,
36  FILE_LIST = 0x123a,
37  STRINGS = 0x123e,
38  UNINSTALLER = 0x123f,
39  FILE_PATCHING_LIST = 0x1242,
40  };
41 
43  protected:
44  ClickteamTag(uint16 tagId, byte *contents, uint32 size) : _tagId(tagId), _contents(contents), _size(size) {
45  }
46  friend class ClickteamInstaller;
47  public:
48  uint16 _tagId;
49  byte *_contents;
50  uint32 _size;
51 
52  ~ClickteamTag() {
53  delete[] _contents;
54  }
55  };
56 
57  bool hasFile(const Common::Path &path) const override;
58  int listMembers(Common::ArchiveMemberList&) const override;
59  const ArchiveMemberPtr getMember(const Common::Path &path) const override;
60  Common::SharedArchiveContents readContentsForPath(const Common::Path &translated) const override;
61 
62  ClickteamTag* getTag(ClickteamTagId tagId) const;
63 
64  static ClickteamInstaller* openPatch(Common::SeekableReadStream *stream, bool verifyOriginal = true, bool verifyAllowSkip = true,
65  Common::Archive *reference = &SearchMan, DisposeAfterUse::Flag dispose = DisposeAfterUse::NO);
66  static ClickteamInstaller* open(Common::SeekableReadStream *stream, DisposeAfterUse::Flag dispose = DisposeAfterUse::NO);
67 
68 private:
69  struct ClickteamPatchDescriptor {
70  uint32 _originalCRC;
71  uint32 _originalSize;
72  uint32 _patchDataOffset;
73  uint32 _patchSize;
74  };
75  class ClickteamFileDescriptor {
76  private:
77  Common::Path _fileName;
78 
79  // Offset of the file contents relative to the beginning of block3
80  uint32 _fileDataOffset;
81  // Offset of file descriptor
82  uint32 _fileDescriptorOffset;
83  uint32 _compressedSize;
84  uint32 _uncompressedSize;
85  uint32 _expectedCRC;
86  bool _supported;
87  bool _isPatchFile;
88  bool _crcIsXorred;
89  bool _isReferenceMissing;
90  //uint16 _field1c;
92 
93  ClickteamFileDescriptor(const ClickteamTag& contentsTag, uint32 off);
94  friend class ClickteamInstaller;
95  public:
96  // It's public for hashmap
97  ClickteamFileDescriptor() : _fileDataOffset(0), _fileDescriptorOffset(0), _compressedSize(0), _uncompressedSize(0) {}
98  };
99 
102  uint32 crcXor, uint32 block3Offset, uint32 block3Size, Common::SeekableReadStream *stream,
103  Common::Archive *reference,
104  DisposeAfterUse::Flag dispose)
105  : _files(files), _tags(tags), _crcXor(crcXor), _block3Offset(block3Offset), /*_block3Size(block3Size), */_stream(stream, dispose),
106  _reference(reference) {
107  }
108 
109  static int findPatchIdx(const ClickteamFileDescriptor &desc, Common::SeekableReadStream *refStream, const Common::Path &fileName,
110  uint32 crcXor, bool doWarn);
114  uint32 _crcXor, _block3Offset/*, _block3Size*/;
115  Common::Archive *_reference;
116 };
117 }
118 #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:32
Definition: algorithm.h:29
Definition: archive.h:224