ScummVM API documentation
advancedDetector.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
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (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, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  */
22 
23 #ifndef ENGINES_ADVANCED_DETECTOR_H
24 #define ENGINES_ADVANCED_DETECTOR_H
25 
26 #include "engines/metaengine.h"
27 #include "engines/engine.h"
28 
29 #include "common/hash-str.h"
30 
31 #include "common/gui_options.h" // FIXME: Temporary hack?
32 
33 namespace Common {
34 class Error;
35 class FSList;
36 }
52  const char *fileName;
53  uint16 fileType;
54  const char *md5;
55  int32 fileSize;
56 };
57 
62 #define AD_LISTEND {NULL, 0, NULL, 0}
63 
68 #define AD_ENTRY1(f, x) {{ f, 0, x, -1}, AD_LISTEND}
69 
74 #define AD_ENTRY1s(f, x, s) {{ f, 0, x, s}, AD_LISTEND}
75 
81  ADGF_REMASTERED = (1 << 18),
82  ADGF_AUTOGENTARGET = (1 << 19),
83  ADGF_UNSTABLE = (1 << 20),
84  ADGF_TESTING = (1 << 21),
85  ADGF_PIRATED = (1 << 22),
86  ADGF_UNSUPPORTED = (1 << 23),
88  ADGF_ADDENGLISH = (1 << 24),
89  ADGF_MACRESFORK = (1 << 25),
90  ADGF_USEEXTRAASTITLE = (1 << 26),
91  ADGF_DROPLANGUAGE = (1 << 27),
92  ADGF_DROPPLATFORM = (1 << 28),
93  ADGF_CD = (1 << 29),
94  ADGF_DEMO = (1 << 30)
95 };
96 
106  const char *gameId;
107 
117  const char *extra;
118 
125  ADGameFileDescription filesDescriptions[14];
126 
130  Common::Language language;
131 
135  Common::Platform platform;
136 
143  uint32 flags;
144 
152  const char *guiOptions;
153 };
154 
163  ADDetectedGame() : desc(nullptr), hasUnknownFiles(false) {}
167  explicit ADDetectedGame(const ADGameDescription *d) : desc(d), hasUnknownFiles(false) {}
168 };
169 
171 typedef Common::Array<ADDetectedGame> ADDetectedGames;
172 
177 #define AD_TABLE_END_MARKER \
178  { NULL, NULL, { { NULL, 0, NULL, 0 } }, Common::UNK_LANG, Common::kPlatformUnknown, ADGF_NO_FLAGS, GUIO0() }
179 
186 
191  const char *filenames[10];
192 };
193 
194 
195 enum ADFlags {
207 };
208 
209 
215  const char *guioFlag;
217 };
218 
219 #define AD_EXTRA_GUI_OPTIONS_TERMINATOR { 0, { 0, 0, 0, 0 } }
220 
225 protected:
233  const byte *_gameDescriptors;
234 
240  const uint _descItemSize;
241 
247 
252 
262  uint _md5Bytes;
263 
270  uint32 _flags;
271 
278  Common::String _guiOptions;
279 
286 
295  const char * const *_directoryGlobs;
296 
308 
315 
316 public:
320  AdvancedMetaEngineDetection(const void *descs, uint descItemSize, const PlainGameDescriptor *gameIds, const ADExtraGuiOptionsMap *extraGuiOptions = 0);
321 
327  PlainGameList getSupportedGames() const override;
328 
330  PlainGameDescriptor findGame(const char *gameId) const override;
331 
337  DetectedGames detectGames(const Common::FSList &fslist) const override;
338 
345  Common::Error createInstance(OSystem *syst, Engine **engine) const;
346 
361  virtual const ExtraGuiOptions getExtraGuiOptions(const Common::String &target) const override;
362 
363 protected:
367  typedef Common::HashMap<Common::String, Common::FSNode, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> FileMap;
368 
373  virtual ADDetectedGame fallbackDetect(const FileMap &allFiles, const Common::FSList &fslist) const {
374  return ADDetectedGame();
375  }
376 
377 private:
378  void initSubSystems(const ADGameDescription *gameDesc) const;
379 
380 protected:
395  virtual ADDetectedGames detectGame(const Common::FSNode &parent, const FileMap &allFiles, Common::Language language, Common::Platform platform, const Common::String &extra) const;
396 
408  ADDetectedGame detectGameFilebased(const FileMap &allFiles, const ADFileBasedFallback *fileBasedFallback) const;
409 
415  void composeFileHashMap(FileMap &allFiles, const Common::FSList &fslist, int depth, const Common::String &parentName = Common::String()) const;
416 
418  bool getFileProperties(const FileMap &allFiles, const ADGameDescription &game, const Common::String fname, FileProperties &fileProps) const;
419 
421  virtual DetectedGame toDetectedGame(const ADDetectedGame &adGame) const;
422 
424  friend class FileMapArchive;
425 };
426 
431 public:
440  virtual Common::Error createInstance(OSystem *syst, Engine **engine) const override;
441 
446  virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const = 0;
447 
455  virtual const char *getName() const override = 0;
456 
457 public:
461  typedef Common::HashMap<Common::String, Common::FSNode, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> FileMap;
462 
476  virtual ADDetectedGame fallbackDetectExtern(uint md5Bytes, const FileMap &allFiles, const Common::FSList &fslist) const {
477  return ADDetectedGame();
478  }
479 
485  bool getFilePropertiesExtern(uint md5Bytes, const FileMap &allFiles, const ADGameDescription &game, const Common::String fname, FileProperties &fileProps) const;
486 };
488 #endif
virtual ADDetectedGame fallbackDetect(const FileMap &allFiles, const Common::FSList &fslist) const
Definition: advancedDetector.h:373
Common::String _guiOptions
Definition: advancedDetector.h:278
Definition: metaengine.h:204
const uint _descItemSize
Definition: advancedDetector.h:240
Add "-remastered&#39; to gameid.
Definition: advancedDetector.h:81
Definition: game.h:124
Definition: advancedDetector.h:224
const PlainGameDescriptor * _gameIds
Definition: advancedDetector.h:246
const char * md5
MD5 of (the beginning of) the described file. Optional. Set to NULL to ignore.
Definition: advancedDetector.h:54
Common::Array< ADDetectedGame > ADDetectedGames
Definition: advancedDetector.h:171
const char * extra
Definition: advancedDetector.h:117
Definition: advancedDetector.h:100
int32 fileSize
Size of the described file. Set to -1 to ignore.
Definition: advancedDetector.h:55
const ADGameDescription * desc
Definition: advancedDetector.h:161
Definition: game.h:105
const char * fileName
Name of the described file.
Definition: advancedDetector.h:52
const ADGameDescription * desc
Definition: advancedDetector.h:185
const char * gameId
Definition: advancedDetector.h:106
Flag to designate not yet officially supported games that are fit for public testing.
Definition: advancedDetector.h:84
ADDetectedGame(const ADGameDescription *d)
Definition: advancedDetector.h:167
Definition: game.h:64
Do not add platform to gameid.
Definition: advancedDetector.h:92
uint16 fileType
Optional. Not used during detection, only by engines.
Definition: advancedDetector.h:53
Common::Array< ExtraGuiOption > ExtraGuiOptions
Definition: metaengine.h:80
Definition: advancedDetector.h:214
const ADExtraGuiOptionsMap *const _extraGuiOptions
Definition: advancedDetector.h:251
uint _md5Bytes
Definition: advancedDetector.h:262
Definition: game.h:49
bool hasUnknownFiles
Definition: advancedDetector.h:159
uint32 flags
Definition: advancedDetector.h:143
ADFlags
Definition: advancedDetector.h:195
Add "-demo" to gameid.
Definition: advancedDetector.h:94
Definition: advancedDetector.h:430
Calculate the MD5 for this entry from the resource fork.
Definition: advancedDetector.h:89
Common::Language language
Definition: advancedDetector.h:130
Definition: metaengine.h:70
uint32 _maxScanDepth
Definition: advancedDetector.h:285
Flag to designate not yet officially supported games that are not fit for public testing.
Definition: advancedDetector.h:83
ExtraGuiOption option
Definition: advancedDetector.h:216
Common::HashMap< Common::String, Common::FSNode, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo > FileMap
Definition: advancedDetector.h:461
Definition: advancedDetector.h:33
Do not add language to gameid.
Definition: advancedDetector.h:91
const char * guiOptions
Definition: advancedDetector.h:152
Definition: metaengine.h:125
Common::HashMap< Common::String, Common::FSNode, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo > FileMap
Definition: advancedDetector.h:367
Add "-cd" to gameid.
Definition: advancedDetector.h:93
Definition: advancedDetector.h:158
Common::Array< DetectedGame > DetectedGames
Definition: game.h:203
Flag to designate well-known pirated versions with cracks.
Definition: advancedDetector.h:85
Definition: advancedDetector.h:180
Definition: advancedDetector.h:86
No flags.
Definition: advancedDetector.h:80
Automatically generate gameid from ADGameDescription::extra.
Definition: advancedDetector.h:82
uint32 _flags
Definition: advancedDetector.h:270
Common::HashMap< Common::String, FileProperties, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo > FilePropertiesMap
Definition: game.h:115
Use ADGameDescription::extra as the main game title, not gameid.
Definition: advancedDetector.h:90
FilePropertiesMap matchedFiles
Definition: advancedDetector.h:160
const char *const * _directoryGlobs
Definition: advancedDetector.h:295
bool _matchFullPaths
Definition: advancedDetector.h:307
Common::Platform platform
Definition: advancedDetector.h:135
int _maxAutogenLength
Definition: advancedDetector.h:314
Definition: engine.h:143
const byte * _gameDescriptors
Definition: advancedDetector.h:233
Definition: advancedDetector.h:206
virtual ADDetectedGame fallbackDetectExtern(uint md5Bytes, const FileMap &allFiles, const Common::FSList &fslist) const
Definition: advancedDetector.h:476
ADGameFlags
Definition: advancedDetector.h:79
const char * guioFlag
Definition: advancedDetector.h:215
Always add English as a language option.
Definition: advancedDetector.h:88
Definition: advancedDetector.h:51