diff options
author | Paul Gilbert | 2018-11-27 21:24:40 -0800 |
---|---|---|
committer | Paul Gilbert | 2018-12-08 19:05:59 -0800 |
commit | 75f4d34070a874437f6f339bac590f99d4b28f65 (patch) | |
tree | 3d451bd343a6f22feb3cecd097bfa43eced14900 /engines/glk/tads/detection.cpp | |
parent | 09b682cb63fed029f43133f4a2d9daa3438ac8e2 (diff) | |
download | scummvm-rg350-75f4d34070a874437f6f339bac590f99d4b28f65.tar.gz scummvm-rg350-75f4d34070a874437f6f339bac590f99d4b28f65.tar.bz2 scummvm-rg350-75f4d34070a874437f6f339bac590f99d4b28f65.zip |
GLK: TADS: Add first detection entry, further fallback detection
Diffstat (limited to 'engines/glk/tads/detection.cpp')
-rw-r--r-- | engines/glk/tads/detection.cpp | 57 |
1 files changed, 38 insertions, 19 deletions
diff --git a/engines/glk/tads/detection.cpp b/engines/glk/tads/detection.cpp index 6627b8f53b..5f0bfea00e 100644 --- a/engines/glk/tads/detection.cpp +++ b/engines/glk/tads/detection.cpp @@ -22,6 +22,7 @@ #include "glk/tads/detection.h" #include "glk/tads/detection_tables.h" +#include "common/debug.h" #include "common/file.h" #include "common/md5.h" #include "engines/game.h" @@ -45,34 +46,52 @@ TADSDescriptor TADSMetaEngine::findGame(const char *gameId) { } bool TADSMetaEngine::detectGames(const Common::FSList &fslist, DetectedGames &gameList) { - Common::File gameFile; - Common::String md5; - // Loop through the files of the folder for (Common::FSList::const_iterator file = fslist.begin(); file != fslist.end(); ++file) { - if (file->isDirectory() || !(file->getName().hasSuffixIgnoreCase(".gam") - || file->getName().hasSuffixIgnoreCase(".t3"))) + // Check for a recognised filename + Common::String filename = file->getName(); + if (file->isDirectory() || !(filename.hasSuffixIgnoreCase(".gam") + || filename.hasSuffixIgnoreCase(".blorb"))) continue; - if (gameFile.open(*file)) { - md5 = Common::computeStreamMD5AsString(gameFile, 5000); + // Open up the file and calculate the md5 + Common::File gameFile; + if (!gameFile.open(*file)) + continue; + Common::String md5 = Common::computeStreamMD5AsString(gameFile, 5000); + size_t filesize = gameFile.size(); + gameFile.close(); - // Scan through the TADS game list for a match - const TADSGame *p = TADS_GAMES; - while (p->_md5 && p->_filesize != gameFile.size() && md5 != p->_md5) - ++p; + // Check for known games + const TADSGameDescription *p = TADS_GAMES; + while (p->_gameId && p->_md5 && (md5 != p->_md5 || filesize != p->_filesize)) + ++p; - if (p->_filesize) { - // Found a match - TADSDescriptor gameDesc = findGame(p->_gameId); - DetectedGame gd(p->_gameId, gameDesc.description, Common::EN_ANY, Common::kPlatformUnknown); - gd.addExtraEntry("filename", file->getName()); + DetectedGame gd; + if (!p->_gameId) { + if (!filename.hasSuffixIgnoreCase(".gam")) + continue; - gameList.push_back(gd); - } + if (gDebugLevel > 0) { + // Print an entry suitable for putting into the detection_tables.h, using the + Common::String fname = filename; + const char *dot = strchr(fname.c_str(), '.'); + if (dot) + fname = Common::String(fname.c_str(), dot); - gameFile.close(); + debug("ENTRY0(\"%s\", \"%s\", %lu),", + fname.c_str(), md5.c_str(), filesize); + } + const TADSDescriptor &desc = TADS_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); } + + gd.addExtraEntry("filename", filename); + gameList.push_back(gd); } return !gameList.empty(); |