aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorBastien Bouclet2017-12-03 12:19:08 +0100
committerBastien Bouclet2018-05-10 09:04:23 +0200
commit5aff87dc153f392cb14423efa78a96397789a6fd (patch)
tree66c2fd4a14f4f9a8668499b17e3630f49809f297 /engines
parent643c24db75797728087999abd8acf1ecc83757fa (diff)
downloadscummvm-rg350-5aff87dc153f392cb14423efa78a96397789a6fd.tar.gz
scummvm-rg350-5aff87dc153f392cb14423efa78a96397789a6fd.tar.bz2
scummvm-rg350-5aff87dc153f392cb14423efa78a96397789a6fd.zip
ENGINES: Turn GameDescriptor into a simple struct
Diffstat (limited to 'engines')
-rw-r--r--engines/advancedDetector.cpp20
-rw-r--r--engines/game.cpp101
-rw-r--r--engines/game.h38
-rw-r--r--engines/scumm/detection.cpp2
-rw-r--r--engines/sword2/sword2.cpp2
5 files changed, 72 insertions, 91 deletions
diff --git a/engines/advancedDetector.cpp b/engines/advancedDetector.cpp
index 562ad5dfe2..ac606d3e4b 100644
--- a/engines/advancedDetector.cpp
+++ b/engines/advancedDetector.cpp
@@ -114,22 +114,22 @@ static Common::String sanitizeName(const char *name) {
void AdvancedMetaEngine::updateGameDescriptor(GameDescriptor &desc, const ADGameDescription *realDesc) const {
if (_singleId != NULL) {
- desc["preferredtarget"] = desc["gameid"];
- desc["gameid"] = _singleId;
+ desc.preferredTarget = desc.gameId;
+ desc.gameId = _singleId;
}
- if (!desc.contains("preferredtarget"))
- desc["preferredtarget"] = desc["gameid"];
+ if (desc.preferredTarget.empty())
+ desc.preferredTarget = desc.gameId;
if (realDesc->flags & ADGF_AUTOGENTARGET) {
if (*realDesc->extra)
- desc["preferredtarget"] = sanitizeName(realDesc->extra);
+ desc.preferredTarget = sanitizeName(realDesc->extra);
}
- desc["preferredtarget"] = generatePreferredTarget(desc["preferredtarget"], realDesc);
+ desc.preferredTarget = generatePreferredTarget(desc.preferredTarget, realDesc);
if (_flags & kADFlagUseExtraAsHint)
- desc["extra"] = realDesc->extra;
+ desc.extra = realDesc->extra;
desc.setGUIOptions(realDesc->guiOptions + _guiOptions);
desc.appendGUIOptions(getGameGUIOptionsDescriptionLanguage(realDesc->language));
@@ -329,13 +329,13 @@ Common::Error AdvancedMetaEngine::createInstance(OSystem *syst, Engine **engine)
showTestingWarning = true;
#endif
- if (((gameDescriptor.getSupportLevel() == kUnstableGame
- || (gameDescriptor.getSupportLevel() == kTestingGame
+ if (((gameDescriptor.gameSupportLevel == kUnstableGame
+ || (gameDescriptor.gameSupportLevel == kTestingGame
&& showTestingWarning)))
&& !Engine::warnUserAboutUnsupportedGame())
return Common::kUserCanceled;
- debug(2, "Running %s", gameDescriptor.description().c_str());
+ debug(2, "Running %s", gameDescriptor.description.c_str());
initSubSystems(agdDesc.desc);
if (!createInstance(syst, engine, agdDesc.desc))
return Common::kNoGameDataFoundError;
diff --git a/engines/game.cpp b/engines/game.cpp
index 177880c39d..1e96020fde 100644
--- a/engines/game.cpp
+++ b/engines/game.cpp
@@ -35,94 +35,75 @@ const PlainGameDescriptor *findPlainGameDescriptor(const char *gameid, const Pla
return 0;
}
-GameDescriptor::GameDescriptor() {
- setVal("gameid", "");
- setVal("description", "");
+GameDescriptor::GameDescriptor() :
+ language(Common::UNK_LANG),
+ platform(Common::kPlatformUnknown),
+ gameSupportLevel(kStableGame) {
}
-GameDescriptor::GameDescriptor(const PlainGameDescriptor &pgd, Common::String guioptions) {
- setVal("gameid", pgd.gameId);
- setVal("description", pgd.description);
+GameDescriptor::GameDescriptor(const PlainGameDescriptor &pgd, const Common::String &guioptions) :
+ language(Common::UNK_LANG),
+ platform(Common::kPlatformUnknown),
+ gameSupportLevel(kStableGame) {
+
+ gameId = pgd.gameId;
+ preferredTarget = pgd.gameId;
+ description = pgd.description;
if (!guioptions.empty())
- setVal("guioptions", Common::getGameGUIOptionsDescription(guioptions));
+ _guiOptions = Common::getGameGUIOptionsDescription(guioptions);
}
-GameDescriptor::GameDescriptor(const Common::String &g, const Common::String &d, Common::Language l, Common::Platform p, Common::String guioptions, GameSupportLevel gsl) {
- setVal("gameid", g);
- setVal("description", d);
- if (l != Common::UNK_LANG)
- setVal("language", Common::getLanguageCode(l));
- if (p != Common::kPlatformUnknown)
- setVal("platform", Common::getPlatformCode(p));
- if (!guioptions.empty())
- setVal("guioptions", Common::getGameGUIOptionsDescription(guioptions));
+GameDescriptor::GameDescriptor(const Common::String &id, const Common::String &d, Common::Language l, Common::Platform p, const Common::String &guioptions, GameSupportLevel gsl) {
+ gameId = id;
+ preferredTarget = id;
+ description = d;
+ language = l;
+ platform = p;
+ gameSupportLevel = gsl;
- setSupportLevel(gsl);
+ if (!guioptions.empty())
+ _guiOptions = Common::getGameGUIOptionsDescription(guioptions);
}
-void GameDescriptor::setGUIOptions(Common::String guioptions) {
- if (!guioptions.empty())
- setVal("guioptions", Common::getGameGUIOptionsDescription(guioptions));
+void GameDescriptor::setGUIOptions(const Common::String &guioptions) {
+ if (guioptions.empty())
+ _guiOptions.clear();
else
- erase("guioptions");
+ _guiOptions = Common::getGameGUIOptionsDescription(guioptions);
}
void GameDescriptor::appendGUIOptions(const Common::String &str) {
- setVal("guioptions", getVal("guioptions", "") + " " + str);
+ if (!_guiOptions.empty())
+ _guiOptions += " ";
+
+ _guiOptions += str;
}
-void GameDescriptor::updateDesc(const char *extra) {
- const bool hasCustomLanguage = (language() != Common::UNK_LANG);
- const bool hasCustomPlatform = (platform() != Common::kPlatformUnknown);
- const bool hasExtraDesc = (extra && extra[0]);
+void GameDescriptor::updateDesc(const char *extraDesc) {
+ const bool hasCustomLanguage = (language != Common::UNK_LANG);
+ const bool hasCustomPlatform = (platform != Common::kPlatformUnknown);
+ const bool hasExtraDesc = (extraDesc && extraDesc[0]);
// Adapt the description string if custom platform/language is set.
if (hasCustomLanguage || hasCustomPlatform || hasExtraDesc) {
- Common::String descr = description();
+ Common::String descr = description;
descr += " (";
if (hasExtraDesc)
- descr += extra;
+ descr += extraDesc;
if (hasCustomPlatform) {
if (hasExtraDesc)
descr += "/";
- descr += Common::getPlatformDescription(platform());
+ descr += Common::getPlatformDescription(platform);
}
if (hasCustomLanguage) {
if (hasExtraDesc || hasCustomPlatform)
descr += "/";
- descr += Common::getLanguageDescription(language());
+ descr += Common::getLanguageDescription(language);
}
descr += ")";
- setVal("description", descr);
- }
-}
-
-GameSupportLevel GameDescriptor::getSupportLevel() {
- GameSupportLevel gsl = kStableGame;
- if (contains("gsl")) {
- Common::String gslString = getVal("gsl");
- if (gslString.equals("unstable"))
- gsl = kUnstableGame;
- else if (gslString.equals("testing"))
- gsl = kTestingGame;
- }
- return gsl;
-}
-
-void GameDescriptor::setSupportLevel(GameSupportLevel gsl) {
- switch (gsl) {
- case kUnstableGame:
- setVal("gsl", "unstable");
- break;
- case kTestingGame:
- setVal("gsl", "testing");
- break;
- case kStableGame:
- // Fall Through intended
- default:
- erase("gsl");
+ description = descr;
}
}
@@ -159,7 +140,7 @@ Common::String DetectionResults::generateUnknownGameReport(bool translate, uint3
const char *reportEngineHeader = _s("Matched game IDs for the %s engine:");
Common::String report = Common::String::format(
- translate ? _(reportStart) : reportStart, _detectedGames[0].matchedGame["path"].c_str(),
+ translate ? _(reportStart) : reportStart, _detectedGames[0].matchedGame.path.c_str(),
"https://bugs.scummvm.org/"
);
report += "\n";
@@ -190,7 +171,7 @@ Common::String DetectionResults::generateUnknownGameReport(bool translate, uint3
// Add the gameId to the list of matched games for the engine
// TODO: Use the gameId here instead of the preferred target.
// This is currently impossible due to the AD singleId feature losing the information.
- report += game.matchedGame["preferredtarget"];
+ report += game.matchedGame.preferredTarget;
// Consolidate matched files across all engines and detection entries
for (FilePropertiesMap::const_iterator it = game.matchedFiles.begin(); it != game.matchedFiles.end(); it++) {
diff --git a/engines/game.h b/engines/game.h
index a5cc4de4ec..053c0c85b1 100644
--- a/engines/game.h
+++ b/engines/game.h
@@ -78,15 +78,15 @@ enum GameSupportLevel {
* can be contained in a GameDescriptor.
* This is an essential part of the glue between the game engines and the launcher code.
*/
-class GameDescriptor : public Common::StringMap {
+class GameDescriptor {
public:
GameDescriptor();
- explicit GameDescriptor(const PlainGameDescriptor &pgd, Common::String guioptions = Common::String());
- GameDescriptor(const Common::String &gameid,
+ explicit GameDescriptor(const PlainGameDescriptor &pgd, const Common::String &guioptions = Common::String());
+ GameDescriptor(const Common::String &id,
const Common::String &description,
Common::Language language = Common::UNK_LANG,
Common::Platform platform = Common::kPlatformUnknown,
- Common::String guioptions = Common::String(),
+ const Common::String &guioptions = Common::String(),
GameSupportLevel gsl = kStableGame);
/**
@@ -94,27 +94,27 @@ public:
* Values that are missing are omitted, so e.g. (EXTRA/LANG) would be
* added if no platform has been specified but a language and an extra string.
*/
- void updateDesc(const char *extra = 0);
+ void updateDesc(const char *extraDesc = 0);
- void setGUIOptions(Common::String options);
+ void setGUIOptions(const Common::String &options);
void appendGUIOptions(const Common::String &str);
+ Common::String getGUIOptions() const { return _guiOptions; }
+
+ Common::String gameId;
+ Common::String preferredTarget;
+ Common::String description;
+ Common::Language language;
+ Common::Platform platform;
+ Common::String path;
+ Common::String extra;
/**
* What level of support is expected of this game
*/
- GameSupportLevel getSupportLevel();
- void setSupportLevel(GameSupportLevel gsl);
-
- Common::String &gameid() { return getVal("gameid"); }
- Common::String &description() { return getVal("description"); }
- const Common::String &gameid() const { return getVal("gameid"); }
- const Common::String &description() const { return getVal("description"); }
- Common::Language language() const { return contains("language") ? Common::parseLanguage(getVal("language")) : Common::UNK_LANG; }
- Common::Platform platform() const { return contains("platform") ? Common::parsePlatform(getVal("platform")) : Common::kPlatformUnknown; }
-
- const Common::String &preferredtarget() const {
- return contains("preferredtarget") ? getVal("preferredtarget") : getVal("gameid");
- }
+ GameSupportLevel gameSupportLevel;
+
+private:
+ Common::String _guiOptions;
};
/** List of games. */
diff --git a/engines/scumm/detection.cpp b/engines/scumm/detection.cpp
index 6276f1ae41..dea0d3a026 100644
--- a/engines/scumm/detection.cpp
+++ b/engines/scumm/detection.cpp
@@ -1044,7 +1044,7 @@ DetectedGames ScummMetaEngine::detectGames(const Common::FSList &fslist) const {
// Compute and set the preferred target name for this game.
// Based on generateComplexID() in advancedDetector.cpp.
- game.matchedGame["preferredtarget"] = generatePreferredTarget(*x);
+ game.matchedGame.preferredTarget = generatePreferredTarget(*x);
game.matchedGame.setGUIOptions(x->game.guioptions + MidiDriver::musicType2GUIO(x->game.midi));
game.matchedGame.appendGUIOptions(getGameGUIOptionsDescriptionLanguage(x->language));
diff --git a/engines/sword2/sword2.cpp b/engines/sword2/sword2.cpp
index f9e308ca63..67f6904cbe 100644
--- a/engines/sword2/sword2.cpp
+++ b/engines/sword2/sword2.cpp
@@ -284,7 +284,7 @@ Common::Error Sword2MetaEngine::createInstance(OSystem *syst, Engine **engine) c
DetectedGames detectedGames = detectGames(fslist);
for (uint i = 0; i < detectedGames.size(); i++) {
- if (detectedGames[i].matchedGame.gameid() == gameid) {
+ if (detectedGames[i].matchedGame.gameId == gameid) {
*engine = new Sword2::Sword2Engine(syst);
return Common::kNoError;
}