aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--base/game.h5
-rw-r--r--base/plugins.h3
-rw-r--r--common/advancedDetector.cpp172
-rw-r--r--common/advancedDetector.h239
-rw-r--r--engines/agos/game.cpp37
-rw-r--r--engines/cine/detection.cpp36
-rw-r--r--engines/kyra/plugin.cpp10
-rw-r--r--engines/saga/game.cpp33
8 files changed, 330 insertions, 205 deletions
diff --git a/base/game.h b/base/game.h
index cdafb2f2ca..cb95f1730e 100644
--- a/base/game.h
+++ b/base/game.h
@@ -25,6 +25,7 @@
#define BASE_GAME_H
#include "common/str.h"
+#include "common/array.h"
struct PlainGameDescriptor {
const char *gameid;
@@ -53,6 +54,10 @@ struct GameDescriptor {
gameid(g.gameid), description(g.description) {}
};
+/** List of games. */
+typedef Common::Array<GameDescriptor> GameList;
+
+
class Plugin;
diff --git a/base/plugins.h b/base/plugins.h
index e5a6882e39..9b14f52d57 100644
--- a/base/plugins.h
+++ b/base/plugins.h
@@ -35,9 +35,6 @@ class Engine;
class FSList;
class OSystem;
-/** List of games. */
-typedef Common::Array<GameDescriptor> GameList;
-
/**
* A detected game. Carries the GameDescriptor, but also (optionally)
* information about the language and platform of the detected game.
diff --git a/common/advancedDetector.cpp b/common/advancedDetector.cpp
index b2107b85f2..9ddae9368c 100644
--- a/common/advancedDetector.cpp
+++ b/common/advancedDetector.cpp
@@ -22,18 +22,184 @@
#include "common/stdafx.h"
+#include "base/plugins.h"
+
#include "common/util.h"
#include "common/hash-str.h"
#include "common/file.h"
#include "common/md5.h"
#include "common/advancedDetector.h"
+#include "common/config-manager.h"
namespace Common {
-bool ADTrue() {
- return true;
+PluginError real_ADVANCED_DETECTOR_ENGINE_CREATE(
+ DetectedGameList (*detectFunc)(const FSList &fslist),
+ const Common::ADObsoleteGameID *obsoleteList
+ ) {
+ const char *gameid = ConfMan.get("gameid").c_str();
+
+ if (obsoleteList != 0) {
+ for (const Common::ADObsoleteGameID *o = obsoleteList; o->from; ++o) {
+ if (!scumm_stricmp(gameid, o->from)) {
+ gameid = o->to;
+ ConfMan.set("gameid", o->to);
+
+ if (o->platform != Common::kPlatformUnknown)
+ ConfMan.set("platform", Common::getPlatformCode(o->platform));
+
+ warning("Target upgraded from %s to %s", o->from, o->to);
+ ConfMan.flushToDisk();
+ break;
+ }
+ }
+ }
+
+ FSList fslist;
+ FilesystemNode dir(ConfMan.get("path"));
+ if (!dir.listDir(fslist, FilesystemNode::kListFilesOnly)) {
+ return kInvalidPathError;
+ }
+
+ DetectedGameList detectedGames = detectFunc(fslist);
+
+ for (uint i = 0; i < detectedGames.size(); i++) {
+ if (detectedGames[i].gameid == gameid) {
+ return kNoError;
+ }
+ }
+
+ return kNoGameDataFoundError;
+}
+
+GameList real_ADVANCED_DETECTOR_GAMEID_LIST(const PlainGameDescriptor *list) {
+ GameList games;
+ const PlainGameDescriptor *g = list;
+ while (g->gameid) {
+ games.push_back(*g);
+ g++;
+ }
+ return games;
}
+GameDescriptor real_ADVANCED_DETECTOR_FIND_GAMEID(
+ const char *gameid,
+ const PlainGameDescriptor *list,
+ const Common::ADObsoleteGameID *obsoleteList
+ ) {
+ const PlainGameDescriptor *g = list;
+ while (g->gameid) {
+ if (0 == scumm_stricmp(gameid, g->gameid))
+ return *g;
+ g++;
+ }
+
+ GameDescriptor gs;
+ if (obsoleteList != 0) {
+ const Common::ADObsoleteGameID *o = obsoleteList;
+ while (o->from) {
+ if (0 == scumm_stricmp(gameid, o->from)) {
+ gs.gameid = gameid;
+ gs.description = "Obsolete game ID";
+ return gs;
+ }
+ o++;
+ }
+ } else
+ return *g;
+ return gs;
+}
+
+DetectedGame toDetectedGame(const ADGameDescription &g, const PlainGameDescriptor *sg) {
+ const char *title = 0;
+
+ while (sg->gameid) {
+ if (!scumm_stricmp(g.name, sg->gameid))
+ title = sg->description;
+ sg++;
+ }
+
+ DetectedGame dg(g.name, title, g.language, g.platform);
+ dg.updateDesc(g.extra);
+ return dg;
+}
+
+DetectedGameList real_ADVANCED_DETECTOR_DETECT_GAMES_FUNCTION(
+ const FSList &fslist,
+ const byte *descs,
+ const int descItemSize,
+ const int descItemCount,
+ const int md5Bytes,
+ const PlainGameDescriptor *list
+ ) {
+ DetectedGameList detectedGames;
+ Common::AdvancedDetector AdvDetector;
+ Common::ADList matches;
+ Common::ADGameDescList descList;
+
+ for (int i = 0; i < descItemCount; i++)
+ descList.push_back((const ADGameDescription *)(descs + i * descItemSize));
+
+ AdvDetector.registerGameDescriptions(descList);
+ AdvDetector.setFileMD5Bytes(md5Bytes);
+
+ matches = AdvDetector.detectGame(&fslist, Common::UNK_LANG, Common::kPlatformUnknown);
+
+ for (uint i = 0; i < matches.size(); i++)
+ detectedGames.push_back(toDetectedGame(*(const ADGameDescription *)(descs + matches[i] * descItemSize), list));
+
+ return detectedGames;
+}
+
+int real_ADVANCED_DETECTOR_DETECT_INIT_GAME(
+ const byte *descs,
+ const int descItemSize,
+ const int descItemCount,
+ const int md5Bytes,
+ const PlainGameDescriptor *list
+ ) {
+ int gameNumber = -1;
+
+ DetectedGameList detectedGames;
+ Common::AdvancedDetector AdvDetector;
+ Common::ADList matches;
+ Common::ADGameDescList descList;
+
+ Common::Language language = Common::UNK_LANG;
+ Common::Platform platform = Common::kPlatformUnknown;
+
+ if (ConfMan.hasKey("language"))
+ language = Common::parseLanguage(ConfMan.get("language"));
+ if (ConfMan.hasKey("platform"))
+ platform = Common::parsePlatform(ConfMan.get("platform"));
+
+ Common::String gameid = ConfMan.get("gameid");
+
+ for (int i = 0; i < descItemCount; i++)
+ descList.push_back((const ADGameDescription *)(descs + i * descItemSize));
+
+ AdvDetector.registerGameDescriptions(descList);
+ AdvDetector.setFileMD5Bytes(md5Bytes);
+
+ matches = AdvDetector.detectGame(0, language, platform);
+
+ for (uint i = 0; i < matches.size(); i++) {
+ if (toDetectedGame(*(const ADGameDescription *)(descs + matches[i] * descItemSize), list).gameid == gameid) {
+ gameNumber = matches[i];
+ break;
+ }
+ }
+
+ if (gameNumber >= descItemCount || gameNumber == -1) {
+ error("TODO invalid gameNumber %d (max. expected value: %d)", gameNumber, descItemCount );
+ }
+
+ debug(2, "Running %s", toDetectedGame(*(const ADGameDescription *)(descs + gameNumber * descItemSize), list).description.c_str());
+
+ return gameNumber;
+}
+
+
AdvancedDetector::AdvancedDetector() {
_fileMD5Bytes = 0;
}
@@ -84,7 +250,7 @@ ADList AdvancedDetector::detectGame(const FSList *fslist, Language language, Pla
}
}
- if (fslist != NULL) {
+ if (fslist != 0) {
for (FSList::const_iterator file = fslist->begin(); file != fslist->end(); ++file) {
if (file->isDirectory()) continue;
tstr = file->name();
diff --git a/common/advancedDetector.h b/common/advancedDetector.h
index c4dd12d534..4ad26dc186 100644
--- a/common/advancedDetector.h
+++ b/common/advancedDetector.h
@@ -24,6 +24,10 @@
#include "common/fs.h"
+#include "base/game.h" // For PlainGameDescriptor and GameList
+#include "base/plugins.h" // For DetectedGameList
+
+
namespace Common {
struct ADGameFileDescription {
@@ -47,186 +51,105 @@ struct ADObsoleteGameID {
Common::Platform platform;
};
-bool ADTrue(void);
-
typedef Array<int> ADList;
typedef Array<const ADGameDescription*> ADGameDescList;
+// FIXME/TODO: Rename this function to something more sensible.
+// Possibly move it inside class AdvancedDetector ?
+// Maybe rename it to something like asGameList or pgdArrayToGameList,
+// and move it to base/game.h. Or add a constructor to GameList ... ?
+GameList real_ADVANCED_DETECTOR_GAMEID_LIST(const PlainGameDescriptor *list);
+
+// FIXME/TODO: Rename this function to something more sensible.
+// Possibly move it inside class AdvancedDetector ?
+GameDescriptor real_ADVANCED_DETECTOR_FIND_GAMEID(
+ const char *gameid,
+ const PlainGameDescriptor *list,
+ const Common::ADObsoleteGameID *obsoleteList
+ );
+
+
+// FIXME/TODO: Rename this function to something more sensible.
+// Possibly move it inside class AdvancedDetector ?
+// Also, we could get rid of the descSize parameter, if we simply terminated the
+// list of game descriptions by an all-zero entry (like the SCUMM engine does in
+// similar cases).
+DetectedGameList real_ADVANCED_DETECTOR_DETECT_GAMES_FUNCTION(
+ const FSList &fslist,
+ const byte *descs,
+ const int descItemSize,
+ const int descItemCount,
+ const int md5Bytes,
+ const PlainGameDescriptor *list
+ );
+
+
+// FIXME/TODO: Rename this function to something more sensible.
+// Possibly move it inside class AdvancedDetector ?
+// Also, we could get rid of the descSize parameter, if we simply terminated the
+// list of game descriptions by an all-zero entry (like the SCUMM engine does in
+// similar cases).
+int real_ADVANCED_DETECTOR_DETECT_INIT_GAME(
+ const byte *descs,
+ const int descItemSize,
+ const int descItemCount,
+ const int md5Bytes,
+ const PlainGameDescriptor *list
+ );
+
+// FIXME/TODO: Rename this function to something more sensible.
+// Possibly move it inside class AdvancedDetector ?
+PluginError real_ADVANCED_DETECTOR_ENGINE_CREATE(
+ DetectedGameList (*detectFunc)(const FSList &fslist),
+ const Common::ADObsoleteGameID *obsoleteList
+ );
+
+
#define ADVANCED_DETECTOR_GAMEID_LIST(engine,list) \
GameList Engine_##engine##_gameIDList() { \
- GameList games; \
- const PlainGameDescriptor *g = list; \
- while (g->gameid) { \
- games.push_back(*g); \
- g++; \
- } \
- \
- return games; \
+ return Common::real_ADVANCED_DETECTOR_GAMEID_LIST(list); \
} \
void dummyFuncToAllowTrailingSemicolon()
-#define ADVANCED_DETECTOR_FIND_GAMEID(engine,list,obsoleteList) \
+#define ADVANCED_DETECTOR_FIND_GAMEID(engine,list,obsoleteList) \
GameDescriptor Engine_##engine##_findGameID(const char *gameid) { \
- const PlainGameDescriptor *g = list; \
- while (g->gameid) { \
- if (0 == scumm_stricmp(gameid, g->gameid)) \
- return *g; \
- g++; \
- } \
- \
- GameDescriptor gs; \
- if (obsoleteList) {\
- const Common::ADObsoleteGameID *o = obsoleteList; \
- while (o->from) { \
- if (0 == scumm_stricmp(gameid, o->from)) { \
- gs.gameid = gameid; \
- gs.description = "Obsolete game ID"; \
- return gs; \
- } \
- o++; \
- } \
- } else \
- return *g; \
- return gs; \
+ return Common::real_ADVANCED_DETECTOR_FIND_GAMEID(gameid,list,obsoleteList); \
} \
void dummyFuncToAllowTrailingSemicolon()
-#define ADVANCED_DETECTOR_DETECT_GAMES(engine,function) \
+#define ADVANCED_DETECTOR_DETECT_GAMES(engine,detectFunc) \
DetectedGameList Engine_##engine##_detectGames(const FSList &fslist) { \
- return function(fslist); \
+ return detectFunc(fslist); \
} \
void dummyFuncToAllowTrailingSemicolon()
-
-#define ADVANCED_DETECTOR_ENGINE_CREATE(engine,createFunction,engineName,obsoleteList) \
+#define ADVANCED_DETECTOR_ENGINE_CREATE(engine,createFunction,detectFunc,obsoleteList) \
PluginError Engine_##engine##_create(OSystem *syst, Engine **engine) { \
assert(syst); \
assert(engine); \
- const char *gameid = ConfMan.get("gameid").c_str(); \
- \
- if (obsoleteList) { \
- for (const Common::ADObsoleteGameID *o = obsoleteList; o->from; ++o) { \
- if (!scumm_stricmp(gameid, o->from)) { \
- gameid = o->to; \
- ConfMan.set("gameid", o->to); \
- \
- if (o->platform != Common::kPlatformUnknown) \
- ConfMan.set("platform", Common::getPlatformCode(o->platform)); \
- \
- warning("Target upgraded from %s to %s", o->from, o->to); \
- ConfMan.flushToDisk(); \
- break; \
- } \
- } \
- } \
- \
- FSList fslist; \
- FilesystemNode dir(ConfMan.get("path")); \
- if (!dir.listDir(fslist, FilesystemNode::kListFilesOnly)) { \
- warning("%s: invalid game path '%s'", engineName, dir.path().c_str()); \
- return kInvalidPathError; \
- } \
- \
- DetectedGameList detectedGames = Engine_##engine##_detectGames(fslist); \
- \
- for (uint i = 0; i < detectedGames.size(); i++) { \
- if (detectedGames[i].gameid == gameid) { \
- *engine = new createFunction(syst); \
- return kNoError; \
- } \
- } \
- \
- warning("%s: Unable to locate game data at path '%s'", engineName, dir.path().c_str()); \
- return kNoGameDataFoundError; \
- } \
- void dummyFuncToAllowTrailingSemicolon()
-
-#define ADVANCED_DETECTOR_TO_DETECTED_GAME(list) \
- DetectedGame toDetectedGame(const ADGameDescription &g) { \
- const char *title = 0; \
- \
- const PlainGameDescriptor *sg = list; \
- while (sg->gameid) { \
- if (!scumm_stricmp(g.name, sg->gameid)) \
- title = sg->description; \
- sg++; \
- } \
- \
- DetectedGame dg(g.name, title, g.language, g.platform); \
- dg.updateDesc(g.extra); \
- return dg; \
- } \
- void dummyFuncToAllowTrailingSemicolon()
-
-#define ADVANCED_DETECTOR_DETECT_GAMES_FUNCTION(function,descriptions) \
- DetectedGameList function(const FSList &fslist) { \
- DetectedGameList detectedGames; \
- Common::AdvancedDetector AdvDetector; \
- Common::ADList matches; \
- Common::ADGameDescList descList; \
- \
- for (int i = 0; i < ARRAYSIZE(descriptions); i++) \
- descList.push_back((const ADGameDescription *)&descriptions[i]); \
- \
- AdvDetector.registerGameDescriptions(descList); \
- AdvDetector.setFileMD5Bytes(FILE_MD5_BYTES); \
- \
- matches = AdvDetector.detectGame(&fslist, Common::UNK_LANG, Common::kPlatformUnknown); \
- \
- for (uint i = 0; i < matches.size(); i++) \
- detectedGames.push_back(toDetectedGame(descriptions[matches[i]].desc)); \
- \
- return detectedGames; \
+ PluginError err = real_ADVANCED_DETECTOR_ENGINE_CREATE(detectFunc, obsoleteList); \
+ if (err == kNoError) \
+ *engine = new createFunction(syst); \
+ return err; \
} \
void dummyFuncToAllowTrailingSemicolon()
-#define ADVANCED_DETECTOR_DETECT_INIT_GAME(function,descriptions,varname,postFunction) \
- bool function() { \
- int gameNumber = -1; \
- \
- DetectedGameList detectedGames; \
- Common::AdvancedDetector AdvDetector; \
- Common::ADList matches; \
- Common::ADGameDescList descList; \
- \
- Common::Language language = Common::UNK_LANG; \
- Common::Platform platform = Common::kPlatformUnknown; \
- \
- if (ConfMan.hasKey("language")) \
- language = Common::parseLanguage(ConfMan.get("language")); \
- if (ConfMan.hasKey("platform")) \
- platform = Common::parsePlatform(ConfMan.get("platform")); \
- \
- Common::String gameid = ConfMan.get("gameid"); \
- \
- for (int i = 0; i < ARRAYSIZE(descriptions); i++) \
- descList.push_back((const ADGameDescription *)&descriptions[i]); \
- \
- AdvDetector.registerGameDescriptions(descList); \
- AdvDetector.setFileMD5Bytes(FILE_MD5_BYTES); \
- \
- matches = AdvDetector.detectGame(NULL, language, platform); \
- \
- for (uint i = 0; i < matches.size(); i++) { \
- if (toDetectedGame(descriptions[matches[i]].desc).gameid == gameid) { \
- gameNumber = matches[i]; \
- break; \
- } \
- } \
- \
- if (gameNumber >= ARRAYSIZE(descriptions) || gameNumber == -1) { \
- error("%s wrong gameNumber", "##function##"); \
- } \
- \
- debug(2, "Running %s", toDetectedGame(descriptions[gameNumber].desc).description.c_str()); \
- \
- varname = &descriptions[gameNumber]; \
- \
- return postFunction(); \
- } \
- void dummyFuncToAllowTrailingSemicolon()
-
-
+#define ADVANCED_DETECTOR_DEFINE_PLUGIN(engine,createFunction,detectFunc,list,obsoleteList) \
+ ADVANCED_DETECTOR_GAMEID_LIST(engine, list); \
+ ADVANCED_DETECTOR_FIND_GAMEID(engine, list, obsoleteList); \
+ ADVANCED_DETECTOR_DETECT_GAMES(engine, detectFunc); \
+ ADVANCED_DETECTOR_ENGINE_CREATE(engine, createFunction, detectFunc, obsoleteList)
+
+
+// TODO/FIXME: Fingolfin asks: Why is AdvancedDetector a class, considering that
+// it is only used as follow:
+// 1) Create an instance of it on the stack
+// 2) invoke registerGameDescriptions and setFileMD5Bytes
+// 3) invoke detectGame *once*
+// Obviously, 2) could also be handled by passing more params to detectGame.
+// So it seem we could replace this class by a simple advancedDetectGame(...)
+// function, w/o a class or instantiating object... ? Or is there a deeper
+// reason I miss?
class AdvancedDetector {
public:
diff --git a/engines/agos/game.cpp b/engines/agos/game.cpp
index 04860c41b4..d297dff825 100644
--- a/engines/agos/game.cpp
+++ b/engines/agos/game.cpp
@@ -54,7 +54,7 @@ static const Common::ADObsoleteGameID obsoleteGameIDsTable[] = {
{"simon2talkie", "simon2", Common::kPlatformPC},
{"simon2mac", "simon2", Common::kPlatformMacintosh},
{"simon2win", "simon2", Common::kPlatformWindows},
- {NULL, NULL, Common::kPlatformUnknown}
+ {0, 0, Common::kPlatformUnknown}
};
static const PlainGameDescriptor simonGames[] = {
@@ -68,16 +68,10 @@ static const PlainGameDescriptor simonGames[] = {
{"jumble", "Jumble"},
{"puzzle", "NoPatience"},
{"swampy", "Swampy Adventures"},
- {NULL, NULL}
+ {0, 0}
};
-ADVANCED_DETECTOR_GAMEID_LIST(AGOS, simonGames);
-
-ADVANCED_DETECTOR_FIND_GAMEID(AGOS, simonGames, obsoleteGameIDsTable);
-
-ADVANCED_DETECTOR_DETECT_GAMES(AGOS, AGOS::GAME_detectGames);
-
-ADVANCED_DETECTOR_ENGINE_CREATE(AGOS, AGOS::AGOSEngine, "AGOSEngine", obsoleteGameIDsTable);
+ADVANCED_DETECTOR_DEFINE_PLUGIN(AGOS, AGOS::AGOSEngine, AGOS::GAME_detectGames, simonGames, obsoleteGameIDsTable);
REGISTER_PLUGIN(AGOS, "AGOS", "AGOS (C) Adventure Soft");
@@ -88,10 +82,27 @@ using Common::ADGameDescription;
#include "agosgame.cpp"
-ADVANCED_DETECTOR_TO_DETECTED_GAME(simonGames);
-
-ADVANCED_DETECTOR_DETECT_INIT_GAME(AGOSEngine::initGame, gameDescriptions, _gameDescription, Common::ADTrue);
+bool AGOSEngine::initGame() {
+ int i = Common::real_ADVANCED_DETECTOR_DETECT_INIT_GAME(
+ (const byte *)gameDescriptions,
+ sizeof(AGOSGameDescription),
+ ARRAYSIZE(gameDescriptions),
+ FILE_MD5_BYTES,
+ simonGames
+ );
+ _gameDescription = &gameDescriptions[i];
+ return true;
+}
-ADVANCED_DETECTOR_DETECT_GAMES_FUNCTION(GAME_detectGames, gameDescriptions);
+DetectedGameList GAME_detectGames(const FSList &fslist) {
+ return real_ADVANCED_DETECTOR_DETECT_GAMES_FUNCTION(
+ fslist,
+ (const byte *)gameDescriptions,
+ sizeof(AGOSGameDescription),
+ ARRAYSIZE(gameDescriptions),
+ FILE_MD5_BYTES,
+ simonGames
+ );
+}
} // End of namespace AGOS
diff --git a/engines/cine/detection.cpp b/engines/cine/detection.cpp
index 4b8ce8d804..451100ebca 100644
--- a/engines/cine/detection.cpp
+++ b/engines/cine/detection.cpp
@@ -41,17 +41,10 @@ using Common::File;
static const PlainGameDescriptor cineGames[] = {
{"fw", "Future Wars"},
{"os", "Operation Stealth"},
- {NULL, NULL}
+ {0, 0}
};
-ADVANCED_DETECTOR_GAMEID_LIST(CINE, cineGames);
-
-ADVANCED_DETECTOR_FIND_GAMEID(CINE, cineGames, NULL);
-
-ADVANCED_DETECTOR_DETECT_GAMES(CINE, Cine::GAME_detectGames);
-
-ADVANCED_DETECTOR_ENGINE_CREATE(CINE, Cine::CineEngine, "CineEngine", NULL);
-
+ADVANCED_DETECTOR_DEFINE_PLUGIN(CINE, Cine::CineEngine, Cine::GAME_detectGames, cineGames, 0);
REGISTER_PLUGIN(CINE, "Cinematique evo 1 engine", "Future Wars & Operation Stealth (C) Delphine Software");
@@ -579,10 +572,27 @@ static const CINEGameDescription gameDescriptions[] = {
};
-ADVANCED_DETECTOR_TO_DETECTED_GAME(cineGames);
-
-ADVANCED_DETECTOR_DETECT_INIT_GAME(CineEngine::initGame, gameDescriptions, _gameDescription, Common::ADTrue);
+bool CineEngine::initGame() {
+ int i = Common::real_ADVANCED_DETECTOR_DETECT_INIT_GAME(
+ (const byte *)gameDescriptions,
+ sizeof(CINEGameDescription),
+ ARRAYSIZE(gameDescriptions),
+ FILE_MD5_BYTES,
+ cineGames
+ );
+ _gameDescription = &gameDescriptions[i];
+ return true;
+}
-ADVANCED_DETECTOR_DETECT_GAMES_FUNCTION(GAME_detectGames, gameDescriptions);
+DetectedGameList GAME_detectGames(const FSList &fslist) {
+ return real_ADVANCED_DETECTOR_DETECT_GAMES_FUNCTION(
+ fslist,
+ (const byte *)gameDescriptions,
+ sizeof(CINEGameDescription),
+ ARRAYSIZE(gameDescriptions),
+ FILE_MD5_BYTES,
+ cineGames
+ );
+}
} // End of namespace Cine
diff --git a/engines/kyra/plugin.cpp b/engines/kyra/plugin.cpp
index e63db7ee05..786c07dbfd 100644
--- a/engines/kyra/plugin.cpp
+++ b/engines/kyra/plugin.cpp
@@ -203,9 +203,13 @@ const PlainGameDescriptor gameList[] = {
} // End of anonymous namespace
-ADVANCED_DETECTOR_GAMEID_LIST(KYRA, gameList);
+GameList Engine_KYRA_gameIDList() {
+ return Common::real_ADVANCED_DETECTOR_GAMEID_LIST(gameList);
+}
-ADVANCED_DETECTOR_FIND_GAMEID(KYRA, gameList, NULL);
+GameDescriptor Engine_KYRA_findGameID(const char *gameid) {
+ return Common::real_ADVANCED_DETECTOR_FIND_GAMEID(gameid, gameList, 0);
+}
DetectedGameList Engine_KYRA_detectGames(const FSList &fslist) {
DetectedGameList detectedGames;
@@ -227,14 +231,12 @@ PluginError Engine_KYRA_create(OSystem *syst, Engine **engine) {
FSList fslist;
FilesystemNode dir(ConfMan.get("path"));
if (!dir.listDir(fslist, FilesystemNode::kListFilesOnly)) {
- warning("KyraEngine: invalid game path '%s'", dir.path().c_str());
return kInvalidPathError;
}
GameFlags flags;
ADList games = detectKyraGames(fslist);
if (!setupGameFlags(games, flags)) {
- warning("KyraEngine: unable to locate game data at path '%s'", dir.path().c_str());
return kNoGameDataFoundError;
}
diff --git a/engines/saga/game.cpp b/engines/saga/game.cpp
index ed5d708c1f..cda47d956c 100644
--- a/engines/saga/game.cpp
+++ b/engines/saga/game.cpp
@@ -48,13 +48,7 @@ static const PlainGameDescriptor saga_games[] = {
{0, 0}
};
-ADVANCED_DETECTOR_GAMEID_LIST(SAGA, saga_games);
-
-ADVANCED_DETECTOR_FIND_GAMEID(SAGA, saga_games, NULL);
-
-ADVANCED_DETECTOR_DETECT_GAMES(SAGA, Saga::GAME_detectGames);
-
-ADVANCED_DETECTOR_ENGINE_CREATE(SAGA, Saga::SagaEngine, "SagaEngine", NULL);
+ADVANCED_DETECTOR_DEFINE_PLUGIN(SAGA, Saga::SagaEngine, Saga::GAME_detectGames, saga_games, 0);
REGISTER_PLUGIN(SAGA, "SAGA Engine", "Inherit the Earth (C) Wyrmkeep Entertainment");
@@ -66,8 +60,6 @@ using Common::ADGameDescription;
#include "sagagame.cpp"
-ADVANCED_DETECTOR_TO_DETECTED_GAME(saga_games);
-
bool SagaEngine::postInitGame() {
_gameDisplayInfo = *_gameDescription->gameDisplayInfo;
_displayClip.right = _gameDisplayInfo.logicalWidth;
@@ -79,8 +71,27 @@ bool SagaEngine::postInitGame() {
return true;
}
-ADVANCED_DETECTOR_DETECT_INIT_GAME(SagaEngine::initGame, gameDescriptions, _gameDescription, postInitGame);
+bool SagaEngine::initGame() {
+ int i = Common::real_ADVANCED_DETECTOR_DETECT_INIT_GAME(
+ (const byte *)gameDescriptions,
+ sizeof(SAGAGameDescription),
+ ARRAYSIZE(gameDescriptions),
+ FILE_MD5_BYTES,
+ saga_games
+ );
+ _gameDescription = &gameDescriptions[i];
+ return postInitGame();
+}
-ADVANCED_DETECTOR_DETECT_GAMES_FUNCTION(GAME_detectGames, gameDescriptions);
+DetectedGameList GAME_detectGames(const FSList &fslist) {
+ return real_ADVANCED_DETECTOR_DETECT_GAMES_FUNCTION(
+ fslist,
+ (const byte *)gameDescriptions,
+ sizeof(SAGAGameDescription),
+ ARRAYSIZE(gameDescriptions),
+ FILE_MD5_BYTES,
+ saga_games
+ );
+}
} // End of namespace Saga