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

sev at users.sourceforge.net sev at users.sourceforge.net
Sat Nov 3 22:06:59 CET 2007


Revision: 29386
          http://scummvm.svn.sourceforge.net/scummvm/?rev=29386&view=rev
Author:   sev
Date:     2007-11-03 14:06:58 -0700 (Sat, 03 Nov 2007)

Log Message:
-----------
Patch #1825276: "DETECTION: advanced detector engine simplification"

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

Modified: scummvm/trunk/common/advancedDetector.cpp
===================================================================
--- scummvm/trunk/common/advancedDetector.cpp	2007-11-03 13:46:45 UTC (rev 29385)
+++ scummvm/trunk/common/advancedDetector.cpp	2007-11-03 21:06:58 UTC (rev 29386)
@@ -70,7 +70,7 @@
 	return GameList(params.list);
 }
 
-static void upgradeTargetIfNecessary(const Common::ADParams &params) {
+void upgradeTargetIfNecessary(const Common::ADParams &params) {
 	if (params.obsoleteList == 0)
 		return;
 
@@ -264,43 +264,6 @@
 	return result;
 }
 
-PluginError detectGameForEngineCreation(
-	const Common::ADParams &params
-	) {
-
-	upgradeTargetIfNecessary(params);
-
-	Common::String gameid = ConfMan.get("gameid");
-
-	FSList fslist;
-	FilesystemNode dir(ConfMan.get("path"));
-	if (!dir.getChildren(fslist, FilesystemNode::kListFilesOnly)) {
-		return kInvalidPathError;
-	}
-
-	ADGameDescList matches = detectGame(&fslist, params, Common::UNK_LANG, Common::kPlatformUnknown);
-
-	// We have single ID set, so we have a game if there are hits
-	if (params.singleid != NULL && matches.size())
-		return kNoError;
-
-	for (uint i = 0; i < matches.size(); i++) {
-		if (matches[i]->gameid == gameid) {
-			return kNoError;
-		}
-	}
-
-	// Use fallback detector if there were no matches by other means
-	if (params.fallbackDetectFunc != NULL) {
-		EncapsulatedADGameDesc fallbackDesc = (*params.fallbackDetectFunc)(&fslist);
-		if (fallbackDesc.realDesc != 0 && (params.singleid != NULL || fallbackDesc.getGameID() == gameid)) {
-			return kNoError;
-		}
-	}
-
-	return kNoGameDataFoundError;
-}
-
 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.

Modified: scummvm/trunk/common/advancedDetector.h
===================================================================
--- scummvm/trunk/common/advancedDetector.h	2007-11-03 13:46:45 UTC (rev 29385)
+++ scummvm/trunk/common/advancedDetector.h	2007-11-03 21:06:58 UTC (rev 29386)
@@ -236,22 +236,13 @@
 // FIXME/TODO: Rename this function to something more sensible.
 EncapsulatedADGameDesc detectBestMatchingGame(const Common::ADParams &params);
 
-// FIXME/TODO: Rename this function to something more sensible.
-// Only used by ADVANCED_DETECTOR_DEFINE_PLUGIN_WITH_FUNC
-PluginError detectGameForEngineCreation(const Common::ADParams &params);
+void upgradeTargetIfNecessary(const Common::ADParams &params);
 
+// FIXME/TODO: Rename this function to something more sensible.
 // Helper function to announce an unknown version of the game (useful for
 // fallback detection functions).
 void reportUnknown(StringList &files, int md5Bytes);
 
-// FIXME: It would probably be good to merge detectBestMatchingGame
-// and detectGameForEngineCreation into a single function. Right now, the
-// detection code called priort to creating an engine instance
-// (i.e. detectGameForEngineCreation) differs from the detection code the 
-// engines call internally (i.e. detectBestMatchingGame). This could lead
-// to hard to debug and odd errors.
-
-
 } // End of namespace AdvancedDetector
 
 
@@ -267,22 +258,11 @@
 	} \
 	void dummyFuncToAllowTrailingSemicolon()
 
-#define _ADVANCED_DETECTOR_DEFINE_PLUGIN_WITH_PREDEFINED_FUNC(engine,factoryFunc,params) \
+#define ADVANCED_DETECTOR_DEFINE_PLUGIN(engine,factoryFunc,params) \
 	_ADVANCED_DETECTOR_DEFINE_PLUGIN_HEAD(engine,params); \
 	PluginError Engine_##engine##_create(OSystem *syst, Engine **engine) { \
-		assert(syst); \
 		assert(engine); \
-		PluginError err = Common::AdvancedDetector::detectGameForEngineCreation(params); \
-		if (err == kNoError) \
-			*engine = factoryFunc(syst); \
-		return err; \
-	} \
-	void dummyFuncToAllowTrailingSemicolon()
-
-#define ADVANCED_DETECTOR_DEFINE_PLUGIN_WITH_COMPLEX_CREATION(engine,factoryFunc,params) \
-	_ADVANCED_DETECTOR_DEFINE_PLUGIN_HEAD(engine,params); \
-	PluginError Engine_##engine##_create(OSystem *syst, Engine **engine) { \
-		assert(engine); \
+		Common::AdvancedDetector::upgradeTargetIfNecessary(params); \
 		Common::EncapsulatedADGameDesc encapsulatedDesc = Common::AdvancedDetector::detectBestMatchingGame(params); \
 		if (encapsulatedDesc.realDesc == 0) { \
 			return kNoGameDataFoundError; \
@@ -294,14 +274,6 @@
 	} \
 	void dummyFuncToAllowTrailingSemicolon()
 
-#define ADVANCED_DETECTOR_DEFINE_PLUGIN(engine,className,params) \
-	static Engine *engine##_createInstance(OSystem *syst) { \
-		return new className(syst); \
-	} \
-	_ADVANCED_DETECTOR_DEFINE_PLUGIN_WITH_PREDEFINED_FUNC(engine,engine##_createInstance,params); \
-	void dummyFuncToAllowTrailingSemicolon()
-
-
 }	// End of namespace Common
 
 #endif

Modified: scummvm/trunk/engines/agi/agi.cpp
===================================================================
--- scummvm/trunk/engines/agi/agi.cpp	2007-11-03 13:46:45 UTC (rev 29385)
+++ scummvm/trunk/engines/agi/agi.cpp	2007-11-03 21:06:58 UTC (rev 29386)
@@ -605,11 +605,11 @@
 	setAmigaStyle(renderMode == Common::kRenderAmiga);
 }
 
-AgiBase::AgiBase(OSystem *syst) : Engine(syst) {
+AgiBase::AgiBase(OSystem *syst, const AGIGameDescription *gameDesc) : Engine(syst), _gameDescription(gameDesc) {
 
 }
 
-AgiEngine::AgiEngine(OSystem *syst) : AgiBase(syst) {
+AgiEngine::AgiEngine(OSystem *syst, const AGIGameDescription *gameDesc) : AgiBase(syst, gameDesc) {
 
 	// Setup mixer
 	if (!_mixer->isReady()) {
@@ -783,13 +783,6 @@
 
 int AgiEngine::init() {
 
-	// Detect game
-	if (!initGame()) {
-		GUIErrorMessage("No valid games were found in the specified directory.");
-		return -1;
-	}
-
-
 	// Initialize backend
 	_system->beginGFXTransaction();
 	initCommonGFX(false);

Modified: scummvm/trunk/engines/agi/agi.h
===================================================================
--- scummvm/trunk/engines/agi/agi.h	2007-11-03 13:46:45 UTC (rev 29385)
+++ scummvm/trunk/engines/agi/agi.h	2007-11-03 21:06:58 UTC (rev 29386)
@@ -656,7 +656,7 @@
 	virtual int agiGetKeypressLow() = 0;
 	virtual int agiIsKeypressLow() = 0;
 
-	AgiBase(OSystem *syst);
+	AgiBase(OSystem *syst, const AGIGameDescription *gameDesc);
 
 	#define INITIAL_IMAGE_STACK_SIZE 32
 
@@ -695,10 +695,8 @@
 	void shutdown();
 	void initialize();
 
-	bool initGame();
-
 public:
-	AgiEngine(OSystem *syst);
+	AgiEngine(OSystem *syst, const AGIGameDescription *gameDesc);
 	virtual ~AgiEngine();
 	int getGameId() {
 		return _gameId;

Modified: scummvm/trunk/engines/agi/detection.cpp
===================================================================
--- scummvm/trunk/engines/agi/detection.cpp	2007-11-03 13:46:45 UTC (rev 29385)
+++ scummvm/trunk/engines/agi/detection.cpp	2007-11-03 21:06:58 UTC (rev 29386)
@@ -2253,13 +2253,13 @@
 
 	switch (gd->gameType) {
 	case Agi::GType_PreAGI:
-		*engine = new Agi::PreAgiEngine(syst);
+		*engine = new Agi::PreAgiEngine(syst, gd);
 		break;
 	case Agi::GType_V2:
-		*engine = new Agi::AgiEngine(syst);
+		*engine = new Agi::AgiEngine(syst, gd);
 		break;
 	case Agi::GType_V3:
-		*engine = new Agi::AgiEngine(syst);
+		*engine = new Agi::AgiEngine(syst, gd);
 		break;
 	default:
 		res = false;
@@ -2269,25 +2269,7 @@
 	return res;
 }
 
-ADVANCED_DETECTOR_DEFINE_PLUGIN_WITH_COMPLEX_CREATION(AGI, engineCreateAgi, detectionParams);
+ADVANCED_DETECTOR_DEFINE_PLUGIN(AGI, engineCreateAgi, detectionParams);
 
 REGISTER_PLUGIN(AGI, "AGI preAGI + v2 + v3 Engine", "Sierra AGI Engine (C) Sierra On-Line Software");
 
-namespace Agi {
-
-bool AgiEngine::initGame() {
-	Common::EncapsulatedADGameDesc encapsulatedDesc = Common::AdvancedDetector::detectBestMatchingGame(detectionParams);
-	_gameDescription = (const AGIGameDescription *)(encapsulatedDesc.realDesc);
-
-	return (_gameDescription != 0);
-}
-
-bool PreAgiEngine::initGame() {
-	Common::EncapsulatedADGameDesc encapsulatedDesc = Common::AdvancedDetector::detectBestMatchingGame(detectionParams);
-	_gameDescription = (const AGIGameDescription *)(encapsulatedDesc.realDesc);
-
-	return (_gameDescription != 0);
-}
-
-} // End of namespace Agi
-

Modified: scummvm/trunk/engines/agi/preagi.cpp
===================================================================
--- scummvm/trunk/engines/agi/preagi.cpp	2007-11-03 13:46:45 UTC (rev 29385)
+++ scummvm/trunk/engines/agi/preagi.cpp	2007-11-03 21:06:58 UTC (rev 29386)
@@ -51,7 +51,7 @@
 
 namespace Agi {
 
-PreAgiEngine::PreAgiEngine(OSystem *syst) : AgiBase(syst) {
+PreAgiEngine::PreAgiEngine(OSystem *syst, const AGIGameDescription *gameDesc) : AgiBase(syst, gameDesc) {
 
 	// Setup mixer
 	if (!_mixer->isReady()) {
@@ -195,13 +195,6 @@
 }
 
 int PreAgiEngine::init() {
-
-	// Detect game
-	if (!initGame()) {
-		GUIErrorMessage("No valid games were found in the specified directory.");
-		return -1;
-	}
-
 	// Initialize backend
 	_system->beginGFXTransaction();
 	initCommonGFX(false);

Modified: scummvm/trunk/engines/agi/preagi.h
===================================================================
--- scummvm/trunk/engines/agi/preagi.h	2007-11-03 13:46:45 UTC (rev 29385)
+++ scummvm/trunk/engines/agi/preagi.h	2007-11-03 21:06:58 UTC (rev 29386)
@@ -40,14 +40,12 @@
 	void shutdown();
 	void initialize();
 
-	bool initGame();
-
 public:
 	void agiTimerLow() {}
 	int agiGetKeypressLow() { return 0; }
 	int agiIsKeypressLow() { return 0; }
 
-	PreAgiEngine(OSystem *syst);
+	PreAgiEngine(OSystem *syst, const AGIGameDescription *gameDesc);
 	virtual ~PreAgiEngine();
 	int getGameId() {
 		return _gameId;

Modified: scummvm/trunk/engines/agos/agos.cpp
===================================================================
--- scummvm/trunk/engines/agos/agos.cpp	2007-11-03 13:46:45 UTC (rev 29385)
+++ scummvm/trunk/engines/agos/agos.cpp	2007-11-03 21:06:58 UTC (rev 29386)
@@ -525,12 +525,6 @@
 }
 
 int AGOSEngine::init() {
-	// Detect game
-	if (!initGame()) {
-		GUIErrorMessage("No valid games were found in the specified directory.");
-		return -1;
-	}
-
 	if (getGameId() == GID_DIMP) {
 		_screenWidth = 496;
 		_screenHeight = 400;

Modified: scummvm/trunk/engines/agos/agos.h
===================================================================
--- scummvm/trunk/engines/agos/agos.h	2007-11-03 13:46:45 UTC (rev 29385)
+++ scummvm/trunk/engines/agos/agos.h	2007-11-03 21:06:58 UTC (rev 29386)
@@ -179,7 +179,6 @@
 
 	const AGOSGameDescription *_gameDescription;
 
-	bool initGame(void);
 	virtual void setupGame();
 
 	int getGameId() const;

Modified: scummvm/trunk/engines/agos/detection.cpp
===================================================================
--- scummvm/trunk/engines/agos/detection.cpp	2007-11-03 13:46:45 UTC (rev 29385)
+++ scummvm/trunk/engines/agos/detection.cpp	2007-11-03 21:06:58 UTC (rev 29386)
@@ -129,24 +129,19 @@
 		res = false;
 		error("AGOS engine: unknown gameType");
 	}
+	if (res) {
+		((AGOS::AGOSEngine *)*engine)->_gameDescription = gd;
+	}
 
 	return res;
 }
 
-ADVANCED_DETECTOR_DEFINE_PLUGIN_WITH_COMPLEX_CREATION(AGOS, engineCreateAgos, detectionParams);
+ADVANCED_DETECTOR_DEFINE_PLUGIN(AGOS, engineCreateAgos, detectionParams);
 
 REGISTER_PLUGIN(AGOS, "AGOS", "AGOS (C) Adventure Soft");
 
 namespace AGOS {
 
-bool AGOSEngine::initGame() {
-	Common::EncapsulatedADGameDesc encapsulatedDesc = Common::AdvancedDetector::detectBestMatchingGame(detectionParams);
-	_gameDescription = (const AGOSGameDescription *)(encapsulatedDesc.realDesc);
-
-	return (_gameDescription != 0);
-}
-
-
 int AGOSEngine::getGameId() const {
 	return _gameDescription->gameId;
 }

Modified: scummvm/trunk/engines/cine/cine.cpp
===================================================================
--- scummvm/trunk/engines/cine/cine.cpp	2007-11-03 13:46:45 UTC (rev 29385)
+++ scummvm/trunk/engines/cine/cine.cpp	2007-11-03 21:06:58 UTC (rev 29386)
@@ -50,7 +50,7 @@
 
 CineEngine *g_cine;
 
-CineEngine::CineEngine(OSystem *syst) : Engine(syst) {
+CineEngine::CineEngine(OSystem *syst, const CINEGameDescription *gameDesc) : Engine(syst), _gameDescription(gameDesc) {
 	Common::addSpecialDebugLevel(kCineDebugScript, "Script", "Script debug level");
 
 	// Setup mixer
@@ -74,12 +74,6 @@
 }
 
 int CineEngine::init() {
-	// Detect game
-	if (!initGame()) {
-		GUIErrorMessage("No valid games were found in the specified directory.");
-		return -1;
-	}
-
 	// Initialize backend
 	_system->beginGFXTransaction();
 	initCommonGFX(false);

Modified: scummvm/trunk/engines/cine/cine.h
===================================================================
--- scummvm/trunk/engines/cine/cine.h	2007-11-03 13:46:45 UTC (rev 29385)
+++ scummvm/trunk/engines/cine/cine.h	2007-11-03 21:06:58 UTC (rev 29386)
@@ -71,7 +71,7 @@
 	bool initGame();
 
 public:
-	CineEngine(OSystem *syst);
+	CineEngine(OSystem *syst, const CINEGameDescription *gameDesc);
 	virtual ~CineEngine();
 
 	int getGameType() const;

Modified: scummvm/trunk/engines/cine/detection.cpp
===================================================================
--- scummvm/trunk/engines/cine/detection.cpp	2007-11-03 13:46:45 UTC (rev 29385)
+++ scummvm/trunk/engines/cine/detection.cpp	2007-11-03 21:06:58 UTC (rev 29386)
@@ -487,17 +487,14 @@
 	Common::kADFlagAugmentPreferredTarget
 };
 
-ADVANCED_DETECTOR_DEFINE_PLUGIN(CINE, Cine::CineEngine, detectionParams);
-
-REGISTER_PLUGIN(CINE, "Cinematique evo 1 engine", "Future Wars & Operation Stealth (C) Delphine Software");
-
-namespace Cine {
-
-bool CineEngine::initGame() {
-	Common::EncapsulatedADGameDesc encapsulatedDesc = Common::AdvancedDetector::detectBestMatchingGame(detectionParams);
-	_gameDescription = (const CINEGameDescription *)(encapsulatedDesc.realDesc);
-
-	return (_gameDescription != 0);
+static bool Engine_CINE_createInstance(OSystem *syst, Engine **engine, Common::EncapsulatedADGameDesc encapsulatedDesc) {
+	const Cine::CINEGameDescription *gd = (const Cine::CINEGameDescription *)(encapsulatedDesc.realDesc);
+	if (gd) {
+		*engine = new Cine::CineEngine(syst, gd);
+	}
+	return gd != 0;
 }
 
-} // End of namespace Cine
+ADVANCED_DETECTOR_DEFINE_PLUGIN(CINE, Engine_CINE_createInstance, detectionParams);
+
+REGISTER_PLUGIN(CINE, "Cinematique evo 1 engine", "Future Wars & Operation Stealth (C) Delphine Software");

Modified: scummvm/trunk/engines/cruise/cruise.cpp
===================================================================
--- scummvm/trunk/engines/cruise/cruise.cpp	2007-11-03 13:46:45 UTC (rev 29385)
+++ scummvm/trunk/engines/cruise/cruise.cpp	2007-11-03 21:06:58 UTC (rev 29386)
@@ -44,7 +44,7 @@
 
 CruiseEngine *g_cruise;
 
-CruiseEngine::CruiseEngine(OSystem * syst) : Engine(syst) {
+CruiseEngine::CruiseEngine(OSystem * syst, const CRUISEGameDescription *gameDesc) : Engine(syst), _gameDescription(gameDesc) {
 
 #ifdef PALMOS_MODE
 	_currentVolumeFile = new Common::File();
@@ -75,11 +75,6 @@
 }
 
 int CruiseEngine::init() {
-	// Detect game
-	if (!initGame()) {
-		GUIErrorMessage ("No valid games were found in the specified directory.");
-		return -1;
-	}
 	// Initialize backend
 	_system->beginGFXTransaction();
 	initCommonGFX(false);

Modified: scummvm/trunk/engines/cruise/cruise.h
===================================================================
--- scummvm/trunk/engines/cruise/cruise.h	2007-11-03 13:46:45 UTC (rev 29385)
+++ scummvm/trunk/engines/cruise/cruise.h	2007-11-03 21:06:58 UTC (rev 29386)
@@ -51,7 +51,7 @@
 	bool initGame();
 
 public:
-	CruiseEngine(OSystem * syst);
+	CruiseEngine(OSystem * syst, const CRUISEGameDescription *gameDesc);
 	virtual ~ CruiseEngine();
 
 	int getGameType() const;

Modified: scummvm/trunk/engines/cruise/detection.cpp
===================================================================
--- scummvm/trunk/engines/cruise/detection.cpp	2007-11-03 13:46:45 UTC (rev 29385)
+++ scummvm/trunk/engines/cruise/detection.cpp	2007-11-03 21:06:58 UTC (rev 29386)
@@ -111,17 +111,14 @@
 	Common::kADFlagAugmentPreferredTarget
 };
 
-ADVANCED_DETECTOR_DEFINE_PLUGIN(CRUISE, Cruise::CruiseEngine, detectionParams);
-
-REGISTER_PLUGIN(CRUISE, "Cinematique evo 2 engine", "Cruise for a Corpse (C) Delphine Software");
-
-namespace Cruise {
-
-bool CruiseEngine::initGame() {
-	Common::EncapsulatedADGameDesc encapsulatedDesc = Common::AdvancedDetector::detectBestMatchingGame(detectionParams);
-	_gameDescription = (const CRUISEGameDescription *)(encapsulatedDesc.realDesc);
-
-	return (_gameDescription != 0);
+static bool Engine_CRUISE_createInstance(OSystem *syst, Engine **engine, Common::EncapsulatedADGameDesc encapsulatedDesc) {
+	const Cruise::CRUISEGameDescription *gd = (const Cruise::CRUISEGameDescription *)(encapsulatedDesc.realDesc);
+	if (gd) {
+		*engine = new Cruise::CruiseEngine(syst, gd);
+	}
+	return gd != 0;
 }
 
-} // End of namespace Cruise
+ADVANCED_DETECTOR_DEFINE_PLUGIN(CRUISE, Engine_CRUISE_createInstance, detectionParams);
+
+REGISTER_PLUGIN(CRUISE, "Cinematique evo 2 engine", "Cruise for a Corpse (C) Delphine Software");

Modified: scummvm/trunk/engines/drascula/detection.cpp
===================================================================
--- scummvm/trunk/engines/drascula/detection.cpp	2007-11-03 13:46:45 UTC (rev 29385)
+++ scummvm/trunk/engines/drascula/detection.cpp	2007-11-03 21:06:58 UTC (rev 29386)
@@ -164,18 +164,15 @@
 	Common::kADFlagAugmentPreferredTarget
 };
 
-ADVANCED_DETECTOR_DEFINE_PLUGIN(DRASCULA, Drascula::DrasculaEngine, detectionParams);
-
-REGISTER_PLUGIN(DRASCULA, "Drascula Engine", "Drascula Engine (C) 2000 Alcachofa Soft, 1996 (C) Digital Dreams Multimedia, 1994 (C) Emilio de Paz");
-
-namespace Drascula {
-
-bool DrasculaEngine::initGame() {
-	Common::EncapsulatedADGameDesc encapsulatedDesc = Common::AdvancedDetector::detectBestMatchingGame(detectionParams);
-	_gameDescription = (const DrasculaGameDescription *)(encapsulatedDesc.realDesc);
-
-	return (_gameDescription != 0);
+static bool Engine_DRASCULA_createInstance(OSystem *syst, Engine **engine, Common::EncapsulatedADGameDesc encapsulatedDesc) {
+	const Drascula::DrasculaGameDescription *gd = (const Drascula::DrasculaGameDescription *)(encapsulatedDesc.realDesc);
+	if (gd) {
+		*engine = new Drascula::DrasculaEngine(syst, gd);
+	}
+	return gd != 0;
 }
 
-} // End of namespace Drascula
+ADVANCED_DETECTOR_DEFINE_PLUGIN(DRASCULA, Engine_DRASCULA_createInstance, detectionParams);
 
+REGISTER_PLUGIN(DRASCULA, "Drascula Engine", "Drascula Engine (C) 2000 Alcachofa Soft, 1996 (C) Digital Dreams Multimedia, 1994 (C) Emilio de Paz");
+

Modified: scummvm/trunk/engines/drascula/drascula.cpp
===================================================================
--- scummvm/trunk/engines/drascula/drascula.cpp	2007-11-03 13:46:45 UTC (rev 29385)
+++ scummvm/trunk/engines/drascula/drascula.cpp	2007-11-03 21:06:58 UTC (rev 29386)
@@ -53,7 +53,7 @@
 	{NULL, NULL, 0, 0, NULL}
 };
 
-DrasculaEngine::DrasculaEngine(OSystem *syst) : Engine(syst) {
+DrasculaEngine::DrasculaEngine(OSystem *syst, const DrasculaGameDescription *gameDesc) : Engine(syst), _gameDescription(gameDesc) {
 
 	// Setup mixer
 	if (!_mixer->isReady()) {
@@ -119,12 +119,6 @@
 static char poder_v[6][14] = {"11.als", "109.als", "111.als", "110.als", "115.als", "116.als"};
 
 int DrasculaEngine::init() {
-	// Detect game
-	if (!initGame()) {
-		GUIErrorMessage("No valid games were found in the specified directory.");
-		return -1;
-	}
-
 	// Initialize backend
 	_system->beginGFXTransaction();
 		initCommonGFX(false);

Modified: scummvm/trunk/engines/drascula/drascula.h
===================================================================
--- scummvm/trunk/engines/drascula/drascula.h	2007-11-03 13:46:45 UTC (rev 29385)
+++ scummvm/trunk/engines/drascula/drascula.h	2007-11-03 21:06:58 UTC (rev 29386)
@@ -337,10 +337,8 @@
 	int go();
 //	void shutdown();
 
-	bool initGame();
-
 public:
-	DrasculaEngine(OSystem *syst);
+	DrasculaEngine(OSystem *syst, const DrasculaGameDescription *gameDesc);
 	virtual ~DrasculaEngine();
 	int getGameId() {
 		return _gameId;

Modified: scummvm/trunk/engines/gob/detection.cpp
===================================================================
--- scummvm/trunk/engines/gob/detection.cpp	2007-11-03 13:46:45 UTC (rev 29385)
+++ scummvm/trunk/engines/gob/detection.cpp	2007-11-03 21:06:58 UTC (rev 29386)
@@ -1701,20 +1701,22 @@
 	kADFlagAugmentPreferredTarget
 };
 
-ADVANCED_DETECTOR_DEFINE_PLUGIN(GOB, Gob::GobEngine, detectionParams);
+static bool Engine_GOB_createInstance(OSystem *syst, Engine **engine, Common::EncapsulatedADGameDesc encapsulatedDesc) {
+	const Gob::GOBGameDescription *gd = (const Gob::GOBGameDescription *)(encapsulatedDesc.realDesc);
+	if (gd) {
+		*engine = new Gob::GobEngine(syst);
+		((Gob::GobEngine *)*engine)->initGame(gd);
+	}
+	return gd != 0;
+}
 
+ADVANCED_DETECTOR_DEFINE_PLUGIN(GOB, Engine_GOB_createInstance, detectionParams);
+
 REGISTER_PLUGIN(GOB, "Gob Engine", "Goblins Games (C) Coktel Vision");
 
-
 namespace Gob {
 
-bool GobEngine::detectGame() {
-	Common::EncapsulatedADGameDesc encapsulatedDesc = Common::AdvancedDetector::detectBestMatchingGame(detectionParams);
-	const GOBGameDescription *gd = (const GOBGameDescription *)(encapsulatedDesc.realDesc);
-
-	if (gd == 0)
-		return false;
-
+void GobEngine::initGame(const GOBGameDescription *gd) {
 	if (gd->startTotBase == 0) {
 		_startTot = new char[10];
 		_startTot0 = new char[11];
@@ -1733,8 +1735,6 @@
 	_features = gd->features;
 	_language = gd->desc.language;
 	_platform = gd->desc.platform;
-
-	return true;
 }
 
 } // End of namespace Gob

Modified: scummvm/trunk/engines/gob/gob.cpp
===================================================================
--- scummvm/trunk/engines/gob/gob.cpp	2007-11-03 13:46:45 UTC (rev 29385)
+++ scummvm/trunk/engines/gob/gob.cpp	2007-11-03 21:06:58 UTC (rev 29386)
@@ -145,12 +145,6 @@
 }
 
 int GobEngine::init() {
-	// Detect game
-	if (!detectGame()) {
-		GUIErrorMessage("No valid games were found in the specified directory.");
-		return -1;
-	}
-
 	if (!initGameParts()) {
 		GUIErrorMessage("GobEngine::init(): Unknown version of game engine");
 		return -1;

Modified: scummvm/trunk/engines/gob/gob.h
===================================================================
--- scummvm/trunk/engines/gob/gob.h	2007-11-03 13:46:45 UTC (rev 29385)
+++ scummvm/trunk/engines/gob/gob.h	2007-11-03 21:06:58 UTC (rev 29386)
@@ -167,6 +167,8 @@
 	friend class Ptr;
 };
 
+struct GOBGameDescription;
+
 class GobEngine : public Engine {
 protected:
 	GobEngine *_vm;
@@ -177,8 +179,6 @@
 	bool initGameParts();
 	void deinitGameParts();
 
-	bool detectGame();
-
 public:
 	static const Common::Language _gobToScummVMLang[];
 
@@ -237,6 +237,8 @@
 
 	GobEngine(OSystem *syst);
 	virtual ~GobEngine();
+
+	void initGame(const GOBGameDescription *gd);
 };
 
 } // End of namespace Gob

Modified: scummvm/trunk/engines/kyra/detection.cpp
===================================================================
--- scummvm/trunk/engines/kyra/detection.cpp	2007-11-03 13:46:45 UTC (rev 29385)
+++ scummvm/trunk/engines/kyra/detection.cpp	2007-11-03 21:06:58 UTC (rev 29386)
@@ -436,7 +436,7 @@
 	return res;
 }
 
-ADVANCED_DETECTOR_DEFINE_PLUGIN_WITH_COMPLEX_CREATION(KYRA, engineCreateKyra, detectionParams);
+ADVANCED_DETECTOR_DEFINE_PLUGIN(KYRA, engineCreateKyra, detectionParams);
 
 REGISTER_PLUGIN(KYRA, "Legend of Kyrandia Engine", "The Legend of Kyrandia (C) Westwood Studios");
 

Modified: scummvm/trunk/engines/parallaction/detection.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/detection.cpp	2007-11-03 13:46:45 UTC (rev 29385)
+++ scummvm/trunk/engines/parallaction/detection.cpp	2007-11-03 21:06:58 UTC (rev 29386)
@@ -184,16 +184,16 @@
 	Common::kADFlagAugmentPreferredTarget
 };
 
-bool engineCreateParallaction(OSystem *syst, Engine **engine, Common::EncapsulatedADGameDesc encapsulatedDesc) {
+static bool Engine_PARALLACTION_createInstance(OSystem *syst, Engine **engine, Common::EncapsulatedADGameDesc encapsulatedDesc) {
 	const Parallaction::PARALLACTIONGameDescription *gd = (const Parallaction::PARALLACTIONGameDescription *)(encapsulatedDesc.realDesc);
 	bool res = true;
 
 	switch (gd->gameType) {
 	case Parallaction::GType_Nippon:
-		*engine = new Parallaction::Parallaction_ns(syst);
+		*engine = new Parallaction::Parallaction_ns(syst, gd);
 		break;
 	case Parallaction::GType_BRA:
-		*engine = new Parallaction::Parallaction_br(syst);
+		*engine = new Parallaction::Parallaction_br(syst, gd);
 		break;
 	default:
 		res = false;
@@ -203,18 +203,6 @@
 	return res;
 }
 
-ADVANCED_DETECTOR_DEFINE_PLUGIN_WITH_COMPLEX_CREATION(PARALLACTION, engineCreateParallaction, detectionParams);
+ADVANCED_DETECTOR_DEFINE_PLUGIN(PARALLACTION, Engine_PARALLACTION_createInstance, detectionParams);
 
 REGISTER_PLUGIN(PARALLACTION, "Parallaction engine", "Nippon Safes Inc. (C) Dynabyte");
-
-
-namespace Parallaction {
-
-bool Parallaction::detectGame() {
-	Common::EncapsulatedADGameDesc encapsulatedDesc = Common::AdvancedDetector::detectBestMatchingGame(detectionParams);
-	_gameDescription = (const PARALLACTIONGameDescription *)(encapsulatedDesc.realDesc);
-
-	return (_gameDescription != 0);
-}
-
-} // End of namespace Parallaction

Modified: scummvm/trunk/engines/parallaction/parallaction.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction.cpp	2007-11-03 13:46:45 UTC (rev 29385)
+++ scummvm/trunk/engines/parallaction/parallaction.cpp	2007-11-03 21:06:58 UTC (rev 29386)
@@ -91,8 +91,8 @@
 static Job	   *_jRunScripts = NULL;
 
 
-Parallaction::Parallaction(OSystem *syst) :
-	Engine(syst), _char(this) {
+Parallaction::Parallaction(OSystem *syst, const PARALLACTIONGameDescription *gameDesc) :
+	Engine(syst), _gameDescription(gameDesc), _char(this) {
 
 	// FIXME: Fingolfin asks: why is there a FIXME here? Please either clarify what
 	// needs fixing, or remove it!

Modified: scummvm/trunk/engines/parallaction/parallaction.h
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction.h	2007-11-03 13:46:45 UTC (rev 29385)
+++ scummvm/trunk/engines/parallaction/parallaction.h	2007-11-03 21:06:58 UTC (rev 29386)
@@ -363,7 +363,7 @@
 
 public:
 
-	Parallaction(OSystem *syst);
+	Parallaction(OSystem *syst, const PARALLACTIONGameDescription *gameDesc);
 	~Parallaction();
 
 	int init();
@@ -640,7 +640,7 @@
 class Parallaction_ns : public Parallaction {
 
 public:
-	Parallaction_ns(OSystem* syst) : Parallaction(syst) { }
+	Parallaction_ns(OSystem* syst, const PARALLACTIONGameDescription *gameDesc) : Parallaction(syst, gameDesc) { }
 	~Parallaction_ns();
 
 	int init();
@@ -922,7 +922,7 @@
 	typedef Parallaction_ns Super;
 
 public:
-	Parallaction_br(OSystem* syst) : Parallaction_ns(syst) { }
+	Parallaction_br(OSystem* syst, const PARALLACTIONGameDescription *gameDesc) : Parallaction_ns(syst, gameDesc) { }
 	~Parallaction_br();
 
 	int init();

Modified: scummvm/trunk/engines/parallaction/parallaction_br.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction_br.cpp	2007-11-03 13:46:45 UTC (rev 29385)
+++ scummvm/trunk/engines/parallaction/parallaction_br.cpp	2007-11-03 21:06:58 UTC (rev 29386)
@@ -59,12 +59,6 @@
 
 int Parallaction_br::init() {
 
-	// Detect game
-	if (!detectGame()) {
-		GUIErrorMessage("No valid games were found in the specified directory.");
-		return -1;
-	}
-
 	_screenWidth = 640;
 	_screenHeight = 400;
 

Modified: scummvm/trunk/engines/parallaction/parallaction_ns.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction_ns.cpp	2007-11-03 13:46:45 UTC (rev 29385)
+++ scummvm/trunk/engines/parallaction/parallaction_ns.cpp	2007-11-03 21:06:58 UTC (rev 29386)
@@ -111,12 +111,6 @@
 
 int Parallaction_ns::init() {
 
-	// Detect game
-	if (!detectGame()) {
-		GUIErrorMessage("No valid games were found in the specified directory.");
-		return -1;
-	}
-
 	_screenWidth = 320;
 	_screenHeight = 200;
 

Modified: scummvm/trunk/engines/saga/detection.cpp
===================================================================
--- scummvm/trunk/engines/saga/detection.cpp	2007-11-03 13:46:45 UTC (rev 29385)
+++ scummvm/trunk/engines/saga/detection.cpp	2007-11-03 21:06:58 UTC (rev 29386)
@@ -139,19 +139,21 @@
 	Common::kADFlagAugmentPreferredTarget
 };
 
-ADVANCED_DETECTOR_DEFINE_PLUGIN(SAGA, Saga::SagaEngine, detectionParams);
+static bool Engine_SAGA_createInstance(OSystem *syst, Engine **engine, Common::EncapsulatedADGameDesc encapsulatedDesc) {
+	const Saga::SAGAGameDescription *gd = (const Saga::SAGAGameDescription *)(encapsulatedDesc.realDesc);
+	if (gd) {
+		*engine = new Saga::SagaEngine(syst, gd);
+	}
+	return gd != 0;
+}
 
+ADVANCED_DETECTOR_DEFINE_PLUGIN(SAGA, Engine_SAGA_createInstance, detectionParams);
+
 REGISTER_PLUGIN(SAGA, "SAGA Engine", "Inherit the Earth (C) Wyrmkeep Entertainment");
 
 namespace Saga {
 
 bool SagaEngine::initGame() {
-	Common::EncapsulatedADGameDesc encapsulatedDesc = Common::AdvancedDetector::detectBestMatchingGame(detectionParams);
-	_gameDescription = (const SAGAGameDescription *)(encapsulatedDesc.realDesc);
-
-	if (_gameDescription == 0)
-		return false;
-
 	_displayClip.right = getDisplayInfo().logicalWidth;
 	_displayClip.bottom = getDisplayInfo().logicalHeight;
 

Modified: scummvm/trunk/engines/saga/saga.cpp
===================================================================
--- scummvm/trunk/engines/saga/saga.cpp	2007-11-03 13:46:45 UTC (rev 29385)
+++ scummvm/trunk/engines/saga/saga.cpp	2007-11-03 21:06:58 UTC (rev 29386)
@@ -59,8 +59,8 @@
 
 #define MAX_TIME_DELTA 100
 
-SagaEngine::SagaEngine(OSystem *syst)
-	: Engine(syst) {
+SagaEngine::SagaEngine(OSystem *syst, const SAGAGameDescription *gameDesc)
+	: Engine(syst), _gameDescription(gameDesc) {
 
 	_leftMouseButtonPressed = _rightMouseButtonPressed = false;
 

Modified: scummvm/trunk/engines/saga/saga.h
===================================================================
--- scummvm/trunk/engines/saga/saga.h	2007-11-03 13:46:45 UTC (rev 29385)
+++ scummvm/trunk/engines/saga/saga.h	2007-11-03 21:06:58 UTC (rev 29386)
@@ -504,7 +504,7 @@
 	int go();
 	int init();
 public:
-	SagaEngine(OSystem *syst);
+	SagaEngine(OSystem *syst, const SAGAGameDescription *gameDesc);
 	virtual ~SagaEngine();
 	void shutDown() { _quit = true; }
 

Modified: scummvm/trunk/engines/touche/detection.cpp
===================================================================
--- scummvm/trunk/engines/touche/detection.cpp	2007-11-03 13:46:45 UTC (rev 29385)
+++ scummvm/trunk/engines/touche/detection.cpp	2007-11-03 21:06:58 UTC (rev 29386)
@@ -110,7 +110,7 @@
 	{ 0, { 0 } }
 };
 
-}
+} // End of namespace Touche
 
 static const Common::ADParams detectionParams = {
 	(const byte *)Touche::gameDescriptions,
@@ -124,21 +124,14 @@
 	Common::kADFlagAugmentPreferredTarget | Common::kADFlagPrintWarningOnFileBasedFallback
 };
 
-ADVANCED_DETECTOR_DEFINE_PLUGIN(TOUCHE, Touche::ToucheEngine, detectionParams);
-
-REGISTER_PLUGIN(TOUCHE, "Touche Engine", "Touche: The Adventures of the 5th Musketeer (C) Clipper Software");
-
-namespace Touche {
-
-bool ToucheEngine::detectGame() {
-	Common::EncapsulatedADGameDesc encapsulatedDesc = Common::AdvancedDetector::detectBestMatchingGame(detectionParams);
+static bool Engine_TOUCHE_createInstance(OSystem *syst, Engine **engine, const Common::EncapsulatedADGameDesc &encapsulatedDesc) {
 	const Common::ADGameDescription *gd = encapsulatedDesc.realDesc;
-
-	if (gd == 0)
-		return false;
-
-	_language = gd->language;
-	return true;
+	if (gd) {
+		*engine = new Touche::ToucheEngine(syst, gd->language);
+	}
+	return gd != 0;
 }
 
-} // End of namespace Touche
+ADVANCED_DETECTOR_DEFINE_PLUGIN(TOUCHE, Engine_TOUCHE_createInstance, detectionParams);
+
+REGISTER_PLUGIN(TOUCHE, "Touche Engine", "Touche: The Adventures of the 5th Musketeer (C) Clipper Software");

Modified: scummvm/trunk/engines/touche/touche.cpp
===================================================================
--- scummvm/trunk/engines/touche/touche.cpp	2007-11-03 13:46:45 UTC (rev 29385)
+++ scummvm/trunk/engines/touche/touche.cpp	2007-11-03 21:06:58 UTC (rev 29386)
@@ -37,8 +37,8 @@
 
 namespace Touche {
 
-ToucheEngine::ToucheEngine(OSystem *system)
-	: Engine(system), _midiPlayer(0) {
+ToucheEngine::ToucheEngine(OSystem *system, Common::Language language)
+	: Engine(system), _midiPlayer(0), _language(language) {
 
 	_saveLoadCurrentPage = 0;
 	_saveLoadCurrentSlot = 0;
@@ -87,12 +87,6 @@
 		_system->initSize(kScreenWidth, kScreenHeight);
 	_system->endGFXTransaction();
 
-	// Detect game
-	if (!detectGame()) {
-		GUIErrorMessage("No valid games were found in the specified directory.");
-		return -1;
-	}
-
 	Graphics::setupFont(_language);
 
 	setupOpcodes();

Modified: scummvm/trunk/engines/touche/touche.h
===================================================================
--- scummvm/trunk/engines/touche/touche.h	2007-11-03 13:46:45 UTC (rev 29385)
+++ scummvm/trunk/engines/touche/touche.h	2007-11-03 21:06:58 UTC (rev 29386)
@@ -351,7 +351,7 @@
 
 	typedef void (ToucheEngine::*OpcodeProc)();
 
-	ToucheEngine(OSystem *system);
+	ToucheEngine(OSystem *system, Common::Language language);
 	virtual ~ToucheEngine();
 
 	virtual int init();


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