[Scummvm-cvs-logs] SF.net SVN: scummvm: [31119] scummvm/trunk

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Fri Mar 14 14:59:32 CET 2008


Revision: 31119
          http://scummvm.svn.sourceforge.net/scummvm/?rev=31119&view=rev
Author:   fingolfin
Date:     2008-03-14 06:59:31 -0700 (Fri, 14 Mar 2008)

Log Message:
-----------
Advanced Detector: Changed fallback detector from a callback function pointer to an overrideable method of AdvancedMetaEngine

Modified Paths:
--------------
    scummvm/trunk/common/advancedDetector.cpp
    scummvm/trunk/common/advancedDetector.h
    scummvm/trunk/engines/agi/detection.cpp
    scummvm/trunk/engines/agos/detection.cpp
    scummvm/trunk/engines/cine/detection.cpp
    scummvm/trunk/engines/cruise/detection.cpp
    scummvm/trunk/engines/drascula/detection.cpp
    scummvm/trunk/engines/gob/detection.cpp
    scummvm/trunk/engines/igor/detection.cpp
    scummvm/trunk/engines/kyra/detection.cpp
    scummvm/trunk/engines/lure/detection.cpp
    scummvm/trunk/engines/parallaction/detection.cpp
    scummvm/trunk/engines/saga/detection.cpp
    scummvm/trunk/engines/touche/detection.cpp

Modified: scummvm/trunk/common/advancedDetector.cpp
===================================================================
--- scummvm/trunk/common/advancedDetector.cpp	2008-03-14 13:35:47 UTC (rev 31118)
+++ scummvm/trunk/common/advancedDetector.cpp	2008-03-14 13:59:31 UTC (rev 31119)
@@ -34,6 +34,8 @@
 
 namespace Common {
 
+using namespace AdvancedDetector;
+
 namespace AdvancedDetector {
 
 // FIXME/TODO: Rename this function to something more sensible.
@@ -209,16 +211,15 @@
 		desc["extra"] = realDesc->extra;
 }
 
-GameList detectAllGames(
-	const FSList &fslist,
-	const Common::ADParams &params
-	) {
+}	// End of namespace AdvancedDetector
+
+GameList AdvancedMetaEngine::detectGames(const FSList &fslist) const {
 	ADGameDescList matches = detectGame(&fslist, params, Common::UNK_LANG, Common::kPlatformUnknown, "");
 	GameList detectedGames;
 
 	// Use fallback detector if there were no matches by other means
-	if (matches.empty() && params.fallbackDetectFunc != NULL) {
-		EncapsulatedADGameDesc fallbackDesc = (*params.fallbackDetectFunc)(&fslist);
+	if (matches.empty()) {
+		EncapsulatedADGameDesc fallbackDesc = fallbackDetect(&fslist);
 		if (fallbackDesc.realDesc != 0) {
 			GameDescriptor desc(toGameDescriptor(fallbackDesc, params.list));
 			updateGameDescriptor(desc, fallbackDesc.realDesc, params);
@@ -233,9 +234,10 @@
 	return detectedGames;
 }
 
-EncapsulatedADGameDesc detectBestMatchingGame(
-	const Common::ADParams &params
-	) {
+PluginError AdvancedMetaEngine::createInstance(OSystem *syst, Engine **engine) const {
+	assert(engine);
+	Common::AdvancedDetector::upgradeTargetIfNecessary(params);
+
 	const ADGameDescription *agdDesc = 0;
 	EncapsulatedADGameDesc result;
 	Common::Language language = Common::UNK_LANG;
@@ -267,8 +269,9 @@
 
 	if (agdDesc != 0) { // Check if we found a match without fallback detection
 		result = EncapsulatedADGameDesc(agdDesc);
-	} else if (params.fallbackDetectFunc != NULL) { // Use fallback detector if there were no matches by other means
-		EncapsulatedADGameDesc fallbackDesc = (*params.fallbackDetectFunc)(NULL);
+	} else {
+		// Use fallback detector if there were no matches by other means
+		EncapsulatedADGameDesc fallbackDesc = fallbackDetect(NULL);
 		if (fallbackDesc.realDesc != 0 && (params.singleid != NULL || fallbackDesc.getGameID() == gameid)) {
 			result = fallbackDesc; // Found a fallback match
 		}
@@ -278,9 +281,17 @@
 		debug(2, "Running %s", toGameDescriptor(result, params.list).description().c_str());
 	}
 
-	return result;
+	if (result.realDesc == 0) {
+		return kNoGameDataFoundError;
+	}
+	if (!createInstance(syst, engine, result)) {
+		return kNoGameDataFoundError;
+	}
+	return kNoError;
 }
 
+namespace AdvancedDetector {
+
 void reportUnknown(StringMap &filesMD5, HashMap<String, int32, Common::CaseSensitiveString_Hash, Common::CaseSensitiveString_EqualTo> &filesSize) {
 	// TODO: This message should be cleaned up / made more specific.
 	// For example, we should specify at least which engine triggered this.
@@ -571,21 +582,5 @@
 GameDescriptor AdvancedMetaEngine::findGame(const char *gameid) const {
 	return Common::AdvancedDetector::findGameID(gameid, params.list, params.obsoleteList);
 }
-GameList AdvancedMetaEngine::detectGames(const FSList &fslist) const {
-	return Common::AdvancedDetector::detectAllGames(fslist, params);
-}
 
-PluginError AdvancedMetaEngine::createInstance(OSystem *syst, Engine **engine) const {
-	assert(engine);
-	Common::AdvancedDetector::upgradeTargetIfNecessary(params);
-	Common::EncapsulatedADGameDesc encapsulatedDesc = Common::AdvancedDetector::detectBestMatchingGame(params);
-	if (encapsulatedDesc.realDesc == 0) {
-		return kNoGameDataFoundError;
-	}
-	if (!createInstance(syst,engine,encapsulatedDesc)) {
-		return kNoGameDataFoundError;
-	}
-	return kNoError;
-}
-
 }	// End of namespace Common

Modified: scummvm/trunk/common/advancedDetector.h
===================================================================
--- scummvm/trunk/common/advancedDetector.h	2008-03-14 13:35:47 UTC (rev 31118)
+++ scummvm/trunk/common/advancedDetector.h	2008-03-14 13:59:31 UTC (rev 31119)
@@ -67,6 +67,8 @@
 /**
  * Encapsulates ADGameDescription and makes gameid and extra strings dynamic.
  * Used in fallback detection when dynamically creating string content.
+ *
+ * @todo Get rid of this once the fallback detection is a member of AdvancedMetaEngine.
  */
 struct EncapsulatedADGameDesc {
 	Common::String gameid;
@@ -76,8 +78,8 @@
 	// Constructor for the EncapsulatedADGameDesc
 	EncapsulatedADGameDesc() : realDesc(0) {}
 	EncapsulatedADGameDesc(const ADGameDescription *paramRealDesc,
-		Common::String paramGameID = Common::String(""),
-		Common::String paramExtra = Common::String(""))
+		Common::String paramGameID = Common::String(),
+		Common::String paramExtra = Common::String())
 		: realDesc(paramRealDesc), gameid(paramGameID), extra(paramExtra) {
 		assert(paramRealDesc != NULL);
 	}
@@ -193,20 +195,6 @@
 	const ADFileBasedFallback *fileBasedFallback;
 
 	/**
-	 * A callback pointing to an (optional) generic fallback detect
-	 * function. If present, this callback is invoked if both the regular
-	 * MD5 based detection as well as the file based fallback failed
-	 * to detect anything.
-	 *
-	 * @note The fslist parameter may be 0 -- in that case, it is assumed
-	 *       that the callback searchs the current directory.
-	 *
-	 * @todo Change this to a member method of AdvancedMetaEngine which can
-	 *       be overriden via subclassing.
-	 */
-	EncapsulatedADGameDesc (*fallbackDetectFunc)(const FSList *fslist);
-
-	/**
 	 * A bitmask of flags which can be used to configure the behavior
 	 * of the AdvancedDetector. Refer to ADFlags for a list of flags
 	 * that can be ORed together and passed here.
@@ -245,6 +233,19 @@
 
 	// To be provided by subclasses
 	virtual bool createInstance(OSystem *syst, Engine **engine, const Common::EncapsulatedADGameDesc &encapsulatedDesc) const = 0;
+
+
+	/**
+	 * An (optional) generic fallback detect function which is invoked
+	 * if both the regular MD5 based detection as well as the file
+	 * based fallback failed to detect anything.
+	 *
+	 * @note The fslist parameter may be 0 -- in that case, it is assumed
+	 *       that the callback searchs the current directory.
+	 */
+	EncapsulatedADGameDesc fallbackDetect(const FSList *fslist) const {
+		return EncapsulatedADGameDesc();
+	}
 };
 
 }	// End of namespace Common

Modified: scummvm/trunk/engines/agi/detection.cpp
===================================================================
--- scummvm/trunk/engines/agi/detection.cpp	2008-03-14 13:35:47 UTC (rev 31118)
+++ scummvm/trunk/engines/agi/detection.cpp	2008-03-14 13:59:31 UTC (rev 31119)
@@ -2255,8 +2255,6 @@
 	"agi",
 	// List of files for file-based fallback detection (optional)
 	0,
-	// Fallback callback
-	Agi::fallbackDetector,
 	// Flags
 	Common::kADFlagAugmentPreferredTarget
 };
@@ -2273,6 +2271,10 @@
 	}
 
 	virtual bool createInstance(OSystem *syst, Engine **engine, const Common::EncapsulatedADGameDesc &encapsulatedDesc) const;
+
+	Common::EncapsulatedADGameDesc fallbackDetect(const FSList *fslist) const {
+		return Agi::fallbackDetector(fslist);
+	}
 };
 
 bool AgiMetaEngine::createInstance(OSystem *syst, Engine **engine, const Common::EncapsulatedADGameDesc &encapsulatedDesc) const {

Modified: scummvm/trunk/engines/agos/detection.cpp
===================================================================
--- scummvm/trunk/engines/agos/detection.cpp	2008-03-14 13:35:47 UTC (rev 31118)
+++ scummvm/trunk/engines/agos/detection.cpp	2008-03-14 13:59:31 UTC (rev 31119)
@@ -93,8 +93,6 @@
 	0,
 	// List of files for file-based fallback detection (optional)
 	0,
-	// Fallback callback
-	0,
 	// Flags
 	Common::kADFlagAugmentPreferredTarget
 };

Modified: scummvm/trunk/engines/cine/detection.cpp
===================================================================
--- scummvm/trunk/engines/cine/detection.cpp	2008-03-14 13:35:47 UTC (rev 31118)
+++ scummvm/trunk/engines/cine/detection.cpp	2008-03-14 13:59:31 UTC (rev 31119)
@@ -482,8 +482,6 @@
 	"cine",
 	// List of files for file-based fallback detection (optional)
 	0,
-	// Fallback callback
-	0,
 	// Flags
 	Common::kADFlagAugmentPreferredTarget
 };

Modified: scummvm/trunk/engines/cruise/detection.cpp
===================================================================
--- scummvm/trunk/engines/cruise/detection.cpp	2008-03-14 13:35:47 UTC (rev 31118)
+++ scummvm/trunk/engines/cruise/detection.cpp	2008-03-14 13:59:31 UTC (rev 31119)
@@ -117,8 +117,6 @@
 	"cruise",
 	// List of files for file-based fallback detection (optional)
 	0,
-	// Fallback callback
-	0,
 	// Flags
 	Common::kADFlagAugmentPreferredTarget
 };

Modified: scummvm/trunk/engines/drascula/detection.cpp
===================================================================
--- scummvm/trunk/engines/drascula/detection.cpp	2008-03-14 13:35:47 UTC (rev 31118)
+++ scummvm/trunk/engines/drascula/detection.cpp	2008-03-14 13:59:31 UTC (rev 31119)
@@ -157,8 +157,6 @@
 	"drascula",
 	// List of files for file-based fallback detection (optional)
 	0,
-	// Fallback callback
-	Drascula::fallbackDetector,
 	// Flags
 	Common::kADFlagAugmentPreferredTarget
 };
@@ -176,6 +174,10 @@
 	}
 
 	virtual bool createInstance(OSystem *syst, Engine **engine, const Common::EncapsulatedADGameDesc &encapsulatedDesc) const;
+
+	Common::EncapsulatedADGameDesc fallbackDetect(const FSList *fslist) const {
+		return Drascula::fallbackDetector(fslist);
+	}
 };
 
 bool DrasculaMetaEngine::createInstance(OSystem *syst, Engine **engine, const Common::EncapsulatedADGameDesc &encapsulatedDesc) const {

Modified: scummvm/trunk/engines/gob/detection.cpp
===================================================================
--- scummvm/trunk/engines/gob/detection.cpp	2008-03-14 13:35:47 UTC (rev 31118)
+++ scummvm/trunk/engines/gob/detection.cpp	2008-03-14 13:59:31 UTC (rev 31119)
@@ -1853,8 +1853,6 @@
 	"gob",
 	// List of files for file-based fallback detection (optional)
 	Gob::fileBased,
-	// Fallback callback
-	0,
 	// Flags
 	kADFlagAugmentPreferredTarget
 };

Modified: scummvm/trunk/engines/igor/detection.cpp
===================================================================
--- scummvm/trunk/engines/igor/detection.cpp	2008-03-14 13:35:47 UTC (rev 31118)
+++ scummvm/trunk/engines/igor/detection.cpp	2008-03-14 13:59:31 UTC (rev 31119)
@@ -101,7 +101,6 @@
 	0,
 	"igor",
 	0,
-	0,
 	Common::kADFlagAugmentPreferredTarget
 };
 

Modified: scummvm/trunk/engines/kyra/detection.cpp
===================================================================
--- scummvm/trunk/engines/kyra/detection.cpp	2008-03-14 13:35:47 UTC (rev 31118)
+++ scummvm/trunk/engines/kyra/detection.cpp	2008-03-14 13:59:31 UTC (rev 31119)
@@ -422,8 +422,6 @@
 	0,
 	// List of files for file-based fallback detection (optional)
 	0,
-	// Fallback callback
-	0,
 	// Flags
 	0
 };

Modified: scummvm/trunk/engines/lure/detection.cpp
===================================================================
--- scummvm/trunk/engines/lure/detection.cpp	2008-03-14 13:35:47 UTC (rev 31118)
+++ scummvm/trunk/engines/lure/detection.cpp	2008-03-14 13:59:31 UTC (rev 31119)
@@ -168,8 +168,6 @@
 	"lure",
 	// List of files for file-based fallback detection (optional)
 	0,
-	// Fallback callback
-	0,
 	// Flags
 	Common::kADFlagAugmentPreferredTarget | Common::kADFlagUseExtraAsHint
 };

Modified: scummvm/trunk/engines/parallaction/detection.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/detection.cpp	2008-03-14 13:35:47 UTC (rev 31118)
+++ scummvm/trunk/engines/parallaction/detection.cpp	2008-03-14 13:59:31 UTC (rev 31119)
@@ -178,8 +178,6 @@
 	"parallaction",
 	// List of files for file-based fallback detection (optional)
 	0,
-	// Fallback callback
-	0,
 	// Flags
 	Common::kADFlagAugmentPreferredTarget
 };

Modified: scummvm/trunk/engines/saga/detection.cpp
===================================================================
--- scummvm/trunk/engines/saga/detection.cpp	2008-03-14 13:35:47 UTC (rev 31118)
+++ scummvm/trunk/engines/saga/detection.cpp	2008-03-14 13:59:31 UTC (rev 31119)
@@ -135,8 +135,6 @@
 	"saga",
 	// List of files for file-based fallback detection (optional)
 	0,
-	// Fallback callback
-	0,
 	// Flags
 	Common::kADFlagAugmentPreferredTarget
 };

Modified: scummvm/trunk/engines/touche/detection.cpp
===================================================================
--- scummvm/trunk/engines/touche/detection.cpp	2008-03-14 13:35:47 UTC (rev 31118)
+++ scummvm/trunk/engines/touche/detection.cpp	2008-03-14 13:59:31 UTC (rev 31119)
@@ -120,7 +120,6 @@
 	0, // no obsolete targets data
 	"touche",
 	Touche::fileBasedFallback, // file-based detection data to enable not yet known versions to start
-	0, // no fallback callback
 	Common::kADFlagAugmentPreferredTarget | Common::kADFlagPrintWarningOnFileBasedFallback
 };
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list