diff options
-rw-r--r-- | engines/glk/alan2/detection.cpp | 10 | ||||
-rw-r--r-- | engines/glk/alan2/detection.h | 18 | ||||
-rw-r--r-- | engines/glk/alan2/detection_tables.h | 3 | ||||
-rw-r--r-- | engines/glk/detection.cpp | 28 | ||||
-rw-r--r-- | engines/glk/detection.h | 33 | ||||
-rw-r--r-- | engines/glk/frotz/detection.cpp | 8 | ||||
-rw-r--r-- | engines/glk/frotz/detection.h | 4 | ||||
-rw-r--r-- | engines/glk/glulxe/detection.cpp | 10 | ||||
-rw-r--r-- | engines/glk/glulxe/detection.h | 18 | ||||
-rw-r--r-- | engines/glk/glulxe/detection_tables.h | 2 | ||||
-rw-r--r-- | engines/glk/scott/detection.cpp | 4 | ||||
-rw-r--r-- | engines/glk/scott/detection.h | 3 | ||||
-rw-r--r-- | engines/glk/tads/detection.cpp | 22 | ||||
-rw-r--r-- | engines/glk/tads/detection.h | 19 | ||||
-rw-r--r-- | engines/glk/tads/detection_tables.h | 10 |
15 files changed, 91 insertions, 101 deletions
diff --git a/engines/glk/alan2/detection.cpp b/engines/glk/alan2/detection.cpp index 175c3d61fc..fab511772b 100644 --- a/engines/glk/alan2/detection.cpp +++ b/engines/glk/alan2/detection.cpp @@ -31,18 +31,18 @@ namespace Glk { namespace Alan2 { void Alan2MetaEngine::getSupportedGames(PlainGameList &games) { - for (const Alan2Descriptor *pd = ALAN2_GAME_LIST; pd->gameId; ++pd) { + for (const PlainGameDescriptor *pd = ALAN2_GAME_LIST; pd->gameId; ++pd) { games.push_back(*pd); } } -Alan2Descriptor Alan2MetaEngine::findGame(const char *gameId) { - for (const Alan2Descriptor *pd = ALAN2_GAME_LIST; pd->gameId; ++pd) { +GameDescriptor Alan2MetaEngine::findGame(const char *gameId) { + for (const PlainGameDescriptor *pd = ALAN2_GAME_LIST; pd->gameId; ++pd) { if (!strcmp(gameId, pd->gameId)) return *pd; } - return Alan2Descriptor(); + return GameDescriptor::empty(); } bool Alan2MetaEngine::detectGames(const Common::FSList &fslist, DetectedGames &gameList) { @@ -107,7 +107,7 @@ bool Alan2MetaEngine::detectGames(const Common::FSList &fslist, DetectedGames &g } void Alan2MetaEngine::detectClashes(Common::StringMap &map) { - for (const Alan2Descriptor *pd = ALAN2_GAME_LIST; pd->gameId; ++pd) { + for (const PlainGameDescriptor *pd = ALAN2_GAME_LIST; pd->gameId; ++pd) { if (map.contains(pd->gameId)) error("Duplicate game Id found - %s", pd->gameId); map[pd->gameId] = ""; diff --git a/engines/glk/alan2/detection.h b/engines/glk/alan2/detection.h index b3fa3bd473..b5587095d0 100644 --- a/engines/glk/alan2/detection.h +++ b/engines/glk/alan2/detection.h @@ -26,26 +26,12 @@ #include "common/fs.h" #include "common/hash-str.h" #include "engines/game.h" +#include "glk/detection.h" namespace Glk { namespace Alan2 { /** - * Alan2 game descriptior - */ -struct Alan2Descriptor { - const char *gameId; - const char *description; - - operator PlainGameDescriptor() const { - PlainGameDescriptor pd; - pd.gameId = gameId; - pd.description = description; - return pd; - } -}; - -/** * Meta engine for Alan2 interpreter */ class Alan2MetaEngine { @@ -58,7 +44,7 @@ public: /** * Returns a game description for the given game Id, if it's supported */ - static Alan2Descriptor findGame(const char *gameId); + static GameDescriptor findGame(const char *gameId); /** * Detect supported games diff --git a/engines/glk/alan2/detection_tables.h b/engines/glk/alan2/detection_tables.h index 2a09a02ed0..c6426520d8 100644 --- a/engines/glk/alan2/detection_tables.h +++ b/engines/glk/alan2/detection_tables.h @@ -38,9 +38,8 @@ struct Alan2GameDescription { Common::Language _language; }; -const Alan2Descriptor ALAN2_GAME_LIST[] = { +const PlainGameDescriptor ALAN2_GAME_LIST[] = { { "alan2", "Alan2 Game" }, - //{ "cragne", "Cragne Manor" }, { nullptr, nullptr } }; diff --git a/engines/glk/detection.cpp b/engines/glk/detection.cpp index 93bffeb852..a1786d047c 100644 --- a/engines/glk/detection.cpp +++ b/engines/glk/detection.cpp @@ -64,7 +64,7 @@ bool Glk::GlkEngine::hasFeature(EngineFeature f) const { } Common::Error GlkMetaEngine::createInstance(OSystem *syst, Engine **engine) const { - Glk::TADS::TADSDescriptor td; + Glk::GameDescriptor td = Glk::GameDescriptor::empty(); assert(engine); // Populate the game description @@ -96,16 +96,16 @@ Common::Error GlkMetaEngine::createInstance(OSystem *syst, Engine **engine) cons f.close(); // Create the correct engine - if (Glk::Alan2::Alan2MetaEngine::findGame(gameDesc._gameId.c_str()).description) { + if (Glk::Alan2::Alan2MetaEngine::findGame(gameDesc._gameId.c_str())._description) { *engine = new Glk::Alan2::Alan2(syst, gameDesc); - } else if (Glk::Frotz::FrotzMetaEngine::findGame(gameDesc._gameId.c_str()).description) { + } else if (Glk::Frotz::FrotzMetaEngine::findGame(gameDesc._gameId.c_str())._description) { *engine = new Glk::Frotz::Frotz(syst, gameDesc); - } else if (Glk::Glulxe::GlulxeMetaEngine::findGame(gameDesc._gameId.c_str()).description) { + } else if (Glk::Glulxe::GlulxeMetaEngine::findGame(gameDesc._gameId.c_str())._description) { *engine = new Glk::Glulxe::Glulxe(syst, gameDesc); - } else if (Glk::Scott::ScottMetaEngine::findGame(gameDesc._gameId.c_str()).description) { + } else if (Glk::Scott::ScottMetaEngine::findGame(gameDesc._gameId.c_str())._description) { *engine = new Glk::Scott::Scott(syst, gameDesc); - } else if ((td = Glk::TADS::TADSMetaEngine::findGame(gameDesc._gameId.c_str())).description) { - if (td.isTADS3) + } else if ((td = Glk::TADS::TADSMetaEngine::findGame(gameDesc._gameId.c_str()))._description) { + if (td._options & Glk::TADS::OPTION_TADS3) *engine = new Glk::TADS::TADS3::TADS3(syst, gameDesc); else *engine = new Glk::TADS::TADS2::TADS2(syst, gameDesc); @@ -150,22 +150,20 @@ PlainGameList GlkMetaEngine::getSupportedGames() const { } PlainGameDescriptor GlkMetaEngine::findGame(const char *gameId) const { - PlainGameDescriptor gd; - - gd = Glk::Alan2::Alan2MetaEngine::findGame(gameId); - if (gd.description) return gd; + Glk::GameDescriptor gd = Glk::Alan2::Alan2MetaEngine::findGame(gameId); + if (gd._description) return gd; gd = Glk::Frotz::FrotzMetaEngine::findGame(gameId); - if (gd.description) return gd; + if (gd._description) return gd; gd = Glk::Glulxe::GlulxeMetaEngine::findGame(gameId); - if (gd.description) return gd; + if (gd._description) return gd; gd = Glk::Scott::ScottMetaEngine::findGame(gameId); - if (gd.description) return gd; + if (gd._description) return gd; gd = Glk::TADS::TADSMetaEngine::findGame(gameId); - if (gd.description) return gd; + if (gd._description) return gd; return PlainGameDescriptor(); } diff --git a/engines/glk/detection.h b/engines/glk/detection.h index e54f744aa3..0b21985349 100644 --- a/engines/glk/detection.h +++ b/engines/glk/detection.h @@ -24,9 +24,13 @@ #define GLK_DETECTION_H #include "engines/advancedDetector.h" +#include "engines/game.h" #define MAX_SAVES 99 +/** + * ScummVM Meta Engine interface + */ class GlkMetaEngine : public MetaEngine { private: Common::String findFileByGameId(const Common::String &gameId) const; @@ -71,4 +75,33 @@ public: void detectClashes() const; }; +namespace Glk { + +/** + * Holds the name of a recognised game + */ +struct GameDescriptor { + const char *_gameId; + const char *_description; + uint _options; + + GameDescriptor(const char *gameId, const char *description, uint options) : + _gameId(gameId), _description(description), _options(options) {} + GameDescriptor(const PlainGameDescriptor &gd) : _gameId(gd.gameId), _description(gd.description), + _options(0) {} + + static PlainGameDescriptor empty() { + return GameDescriptor(nullptr, nullptr, 0); + } + + operator PlainGameDescriptor() const { + PlainGameDescriptor pd; + pd.gameId = _gameId; + pd.description = _description; + return pd; + } +}; + +} // End of namespace Glk + #endif diff --git a/engines/glk/frotz/detection.cpp b/engines/glk/frotz/detection.cpp index 97d7084a8c..57e2961fd7 100644 --- a/engines/glk/frotz/detection.cpp +++ b/engines/glk/frotz/detection.cpp @@ -39,7 +39,7 @@ void FrotzMetaEngine::getSupportedGames(PlainGameList &games) { games.push_back(*pd); } -PlainGameDescriptor FrotzMetaEngine::findGame(const char *gameId) { +GameDescriptor FrotzMetaEngine::findGame(const char *gameId) { for (const PlainGameDescriptor *pd = INFOCOM_GAME_LIST; pd->gameId; ++pd) { if (!strcmp(gameId, pd->gameId)) return *pd; @@ -49,7 +49,7 @@ PlainGameDescriptor FrotzMetaEngine::findGame(const char *gameId) { return *pd; } - return PlainGameDescriptor();; + return GameDescriptor::empty(); } bool FrotzMetaEngine::detectGames(const Common::FSList &fslist, DetectedGames &gameList) { @@ -129,8 +129,8 @@ bool FrotzMetaEngine::detectGames(const Common::FSList &fslist, DetectedGames &g const PlainGameDescriptor &desc = ZCODE_GAME_LIST[0]; gd = DetectedGame(desc.gameId, desc.description, Common::UNK_LANG, Common::kPlatformUnknown); } else { - PlainGameDescriptor gameDesc = findGame(p->_gameId); - gd = DetectedGame(p->_gameId, gameDesc.description, p->_language, Common::kPlatformUnknown, p->_extra); + GameDescriptor gameDesc = findGame(p->_gameId); + gd = DetectedGame(p->_gameId, gameDesc._description, p->_language, Common::kPlatformUnknown, p->_extra); gd.setGUIOptions(p->_guiOptions); } diff --git a/engines/glk/frotz/detection.h b/engines/glk/frotz/detection.h index 6cc72aed38..e0163bc9f7 100644 --- a/engines/glk/frotz/detection.h +++ b/engines/glk/frotz/detection.h @@ -27,6 +27,7 @@ #include "common/hash-str.h" #include "engines/game.h" #include "glk/streams.h" +#include "glk/detection.h" namespace Glk { namespace Frotz { @@ -38,11 +39,10 @@ public: */ static void getSupportedGames(PlainGameList &games); - /** * Returns a game description for the given game Id, if it's supported */ - static PlainGameDescriptor findGame(const char *gameId); + static GameDescriptor findGame(const char *gameId); /** * Detect supported games diff --git a/engines/glk/glulxe/detection.cpp b/engines/glk/glulxe/detection.cpp index 09b6e97d0b..06ce40362d 100644 --- a/engines/glk/glulxe/detection.cpp +++ b/engines/glk/glulxe/detection.cpp @@ -31,18 +31,18 @@ namespace Glk { namespace Glulxe { void GlulxeMetaEngine::getSupportedGames(PlainGameList &games) { - for (const GlulxeDescriptor *pd = GLULXE_GAME_LIST; pd->gameId; ++pd) { + for (const PlainGameDescriptor *pd = GLULXE_GAME_LIST; pd->gameId; ++pd) { games.push_back(*pd); } } -GlulxeDescriptor GlulxeMetaEngine::findGame(const char *gameId) { - for (const GlulxeDescriptor *pd = GLULXE_GAME_LIST; pd->gameId; ++pd) { +GameDescriptor GlulxeMetaEngine::findGame(const char *gameId) { + for (const PlainGameDescriptor *pd = GLULXE_GAME_LIST; pd->gameId; ++pd) { if (!strcmp(gameId, pd->gameId)) return *pd; } - return GlulxeDescriptor(); + return GameDescriptor::empty(); } bool GlulxeMetaEngine::detectGames(const Common::FSList &fslist, DetectedGames &gameList) { @@ -107,7 +107,7 @@ bool GlulxeMetaEngine::detectGames(const Common::FSList &fslist, DetectedGames & } void GlulxeMetaEngine::detectClashes(Common::StringMap &map) { - for (const GlulxeDescriptor *pd = GLULXE_GAME_LIST; pd->gameId; ++pd) { + for (const PlainGameDescriptor *pd = GLULXE_GAME_LIST; pd->gameId; ++pd) { if (map.contains(pd->gameId)) error("Duplicate game Id found - %s", pd->gameId); map[pd->gameId] = ""; diff --git a/engines/glk/glulxe/detection.h b/engines/glk/glulxe/detection.h index 654977a0b2..9c38354f98 100644 --- a/engines/glk/glulxe/detection.h +++ b/engines/glk/glulxe/detection.h @@ -26,26 +26,12 @@ #include "common/fs.h" #include "common/hash-str.h" #include "engines/game.h" +#include "glk/detection.h" namespace Glk { namespace Glulxe { /** - * Glulxe game descriptior - */ -struct GlulxeDescriptor { - const char *gameId; - const char *description; - - operator PlainGameDescriptor() const { - PlainGameDescriptor pd; - pd.gameId = gameId; - pd.description = description; - return pd; - } -}; - -/** * Meta engine for Glulxe interpreter */ class GlulxeMetaEngine { @@ -58,7 +44,7 @@ public: /** * Returns a game description for the given game Id, if it's supported */ - static GlulxeDescriptor findGame(const char *gameId); + static GameDescriptor findGame(const char *gameId); /** * Detect supported games diff --git a/engines/glk/glulxe/detection_tables.h b/engines/glk/glulxe/detection_tables.h index 17c5ffd55b..cdbe228bce 100644 --- a/engines/glk/glulxe/detection_tables.h +++ b/engines/glk/glulxe/detection_tables.h @@ -38,7 +38,7 @@ struct GlulxeGameDescription { Common::Language _language; }; -const GlulxeDescriptor GLULXE_GAME_LIST[] = { +const PlainGameDescriptor GLULXE_GAME_LIST[] = { { "glulxe", "Glulxe Game" }, { "cragne", "Cragne Manor" }, diff --git a/engines/glk/scott/detection.cpp b/engines/glk/scott/detection.cpp index c41825140c..f1c4b9aa69 100644 --- a/engines/glk/scott/detection.cpp +++ b/engines/glk/scott/detection.cpp @@ -34,13 +34,13 @@ void ScottMetaEngine::getSupportedGames(PlainGameList &games) { games.push_back(*pd); } -PlainGameDescriptor ScottMetaEngine::findGame(const char *gameId) { +GameDescriptor ScottMetaEngine::findGame(const char *gameId) { for (const PlainGameDescriptor *pd = SCOTT_GAME_LIST; pd->gameId; ++pd) { if (!strcmp(gameId, pd->gameId)) return *pd; } - return PlainGameDescriptor();; + return GameDescriptor::empty(); } bool ScottMetaEngine::detectGames(const Common::FSList &fslist, DetectedGames &gameList) { diff --git a/engines/glk/scott/detection.h b/engines/glk/scott/detection.h index 709b7de1d9..b483e1a924 100644 --- a/engines/glk/scott/detection.h +++ b/engines/glk/scott/detection.h @@ -26,6 +26,7 @@ #include "common/fs.h" #include "common/hash-str.h" #include "engines/game.h" +#include "glk/detection.h" namespace Glk { namespace Scott { @@ -40,7 +41,7 @@ public: /** * Returns a game description for the given game Id, if it's supported */ - static PlainGameDescriptor findGame(const char *gameId); + static GameDescriptor findGame(const char *gameId); /** * Detect supported games diff --git a/engines/glk/tads/detection.cpp b/engines/glk/tads/detection.cpp index 95f7330d65..9206193f63 100644 --- a/engines/glk/tads/detection.cpp +++ b/engines/glk/tads/detection.cpp @@ -31,18 +31,18 @@ namespace Glk { namespace TADS { void TADSMetaEngine::getSupportedGames(PlainGameList &games) { - for (const TADSDescriptor *pd = TADS_GAME_LIST; pd->gameId; ++pd) { + for (const GameDescriptor *pd = TADS_GAME_LIST; pd->_gameId; ++pd) { games.push_back(*pd); } } -TADSDescriptor TADSMetaEngine::findGame(const char *gameId) { - for (const TADSDescriptor *pd = TADS_GAME_LIST; pd->gameId; ++pd) { - if (!strcmp(gameId, pd->gameId)) +GameDescriptor TADSMetaEngine::findGame(const char *gameId) { + for (const GameDescriptor *pd = TADS_GAME_LIST; pd->_gameId; ++pd) { + if (!strcmp(gameId, pd->_gameId)) return *pd; } - return TADSDescriptor();; + return GameDescriptor::empty(); } bool TADSMetaEngine::detectGames(const Common::FSList &fslist, DetectedGames &gameList) { @@ -81,8 +81,8 @@ bool TADSMetaEngine::detectGames(const Common::FSList &fslist, DetectedGames &ga debug("ENTRY0(\"%s\", \"%s\", %u),", fname.c_str(), md5.c_str(), (uint)filesize); } - const TADSDescriptor &desc = TADS_GAME_LIST[0]; - gd = DetectedGame(desc.gameId, desc.description, Common::UNK_LANG, Common::kPlatformUnknown); + const GameDescriptor &desc = TADS_GAME_LIST[0]; + gd = DetectedGame(desc._gameId, desc._description, Common::UNK_LANG, Common::kPlatformUnknown); } else { PlainGameDescriptor gameDesc = findGame(p->_gameId); @@ -97,10 +97,10 @@ bool TADSMetaEngine::detectGames(const Common::FSList &fslist, DetectedGames &ga } void TADSMetaEngine::detectClashes(Common::StringMap &map) { - for (const TADSDescriptor *pd = TADS_GAME_LIST; pd->gameId; ++pd) { - if (map.contains(pd->gameId)) - error("Duplicate game Id found - %s", pd->gameId); - map[pd->gameId] = ""; + for (const GameDescriptor *pd = TADS_GAME_LIST; pd->_gameId; ++pd) { + if (map.contains(pd->_gameId)) + error("Duplicate game Id found - %s", pd->_gameId); + map[pd->_gameId] = ""; } } diff --git a/engines/glk/tads/detection.h b/engines/glk/tads/detection.h index f876cb2cf2..0ed1e94214 100644 --- a/engines/glk/tads/detection.h +++ b/engines/glk/tads/detection.h @@ -25,25 +25,12 @@ #include "common/fs.h" #include "engines/game.h" +#include "glk/detection.h" namespace Glk { namespace TADS { -/** - * TADS game descriptior - */ -struct TADSDescriptor { - const char *gameId; - const char *description; - bool isTADS3; - - operator PlainGameDescriptor() const { - PlainGameDescriptor pd; - pd.gameId = gameId; - pd.description = description; - return pd; - } -}; +enum TADSOption { OPTION_TADS2 = 0, OPTION_TADS3 = 1 }; /** * Meta engine for TADS interpreter @@ -58,7 +45,7 @@ public: /** * Returns a game description for the given game Id, if it's supported */ - static TADSDescriptor findGame(const char *gameId); + static GameDescriptor findGame(const char *gameId); /** * Detect supported games diff --git a/engines/glk/tads/detection_tables.h b/engines/glk/tads/detection_tables.h index d4d570920b..322c9dbb91 100644 --- a/engines/glk/tads/detection_tables.h +++ b/engines/glk/tads/detection_tables.h @@ -38,14 +38,14 @@ struct TADSGameDescription { Common::Language _language; }; -const TADSDescriptor TADS_GAME_LIST[] = { +const GameDescriptor TADS_GAME_LIST[] = { // TADS 2 Games - { "tads2", "TADS 2 Game", false }, - { "oncefuture", "Once and Future", false }, + { "tads2", "TADS 2 Game", OPTION_TADS2 }, + { "oncefuture", "Once and Future", OPTION_TADS2 }, // TADS 3 Games - { "tads3", "TADS 3 Game", true }, - { nullptr, nullptr, false } + { "tads3", "TADS 3 Game", OPTION_TADS3 }, + { nullptr, nullptr, 0 } }; #define ENTRY0(ID, MD5, FILESIZE) { ID, "", MD5, FILESIZE, Common::EN_ANY } |