[Scummvm-cvs-logs] SF.net SVN: scummvm: [25179] scummvm/trunk/common/advancedDetector.cpp
fingolfin at users.sourceforge.net
fingolfin at users.sourceforge.net
Thu Jan 25 02:08:00 CET 2007
Revision: 25179
http://scummvm.svn.sourceforge.net/scummvm/?rev=25179&view=rev
Author: fingolfin
Date: 2007-01-24 17:07:59 -0800 (Wed, 24 Jan 2007)
Log Message:
-----------
cleanup
Modified Paths:
--------------
scummvm/trunk/common/advancedDetector.cpp
Modified: scummvm/trunk/common/advancedDetector.cpp
===================================================================
--- scummvm/trunk/common/advancedDetector.cpp 2007-01-25 01:05:25 UTC (rev 25178)
+++ scummvm/trunk/common/advancedDetector.cpp 2007-01-25 01:07:59 UTC (rev 25179)
@@ -45,7 +45,7 @@
* @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 ¶ms, Language language, Platform platform);
+static ADList detectGame(const FSList *fslist, const Common::ADParams ¶ms, Language language, Platform platform);
PluginError ADVANCED_DETECTOR_ENGINE_CREATE(
@@ -132,18 +132,9 @@
const FSList &fslist,
const Common::ADParams ¶ms
) {
- GameList detectedGames;
- Common::ADList matches;
- Common::ADGameDescList descList;
- const byte *descPtr;
+ Common::ADList matches = detectGame(&fslist, params, Common::UNK_LANG, Common::kPlatformUnknown);
- 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);
-
+ 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 @@
int ADVANCED_DETECTOR_DETECT_INIT_GAME(
const Common::ADParams ¶ms
) {
- 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 @@
Common::String gameid = ConfMan.get("gameid");
- for (descPtr = params.descs; ((const ADGameDescription *)descPtr)->gameid != 0; descPtr += params.descItemSize)
- descList.push_back((const ADGameDescription *)descPtr);
+ Common::ADList matches = detectGame(0, params, language, platform);
- matches = detectGame(descList, 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 @@
}
}
- 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 ¶ms, Language language, Platform platform) {
+static ADList detectGame(const FSList *fslist, const Common::ADParams ¶ms, Language language, Platform platform) {
typedef HashMap<String, bool, CaseSensitiveString_Hash, CaseSensitiveString_EqualTo> StringSet;
StringSet filesList;
@@ -211,8 +193,13 @@
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++) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list