aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/advancedDetector.cpp39
-rw-r--r--common/advancedDetector.h36
-rw-r--r--engines/agi/agi.cpp11
-rw-r--r--engines/agi/agi.h6
-rw-r--r--engines/agi/detection.cpp26
-rw-r--r--engines/agi/preagi.cpp9
-rw-r--r--engines/agi/preagi.h4
-rw-r--r--engines/agos/agos.cpp6
-rw-r--r--engines/agos/agos.h1
-rw-r--r--engines/agos/detection.cpp13
-rw-r--r--engines/cine/cine.cpp8
-rw-r--r--engines/cine/cine.h2
-rw-r--r--engines/cine/detection.cpp21
-rw-r--r--engines/cruise/cruise.cpp7
-rw-r--r--engines/cruise/cruise.h2
-rw-r--r--engines/cruise/detection.cpp21
-rw-r--r--engines/drascula/detection.cpp21
-rw-r--r--engines/drascula/drascula.cpp8
-rw-r--r--engines/drascula/drascula.h4
-rw-r--r--engines/gob/detection.cpp22
-rw-r--r--engines/gob/gob.cpp6
-rw-r--r--engines/gob/gob.h6
-rw-r--r--engines/kyra/detection.cpp2
-rw-r--r--engines/parallaction/detection.cpp20
-rw-r--r--engines/parallaction/parallaction.cpp4
-rw-r--r--engines/parallaction/parallaction.h6
-rw-r--r--engines/parallaction/parallaction_br.cpp6
-rw-r--r--engines/parallaction/parallaction_ns.cpp6
-rw-r--r--engines/saga/detection.cpp16
-rw-r--r--engines/saga/saga.cpp4
-rw-r--r--engines/saga/saga.h2
-rw-r--r--engines/touche/detection.cpp25
-rw-r--r--engines/touche/touche.cpp10
-rw-r--r--engines/touche/touche.h2
34 files changed, 101 insertions, 281 deletions
diff --git a/common/advancedDetector.cpp b/common/advancedDetector.cpp
index b15477c5a2..3b235835f3 100644
--- a/common/advancedDetector.cpp
+++ b/common/advancedDetector.cpp
@@ -70,7 +70,7 @@ GameList gameIDList(const Common::ADParams &params) {
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 @@ EncapsulatedADGameDesc detectBestMatchingGame(
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.
diff --git a/common/advancedDetector.h b/common/advancedDetector.h
index b98b7a45ff..9acd2d22be 100644
--- a/common/advancedDetector.h
+++ b/common/advancedDetector.h
@@ -236,22 +236,13 @@ GameList detectAllGames(const FSList &fslist, const Common::ADParams &params);
// 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 reportUnknown(StringList &files, int md5Bytes);
} \
void dummyFuncToAllowTrailingSemicolon()
-#define _ADVANCED_DETECTOR_DEFINE_PLUGIN_WITH_PREDEFINED_FUNC(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) \
+#define ADVANCED_DETECTOR_DEFINE_PLUGIN(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 reportUnknown(StringList &files, int md5Bytes);
} \
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
diff --git a/engines/agi/agi.cpp b/engines/agi/agi.cpp
index a8d521ff69..e46b017ad8 100644
--- a/engines/agi/agi.cpp
+++ b/engines/agi/agi.cpp
@@ -605,11 +605,11 @@ AgiButtonStyle::AgiButtonStyle(Common::RenderMode renderMode) {
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 @@ AgiEngine::~AgiEngine() {
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);
diff --git a/engines/agi/agi.h b/engines/agi/agi.h
index 358660619b..c1b649435c 100644
--- a/engines/agi/agi.h
+++ b/engines/agi/agi.h
@@ -656,7 +656,7 @@ public:
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 @@ protected:
void shutdown();
void initialize();
- bool initGame();
-
public:
- AgiEngine(OSystem *syst);
+ AgiEngine(OSystem *syst, const AGIGameDescription *gameDesc);
virtual ~AgiEngine();
int getGameId() {
return _gameId;
diff --git a/engines/agi/detection.cpp b/engines/agi/detection.cpp
index 9bb767f7d8..2b64913992 100644
--- a/engines/agi/detection.cpp
+++ b/engines/agi/detection.cpp
@@ -2253,13 +2253,13 @@ bool engineCreateAgi(OSystem *syst, Engine **engine, Common::EncapsulatedADGameD
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 @@ bool engineCreateAgi(OSystem *syst, Engine **engine, Common::EncapsulatedADGameD
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
-
diff --git a/engines/agi/preagi.cpp b/engines/agi/preagi.cpp
index 1ef889a5fa..217134c525 100644
--- a/engines/agi/preagi.cpp
+++ b/engines/agi/preagi.cpp
@@ -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 @@ PreAgiEngine::~PreAgiEngine() {
}
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);
diff --git a/engines/agi/preagi.h b/engines/agi/preagi.h
index ef2ea41528..39e61592ae 100644
--- a/engines/agi/preagi.h
+++ b/engines/agi/preagi.h
@@ -40,14 +40,12 @@ protected:
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;
diff --git a/engines/agos/agos.cpp b/engines/agos/agos.cpp
index 09249a2535..ccb53bec77 100644
--- a/engines/agos/agos.cpp
+++ b/engines/agos/agos.cpp
@@ -525,12 +525,6 @@ AGOSEngine::AGOSEngine(OSystem *syst)
}
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;
diff --git a/engines/agos/agos.h b/engines/agos/agos.h
index bf64a3bf84..2d7f871ed7 100644
--- a/engines/agos/agos.h
+++ b/engines/agos/agos.h
@@ -179,7 +179,6 @@ public:
const AGOSGameDescription *_gameDescription;
- bool initGame(void);
virtual void setupGame();
int getGameId() const;
diff --git a/engines/agos/detection.cpp b/engines/agos/detection.cpp
index 268b62cab2..c309ccfecd 100644
--- a/engines/agos/detection.cpp
+++ b/engines/agos/detection.cpp
@@ -129,24 +129,19 @@ bool engineCreateAgos(OSystem *syst, Engine **engine, Common::EncapsulatedADGame
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;
}
diff --git a/engines/cine/cine.cpp b/engines/cine/cine.cpp
index 70be3e821d..7a8dfac60f 100644
--- a/engines/cine/cine.cpp
+++ b/engines/cine/cine.cpp
@@ -50,7 +50,7 @@ Common::SaveFileManager *g_saveFileMan;
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 @@ CineEngine::~CineEngine() {
}
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);
diff --git a/engines/cine/cine.h b/engines/cine/cine.h
index 026fb3e54c..b225f9490a 100644
--- a/engines/cine/cine.h
+++ b/engines/cine/cine.h
@@ -71,7 +71,7 @@ protected:
bool initGame();
public:
- CineEngine(OSystem *syst);
+ CineEngine(OSystem *syst, const CINEGameDescription *gameDesc);
virtual ~CineEngine();
int getGameType() const;
diff --git a/engines/cine/detection.cpp b/engines/cine/detection.cpp
index f4b9b0c94e..9e449e2ca1 100644
--- a/engines/cine/detection.cpp
+++ b/engines/cine/detection.cpp
@@ -487,17 +487,14 @@ static const Common::ADParams detectionParams = {
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");
diff --git a/engines/cruise/cruise.cpp b/engines/cruise/cruise.cpp
index 3e7f42c3e4..8252877046 100644
--- a/engines/cruise/cruise.cpp
+++ b/engines/cruise/cruise.cpp
@@ -44,7 +44,7 @@ Common::SaveFileManager * g_saveFileMan;
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 @@ CruiseEngine::~CruiseEngine() {
}
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);
diff --git a/engines/cruise/cruise.h b/engines/cruise/cruise.h
index d99860d254..4a6bcff498 100644
--- a/engines/cruise/cruise.h
+++ b/engines/cruise/cruise.h
@@ -51,7 +51,7 @@ protected:
bool initGame();
public:
- CruiseEngine(OSystem * syst);
+ CruiseEngine(OSystem * syst, const CRUISEGameDescription *gameDesc);
virtual ~ CruiseEngine();
int getGameType() const;
diff --git a/engines/cruise/detection.cpp b/engines/cruise/detection.cpp
index 8307a483ad..1c311dc39d 100644
--- a/engines/cruise/detection.cpp
+++ b/engines/cruise/detection.cpp
@@ -111,17 +111,14 @@ static const Common::ADParams detectionParams = {
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");
diff --git a/engines/drascula/detection.cpp b/engines/drascula/detection.cpp
index 057b8083c8..0bee2b534d 100644
--- a/engines/drascula/detection.cpp
+++ b/engines/drascula/detection.cpp
@@ -164,18 +164,15 @@ static const Common::ADParams detectionParams = {
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");
diff --git a/engines/drascula/drascula.cpp b/engines/drascula/drascula.cpp
index 8432aea9f2..65f4f717a7 100644
--- a/engines/drascula/drascula.cpp
+++ b/engines/drascula/drascula.cpp
@@ -53,7 +53,7 @@ static const GameSettings drasculaSettings[] = {
{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_t[6][88] = {TEXT11, TEXT109, TEXT111, TEXT110, TEXT115, TEXT11
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);
diff --git a/engines/drascula/drascula.h b/engines/drascula/drascula.h
index 221664aa63..df581b1700 100644
--- a/engines/drascula/drascula.h
+++ b/engines/drascula/drascula.h
@@ -337,10 +337,8 @@ protected:
int go();
// void shutdown();
- bool initGame();
-
public:
- DrasculaEngine(OSystem *syst);
+ DrasculaEngine(OSystem *syst, const DrasculaGameDescription *gameDesc);
virtual ~DrasculaEngine();
int getGameId() {
return _gameId;
diff --git a/engines/gob/detection.cpp b/engines/gob/detection.cpp
index 22b249a4a8..db07c72414 100644
--- a/engines/gob/detection.cpp
+++ b/engines/gob/detection.cpp
@@ -1701,20 +1701,22 @@ static const ADParams detectionParams = {
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;
+}
-REGISTER_PLUGIN(GOB, "Gob Engine", "Goblins Games (C) Coktel Vision");
+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 @@ bool GobEngine::detectGame() {
_features = gd->features;
_language = gd->desc.language;
_platform = gd->desc.platform;
-
- return true;
}
} // End of namespace Gob
diff --git a/engines/gob/gob.cpp b/engines/gob/gob.cpp
index 13f310aee0..aa014a0427 100644
--- a/engines/gob/gob.cpp
+++ b/engines/gob/gob.cpp
@@ -145,12 +145,6 @@ void GobEngine::validateVideoMode(int16 videoMode) {
}
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;
diff --git a/engines/gob/gob.h b/engines/gob/gob.h
index 6f83fce1a2..9f4c90c5c5 100644
--- a/engines/gob/gob.h
+++ b/engines/gob/gob.h
@@ -167,6 +167,8 @@ private:
friend class Ptr;
};
+struct GOBGameDescription;
+
class GobEngine : public Engine {
protected:
GobEngine *_vm;
@@ -177,8 +179,6 @@ protected:
bool initGameParts();
void deinitGameParts();
- bool detectGame();
-
public:
static const Common::Language _gobToScummVMLang[];
@@ -237,6 +237,8 @@ public:
GobEngine(OSystem *syst);
virtual ~GobEngine();
+
+ void initGame(const GOBGameDescription *gd);
};
} // End of namespace Gob
diff --git a/engines/kyra/detection.cpp b/engines/kyra/detection.cpp
index 58622b3514..2c006dd61a 100644
--- a/engines/kyra/detection.cpp
+++ b/engines/kyra/detection.cpp
@@ -436,7 +436,7 @@ bool engineCreateKyra(OSystem *syst, Engine **engine, Common::EncapsulatedADGame
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");
diff --git a/engines/parallaction/detection.cpp b/engines/parallaction/detection.cpp
index 33da65fba4..ba87b6cee0 100644
--- a/engines/parallaction/detection.cpp
+++ b/engines/parallaction/detection.cpp
@@ -184,16 +184,16 @@ static const Common::ADParams detectionParams = {
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 @@ bool engineCreateParallaction(OSystem *syst, Engine **engine, Common::Encapsulat
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
diff --git a/engines/parallaction/parallaction.cpp b/engines/parallaction/parallaction.cpp
index 9ae5e97d0c..b942cd81ad 100644
--- a/engines/parallaction/parallaction.cpp
+++ b/engines/parallaction/parallaction.cpp
@@ -91,8 +91,8 @@ static Job *_jDrawInventory = NULL;
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!
diff --git a/engines/parallaction/parallaction.h b/engines/parallaction/parallaction.h
index 01e3997b95..7a1a272cb7 100644
--- a/engines/parallaction/parallaction.h
+++ b/engines/parallaction/parallaction.h
@@ -363,7 +363,7 @@ class Parallaction : public Engine {
public:
- Parallaction(OSystem *syst);
+ Parallaction(OSystem *syst, const PARALLACTIONGameDescription *gameDesc);
~Parallaction();
int init();
@@ -640,7 +640,7 @@ public:
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 @@ class Parallaction_br : public Parallaction_ns {
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();
diff --git a/engines/parallaction/parallaction_br.cpp b/engines/parallaction/parallaction_br.cpp
index 1a38cda9d8..97e9784d47 100644
--- a/engines/parallaction/parallaction_br.cpp
+++ b/engines/parallaction/parallaction_br.cpp
@@ -59,12 +59,6 @@ const char *partFirstLocation[] = {
int Parallaction_br::init() {
- // Detect game
- if (!detectGame()) {
- GUIErrorMessage("No valid games were found in the specified directory.");
- return -1;
- }
-
_screenWidth = 640;
_screenHeight = 400;
diff --git a/engines/parallaction/parallaction_ns.cpp b/engines/parallaction/parallaction_ns.cpp
index 652ffd1d64..0075664a42 100644
--- a/engines/parallaction/parallaction_ns.cpp
+++ b/engines/parallaction/parallaction_ns.cpp
@@ -111,12 +111,6 @@ void LocationName::bind(const char *s) {
int Parallaction_ns::init() {
- // Detect game
- if (!detectGame()) {
- GUIErrorMessage("No valid games were found in the specified directory.");
- return -1;
- }
-
_screenWidth = 320;
_screenHeight = 200;
diff --git a/engines/saga/detection.cpp b/engines/saga/detection.cpp
index 2ca1ae4482..95a2cd297d 100644
--- a/engines/saga/detection.cpp
+++ b/engines/saga/detection.cpp
@@ -139,19 +139,21 @@ static const Common::ADParams detectionParams = {
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;
diff --git a/engines/saga/saga.cpp b/engines/saga/saga.cpp
index 4cd0c1a381..2723551d94 100644
--- a/engines/saga/saga.cpp
+++ b/engines/saga/saga.cpp
@@ -59,8 +59,8 @@ namespace Saga {
#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;
diff --git a/engines/saga/saga.h b/engines/saga/saga.h
index 0879d15a0d..cac2b911db 100644
--- a/engines/saga/saga.h
+++ b/engines/saga/saga.h
@@ -504,7 +504,7 @@ protected:
int go();
int init();
public:
- SagaEngine(OSystem *syst);
+ SagaEngine(OSystem *syst, const SAGAGameDescription *gameDesc);
virtual ~SagaEngine();
void shutDown() { _quit = true; }
diff --git a/engines/touche/detection.cpp b/engines/touche/detection.cpp
index 3fe558b01f..41b2062ffc 100644
--- a/engines/touche/detection.cpp
+++ b/engines/touche/detection.cpp
@@ -110,7 +110,7 @@ static const Common::ADFileBasedFallback fileBasedFallback[] = {
{ 0, { 0 } }
};
-}
+} // End of namespace Touche
static const Common::ADParams detectionParams = {
(const byte *)Touche::gameDescriptions,
@@ -124,21 +124,14 @@ static const Common::ADParams detectionParams = {
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");
diff --git a/engines/touche/touche.cpp b/engines/touche/touche.cpp
index 7e1a839fe9..bb02b7e58c 100644
--- a/engines/touche/touche.cpp
+++ b/engines/touche/touche.cpp
@@ -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 @@ int ToucheEngine::init() {
_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();
diff --git a/engines/touche/touche.h b/engines/touche/touche.h
index 5c27f58c92..c1bc12655f 100644
--- a/engines/touche/touche.h
+++ b/engines/touche/touche.h
@@ -351,7 +351,7 @@ public:
typedef void (ToucheEngine::*OpcodeProc)();
- ToucheEngine(OSystem *system);
+ ToucheEngine(OSystem *system, Common::Language language);
virtual ~ToucheEngine();
virtual int init();