aboutsummaryrefslogtreecommitdiff
path: root/engines/glk/tads
diff options
context:
space:
mode:
authorCameron Cawley2019-03-30 23:30:10 +0000
committerPaul Gilbert2019-03-31 16:37:47 -0700
commit7b4c6d6a35f00e46d9021b236393a40aa54e6a6e (patch)
treebc6478a404a3ff9014620fe52a370b6a0cf7a5fc /engines/glk/tads
parent82ccce948aaafed2f8e847359ab87c1a4878c74b (diff)
downloadscummvm-rg350-7b4c6d6a35f00e46d9021b236393a40aa54e6a6e.tar.gz
scummvm-rg350-7b4c6d6a35f00e46d9021b236393a40aa54e6a6e.tar.bz2
scummvm-rg350-7b4c6d6a35f00e46d9021b236393a40aa54e6a6e.zip
GLK: Improved detection of Blorb files
Diffstat (limited to 'engines/glk/tads')
-rw-r--r--engines/glk/tads/detection.cpp20
1 files changed, 14 insertions, 6 deletions
diff --git a/engines/glk/tads/detection.cpp b/engines/glk/tads/detection.cpp
index 9e1eb0833d..92633dacef 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 "glk/blorb.h"
#include "common/debug.h"
#include "common/file.h"
#include "common/md5.h"
@@ -58,22 +59,32 @@ GameDescriptor TADSMetaEngine::findGame(const char *gameId) {
}
bool TADSMetaEngine::detectGames(const Common::FSList &fslist, DetectedGames &gameList) {
+ const char *const EXTENSIONS[] = { ".gam", nullptr };
+
// Loop through the files of the folder
for (Common::FSList::const_iterator file = fslist.begin(); file != fslist.end(); ++file) {
// Check for a recognised filename
- Common::String filename = file->getName();
- if (file->isDirectory() || !(filename.hasSuffixIgnoreCase(".gam")
- || filename.hasSuffixIgnoreCase(".blorb")))
+ if (file->isDirectory())
continue;
+ Common::String filename = file->getName();
+ bool hasExt = false, isBlorb = false;
+ for (const char *const *ext = &EXTENSIONS[0]; *ext && !hasExt; ++ext)
+ hasExt = filename.hasSuffixIgnoreCase(*ext);
+
// 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.seek(0);
+ isBlorb = Blorb::isBlorb(gameFile, ID_TAD2) || Blorb::isBlorb(gameFile, ID_TAD3);
gameFile.close();
+ if (!hasExt && !isBlorb)
+ continue;
+
// Check for known games
const TADSGameDescription *p = TADS_GAMES;
while (p->_gameId && p->_md5 && (md5 != p->_md5 || filesize != p->_filesize))
@@ -81,9 +92,6 @@ bool TADSMetaEngine::detectGames(const Common::FSList &fslist, DetectedGames &ga
DetectedGame gd;
if (!p->_gameId) {
- if (!filename.hasSuffixIgnoreCase(".gam"))
- continue;
-
if (gDebugLevel > 0) {
// Print an entry suitable for putting into the detection_tables.h, using the
Common::String fname = filename;