aboutsummaryrefslogtreecommitdiff
path: root/common/advancedDetector.cpp
diff options
context:
space:
mode:
authorMax Horn2007-01-25 21:16:57 +0000
committerMax Horn2007-01-25 21:16:57 +0000
commitd70c83bd4b6b5a37a8c90abfff954823b49e9524 (patch)
tree818edf68094e3c2364035e7a939b89bddbbac759 /common/advancedDetector.cpp
parent6844eef41a2ae4d53f8526162683737b8ac2a82c (diff)
downloadscummvm-rg350-d70c83bd4b6b5a37a8c90abfff954823b49e9524.tar.gz
scummvm-rg350-d70c83bd4b6b5a37a8c90abfff954823b49e9524.tar.bz2
scummvm-rg350-d70c83bd4b6b5a37a8c90abfff954823b49e9524.zip
Lots of cleanup in the AdvancedDetector
svn-id: r25194
Diffstat (limited to 'common/advancedDetector.cpp')
-rw-r--r--common/advancedDetector.cpp49
1 files changed, 28 insertions, 21 deletions
diff --git a/common/advancedDetector.cpp b/common/advancedDetector.cpp
index fcb6e5f26c..ca0b9b547f 100644
--- a/common/advancedDetector.cpp
+++ b/common/advancedDetector.cpp
@@ -33,6 +33,8 @@
namespace Common {
+namespace AdvancedDetector {
+
/**
* Detect games in specified directory.
* Parameters language and platform are used to pass on values
@@ -48,27 +50,32 @@ namespace Common {
static ADList detectGame(const FSList *fslist, const Common::ADParams &params, Language language, Platform platform);
-PluginError ADVANCED_DETECTOR_ENGINE_CREATE(
- GameList (*detectFunc)(const FSList &fslist),
- const Common::ADParams &params
- ) {
+void upgradeTargetIfNecessary(const Common::ADParams &params) {
+ if (params.obsoleteList == 0)
+ return;
+
const char *gameid = ConfMan.get("gameid").c_str();
- if (params.obsoleteList != 0) {
- for (const Common::ADObsoleteGameID *o = params.obsoleteList; o->from; ++o) {
- if (!scumm_stricmp(gameid, o->from)) {
- gameid = o->to;
- ConfMan.set("gameid", o->to);
+ for (const Common::ADObsoleteGameID *o = params.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));
+ 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;
- }
+ warning("Target upgraded from %s to %s", o->from, o->to);
+ ConfMan.flushToDisk();
+ break;
}
}
+}
+
+PluginError detectGameForEngineCreation(
+ GameList (*detectFunc)(const FSList &fslist),
+ const Common::ADParams &params
+ ) {
+ Common::String gameid = ConfMan.get("gameid");
FSList fslist;
FilesystemNode dir(ConfMan.get("path"));
@@ -87,7 +94,7 @@ PluginError ADVANCED_DETECTOR_ENGINE_CREATE(
return kNoGameDataFoundError;
}
-GameDescriptor ADVANCED_DETECTOR_FIND_GAMEID(
+GameDescriptor findGameID(
const char *gameid,
const Common::ADParams &params
) {
@@ -128,7 +135,7 @@ static GameDescriptor toGameDescriptor(const ADGameDescription &g, const PlainGa
return gd;
}
-GameList ADVANCED_DETECTOR_DETECT_GAMES_FUNCTION(
+GameList detectAllGames(
const FSList &fslist,
const Common::ADParams &params
) {
@@ -141,7 +148,7 @@ GameList ADVANCED_DETECTOR_DETECT_GAMES_FUNCTION(
return detectedGames;
}
-int ADVANCED_DETECTOR_DETECT_INIT_GAME(
+int detectBestMatchingGame(
const Common::ADParams &params
) {
Common::Language language = Common::UNK_LANG;
@@ -164,9 +171,7 @@ int ADVANCED_DETECTOR_DETECT_INIT_GAME(
}
}
- if (gameNumber < 0) {
- error("ADVANCED_DETECTOR_DETECT_INIT_GAME: no match found (TODO: Let the caller handle this)");
- } else {
+ if (gameNumber >= 0) {
debug(2, "Running %s", toGameDescriptor(*(const ADGameDescription *)(params.descs + gameNumber * params.descItemSize), params.list).description().c_str());
}
@@ -340,4 +345,6 @@ static ADList detectGame(const FSList *fslist, const Common::ADParams &params, L
return matched;
}
+} // End of namespace AdvancedDetector
+
} // End of namespace Common