aboutsummaryrefslogtreecommitdiff
path: root/common/advancedDetector.cpp
diff options
context:
space:
mode:
authorMax Horn2007-02-13 23:47:41 +0000
committerMax Horn2007-02-13 23:47:41 +0000
commit59b1526e5aee8094e51d76305c1e5a7ab3aa88e8 (patch)
treec56e8fe7563c9c19d86fc6ba7fe57052878e8452 /common/advancedDetector.cpp
parent7572d2b4f2ac98cf31602d6c5e4ed7399de54a30 (diff)
downloadscummvm-rg350-59b1526e5aee8094e51d76305c1e5a7ab3aa88e8.tar.gz
scummvm-rg350-59b1526e5aee8094e51d76305c1e5a7ab3aa88e8.tar.bz2
scummvm-rg350-59b1526e5aee8094e51d76305c1e5a7ab3aa88e8.zip
Since detectBestMatchingGame now returns a ADGameDescription pointer, we can change detectGame to return a ADGameDescList
svn-id: r25575
Diffstat (limited to 'common/advancedDetector.cpp')
-rw-r--r--common/advancedDetector.cpp36
1 files changed, 16 insertions, 20 deletions
diff --git a/common/advancedDetector.cpp b/common/advancedDetector.cpp
index 1b0f5e2817..54576fdfa7 100644
--- a/common/advancedDetector.cpp
+++ b/common/advancedDetector.cpp
@@ -33,7 +33,6 @@
namespace Common {
-typedef Array<int> ADList;
typedef Array<const ADGameDescription*> ADGameDescList;
namespace AdvancedDetector {
@@ -48,9 +47,9 @@ namespace AdvancedDetector {
* @param params a ADParams struct containing various parameters
* @param language restrict results to specified language only
* @param platform restrict results to specified platform only
- * @return list of indexes to GameDescriptions of matched games
+ * @return list of ADGameDescription (or subclass) pointers corresponding to matched games
*/
-static ADList detectGame(const FSList *fslist, const Common::ADParams &params, Language language, Platform platform);
+static ADGameDescList detectGame(const FSList *fslist, const Common::ADParams &params, Language language, Platform platform);
GameList gameIDList(const Common::ADParams &params) {
@@ -163,12 +162,11 @@ GameList detectAllGames(
const FSList &fslist,
const Common::ADParams &params
) {
- Common::ADList matches = detectGame(&fslist, params, Common::UNK_LANG, Common::kPlatformUnknown);
+ ADGameDescList matches = detectGame(&fslist, params, Common::UNK_LANG, Common::kPlatformUnknown);
GameList detectedGames;
for (uint i = 0; i < matches.size(); i++) {
- const ADGameDescription *adgDesc = (const ADGameDescription *)(params.descs + matches[i] * params.descItemSize);
- GameDescriptor desc(toGameDescriptor(*adgDesc, params.list));
+ GameDescriptor desc(toGameDescriptor(*matches[i], params.list));
if (params.singleid != NULL) {
desc["preferredtarget"] = desc["gameid"];
@@ -179,7 +177,7 @@ GameList detectAllGames(
if (!desc.contains("preferredtarget"))
desc["preferredtarget"] = desc["gameid"];
- desc["preferredtarget"] = generatePreferredTarget(desc["preferredtarget"], adgDesc);
+ desc["preferredtarget"] = generatePreferredTarget(desc["preferredtarget"], matches[i]);
}
detectedGames.push_back(desc);
@@ -202,18 +200,17 @@ const ADGameDescription *detectBestMatchingGame(
Common::String gameid = ConfMan.get("gameid");
- Common::ADList matches = detectGame(0, params, language, platform);
+ ADGameDescList matches = detectGame(0, params, language, platform);
if (params.singleid == NULL) {
for (uint i = 0; i < matches.size(); i++) {
- agdDesc = (const ADGameDescription *)(params.descs + matches[i] * params.descItemSize);
- if (agdDesc->gameid == gameid) {
+ if (matches[i]->gameid == gameid) {
+ agdDesc = matches[i];
break;
}
- agdDesc = 0;
}
} else if (matches.size() > 0) {
- agdDesc = (const ADGameDescription *)(params.descs + matches[0] * params.descItemSize);
+ agdDesc = matches[0];
}
if (agdDesc != 0) {
@@ -234,15 +231,14 @@ PluginError detectGameForEngineCreation(
return kInvalidPathError;
}
- Common::ADList matches = detectGame(&fslist, params, Common::UNK_LANG, Common::kPlatformUnknown);
+ 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++) {
- const ADGameDescription *adgDesc = (const ADGameDescription *)(params.descs + matches[i] * params.descItemSize);
- if (adgDesc->gameid == gameid) {
+ if (matches[i]->gameid == gameid) {
return kNoError;
}
}
@@ -250,7 +246,7 @@ PluginError detectGameForEngineCreation(
return kNoGameDataFoundError;
}
-static ADList detectGame(const FSList *fslist, const Common::ADParams &params, Language language, Platform platform) {
+static ADGameDescList detectGame(const FSList *fslist, const Common::ADParams &params, Language language, Platform platform) {
typedef HashMap<String, bool, CaseSensitiveString_Hash, CaseSensitiveString_EqualTo> StringSet;
StringSet filesList;
@@ -346,7 +342,7 @@ static ADList detectGame(const FSList *fslist, const Common::ADParams &params, L
}
}
- ADList matched;
+ ADGameDescList matched;
int maxFilesMatched = 0;
for (i = 0; i < gameDescriptions.size(); i++) {
@@ -408,9 +404,9 @@ static ADList detectGame(const FSList *fslist, const Common::ADParams &params, L
debug(2, " ... new best match, removing all previous candidates");
maxFilesMatched = curFilesMatched;
matched.clear();
- matched.push_back(i);
+ matched.push_back(g);
} else if (curFilesMatched == maxFilesMatched) {
- matched.push_back(i);
+ matched.push_back(g);
} else {
debug(2, " ... skipped");
}
@@ -521,7 +517,7 @@ static ADList detectGame(const FSList *fslist, const Common::ADParams &params, L
// extremly cryptic!
warning("But it looks like unknown variant of %s", *matchEntry);
- matched.push_back(i);
+ matched.push_back(gameDescriptions[i]);
}
}
}