aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorMax Horn2008-03-15 15:25:49 +0000
committerMax Horn2008-03-15 15:25:49 +0000
commit05dd6cee3ae0b93db0463e22acf9e9c3463a8712 (patch)
treeeb1988277b900b6d0daaa8e6196252a430bb2372 /common
parentdc319c719fdc1526b546cb5d3b0ecc519c1d0369 (diff)
downloadscummvm-rg350-05dd6cee3ae0b93db0463e22acf9e9c3463a8712.tar.gz
scummvm-rg350-05dd6cee3ae0b93db0463e22acf9e9c3463a8712.tar.bz2
scummvm-rg350-05dd6cee3ae0b93db0463e22acf9e9c3463a8712.zip
Got rid of EncapsulatedADGameDesc
svn-id: r31130
Diffstat (limited to 'common')
-rw-r--r--common/advancedDetector.cpp46
-rw-r--r--common/advancedDetector.h29
2 files changed, 16 insertions, 59 deletions
diff --git a/common/advancedDetector.cpp b/common/advancedDetector.cpp
index cc3b269fc1..33af4736d2 100644
--- a/common/advancedDetector.cpp
+++ b/common/advancedDetector.cpp
@@ -148,24 +148,6 @@ static GameDescriptor toGameDescriptor(const ADGameDescription &g, const PlainGa
return gd;
}
-// Almost identical to the toGameDescriptor function that takes a ADGameDescription and PlainGameDescriptor.
-// Just a little fine tuning about accessing variables.
-// Used because of fallback detection and the dynamic string content it needs.
-static GameDescriptor toGameDescriptor(const EncapsulatedADGameDesc &g, const PlainGameDescriptor *sg) {
- const char *title = 0;
-
- while (sg->gameid) {
- if (!scumm_stricmp(g.getGameID(), sg->gameid))
- title = sg->description;
- sg++;
- }
-
- assert(g.realDesc);
- GameDescriptor gd(g.getGameID(), title, g.realDesc->language, g.realDesc->platform);
- gd.updateDesc(g.getExtra());
- return gd;
-}
-
/**
* Generate a preferred target value as
* GAMEID-PLAFORM-LANG
@@ -213,10 +195,10 @@ GameList AdvancedMetaEngine::detectGames(const FSList &fslist) const {
// Use fallback detector if there were no matches by other means
if (matches.empty()) {
- EncapsulatedADGameDesc fallbackDesc = fallbackDetect(&fslist);
- if (fallbackDesc.realDesc != 0) {
- GameDescriptor desc(toGameDescriptor(fallbackDesc, params.list));
- updateGameDescriptor(desc, fallbackDesc.realDesc, params);
+ const Common::ADGameDescription *fallbackDesc = fallbackDetect(&fslist);
+ if (fallbackDesc != 0) {
+ GameDescriptor desc(toGameDescriptor(*fallbackDesc, params.list));
+ updateGameDescriptor(desc, fallbackDesc, params);
detectedGames.push_back(desc);
}
} else for (uint i = 0; i < matches.size(); i++) { // Otherwise use the found matches
@@ -233,7 +215,6 @@ PluginError AdvancedMetaEngine::createInstance(OSystem *syst, Engine **engine) c
upgradeTargetIfNecessary(params);
const ADGameDescription *agdDesc = 0;
- EncapsulatedADGameDesc result;
Common::Language language = Common::UNK_LANG;
Common::Platform platform = Common::kPlatformUnknown;
Common::String extra("");
@@ -261,22 +242,23 @@ PluginError AdvancedMetaEngine::createInstance(OSystem *syst, Engine **engine) c
agdDesc = matches[0];
}
- if (agdDesc != 0) { // Check if we found a match without fallback detection
- result = EncapsulatedADGameDesc(agdDesc);
- } else {
+ if (agdDesc == 0) {
// Use fallback detector if there were no matches by other means
- EncapsulatedADGameDesc fallbackDesc = fallbackDetect(NULL);
- if (fallbackDesc.realDesc != 0 && (params.singleid != NULL || fallbackDesc.getGameID() == gameid)) {
- result = fallbackDesc; // Found a fallback match
+ agdDesc = fallbackDetect(NULL);
+ if (agdDesc != 0) {
+ // Seems we found a fallback match. But first perform a basic
+ // sanity check: the gameid must match.
+ if (params.singleid == NULL && agdDesc->gameid != gameid)
+ agdDesc = 0;
}
}
- if (result.realDesc == 0) {
+ if (agdDesc == 0) {
return kNoGameDataFoundError;
}
- debug(2, "Running %s", toGameDescriptor(result, params.list).description().c_str());
- if (!createInstance(syst, engine, result.realDesc)) {
+ debug(2, "Running %s", toGameDescriptor(*agdDesc, params.list).description().c_str());
+ if (!createInstance(syst, engine, agdDesc)) {
return kNoGameDataFoundError;
}
return kNoError;
diff --git a/common/advancedDetector.h b/common/advancedDetector.h
index cb93510231..94e21a3a9b 100644
--- a/common/advancedDetector.h
+++ b/common/advancedDetector.h
@@ -65,31 +65,6 @@ struct ADGameDescription {
};
/**
- * Encapsulates ADGameDescription and makes gameid and extra strings dynamic.
- * Used in fallback detection when dynamically creating string content.
- *
- * @todo Get rid of this once the fallback detection is a member of AdvancedMetaEngine.
- */
-struct EncapsulatedADGameDesc {
- Common::String gameid;
- Common::String extra;
- const ADGameDescription *realDesc;
-
- // Constructor for the EncapsulatedADGameDesc
- EncapsulatedADGameDesc() : realDesc(0) {}
- EncapsulatedADGameDesc(const ADGameDescription *paramRealDesc,
- Common::String paramGameID = Common::String(),
- Common::String paramExtra = Common::String())
- : realDesc(paramRealDesc), gameid(paramGameID), extra(paramExtra) {
- assert(paramRealDesc != NULL);
- }
-
- // Functions for getting the correct gameid and extra values from the struct
- const char *getGameID() const { return (gameid.empty() && realDesc != 0) ? realDesc->gameid : gameid.c_str(); }
- const char *getExtra() const { return (extra.empty() && realDesc != 0) ? realDesc->extra : extra.c_str(); }
-};
-
-/**
* A list of pointers to ADGameDescription structs (or subclasses thereof).
*/
typedef Array<const ADGameDescription*> ADGameDescList;
@@ -242,8 +217,8 @@ public:
* @note The fslist parameter may be 0 -- in that case, it is assumed
* that the callback searchs the current directory.
*/
- EncapsulatedADGameDesc fallbackDetect(const FSList *fslist) const {
- return EncapsulatedADGameDesc();
+ const Common::ADGameDescription *fallbackDetect(const FSList *fslist) const {
+ return 0;
}
};