aboutsummaryrefslogtreecommitdiff
path: root/common/advancedDetector.cpp
diff options
context:
space:
mode:
authorMax Horn2007-01-25 01:07:59 +0000
committerMax Horn2007-01-25 01:07:59 +0000
commit85dc27db2f15af8f4263b5f16448191dcba10b52 (patch)
treebcfe155724ae1816964fff2cd5f763dd768cd493 /common/advancedDetector.cpp
parentbb3cc79bc695eb3210ce9a54fa55262a99d394c9 (diff)
downloadscummvm-rg350-85dc27db2f15af8f4263b5f16448191dcba10b52.tar.gz
scummvm-rg350-85dc27db2f15af8f4263b5f16448191dcba10b52.tar.bz2
scummvm-rg350-85dc27db2f15af8f4263b5f16448191dcba10b52.zip
cleanup
svn-id: r25179
Diffstat (limited to 'common/advancedDetector.cpp')
-rw-r--r--common/advancedDetector.cpp43
1 files changed, 15 insertions, 28 deletions
diff --git a/common/advancedDetector.cpp b/common/advancedDetector.cpp
index 8bee0a9556..fcb6e5f26c 100644
--- a/common/advancedDetector.cpp
+++ b/common/advancedDetector.cpp
@@ -45,7 +45,7 @@ namespace Common {
* @param platform restrict results to specified platform only
* @return list of indexes to GameDescriptions of matched games
*/
-static ADList detectGame(ADGameDescList gameDescriptions, const FSList *fslist, const Common::ADParams &params, Language language, Platform platform);
+static ADList detectGame(const FSList *fslist, const Common::ADParams &params, Language language, Platform platform);
PluginError ADVANCED_DETECTOR_ENGINE_CREATE(
@@ -132,18 +132,9 @@ GameList ADVANCED_DETECTOR_DETECT_GAMES_FUNCTION(
const FSList &fslist,
const Common::ADParams &params
) {
- GameList detectedGames;
- Common::ADList matches;
- Common::ADGameDescList descList;
- const byte *descPtr;
-
- for (descPtr = params.descs; ((const ADGameDescription *)descPtr)->gameid != 0; descPtr += params.descItemSize)
- descList.push_back((const ADGameDescription *)descPtr);
-
- debug(3, "%s: cnt: %d", ((const ADGameDescription *)params.descs)->gameid, descList.size());
-
- matches = detectGame(descList, &fslist, params, Common::UNK_LANG, Common::kPlatformUnknown);
+ Common::ADList matches = detectGame(&fslist, params, Common::UNK_LANG, Common::kPlatformUnknown);
+ GameList detectedGames;
for (uint i = 0; i < matches.size(); i++)
detectedGames.push_back(toGameDescriptor(*(const ADGameDescription *)(params.descs + matches[i] * params.descItemSize), params.list));
@@ -153,13 +144,6 @@ GameList ADVANCED_DETECTOR_DETECT_GAMES_FUNCTION(
int ADVANCED_DETECTOR_DETECT_INIT_GAME(
const Common::ADParams &params
) {
- int gameNumber = -1;
-
- GameList detectedGames;
- Common::ADList matches;
- Common::ADGameDescList descList;
- const byte *descPtr;
-
Common::Language language = Common::UNK_LANG;
Common::Platform platform = Common::kPlatformUnknown;
@@ -170,11 +154,9 @@ int ADVANCED_DETECTOR_DETECT_INIT_GAME(
Common::String gameid = ConfMan.get("gameid");
- for (descPtr = params.descs; ((const ADGameDescription *)descPtr)->gameid != 0; descPtr += params.descItemSize)
- descList.push_back((const ADGameDescription *)descPtr);
-
- matches = detectGame(descList, 0, params, language, platform);
+ Common::ADList matches = detectGame(0, params, language, platform);
+ int gameNumber = -1;
for (uint i = 0; i < matches.size(); i++) {
if (((const ADGameDescription *)(params.descs + matches[i] * params.descItemSize))->gameid == gameid) {
gameNumber = matches[i];
@@ -182,17 +164,17 @@ int ADVANCED_DETECTOR_DETECT_INIT_GAME(
}
}
- if (gameNumber >= (int)descList.size() || gameNumber == -1) {
- error("TODO invalid gameNumber %d (max. expected value: %d)", gameNumber, descList.size());
+ if (gameNumber < 0) {
+ error("ADVANCED_DETECTOR_DETECT_INIT_GAME: no match found (TODO: Let the caller handle this)");
+ } else {
+ debug(2, "Running %s", toGameDescriptor(*(const ADGameDescription *)(params.descs + gameNumber * params.descItemSize), params.list).description().c_str());
}
- debug(2, "Running %s", toGameDescriptor(*(const ADGameDescription *)(params.descs + gameNumber * params.descItemSize), params.list).description().c_str());
-
return gameNumber;
}
-static ADList detectGame(ADGameDescList gameDescriptions, const FSList *fslist, const Common::ADParams &params, Language language, Platform platform) {
+static ADList detectGame(const FSList *fslist, const Common::ADParams &params, Language language, Platform platform) {
typedef HashMap<String, bool, CaseSensitiveString_Hash, CaseSensitiveString_EqualTo> StringSet;
StringSet filesList;
@@ -211,8 +193,13 @@ static ADList detectGame(ADGameDescList gameDescriptions, const FSList *fslist,
bool fileMissing;
const ADGameFileDescription *fileDesc;
+ Common::ADGameDescList gameDescriptions;
+ for (const byte *descPtr = params.descs; ((const ADGameDescription *)descPtr)->gameid != 0; descPtr += params.descItemSize)
+ gameDescriptions.push_back((const ADGameDescription *)descPtr);
+
assert(gameDescriptions.size());
+
// First we compose list of files which we need MD5s for
for (i = 0; i < gameDescriptions.size(); i++) {
for (j = 0; gameDescriptions[i]->filesDescriptions[j].fileName; j++) {