aboutsummaryrefslogtreecommitdiff
path: root/engines/glk/tads
diff options
context:
space:
mode:
authorPaul Gilbert2018-11-27 21:24:40 -0800
committerPaul Gilbert2018-12-08 19:05:59 -0800
commit75f4d34070a874437f6f339bac590f99d4b28f65 (patch)
tree3d451bd343a6f22feb3cecd097bfa43eced14900 /engines/glk/tads
parent09b682cb63fed029f43133f4a2d9daa3438ac8e2 (diff)
downloadscummvm-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')
-rw-r--r--engines/glk/tads/detection.cpp57
-rw-r--r--engines/glk/tads/detection_tables.h24
2 files changed, 55 insertions, 26 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();
diff --git a/engines/glk/tads/detection_tables.h b/engines/glk/tads/detection_tables.h
index c8fe3184b5..d4d570920b 100644
--- a/engines/glk/tads/detection_tables.h
+++ b/engines/glk/tads/detection_tables.h
@@ -28,22 +28,32 @@ namespace Glk {
namespace TADS {
/**
- * Game descriptor
+ * Game description
*/
-struct TADSGame {
- const char *_md5;
- const char *_gameId;
- int32 _filesize;
+struct TADSGameDescription {
+ const char *const _gameId;
+ const char *const _extra;
+ const char *const _md5;
+ size_t _filesize;
+ Common::Language _language;
};
const TADSDescriptor TADS_GAME_LIST[] = {
+ // TADS 2 Games
{ "tads2", "TADS 2 Game", false },
+ { "oncefuture", "Once and Future", false },
+
+ // TADS 3 Games
{ "tads3", "TADS 3 Game", true },
{ nullptr, nullptr, false }
};
-const TADSGame TADS_GAMES[] = {
- { nullptr, nullptr, 0 }
+#define ENTRY0(ID, MD5, FILESIZE) { ID, "", MD5, FILESIZE, Common::EN_ANY }
+#define TABLE_END_MARKER { nullptr, nullptr, nullptr, 0, Common::EN_ANY }
+
+const TADSGameDescription TADS_GAMES[] = {
+ ENTRY0("oncefuture", "4ed995d0784520ca6f0ec5391d92f4d8", 909993),
+ TABLE_END_MARKER
};
} // End of namespace Frotz