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
This commit is contained in:
Eugene Sandulenko 2010-06-14 14:50:23 +00:00
parent 4f3bb60cd5
commit 4d517ed0e9
22 changed files with 95 additions and 32 deletions

View File

@ -340,6 +340,35 @@ static void reportUnknown(const Common::FSNode &path, const SizeMD5Map &filesSiz
static ADGameDescList detectGameFilebased(const FileMap &allFiles, const ADParams &params);
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 &params, 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.

View File

@ -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;
};

View File

@ -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

View File

@ -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;

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {

View File

@ -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
};

View File

@ -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

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {

View File

@ -91,7 +91,8 @@ static const ADParams detectionParams = {
"teenagent",
0,
0,
Common::GUIO_NONE
Common::GUIO_NONE,
1
};
#define MAX_SAVES 20

View File

@ -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 {

View File

@ -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 {

View File

@ -114,7 +114,8 @@ static const ADParams detectionParams = {
"tucker",
0,
0,
Common::GUIO_NONE
Common::GUIO_NONE,
1
};
static const ADGameDescription tuckerDemoGameDescription = {