From 8fb149e3c7603f023dfccf2b2056a9a2fda431c2 Mon Sep 17 00:00:00 2001 From: Bastien Bouclet Date: Sun, 6 May 2018 12:57:08 +0200 Subject: ENGINES: Change MetaEngine::findGame to return a plain game descriptor --- engines/advancedDetector.cpp | 6 +++--- engines/advancedDetector.h | 2 +- engines/agos/detection.cpp | 2 +- engines/cine/detection.cpp | 2 +- engines/game.h | 5 ++++- engines/gob/detection/detection.cpp | 4 ++-- engines/metaengine.h | 8 ++++---- engines/obsolete.cpp | 10 +++++----- engines/obsolete.h | 2 +- engines/saga/detection.cpp | 2 +- engines/scumm/detection.cpp | 4 ++-- engines/sky/detection.cpp | 8 ++++---- engines/sword1/detection.cpp | 18 +++++++++--------- engines/sword2/sword2.cpp | 6 +++--- 14 files changed, 41 insertions(+), 38 deletions(-) (limited to 'engines') diff --git a/engines/advancedDetector.cpp b/engines/advancedDetector.cpp index 9c1a700423..43c2082c7d 100644 --- a/engines/advancedDetector.cpp +++ b/engines/advancedDetector.cpp @@ -602,14 +602,14 @@ GameList AdvancedMetaEngine::getSupportedGames() const { return GameList(_gameIds); } -GameDescriptor AdvancedMetaEngine::findGame(const char *gameId) const { +PlainGameDescriptor AdvancedMetaEngine::findGame(const char *gameId) const { // First search the list of supported gameids for a match. const PlainGameDescriptor *g = findPlainGameDescriptor(gameId, _gameIds); if (g) - return GameDescriptor(*g); + return *g; // No match found - return GameDescriptor(); + return PlainGameDescriptor(); } AdvancedMetaEngine::AdvancedMetaEngine(const void *descs, uint descItemSize, const PlainGameDescriptor *gameIds, const ADExtraGuiOptionsMap *extraGuiOptions) diff --git a/engines/advancedDetector.h b/engines/advancedDetector.h index f1f55d0b4b..ec52134c78 100644 --- a/engines/advancedDetector.h +++ b/engines/advancedDetector.h @@ -267,7 +267,7 @@ public: */ virtual GameList getSupportedGames() const; - virtual GameDescriptor findGame(const char *gameId) const; + PlainGameDescriptor findGame(const char *gameId) const override; DetectedGames detectGames(const Common::FSList &fslist) const override; diff --git a/engines/agos/detection.cpp b/engines/agos/detection.cpp index dbc4ee9145..1847434200 100644 --- a/engines/agos/detection.cpp +++ b/engines/agos/detection.cpp @@ -99,7 +99,7 @@ public: _directoryGlobs = directoryGlobs; } - virtual GameDescriptor findGame(const char *gameId) const { + PlainGameDescriptor findGame(const char *gameId) const override { return Engines::findGameID(gameId, _gameIds, obsoleteGameIDsTable); } diff --git a/engines/cine/detection.cpp b/engines/cine/detection.cpp index 6c8b4a676d..f1636c902b 100644 --- a/engines/cine/detection.cpp +++ b/engines/cine/detection.cpp @@ -84,7 +84,7 @@ public: _guiOptions = GUIO2(GUIO_NOSPEECH, GAMEOPTION_ORIGINAL_SAVELOAD); } - virtual GameDescriptor findGame(const char *gameId) const { + PlainGameDescriptor findGame(const char *gameId) const override { return Engines::findGameID(gameId, _gameIds, obsoleteGameIDsTable); } diff --git a/engines/game.h b/engines/game.h index 54c1af3949..88033dcf09 100644 --- a/engines/game.h +++ b/engines/game.h @@ -38,6 +38,9 @@ struct PlainGameDescriptor { const char *gameId; const char *description; + + PlainGameDescriptor() : gameId(nullptr), description(nullptr) {} + PlainGameDescriptor(const char *id, const char *desc) : gameId(id), description(desc) {} }; /** @@ -66,7 +69,7 @@ enum GameSupportLevel { class GameDescriptor : public Common::StringMap { public: GameDescriptor(); - GameDescriptor(const PlainGameDescriptor &pgd, Common::String guioptions = Common::String()); + explicit GameDescriptor(const PlainGameDescriptor &pgd, Common::String guioptions = Common::String()); GameDescriptor(const Common::String &gameid, const Common::String &description, Common::Language language = Common::UNK_LANG, diff --git a/engines/gob/detection/detection.cpp b/engines/gob/detection/detection.cpp index 487b65f4a8..864a701aa6 100644 --- a/engines/gob/detection/detection.cpp +++ b/engines/gob/detection/detection.cpp @@ -33,7 +33,7 @@ class GobMetaEngine : public AdvancedMetaEngine { public: GobMetaEngine(); - virtual GameDescriptor findGame(const char *gameId) const; + PlainGameDescriptor findGame(const char *gameId) const override; ADDetectedGame fallbackDetect(const FileMap &allFiles, const Common::FSList &fslist) const override; @@ -59,7 +59,7 @@ GobMetaEngine::GobMetaEngine() : _guiOptions = GUIO1(GUIO_NOLAUNCHLOAD); } -GameDescriptor GobMetaEngine::findGame(const char *gameId) const { +PlainGameDescriptor GobMetaEngine::findGame(const char *gameId) const { return Engines::findGameID(gameId, _gameIds, obsoleteGameIDsTable); } diff --git a/engines/metaengine.h b/engines/metaengine.h index 9a0280d116..9ce8dc9f11 100644 --- a/engines/metaengine.h +++ b/engines/metaengine.h @@ -71,8 +71,8 @@ public: /** Returns a list of games supported by this engine. */ virtual GameList getSupportedGames() const = 0; - /** Query the engine for a GameDescriptor for the specified gameid, if any. */ - virtual GameDescriptor findGame(const char *gameid) const = 0; + /** Query the engine for a PlainGameDescriptor for the specified gameid, if any. */ + virtual PlainGameDescriptor findGame(const char *gameId) const = 0; /** * Runs the engine's game detector on the given list of files, and returns a @@ -267,8 +267,8 @@ public: */ class EngineManager : public Common::Singleton { public: - GameDescriptor findGameInLoadedPlugins(const Common::String &gameName, const Plugin **plugin = NULL) const; - GameDescriptor findGame(const Common::String &gameName, const Plugin **plugin = NULL) const; + PlainGameDescriptor findGameInLoadedPlugins(const Common::String &gameName, const Plugin **plugin = NULL) const; + PlainGameDescriptor findGame(const Common::String &gameName, const Plugin **plugin = NULL) const; DetectionResults detectGames(const Common::FSList &fslist) const; const PluginList &getPlugins() const; }; diff --git a/engines/obsolete.cpp b/engines/obsolete.cpp index d65fb13ec1..48809df712 100644 --- a/engines/obsolete.cpp +++ b/engines/obsolete.cpp @@ -55,7 +55,7 @@ void upgradeTargetIfNecessary(const ObsoleteGameID *obsoleteList) { } } -GameDescriptor findGameID( +PlainGameDescriptor findGameID( const char *gameid, const PlainGameDescriptor *gameids, const ObsoleteGameID *obsoleteList @@ -63,7 +63,7 @@ GameDescriptor findGameID( // First search the list of supported gameids for a match. const PlainGameDescriptor *g = findPlainGameDescriptor(gameid, gameids); if (g) - return GameDescriptor(*g); + return *g; // If we didn't find the gameid in the main list, check if it // is an obsolete game id. @@ -73,16 +73,16 @@ GameDescriptor findGameID( if (0 == scumm_stricmp(gameid, o->from)) { g = findPlainGameDescriptor(o->to, gameids); if (g && g->description) - return GameDescriptor(gameid, "Obsolete game ID (" + Common::String(g->description) + ")"); + return PlainGameDescriptor(gameid, g->description); else - return GameDescriptor(gameid, "Obsolete game ID"); + return PlainGameDescriptor(gameid, "Obsolete game ID"); } o++; } } // No match found - return GameDescriptor(); + return PlainGameDescriptor(); } } // End of namespace Engines diff --git a/engines/obsolete.h b/engines/obsolete.h index be0963a7dc..7c7249e52b 100644 --- a/engines/obsolete.h +++ b/engines/obsolete.h @@ -66,7 +66,7 @@ void upgradeTargetIfNecessary(const ObsoleteGameID *obsoleteList); * Optionally can take a list of obsolete game ids into account in order * to support obsolete gameids. */ -GameDescriptor findGameID( +PlainGameDescriptor findGameID( const char *gameid, const PlainGameDescriptor *gameids, const ObsoleteGameID *obsoleteList = 0 diff --git a/engines/saga/detection.cpp b/engines/saga/detection.cpp index fcd78502d9..82c29d3389 100644 --- a/engines/saga/detection.cpp +++ b/engines/saga/detection.cpp @@ -105,7 +105,7 @@ public: _singleId = "saga"; } - virtual GameDescriptor findGame(const char *gameId) const { + PlainGameDescriptor findGame(const char *gameId) const override { return Engines::findGameID(gameId, _gameIds, obsoleteGameIDsTable); } diff --git a/engines/scumm/detection.cpp b/engines/scumm/detection.cpp index 078cc8de27..2ba5bd3f74 100644 --- a/engines/scumm/detection.cpp +++ b/engines/scumm/detection.cpp @@ -960,7 +960,7 @@ public: virtual bool hasFeature(MetaEngineFeature f) const; virtual GameList getSupportedGames() const; - virtual GameDescriptor findGame(const char *gameid) const; + PlainGameDescriptor findGame(const char *gameid) const override; virtual DetectedGames detectGames(const Common::FSList &fslist) const override; virtual Common::Error createInstance(OSystem *syst, Engine **engine) const; @@ -996,7 +996,7 @@ GameList ScummMetaEngine::getSupportedGames() const { return GameList(gameDescriptions); } -GameDescriptor ScummMetaEngine::findGame(const char *gameid) const { +PlainGameDescriptor ScummMetaEngine::findGame(const char *gameid) const { return Engines::findGameID(gameid, gameDescriptions, obsoleteGameIDsTable); } diff --git a/engines/sky/detection.cpp b/engines/sky/detection.cpp index cc1f1adc82..629996bae1 100644 --- a/engines/sky/detection.cpp +++ b/engines/sky/detection.cpp @@ -78,7 +78,7 @@ public: virtual bool hasFeature(MetaEngineFeature f) const; virtual GameList getSupportedGames() const; virtual const ExtraGuiOptions getExtraGuiOptions(const Common::String &target) const; - virtual GameDescriptor findGame(const char *gameid) const; + PlainGameDescriptor findGame(const char *gameid) const override; DetectedGames detectGames(const Common::FSList &fslist) const override; virtual Common::Error createInstance(OSystem *syst, Engine **engine) const; @@ -112,7 +112,7 @@ bool Sky::SkyEngine::hasFeature(EngineFeature f) const { GameList SkyMetaEngine::getSupportedGames() const { GameList games; - games.push_back(skySetting); + games.push_back(GameDescriptor(skySetting)); return games; } @@ -135,10 +135,10 @@ const ExtraGuiOptions SkyMetaEngine::getExtraGuiOptions(const Common::String &ta return options; } -GameDescriptor SkyMetaEngine::findGame(const char *gameid) const { +PlainGameDescriptor SkyMetaEngine::findGame(const char *gameid) const { if (0 == scumm_stricmp(gameid, skySetting.gameId)) return skySetting; - return GameDescriptor(); + return PlainGameDescriptor(); } DetectedGames SkyMetaEngine::detectGames(const Common::FSList &fslist) const { diff --git a/engines/sword1/detection.cpp b/engines/sword1/detection.cpp index 7fb86fec0b..62e8f1c905 100644 --- a/engines/sword1/detection.cpp +++ b/engines/sword1/detection.cpp @@ -88,7 +88,7 @@ public: virtual bool hasFeature(MetaEngineFeature f) const; virtual GameList getSupportedGames() const; - virtual GameDescriptor findGame(const char *gameid) const; + PlainGameDescriptor findGame(const char *gameId) const override; DetectedGames detectGames(const Common::FSList &fslist) const override; virtual SaveStateList listSaves(const char *target) const; virtual int getMaximumSaveSlot() const; @@ -127,20 +127,20 @@ GameList SwordMetaEngine::getSupportedGames() const { return games; } -GameDescriptor SwordMetaEngine::findGame(const char *gameid) const { - if (0 == scumm_stricmp(gameid, sword1FullSettings.gameId)) +PlainGameDescriptor SwordMetaEngine::findGame(const char *gameId) const { + if (0 == scumm_stricmp(gameId, sword1FullSettings.gameId)) return sword1FullSettings; - if (0 == scumm_stricmp(gameid, sword1DemoSettings.gameId)) + if (0 == scumm_stricmp(gameId, sword1DemoSettings.gameId)) return sword1DemoSettings; - if (0 == scumm_stricmp(gameid, sword1MacFullSettings.gameId)) + if (0 == scumm_stricmp(gameId, sword1MacFullSettings.gameId)) return sword1MacFullSettings; - if (0 == scumm_stricmp(gameid, sword1MacDemoSettings.gameId)) + if (0 == scumm_stricmp(gameId, sword1MacDemoSettings.gameId)) return sword1MacDemoSettings; - if (0 == scumm_stricmp(gameid, sword1PSXSettings.gameId)) + if (0 == scumm_stricmp(gameId, sword1PSXSettings.gameId)) return sword1PSXSettings; - if (0 == scumm_stricmp(gameid, sword1PSXDemoSettings.gameId)) + if (0 == scumm_stricmp(gameId, sword1PSXDemoSettings.gameId)) return sword1PSXDemoSettings; - return GameDescriptor(); + return PlainGameDescriptor(); } void Sword1CheckDirectory(const Common::FSList &fslist, bool *filesFound, bool recursion = false) { diff --git a/engines/sword2/sword2.cpp b/engines/sword2/sword2.cpp index 27fcc74ad5..bf2f329119 100644 --- a/engines/sword2/sword2.cpp +++ b/engines/sword2/sword2.cpp @@ -94,7 +94,7 @@ public: virtual bool hasFeature(MetaEngineFeature f) const; virtual GameList getSupportedGames() const; virtual const ExtraGuiOptions getExtraGuiOptions(const Common::String &target) const; - virtual GameDescriptor findGame(const char *gameid) const; + PlainGameDescriptor findGame(const char *gameid) const override; virtual DetectedGames detectGames(const Common::FSList &fslist) const; virtual SaveStateList listSaves(const char *target) const; virtual int getMaximumSaveSlot() const; @@ -135,14 +135,14 @@ const ExtraGuiOptions Sword2MetaEngine::getExtraGuiOptions(const Common::String return options; } -GameDescriptor Sword2MetaEngine::findGame(const char *gameid) const { +PlainGameDescriptor Sword2MetaEngine::findGame(const char *gameid) const { const Sword2::GameSettings *g = Sword2::sword2_settings; while (g->gameid) { if (0 == scumm_stricmp(gameid, g->gameid)) break; g++; } - return GameDescriptor(g->gameid, g->description); + return PlainGameDescriptor(g->gameid, g->description); } bool isFullGame(const Common::FSList &fslist) { -- cgit v1.2.3