aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Horn2007-01-25 00:43:35 +0000
committerMax Horn2007-01-25 00:43:35 +0000
commit9dada67e5af879cd2556d43e33e521a9bd1b2ab4 (patch)
tree7f3a27bb30be5de7587a7ac5afb2063486404195
parent5f91f6d1e57522d45613865c8cb0d8398d3f7b07 (diff)
downloadscummvm-rg350-9dada67e5af879cd2556d43e33e521a9bd1b2ab4.tar.gz
scummvm-rg350-9dada67e5af879cd2556d43e33e521a9bd1b2ab4.tar.bz2
scummvm-rg350-9dada67e5af879cd2556d43e33e521a9bd1b2ab4.zip
Removed class AdvancedDetector
svn-id: r25174
-rw-r--r--common/advancedDetector.cpp39
-rw-r--r--common/advancedDetector.h45
2 files changed, 27 insertions, 57 deletions
diff --git a/common/advancedDetector.cpp b/common/advancedDetector.cpp
index 8157bb20a3..c64aecc3c2 100644
--- a/common/advancedDetector.cpp
+++ b/common/advancedDetector.cpp
@@ -33,6 +33,21 @@
namespace Common {
+/**
+ * Detect games in specified directory.
+ * Parameters language and platform are used to pass on values
+ * specified by the user. I.e. this is used to restrict search scope.
+ *
+ * @param fslist FSList to scan or NULL for scanning all specified
+ * default directories.
+ * @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
+ */
+static ADList detectGame(ADGameDescList gameDescriptions, 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
@@ -118,7 +133,6 @@ GameList ADVANCED_DETECTOR_DETECT_GAMES_FUNCTION(
const Common::ADParams &params
) {
GameList detectedGames;
- Common::AdvancedDetector ad;
Common::ADList matches;
Common::ADGameDescList descList;
const byte *descPtr;
@@ -126,11 +140,9 @@ GameList ADVANCED_DETECTOR_DETECT_GAMES_FUNCTION(
for (descPtr = params.descs; ((const ADGameDescription *)descPtr)->gameid != 0; descPtr += params.descItemSize)
descList.push_back((const ADGameDescription *)descPtr);
- ad.registerGameDescriptions(descList);
-
debug(3, "%s: cnt: %d", ((const ADGameDescription *)params.descs)->gameid, descList.size());
- matches = ad.detectGame(&fslist, params, Common::UNK_LANG, Common::kPlatformUnknown);
+ matches = detectGame(descList, &fslist, params, Common::UNK_LANG, Common::kPlatformUnknown);
for (uint i = 0; i < matches.size(); i++)
detectedGames.push_back(toGameDescriptor(*(const ADGameDescription *)(params.descs + matches[i] * params.descItemSize), params.list));
@@ -144,7 +156,6 @@ int ADVANCED_DETECTOR_DETECT_INIT_GAME(
int gameNumber = -1;
GameList detectedGames;
- Common::AdvancedDetector ad;
Common::ADList matches;
Common::ADGameDescList descList;
const byte *descPtr;
@@ -162,9 +173,7 @@ int ADVANCED_DETECTOR_DETECT_INIT_GAME(
for (descPtr = params.descs; ((const ADGameDescription *)descPtr)->gameid != 0; descPtr += params.descItemSize)
descList.push_back((const ADGameDescription *)descPtr);
- ad.registerGameDescriptions(descList);
-
- matches = ad.detectGame(0, params, language, platform);
+ matches = detectGame(descList, 0, params, language, platform);
for (uint i = 0; i < matches.size(); i++) {
if (((const ADGameDescription *)(params.descs + matches[i] * params.descItemSize))->gameid == gameid) {
@@ -192,7 +201,7 @@ static String getDescription(const ADGameDescription *g) {
return String(tmp);
}
-ADList AdvancedDetector::detectGame(const FSList *fslist, const Common::ADParams &params, Language language, Platform platform) {
+static ADList detectGame(ADGameDescList gameDescriptions, const FSList *fslist, const Common::ADParams &params, Language language, Platform platform) {
typedef HashMap<String, bool, CaseSensitiveString_Hash, CaseSensitiveString_EqualTo> StringSet;
StringSet filesList;
@@ -211,12 +220,12 @@ ADList AdvancedDetector::detectGame(const FSList *fslist, const Common::ADParams
bool fileMissing;
const ADGameFileDescription *fileDesc;
- assert(_gameDescriptions.size());
+ 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++) {
- tstr = String(_gameDescriptions[i]->filesDescriptions[j].fileName);
+ for (i = 0; i < gameDescriptions.size(); i++) {
+ for (j = 0; gameDescriptions[i]->filesDescriptions[j].fileName; j++) {
+ tstr = String(gameDescriptions[i]->filesDescriptions[j].fileName);
tstr.toLowercase();
tstr2 = tstr + ".";
filesList[tstr] = true;
@@ -275,8 +284,8 @@ ADList AdvancedDetector::detectGame(const FSList *fslist, const Common::ADParams
ADList matched;
int maxFilesMatched = 0;
- for (i = 0; i < _gameDescriptions.size(); i++) {
- const ADGameDescription *g = _gameDescriptions[i];
+ 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
diff --git a/common/advancedDetector.h b/common/advancedDetector.h
index 84cfe8c17c..72c9a3838e 100644
--- a/common/advancedDetector.h
+++ b/common/advancedDetector.h
@@ -32,9 +32,9 @@ namespace Common {
struct ADGameFileDescription {
const char *fileName;
- uint16 fileType; // Optional. Not used in detection, only be engines
- const char *md5; // Optional could be NULL
- const int32 fileSize; // Optional. Set to -1 to ignore
+ uint16 fileType; // Optional. Not used during detection, only by engines.
+ const char *md5; // Optional. May be NULL.
+ const int32 fileSize; // Optional. Set to -1 to ignore.
};
struct ADGameDescription {
@@ -70,43 +70,7 @@ typedef Array<const ADGameDescription*> ADGameDescList;
#define AD_ENTRY1(f, x) {{ f, 0, x, -1}, {NULL, 0, NULL, 0}}
-// TODO/FIXME: Fingolfin asks: Why is AdvancedDetector a class, considering that
-// it is only used as follow:
-// 1) Create an instance of it on the stack
-// 2) invoke registerGameDescriptions and setFileMD5Bytes
-// 3) invoke detectGame *once*
-// Obviously, 2) could also be handled by passing more params to detectGame.
-// So it seem we could replace this class by a simple advancedDetectGame(...)
-// function, w/o a class or instantiating object... ? Or is there a deeper
-// reason I miss?
-class AdvancedDetector {
-public:
-
- void registerGameDescriptions(ADGameDescList gameDescriptions) {
- _gameDescriptions = gameDescriptions;
- }
-
- /**
- * Detect games in specified directory.
- * Parameters language and platform are used to pass on values
- * specified by the user. I.e. this is used to restrict search scope.
- *
- * @param fslist FSList to scan or NULL for scanning all specified
- * default directories.
- * @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
- */
- ADList detectGame(const FSList *fslist, const Common::ADParams &params, Language language, Platform platform);
-
-private:
- ADGameDescList _gameDescriptions;
-};
-
-
// FIXME/TODO: Rename this function to something more sensible.
-// Possibly move it inside class AdvancedDetector ?
GameDescriptor ADVANCED_DETECTOR_FIND_GAMEID(
const char *gameid,
const Common::ADParams &params
@@ -114,7 +78,6 @@ GameDescriptor ADVANCED_DETECTOR_FIND_GAMEID(
// FIXME/TODO: Rename this function to something more sensible.
-// Possibly move it inside class AdvancedDetector ?
GameList ADVANCED_DETECTOR_DETECT_GAMES_FUNCTION(
const FSList &fslist,
const Common::ADParams &params
@@ -122,13 +85,11 @@ GameList ADVANCED_DETECTOR_DETECT_GAMES_FUNCTION(
// FIXME/TODO: Rename this function to something more sensible.
-// Possibly move it inside class AdvancedDetector ?
int ADVANCED_DETECTOR_DETECT_INIT_GAME(
const Common::ADParams &params
);
// FIXME/TODO: Rename this function to something more sensible.
-// Possibly move it inside class AdvancedDetector ?
PluginError ADVANCED_DETECTOR_ENGINE_CREATE(
GameList (*detectFunc)(const FSList &fslist),
const Common::ADParams &params