aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorBastien Bouclet2018-05-06 15:51:03 +0200
committerBastien Bouclet2018-05-10 09:04:23 +0200
commit90b78c544657bf0fc41d6b86276a0873060345b5 (patch)
treea9187f2a6d924360f6b0960fd08a7cf7cddbc8ba /engines
parentfaa2534f46611a47913004b55aa0e5ed5b7e4b7a (diff)
downloadscummvm-rg350-90b78c544657bf0fc41d6b86276a0873060345b5.tar.gz
scummvm-rg350-90b78c544657bf0fc41d6b86276a0873060345b5.tar.bz2
scummvm-rg350-90b78c544657bf0fc41d6b86276a0873060345b5.zip
ENGINES: Merge GameDescriptor and DetectedGame
Diffstat (limited to 'engines')
-rw-r--r--engines/advancedDetector.cpp50
-rw-r--r--engines/advancedDetector.h2
-rw-r--r--engines/game.cpp27
-rw-r--r--engines/game.h96
-rw-r--r--engines/metaengine.h2
-rw-r--r--engines/scumm/detection.cpp9
-rw-r--r--engines/sky/detection.cpp10
-rw-r--r--engines/sword1/detection.cpp28
-rw-r--r--engines/sword2/sword2.cpp7
9 files changed, 105 insertions, 126 deletions
diff --git a/engines/advancedDetector.cpp b/engines/advancedDetector.cpp
index b7bf4b40e0..8e7ec4856f 100644
--- a/engines/advancedDetector.cpp
+++ b/engines/advancedDetector.cpp
@@ -33,42 +33,32 @@
#include "engines/advancedDetector.h"
#include "engines/obsolete.h"
-static GameDescriptor toGameDescriptor(const ADGameDescription &g, const PlainGameDescriptor *sg) {
- const char *title = 0;
+DetectedGame AdvancedMetaEngine::toDetectedGame(const ADDetectedGame &adGame) const {
+ const char *title;
const char *extra;
- if (g.flags & ADGF_USEEXTRAASTITLE) {
- title = g.extra;
+ if (adGame.desc->flags & ADGF_USEEXTRAASTITLE) {
+ title = adGame.desc->extra;
extra = "";
} else {
- while (sg->gameId) {
- if (!scumm_stricmp(g.gameId, sg->gameId))
- title = sg->description;
- sg++;
- }
-
- extra = g.extra;
+ const PlainGameDescriptor *pgd = findPlainGameDescriptor(adGame.desc->gameId, _gameIds);
+ title = pgd->description;
+ extra = adGame.desc->extra;
}
- GameSupportLevel gsl = kStableGame;
- if (g.flags & ADGF_UNSTABLE)
- gsl = kUnstableGame;
- else if (g.flags & ADGF_TESTING)
- gsl = kTestingGame;
-
- GameDescriptor gd(g.gameId, title, g.language, g.platform, extra);
- gd.gameSupportLevel = gsl;
- return gd;
-}
-
-DetectedGame AdvancedMetaEngine::toDetectedGame(const ADDetectedGame &adGame) const {
- DetectedGame game;
+ DetectedGame game(adGame.desc->gameId, title, adGame.desc->language, adGame.desc->platform, extra);
game.engineName = getName();
- game.gameId = adGame.desc->gameId;
game.hasUnknownFiles = adGame.hasUnknownFiles;
game.matchedFiles = adGame.matchedFiles;
- game.matchedGame = toGameDescriptor(*adGame.desc, _gameIds);
- updateGameDescriptor(game.matchedGame, adGame.desc);
+
+ game.gameSupportLevel = kStableGame;
+ if (adGame.desc->flags & ADGF_UNSTABLE)
+ game.gameSupportLevel = kUnstableGame;
+ else if (adGame.desc->flags & ADGF_TESTING)
+ game.gameSupportLevel = kTestingGame;
+
+ updateGameDescriptor(game, adGame.desc);
+
return game;
}
@@ -112,8 +102,8 @@ static Common::String sanitizeName(const char *name) {
return res;
}
-void AdvancedMetaEngine::updateGameDescriptor(GameDescriptor &desc, const ADGameDescription *realDesc) const {
- if (_singleId != NULL) {
+void AdvancedMetaEngine::updateGameDescriptor(DetectedGame &desc, const ADGameDescription *realDesc) const {
+ if (_singleId) {
desc.preferredTarget = desc.gameId;
desc.gameId = _singleId;
}
@@ -321,7 +311,7 @@ Common::Error AdvancedMetaEngine::createInstance(OSystem *syst, Engine **engine)
Common::updateGameGUIOptions(agdDesc.desc->guiOptions + _guiOptions, lang);
- GameDescriptor gameDescriptor = toGameDescriptor(*agdDesc.desc, _gameIds);
+ DetectedGame gameDescriptor = toDetectedGame(agdDesc);
bool showTestingWarning = false;
diff --git a/engines/advancedDetector.h b/engines/advancedDetector.h
index 5762009ea7..9f2016465d 100644
--- a/engines/advancedDetector.h
+++ b/engines/advancedDetector.h
@@ -321,7 +321,7 @@ protected:
ADDetectedGame detectGameFilebased(const FileMap &allFiles, const Common::FSList &fslist, const ADFileBasedFallback *fileBasedFallback) const;
// TODO
- void updateGameDescriptor(GameDescriptor &desc, const ADGameDescription *realDesc) const;
+ void updateGameDescriptor(DetectedGame &desc, const ADGameDescription *realDesc) const;
/**
* Compose a hashmap of all files in fslist.
diff --git a/engines/game.cpp b/engines/game.cpp
index bdf8e322dd..d23a006a4c 100644
--- a/engines/game.cpp
+++ b/engines/game.cpp
@@ -35,13 +35,19 @@ const PlainGameDescriptor *findPlainGameDescriptor(const char *gameid, const Pla
return 0;
}
-GameDescriptor::GameDescriptor() :
+DetectedGame::DetectedGame() :
+ engineName(nullptr),
+ hasUnknownFiles(false),
+ canBeAdded(true),
language(Common::UNK_LANG),
platform(Common::kPlatformUnknown),
gameSupportLevel(kStableGame) {
}
-GameDescriptor::GameDescriptor(const PlainGameDescriptor &pgd) :
+DetectedGame::DetectedGame(const PlainGameDescriptor &pgd) :
+ engineName(nullptr),
+ hasUnknownFiles(false),
+ canBeAdded(true),
language(Common::UNK_LANG),
platform(Common::kPlatformUnknown),
gameSupportLevel(kStableGame) {
@@ -51,7 +57,12 @@ GameDescriptor::GameDescriptor(const PlainGameDescriptor &pgd) :
description = pgd.description;
}
-GameDescriptor::GameDescriptor(const Common::String &id, const Common::String &d, Common::Language l, Common::Platform p, const Common::String &ex) {
+DetectedGame::DetectedGame(const Common::String &id, const Common::String &d, Common::Language l, Common::Platform p, const Common::String &ex) :
+ engineName(nullptr),
+ hasUnknownFiles(false),
+ canBeAdded(true),
+ gameSupportLevel(kStableGame) {
+
gameId = id;
preferredTarget = id;
description = d;
@@ -63,21 +74,21 @@ GameDescriptor::GameDescriptor(const Common::String &id, const Common::String &d
description += updateDesc();
}
-void GameDescriptor::setGUIOptions(const Common::String &guioptions) {
+void DetectedGame::setGUIOptions(const Common::String &guioptions) {
if (guioptions.empty())
_guiOptions.clear();
else
_guiOptions = Common::getGameGUIOptionsDescription(guioptions);
}
-void GameDescriptor::appendGUIOptions(const Common::String &str) {
+void DetectedGame::appendGUIOptions(const Common::String &str) {
if (!_guiOptions.empty())
_guiOptions += " ";
_guiOptions += str;
}
-Common::String GameDescriptor::updateDesc() const {
+Common::String DetectedGame::updateDesc() const {
const bool hasCustomLanguage = (language != Common::UNK_LANG);
const bool hasCustomPlatform = (platform != Common::kPlatformUnknown);
const bool hasExtraDesc = !extra.empty();
@@ -140,7 +151,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].path.c_str(),
"https://bugs.scummvm.org/"
);
report += "\n";
@@ -171,7 +182,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.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 d675e7bdf4..660a94ad6c 100644
--- a/engines/game.h
+++ b/engines/game.h
@@ -71,53 +71,6 @@ enum GameSupportLevel {
kUnstableGame // the game is not even ready for public testing yet
};
-/**
- * A hashmap describing details about a given game. In a sense this is a refined
- * version of PlainGameDescriptor, as it also contains a gameid and a description string.
- * But in addition, platform and language settings, as well as arbitrary other settings,
- * 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:
- GameDescriptor();
- explicit GameDescriptor(const PlainGameDescriptor &pgd);
- GameDescriptor(const Common::String &id,
- const Common::String &description,
- Common::Language language = Common::UNK_LANG,
- Common::Platform platform = Common::kPlatformUnknown,
- const Common::String &extra = Common::String());
-
- 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 gameSupportLevel;
-
-private:
- /**
- * Update the description string by appending (EXTRA/PLATFORM/LANG) to it.
- * 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.
- */
- Common::String updateDesc() const;
-
- Common::String _guiOptions;
-};
-
-/** List of games. */
-typedef Common::Array<GameDescriptor> GameList;
/**
* A record describing the properties of a file. Used on the existing
@@ -135,20 +88,32 @@ struct FileProperties {
*/
typedef Common::HashMap<Common::String, FileProperties, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> FilePropertiesMap;
+/**
+ * Details about a given game.
+ *
+ * While PlainGameDescriptor refers to a game supported by an engine, this refers to a game copy
+ * that has been detected by an engine's detector.
+ * It contains all the necessary data to add the game to the configuration manager and / or to launch it.
+ */
struct DetectedGame {
+ DetectedGame();
+ explicit DetectedGame(const PlainGameDescriptor &pgd);
+ DetectedGame(const Common::String &id,
+ const Common::String &description,
+ Common::Language language = Common::UNK_LANG,
+ Common::Platform platform = Common::kPlatformUnknown,
+ const Common::String &extra = Common::String());
+
+ void setGUIOptions(const Common::String &options);
+ void appendGUIOptions(const Common::String &str);
+ Common::String getGUIOptions() const { return _guiOptions; }
+
/**
* The name of the engine supporting the detected game
*/
const char *engineName;
/**
- * The identifier of the detected game
- *
- * For engines using the singleId feature, this is the true engine-specific gameId, not the singleId.
- */
- const char *gameId;
-
- /**
* A game was detected, but some files were not recognized
*
* This can happen when the md5 or size of the detected files did not match the engine's detection tables.
@@ -170,14 +135,31 @@ struct DetectedGame {
*/
bool canBeAdded;
+ 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 gameSupportLevel;
+
+private:
/**
- * Details about the detected game
+ * Update the description string by appending (EXTRA/PLATFORM/LANG) to it.
+ * 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.
*/
- GameDescriptor matchedGame;
+ Common::String updateDesc() const;
- DetectedGame() : engineName(nullptr), gameId(nullptr), hasUnknownFiles(false), canBeAdded(true) {}
+ Common::String _guiOptions;
};
+/** List of games. */
typedef Common::Array<DetectedGame> DetectedGames;
/**
diff --git a/engines/metaengine.h b/engines/metaengine.h
index 6e8ab16af8..a95ff1593e 100644
--- a/engines/metaengine.h
+++ b/engines/metaengine.h
@@ -277,7 +277,7 @@ public:
*
* Returns the created target name.
*/
- Common::String createTargetForGame(const GameDescriptor &game);
+ Common::String createTargetForGame(const DetectedGame &game);
};
/** Convenience shortcut for accessing the engine manager. */
diff --git a/engines/scumm/detection.cpp b/engines/scumm/detection.cpp
index 1395fc4fd7..fccb30b0fa 100644
--- a/engines/scumm/detection.cpp
+++ b/engines/scumm/detection.cpp
@@ -1036,15 +1036,14 @@ DetectedGames ScummMetaEngine::detectGames(const Common::FSList &fslist) const {
const PlainGameDescriptor *g = findPlainGameDescriptor(x->game.gameid, gameDescriptions);
assert(g);
- DetectedGame game;
- game.matchedGame = GameDescriptor(x->game.gameid, g->description, x->language, x->game.platform, x->extra);
+ DetectedGame game = DetectedGame(x->game.gameid, g->description, x->language, x->game.platform, x->extra);
// Compute and set the preferred target name for this game.
// Based on generateComplexID() in advancedDetector.cpp.
- game.matchedGame.preferredTarget = generatePreferredTarget(*x);
+ game.preferredTarget = generatePreferredTarget(*x);
- game.matchedGame.setGUIOptions(x->game.guioptions + MidiDriver::musicType2GUIO(x->game.midi));
- game.matchedGame.appendGUIOptions(getGameGUIOptionsDescriptionLanguage(x->language));
+ game.setGUIOptions(x->game.guioptions + MidiDriver::musicType2GUIO(x->game.midi));
+ game.appendGUIOptions(getGameGUIOptionsDescriptionLanguage(x->language));
detectedGames.push_back(game);
}
diff --git a/engines/sky/detection.cpp b/engines/sky/detection.cpp
index b8abd6bcb5..6beaf02fdc 100644
--- a/engines/sky/detection.cpp
+++ b/engines/sky/detection.cpp
@@ -182,18 +182,16 @@ DetectedGames SkyMetaEngine::detectGames(const Common::FSList &fslist) const {
++sv;
}
- DetectedGame game;
if (sv->dinnerTableEntries) {
Common::String extra = Common::String::format("v0.0%d %s", sv->version, sv->extraDesc);
- game.matchedGame = GameDescriptor(skySetting.gameId, skySetting.description, Common::UNK_LANG, Common::kPlatformUnknown, extra);
- game.matchedGame.setGUIOptions(sv->guioptions);
+ DetectedGame game = DetectedGame(skySetting.gameId, skySetting.description, Common::UNK_LANG, Common::kPlatformUnknown, extra);
+ game.setGUIOptions(sv->guioptions);
+ detectedGames.push_back(game);
} else {
- game.matchedGame = GameDescriptor(skySetting.gameId, skySetting.description);
+ detectedGames.push_back(DetectedGame(skySetting.gameId, skySetting.description));
}
-
- detectedGames.push_back(game);
}
return detectedGames;
diff --git a/engines/sword1/detection.cpp b/engines/sword1/detection.cpp
index 205640a0a6..6504806423 100644
--- a/engines/sword1/detection.cpp
+++ b/engines/sword1/detection.cpp
@@ -214,29 +214,29 @@ DetectedGames SwordMetaEngine::detectGames(const Common::FSList &fslist) const {
DetectedGame game;
if (mainFilesFound && pcFilesFound && demoFilesFound)
- game.matchedGame = GameDescriptor(sword1DemoSettings);
+ game = DetectedGame(sword1DemoSettings);
else if (mainFilesFound && pcFilesFound && psxFilesFound)
- game.matchedGame = GameDescriptor(sword1PSXSettings);
+ game = DetectedGame(sword1PSXSettings);
else if (mainFilesFound && pcFilesFound && psxDemoFilesFound)
- game.matchedGame = GameDescriptor(sword1PSXDemoSettings);
+ game = DetectedGame(sword1PSXDemoSettings);
else if (mainFilesFound && pcFilesFound && !psxFilesFound)
- game.matchedGame = GameDescriptor(sword1FullSettings);
+ game = DetectedGame(sword1FullSettings);
else if (mainFilesFound && macFilesFound)
- game.matchedGame = GameDescriptor(sword1MacFullSettings);
+ game = DetectedGame(sword1MacFullSettings);
else if (mainFilesFound && macDemoFilesFound)
- game.matchedGame = GameDescriptor(sword1MacDemoSettings);
+ game = DetectedGame(sword1MacDemoSettings);
else
return detectedGames;
- game.matchedGame.setGUIOptions(GUIO2(GUIO_NOMIDI, GUIO_NOASPECT));
+ game.setGUIOptions(GUIO2(GUIO_NOMIDI, GUIO_NOASPECT));
- game.matchedGame.appendGUIOptions(getGameGUIOptionsDescriptionLanguage(Common::EN_ANY));
- game.matchedGame.appendGUIOptions(getGameGUIOptionsDescriptionLanguage(Common::DE_DEU));
- game.matchedGame.appendGUIOptions(getGameGUIOptionsDescriptionLanguage(Common::FR_FRA));
- game.matchedGame.appendGUIOptions(getGameGUIOptionsDescriptionLanguage(Common::IT_ITA));
- game.matchedGame.appendGUIOptions(getGameGUIOptionsDescriptionLanguage(Common::ES_ESP));
- game.matchedGame.appendGUIOptions(getGameGUIOptionsDescriptionLanguage(Common::PT_BRA));
- game.matchedGame.appendGUIOptions(getGameGUIOptionsDescriptionLanguage(Common::CZ_CZE));
+ game.appendGUIOptions(getGameGUIOptionsDescriptionLanguage(Common::EN_ANY));
+ game.appendGUIOptions(getGameGUIOptionsDescriptionLanguage(Common::DE_DEU));
+ game.appendGUIOptions(getGameGUIOptionsDescriptionLanguage(Common::FR_FRA));
+ game.appendGUIOptions(getGameGUIOptionsDescriptionLanguage(Common::IT_ITA));
+ game.appendGUIOptions(getGameGUIOptionsDescriptionLanguage(Common::ES_ESP));
+ game.appendGUIOptions(getGameGUIOptionsDescriptionLanguage(Common::PT_BRA));
+ game.appendGUIOptions(getGameGUIOptionsDescriptionLanguage(Common::CZ_CZE));
detectedGames.push_back(game);
diff --git a/engines/sword2/sword2.cpp b/engines/sword2/sword2.cpp
index 231074641e..0ec0e3f726 100644
--- a/engines/sword2/sword2.cpp
+++ b/engines/sword2/sword2.cpp
@@ -192,9 +192,8 @@ DetectedGames detectGamesImpl(const Common::FSList &fslist, bool recursion = fal
continue;
// Match found, add to list of candidates, then abort inner loop.
- DetectedGame game;
- game.matchedGame = GameDescriptor(g->gameid, g->description);
- game.matchedGame.setGUIOptions(GUIO2(GUIO_NOMIDI, GUIO_NOASPECT));
+ DetectedGame game = DetectedGame(g->gameid, g->description);
+ game.setGUIOptions(GUIO2(GUIO_NOMIDI, GUIO_NOASPECT));
detectedGames.push_back(game);
break;
@@ -285,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].gameId == gameid) {
*engine = new Sword2::Sword2Engine(syst);
return Common::kNoError;
}