From 4d517ed0e9870ef75b7b0c3eeda9659563d3ace9 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Mon, 14 Jun 2010 14:50:23 +0000 Subject: [PATCH] Extended advancedDetector with depth parameter. Now AD can search nested directories. By default it is turned off, but there is new parameter to ADParameters struct. Usually value of 2 is good enough for all purposes. svn-id: r49653 --- engines/advancedDetector.cpp | 42 +++++++++++++++++++++--------- engines/advancedDetector.h | 7 +++++ engines/agi/detection.cpp | 4 ++- engines/agos/detection.cpp | 4 ++- engines/cine/detection.cpp | 4 ++- engines/cruise/detection.cpp | 4 ++- engines/draci/detection.cpp | 4 ++- engines/drascula/detection.cpp | 4 ++- engines/gob/detection.cpp | 4 ++- engines/groovie/detection.cpp | 4 ++- engines/kyra/detection.cpp | 4 ++- engines/lure/detection.cpp | 4 ++- engines/m4/detection.cpp | 4 ++- engines/made/detection.cpp | 4 ++- engines/mohawk/detection.cpp | 4 ++- engines/parallaction/detection.cpp | 4 ++- engines/saga/detection.cpp | 4 ++- engines/sci/detection.cpp | 4 ++- engines/teenagent/detection.cpp | 3 ++- engines/tinsel/detection.cpp | 4 ++- engines/touche/detection.cpp | 4 ++- engines/tucker/detection.cpp | 3 ++- 22 files changed, 95 insertions(+), 32 deletions(-) diff --git a/engines/advancedDetector.cpp b/engines/advancedDetector.cpp index b149b43ad7b..f4932a10555 100644 --- a/engines/advancedDetector.cpp +++ b/engines/advancedDetector.cpp @@ -340,6 +340,35 @@ static void reportUnknown(const Common::FSNode &path, const SizeMD5Map &filesSiz static ADGameDescList detectGameFilebased(const FileMap &allFiles, const ADParams ¶ms); +static void composeFileHashMap(const Common::FSList &fslist, FileMap &allFiles, int depth) { + if (depth == 0) + return; + + if (fslist.empty()) + return; + + // First we compose a hashmap of all files in fslist. + // Includes nifty stuff like removing trailing dots and ignoring case. + for (Common::FSList::const_iterator file = fslist.begin(); file != fslist.end(); ++file) { + if (file->isDirectory()) { + Common::FSList files; + + if (!file->getChildren(files, Common::FSNode::kListAll)) + continue; + + composeFileHashMap(files, allFiles, depth - 1); + } + + Common::String tstr = file->getName(); + + // Strip any trailing dot + if (tstr.lastChar() == '.') + tstr.deleteLastChar(); + + allFiles[tstr] = *file; // Record the presence of this file + } +} + static ADGameDescList detectGame(const Common::FSList &fslist, const ADParams ¶ms, Common::Language language, Common::Platform platform, const Common::String &extra) { FileMap allFiles; SizeMD5Map filesSizeMD5; @@ -355,18 +384,7 @@ static ADGameDescList detectGame(const Common::FSList &fslist, const ADParams &p // First we compose a hashmap of all files in fslist. // Includes nifty stuff like removing trailing dots and ignoring case. - for (Common::FSList::const_iterator file = fslist.begin(); file != fslist.end(); ++file) { - if (file->isDirectory()) - continue; - - Common::String tstr = file->getName(); - - // Strip any trailing dot - if (tstr.lastChar() == '.') - tstr.deleteLastChar(); - - allFiles[tstr] = *file; // Record the presence of this file - } + composeFileHashMap(fslist, allFiles, (params.depth == 0 ? 1 : params.depth)); // Check which files are included in some ADGameDescription *and* present // in fslist. Compute MD5s and file sizes for these files. diff --git a/engines/advancedDetector.h b/engines/advancedDetector.h index 370d958ce6a..a48dd0c1d24 100644 --- a/engines/advancedDetector.h +++ b/engines/advancedDetector.h @@ -190,6 +190,13 @@ struct ADParams { * enum for the list. */ uint32 guioptions; + + /** + * + * Maximum depth of directories to look up + * If set to 0, the depth is 1 level + */ + uint32 depth; }; diff --git a/engines/agi/detection.cpp b/engines/agi/detection.cpp index e72647d5e2e..1c2638fc899 100644 --- a/engines/agi/detection.cpp +++ b/engines/agi/detection.cpp @@ -979,7 +979,9 @@ static const ADParams detectionParams = { // Flags 0, // Additional GUI options (for every game} - Common::GUIO_NOSPEECH | Common::GUIO_NOMIDI + Common::GUIO_NOSPEECH | Common::GUIO_NOMIDI, + // Maximum directory depth + 1 }; } // End of namespace Agi diff --git a/engines/agos/detection.cpp b/engines/agos/detection.cpp index 39974f9d537..d22ee720d70 100644 --- a/engines/agos/detection.cpp +++ b/engines/agos/detection.cpp @@ -102,7 +102,9 @@ static const ADParams detectionParams = { // Flags 0, // Additional GUI options (for every game} - Common::GUIO_NOLAUNCHLOAD + Common::GUIO_NOLAUNCHLOAD, + // Maximum directory depth + 1 }; using namespace AGOS; diff --git a/engines/cine/detection.cpp b/engines/cine/detection.cpp index fcfa1f7f202..1cf9ed5fad1 100644 --- a/engines/cine/detection.cpp +++ b/engines/cine/detection.cpp @@ -569,7 +569,9 @@ static const ADParams detectionParams = { // Flags 0, // Additional GUI options (for every game} - Common::GUIO_NOSPEECH | Common::GUIO_NOMIDI + Common::GUIO_NOSPEECH | Common::GUIO_NOMIDI, + // Maximum directory depth + 1 }; class CineMetaEngine : public AdvancedMetaEngine { diff --git a/engines/cruise/detection.cpp b/engines/cruise/detection.cpp index e1f12b734e9..9088b8261e5 100644 --- a/engines/cruise/detection.cpp +++ b/engines/cruise/detection.cpp @@ -237,7 +237,9 @@ static const ADParams detectionParams = { // Flags 0, // Additional GUI options (for every game} - Common::GUIO_NOSPEECH | Common::GUIO_NOMIDI + Common::GUIO_NOSPEECH | Common::GUIO_NOMIDI, + // Maximum directory depth + 1 }; class CruiseMetaEngine : public AdvancedMetaEngine { diff --git a/engines/draci/detection.cpp b/engines/draci/detection.cpp index c3204fc6561..39834ab5fab 100644 --- a/engines/draci/detection.cpp +++ b/engines/draci/detection.cpp @@ -94,7 +94,9 @@ const ADParams detectionParams = { // Flags 0, // Global GUI options - Common::GUIO_NONE + Common::GUIO_NONE, + // Maximum directory depth + 1 }; class DraciMetaEngine : public AdvancedMetaEngine { diff --git a/engines/drascula/detection.cpp b/engines/drascula/detection.cpp index 76d48b7b89c..a0781e0bff0 100644 --- a/engines/drascula/detection.cpp +++ b/engines/drascula/detection.cpp @@ -264,7 +264,9 @@ static const ADParams detectionParams = { // Flags 0, // Additional GUI options (for every game} - Common::GUIO_NOMIDI + Common::GUIO_NOMIDI, + // Maximum directory depth + 1 }; class DrasculaMetaEngine : public AdvancedMetaEngine { diff --git a/engines/gob/detection.cpp b/engines/gob/detection.cpp index 1f8bfdc1381..feb76fe0914 100644 --- a/engines/gob/detection.cpp +++ b/engines/gob/detection.cpp @@ -5094,7 +5094,9 @@ static const ADParams detectionParams = { // Flags 0, // Additional GUI options (for every game} - Common::GUIO_NOLAUNCHLOAD + Common::GUIO_NOLAUNCHLOAD, + // Maximum directory depth + 1 }; class GobMetaEngine : public AdvancedMetaEngine { diff --git a/engines/groovie/detection.cpp b/engines/groovie/detection.cpp index ec401e7d249..1f7156b2fc9 100644 --- a/engines/groovie/detection.cpp +++ b/engines/groovie/detection.cpp @@ -176,7 +176,9 @@ static const ADParams detectionParams = { // Flags kADFlagUseExtraAsHint, // Additional GUI options (for every game} - Common::GUIO_NOSUBTITLES | Common::GUIO_NOSFX + Common::GUIO_NOSUBTITLES | Common::GUIO_NOSFX, + // Maximum directory depth + 1 }; diff --git a/engines/kyra/detection.cpp b/engines/kyra/detection.cpp index 6e9359e7fc1..90a107099fc 100644 --- a/engines/kyra/detection.cpp +++ b/engines/kyra/detection.cpp @@ -1226,7 +1226,9 @@ const ADParams detectionParams = { // Flags 0, // Additional GUI options (for every game} - Common::GUIO_NONE + Common::GUIO_NONE, + // Maximum directory depth + 1 }; } // End of anonymous namespace diff --git a/engines/lure/detection.cpp b/engines/lure/detection.cpp index 36c1cf237d8..d8c7b483f8e 100644 --- a/engines/lure/detection.cpp +++ b/engines/lure/detection.cpp @@ -196,7 +196,9 @@ static const ADParams detectionParams = { // Flags kADFlagUseExtraAsHint, // Additional GUI options (for every game} - Common::GUIO_NOSPEECH + Common::GUIO_NOSPEECH, + // Maximum directory depth + 1 }; class LureMetaEngine : public AdvancedMetaEngine { diff --git a/engines/m4/detection.cpp b/engines/m4/detection.cpp index 9493226c1a7..80a899f1ac1 100644 --- a/engines/m4/detection.cpp +++ b/engines/m4/detection.cpp @@ -400,7 +400,9 @@ static const ADParams detectionParams = { // Flags 0, // Additional GUI options (for every game} - Common::GUIO_NOMIDI + Common::GUIO_NOMIDI, + // Maximum directory depth + 1 }; class M4MetaEngine : public AdvancedMetaEngine { diff --git a/engines/made/detection.cpp b/engines/made/detection.cpp index 1dfc0c3f83f..081bb980061 100644 --- a/engines/made/detection.cpp +++ b/engines/made/detection.cpp @@ -493,7 +493,9 @@ static const ADParams detectionParams = { // Flags 0, // Additional GUI options (for every game} - Common::GUIO_NONE + Common::GUIO_NONE, + // Maximum directory depth + 1 }; class MadeMetaEngine : public AdvancedMetaEngine { diff --git a/engines/mohawk/detection.cpp b/engines/mohawk/detection.cpp index 7f2e0cb312e..44c3bc4f6de 100644 --- a/engines/mohawk/detection.cpp +++ b/engines/mohawk/detection.cpp @@ -1011,7 +1011,9 @@ static const ADParams detectionParams = { // Flags 0, // Additional GUI options (for every game) - Common::GUIO_NONE + Common::GUIO_NONE, + // Maximum directory depth + 1 }; class MohawkMetaEngine : public AdvancedMetaEngine { diff --git a/engines/parallaction/detection.cpp b/engines/parallaction/detection.cpp index e5e2b226444..2ecaf1c2d60 100644 --- a/engines/parallaction/detection.cpp +++ b/engines/parallaction/detection.cpp @@ -240,7 +240,9 @@ static const ADParams detectionParams = { // Flags 0, // Additional GUI options (for every game} - Common::GUIO_NOLAUNCHLOAD + Common::GUIO_NOLAUNCHLOAD, + // Maximum directory depth + 1 }; class ParallactionMetaEngine : public AdvancedMetaEngine { diff --git a/engines/saga/detection.cpp b/engines/saga/detection.cpp index 1c2c6bacffd..b57b056806a 100644 --- a/engines/saga/detection.cpp +++ b/engines/saga/detection.cpp @@ -122,7 +122,9 @@ static const ADParams detectionParams = { // Flags 0, // Additional GUI options (for every game} - Common::GUIO_NONE + Common::GUIO_NONE, + // Maximum directory depth + 1 }; class SagaMetaEngine : public AdvancedMetaEngine { diff --git a/engines/sci/detection.cpp b/engines/sci/detection.cpp index 579414b3ead..7f0a27c14f1 100644 --- a/engines/sci/detection.cpp +++ b/engines/sci/detection.cpp @@ -310,7 +310,9 @@ static const ADParams detectionParams = { // Flags 0, // Additional GUI options (for every game} - Common::GUIO_NONE + Common::GUIO_NONE, + // Maximum directory depth + 1 }; class SciMetaEngine : public AdvancedMetaEngine { diff --git a/engines/teenagent/detection.cpp b/engines/teenagent/detection.cpp index 258bd982ed8..4c61e20b7a8 100644 --- a/engines/teenagent/detection.cpp +++ b/engines/teenagent/detection.cpp @@ -91,7 +91,8 @@ static const ADParams detectionParams = { "teenagent", 0, 0, - Common::GUIO_NONE + Common::GUIO_NONE, + 1 }; #define MAX_SAVES 20 diff --git a/engines/tinsel/detection.cpp b/engines/tinsel/detection.cpp index 70a2f475ee4..a70b75f1367 100644 --- a/engines/tinsel/detection.cpp +++ b/engines/tinsel/detection.cpp @@ -637,7 +637,9 @@ static const ADParams detectionParams = { // Flags 0, // Additional GUI options (for every game} - Common::GUIO_NONE + Common::GUIO_NONE, + // Maximum directory depth + 1 }; class TinselMetaEngine : public AdvancedMetaEngine { diff --git a/engines/touche/detection.cpp b/engines/touche/detection.cpp index 65a6a29bcc6..72f87a2f3fe 100644 --- a/engines/touche/detection.cpp +++ b/engines/touche/detection.cpp @@ -134,7 +134,9 @@ static const ADParams detectionParams = { Touche::fileBasedFallback, // file-based detection data to enable not yet known versions to start kADFlagPrintWarningOnFileBasedFallback, // Additional GUI options (for every game} - Common::GUIO_NONE + Common::GUIO_NONE, + // Maximum directory depth + 1 }; class ToucheMetaEngine : public AdvancedMetaEngine { diff --git a/engines/tucker/detection.cpp b/engines/tucker/detection.cpp index b4f30cb7fdf..7f88a8ff2ff 100644 --- a/engines/tucker/detection.cpp +++ b/engines/tucker/detection.cpp @@ -114,7 +114,8 @@ static const ADParams detectionParams = { "tucker", 0, 0, - Common::GUIO_NONE + Common::GUIO_NONE, + 1 }; static const ADGameDescription tuckerDemoGameDescription = {