aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorMax Horn2006-12-19 23:37:03 +0000
committerMax Horn2006-12-19 23:37:03 +0000
commit07c6fa980f90946baa779716da2664d231176808 (patch)
treea71cd420dae43c1d7b8521602af856449e6d064c /common
parent296914412064931ce13d502a20ef521fbed3197c (diff)
downloadscummvm-rg350-07c6fa980f90946baa779716da2664d231176808.tar.gz
scummvm-rg350-07c6fa980f90946baa779716da2664d231176808.tar.bz2
scummvm-rg350-07c6fa980f90946baa779716da2664d231176808.zip
Further AdvancedDetector cleanup (in particular, renamed ADGameDescription::name to the more suitable ADGameDescription::gameid)
svn-id: r24895
Diffstat (limited to 'common')
-rw-r--r--common/advancedDetector.cpp26
-rw-r--r--common/advancedDetector.h35
2 files changed, 21 insertions, 40 deletions
diff --git a/common/advancedDetector.cpp b/common/advancedDetector.cpp
index 7d6fd630ff..9969d46498 100644
--- a/common/advancedDetector.cpp
+++ b/common/advancedDetector.cpp
@@ -104,12 +104,12 @@ static DetectedGame toDetectedGame(const ADGameDescription &g, const PlainGameDe
const char *title = 0;
while (sg->gameid) {
- if (!scumm_stricmp(g.name, sg->gameid))
+ if (!scumm_stricmp(g.gameid, sg->gameid))
title = sg->description;
sg++;
}
- DetectedGame dg(g.name, title, g.language, g.platform);
+ DetectedGame dg(g.gameid, title, g.language, g.platform);
dg.updateDesc(g.extra);
return dg;
}
@@ -132,7 +132,7 @@ DetectedGameList real_ADVANCED_DETECTOR_DETECT_GAMES_FUNCTION(
ad.registerGameDescriptions(descList);
- debug(3, "%s: cnt: %d", ((const ADGameDescription *)descs)->name, descList.size());
+ debug(3, "%s: cnt: %d", ((const ADGameDescription *)descs)->gameid, descList.size());
matches = ad.detectGame(&fslist, md5Bytes, Common::UNK_LANG, Common::kPlatformUnknown);
@@ -190,11 +190,10 @@ int real_ADVANCED_DETECTOR_DETECT_INIT_GAME(
}
-String AdvancedDetector::getDescription(int num) const {
+static String getDescription(const ADGameDescription *g) {
char tmp[256];
- const ADGameDescription *g = _gameDescriptions[num];
- snprintf(tmp, 256, "%s (%s %s/%s)", g->name, g->extra,
+ snprintf(tmp, 256, "%s (%s %s/%s)", g->gameid, g->extra,
getPlatformDescription(g->platform), getLanguageDescription(g->language));
return String(tmp);
@@ -274,18 +273,19 @@ ADList AdvancedDetector::detectGame(const FSList *fslist, int md5Bytes, Language
int maxFilesMatched = 0;
for (i = 0; i < _gameDescriptions.size(); i++) {
+ const ADGameDescription *g = _gameDescriptions[i];
fileMissing = false;
// Do not even bother to look at entries which do not have matching
// language and platform (if specified).
- if ((_gameDescriptions[i]->language != language && language != UNK_LANG) ||
- (_gameDescriptions[i]->platform != platform && platform != kPlatformUnknown)) {
+ if ((g->language != language && language != UNK_LANG) ||
+ (g->platform != platform && platform != kPlatformUnknown)) {
continue;
}
// Try to open all files for this game
- for (j = 0; _gameDescriptions[i]->filesDescriptions[j].fileName; j++) {
- fileDesc = &_gameDescriptions[i]->filesDescriptions[j];
+ for (j = 0; g->filesDescriptions[j].fileName; j++) {
+ fileDesc = &g->filesDescriptions[j];
tstr = fileDesc->fileName;
tstr.toLowercase();
tstr2 = tstr + ".";
@@ -301,12 +301,12 @@ ADList AdvancedDetector::detectGame(const FSList *fslist, int md5Bytes, Language
debug(3, "Matched file: %s", tstr.c_str());
}
if (!fileMissing) {
- debug(2, "Found game: %s (%d)", getDescription(i).c_str(), i);
+ debug(2, "Found game: %s (%d)", getDescription(g).c_str(), i);
// Count the number of matching files. Then, only keep those
// entries which match a maximal amount of files.
int curFilesMatched = 0;
- for (j = 0; _gameDescriptions[i]->filesDescriptions[j].fileName; j++)
+ for (j = 0; g->filesDescriptions[j].fileName; j++)
curFilesMatched++;
if (curFilesMatched > maxFilesMatched) {
@@ -321,7 +321,7 @@ ADList AdvancedDetector::detectGame(const FSList *fslist, int md5Bytes, Language
}
} else {
- debug(5, "Skipping game: %s (%d)", getDescription(i).c_str(), i);
+ debug(5, "Skipping game: %s (%d)", getDescription(g).c_str(), i);
}
}
diff --git a/common/advancedDetector.h b/common/advancedDetector.h
index 00f223cf3f..6e186acb87 100644
--- a/common/advancedDetector.h
+++ b/common/advancedDetector.h
@@ -37,7 +37,7 @@ struct ADGameFileDescription {
};
struct ADGameDescription {
- const char *name;
+ const char *gameid;
const char *extra;
const ADGameFileDescription *filesDescriptions;
Language language;
@@ -65,11 +65,7 @@ typedef Array<const ADGameDescription*> ADGameDescList;
// function, w/o a class or instantiating object... ? Or is there a deeper
// reason I miss?
class AdvancedDetector {
-
public:
- AdvancedDetector() {}
- ~AdvancedDetector() {}
-
void registerGameDescriptions(ADGameDescList gameDescriptions) {
_gameDescriptions = gameDescriptions;
@@ -91,8 +87,6 @@ public:
private:
ADGameDescList _gameDescriptions;
-
- String getDescription(int num) const;
};
@@ -107,9 +101,6 @@ GameDescriptor real_ADVANCED_DETECTOR_FIND_GAMEID(
// 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,
@@ -121,9 +112,6 @@ DetectedGameList real_ADVANCED_DETECTOR_DETECT_GAMES_FUNCTION(
// 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,
@@ -139,13 +127,16 @@ PluginError real_ADVANCED_DETECTOR_ENGINE_CREATE(
);
-#define ADVANCED_DETECTOR_DETECT_GAMES(engine,detectFunc) \
+#define ADVANCED_DETECTOR_DEFINE_PLUGIN(engine,createFunction,detectFunc,list,obsoleteList) \
+ GameList Engine_##engine##_gameIDList() { \
+ return GameList(list); \
+ } \
+ GameDescriptor Engine_##engine##_findGameID(const char *gameid) { \
+ return Common::real_ADVANCED_DETECTOR_FIND_GAMEID(gameid,list,obsoleteList); \
+ } \
DetectedGameList Engine_##engine##_detectGames(const FSList &fslist) { \
return detectFunc(fslist); \
} \
- void dummyFuncToAllowTrailingSemicolon()
-
-#define ADVANCED_DETECTOR_ENGINE_CREATE(engine,createFunction,detectFunc,obsoleteList) \
PluginError Engine_##engine##_create(OSystem *syst, Engine **engine) { \
assert(syst); \
assert(engine); \
@@ -156,16 +147,6 @@ PluginError real_ADVANCED_DETECTOR_ENGINE_CREATE(
} \
void dummyFuncToAllowTrailingSemicolon()
-#define ADVANCED_DETECTOR_DEFINE_PLUGIN(engine,createFunction,detectFunc,list,obsoleteList) \
- GameList Engine_##engine##_gameIDList() { \
- return GameList(list); \
- } \
- GameDescriptor Engine_##engine##_findGameID(const char *gameid) { \
- return Common::real_ADVANCED_DETECTOR_FIND_GAMEID(gameid,list,obsoleteList); \
- } \
- ADVANCED_DETECTOR_DETECT_GAMES(engine, detectFunc); \
- ADVANCED_DETECTOR_ENGINE_CREATE(engine, createFunction, detectFunc, obsoleteList)
-
} // End of namespace Common