diff options
Diffstat (limited to 'engines/advancedDetector.h')
-rw-r--r-- | engines/advancedDetector.h | 89 |
1 files changed, 37 insertions, 52 deletions
diff --git a/engines/advancedDetector.h b/engines/advancedDetector.h index 5160a99679..326cb79c49 100644 --- a/engines/advancedDetector.h +++ b/engines/advancedDetector.h @@ -41,27 +41,13 @@ class FSList; * enable detection. */ struct ADGameFileDescription { - const char *fileName; ///< Name of described file. - uint16 fileType; ///< Optional. Not used during detection, only by engines. - const char *md5; ///< MD5 of (the beginning of) the described file. Optional. Set to NULL to ignore. - int32 fileSize; ///< Size of the described file. Set to -1 to ignore. + const char *fileName; ///< Name of described file. + uint16 fileType; ///< Optional. Not used during detection, only by engines. + const char *md5; ///< MD5 of (the beginning of) the described file. Optional. Set to NULL to ignore. + int32 fileSize; ///< Size of the described file. Set to -1 to ignore. }; /** - * A record describing the properties of a file. Used on the existing - * files while detecting a game. - */ -struct ADFileProperties { - int32 size; - Common::String md5; -}; - -/** - * A map of all relevant existing files in a game directory while detecting. - */ -typedef Common::HashMap<Common::String, ADFileProperties, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> ADFilePropertiesMap; - -/** * A shortcut to produce an empty ADGameFileDescription record. Used to mark * the end of a list of these. */ @@ -80,18 +66,18 @@ typedef Common::HashMap<Common::String, ADFileProperties, Common::IgnoreCase_Has #define AD_ENTRY1s(f, x, s) {{ f, 0, x, s}, AD_LISTEND} enum ADGameFlags { - ADGF_NO_FLAGS = 0, - ADGF_AUTOGENTARGET = (1 << 20), // automatically generate gameid from extra - ADGF_UNSTABLE = (1 << 21), // flag to designate not yet officially-supported games that are not fit for public testing - ADGF_TESTING = (1 << 22), // flag to designate not yet officially-supported games that are fit for public testing - ADGF_PIRATED = (1 << 23), ///< flag to designate well known pirated versions with cracks - ADGF_ADDENGLISH = (1 << 24), ///< always add English as language option - ADGF_MACRESFORK = (1 << 25), ///< the md5 for this entry will be calculated from the resource fork + ADGF_NO_FLAGS = 0, + ADGF_AUTOGENTARGET = (1 << 20), ///< automatically generate gameid from extra + ADGF_UNSTABLE = (1 << 21), ///< flag to designate not yet officially-supported games that are not fit for public testing + ADGF_TESTING = (1 << 22), ///< flag to designate not yet officially-supported games that are fit for public testing + ADGF_PIRATED = (1 << 23), ///< flag to designate well known pirated versions with cracks + ADGF_ADDENGLISH = (1 << 24), ///< always add English as language option + ADGF_MACRESFORK = (1 << 25), ///< the md5 for this entry will be calculated from the resource fork ADGF_USEEXTRAASTITLE = (1 << 26), ///< Extra field value will be used as main game title, not gameid - ADGF_DROPLANGUAGE = (1 << 27), ///< don't add language to gameid - ADGF_DROPPLATFORM = (1 << 28), ///< don't add platform to gameid - ADGF_CD = (1 << 29), ///< add "-cd" to gameid - ADGF_DEMO = (1 << 30) ///< add "-demo" to gameid + ADGF_DROPLANGUAGE = (1 << 27), ///< don't add language to gameid + ADGF_DROPPLATFORM = (1 << 28), ///< don't add platform to gameid + ADGF_CD = (1 << 29), ///< add "-cd" to gameid + ADGF_DEMO = (1 << 30) ///< add "-demo" to gameid }; struct ADGameDescription { @@ -112,14 +98,19 @@ struct ADGameDescription { }; /** - * A list of pointers to ADGameDescription structs (or subclasses thereof). + * A game installation matching an AD game description */ -typedef Common::Array<const ADGameDescription *> ADGameDescList; +struct ADDetectedGame { + bool hasUnknownFiles; + FilePropertiesMap matchedFiles; + const ADGameDescription *desc; -/** - * A list of raw game ID strings. - */ -typedef Common::Array<const char *> ADGameIdList; + ADDetectedGame() : desc(nullptr), hasUnknownFiles(false) {} + explicit ADDetectedGame(const ADGameDescription *d) : desc(d), hasUnknownFiles(false) {} +}; + +/** A list of games detected by the AD */ +typedef Common::Array<ADDetectedGame> ADDetectedGames; /** * End marker for a table of ADGameDescription structs. Use this to @@ -274,11 +265,11 @@ public: * Returns list of targets supported by the engine. * Distinguishes engines with single ID */ - virtual GameList getSupportedGames() const; + PlainGameList getSupportedGames() const override; - virtual GameDescriptor findGame(const char *gameId) const; + PlainGameDescriptor findGame(const char *gameId) const override; - virtual GameList detectGames(const Common::FSList &fslist) const; + DetectedGames detectGames(const Common::FSList &fslist) const override; virtual Common::Error createInstance(OSystem *syst, Engine **engine) const; @@ -294,8 +285,8 @@ protected: * An (optional) generic fallback detect function which is invoked * if the regular MD5 based detection failed to detect anything. */ - virtual const ADGameDescription *fallbackDetect(const FileMap &allFiles, const Common::FSList &fslist) const { - return 0; + virtual ADDetectedGame fallbackDetect(const FileMap &allFiles, const Common::FSList &fslist) const { + return ADDetectedGame(); } private: @@ -313,7 +304,7 @@ protected: * @param extra restrict results to specified extra string (only if kADFlagUseExtraAsHint is set) * @return list of ADGameDescription pointers corresponding to matched games */ - virtual ADGameDescList detectGame(const Common::FSNode &parent, const FileMap &allFiles, Common::Language language, Common::Platform platform, const Common::String &extra) const; + virtual ADDetectedGames detectGame(const Common::FSNode &parent, const FileMap &allFiles, Common::Language language, Common::Platform platform, const Common::String &extra) const; /** * Iterates over all ADFileBasedFallback records inside fileBasedFallback. @@ -327,16 +318,7 @@ protected: * @param fileBasedFallback a list of ADFileBasedFallback records, zero-terminated * @param filesProps if not 0, return a map of properties for all detected files here */ - const ADGameDescription *detectGameFilebased(const FileMap &allFiles, const Common::FSList &fslist, const ADFileBasedFallback *fileBasedFallback, ADFilePropertiesMap *filesProps = 0) const; - - /** - * Log and print a report that we found an unknown game variant, together with the file - * names, sizes and MD5 sums. - */ - void reportUnknown(const Common::FSNode &path, const ADFilePropertiesMap &filesProps, const ADGameIdList &matchedGameIds = ADGameIdList()) const; - - // TODO - void updateGameDescriptor(GameDescriptor &desc, const ADGameDescription *realDesc) const; + ADDetectedGame detectGameFilebased(const FileMap &allFiles, const Common::FSList &fslist, const ADFileBasedFallback *fileBasedFallback) const; /** * Compose a hashmap of all files in fslist. @@ -345,7 +327,10 @@ protected: void composeFileHashMap(FileMap &allFiles, const Common::FSList &fslist, int depth, const Common::String &parentName = Common::String()) const; /** Get the properties (size and MD5) of this file. */ - bool getFileProperties(const Common::FSNode &parent, const FileMap &allFiles, const ADGameDescription &game, const Common::String fname, ADFileProperties &fileProps) const; + bool getFileProperties(const Common::FSNode &parent, const FileMap &allFiles, const ADGameDescription &game, const Common::String fname, FileProperties &fileProps) const; + + /** Convert an AD game description into the shared game description format */ + DetectedGame toDetectedGame(const ADDetectedGame &adGame) const; }; #endif |