From 5f5ac6b475599da5c11df98852f1dbd1e62db8b5 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 7 May 2019 15:27:14 +1000 Subject: GLK: MAGNETIC: Hook up Magnetic sub-engine --- engines/glk/magnetic/detection.cpp | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) (limited to 'engines/glk/magnetic/detection.cpp') diff --git a/engines/glk/magnetic/detection.cpp b/engines/glk/magnetic/detection.cpp index cfd0102895..db899a28be 100644 --- a/engines/glk/magnetic/detection.cpp +++ b/engines/glk/magnetic/detection.cpp @@ -31,22 +31,22 @@ namespace Glk { namespace Magnetic { void MagneticMetaEngine::getSupportedGames(PlainGameList &games) { - for (const MagneticDescriptor *pd = MAGNETIC_GAME_LIST; pd->gameId; ++pd) { + for (const PlainGameDescriptor *pd = MAGNETIC_GAME_LIST; pd->gameId; ++pd) { games.push_back(*pd); } } -MagneticDescriptor MagneticMetaEngine::findGame(const char *gameId) { - for (const MagneticDescriptor *pd = MAGNETIC_GAME_LIST; pd->gameId; ++pd) { +GameDescriptor MagneticMetaEngine::findGame(const char *gameId) { + for (const PlainGameDescriptor *pd = MAGNETIC_GAME_LIST; pd->gameId; ++pd) { if (!strcmp(gameId, pd->gameId)) return *pd; } - return MagneticDescriptor(); + return PlainGameDescriptor(); } bool MagneticMetaEngine::detectGames(const Common::FSList &fslist, DetectedGames &gameList) { - const char *const EXTENSIONS[] = { ".magnetic", nullptr }; + const char *const EXTENSIONS[] = { ".rsc", nullptr }; // Loop through the files of the folder for (Common::FSList::const_iterator file = fslist.begin(); file != fslist.end(); ++file) { @@ -64,6 +64,12 @@ bool MagneticMetaEngine::detectGames(const Common::FSList &fslist, DetectedGames Common::File gameFile; if (!gameFile.open(*file)) continue; + if (gameFile.readUint32BE() != MKTAG('M', 'a', 'S', 'c')) { + gameFile.close(); + continue; + } + + gameFile.seek(0); Common::String md5 = Common::computeStreamMD5AsString(gameFile, 5000); size_t filesize = gameFile.size(); gameFile.close(); @@ -76,18 +82,10 @@ bool MagneticMetaEngine::detectGames(const Common::FSList &fslist, DetectedGames DetectedGame gd; if (!p->_gameId) { if (gDebugLevel > 0) { - // Print an entry suitable for putting into the detection_tables.h, using the - // name of the parent folder the game is in as the presumed game Id - Common::String folderName = file->getParent().getName(); - if (folderName.hasSuffix("\\")) - folderName.deleteLastChar(); - Common::String fname = filename; - const char *dot = strchr(fname.c_str(), '.'); - if (dot) - fname = Common::String(fname.c_str(), dot); - - debug("ENTRY0(\"%s\", \"%s\", %u),", fname.c_str(), md5.c_str(), (uint)filesize); + // Print an entry suitable for putting into the detection_tables.h + debug("ENTRY0(\"%s\", \"%s\", %u),", filename.c_str(), md5.c_str(), (uint)filesize); } + const PlainGameDescriptor &desc = MAGNETIC_GAME_LIST[0]; gd = DetectedGame(desc.gameId, desc.description, Common::UNK_LANG, Common::kPlatformUnknown); } else { @@ -104,7 +102,7 @@ bool MagneticMetaEngine::detectGames(const Common::FSList &fslist, DetectedGames } void MagneticMetaEngine::detectClashes(Common::StringMap &map) { - for (const MagneticDescriptor *pd = MAGNETIC_GAME_LIST; pd->gameId; ++pd) { + for (const PlainGameDescriptor *pd = MAGNETIC_GAME_LIST; pd->gameId; ++pd) { if (map.contains(pd->gameId)) error("Duplicate game Id found - %s", pd->gameId); map[pd->gameId] = ""; -- cgit v1.2.3