aboutsummaryrefslogtreecommitdiff
path: root/engines/glk/scott
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/scott
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/scott')
-rw-r--r--engines/glk/scott/detection.cpp45
1 files changed, 24 insertions, 21 deletions
diff --git a/engines/glk/scott/detection.cpp b/engines/glk/scott/detection.cpp
index f1c4b9aa69..0e89b13f86 100644
--- a/engines/glk/scott/detection.cpp
+++ b/engines/glk/scott/detection.cpp
@@ -22,6 +22,7 @@
#include "glk/scott/detection.h"
#include "glk/scott/detection_tables.h"
+#include "glk/blorb.h"
#include "common/file.h"
#include "common/md5.h"
#include "engines/game.h"
@@ -44,41 +45,43 @@ GameDescriptor ScottMetaEngine::findGame(const char *gameId) {
}
bool ScottMetaEngine::detectGames(const Common::FSList &fslist, DetectedGames &gameList) {
- const char *const EXTENSIONS[] = { ".saga", ".dat", ".blb", ".blorb", nullptr };
- Common::File gameFile;
- Common::String md5;
+ const char *const EXTENSIONS[] = { ".saga", ".dat", nullptr };
// Loop through the files of the folder
for (Common::FSList::const_iterator file = fslist.begin(); file != fslist.end(); ++file) {
- Common::String name = file->getName();
+ // Check for a recognised filename
if (file->isDirectory())
continue;
Common::String filename = file->getName();
- bool hasExt = false;
+ bool hasExt = false, isBlorb = false;
for (const char *const *ext = &EXTENSIONS[0]; *ext && !hasExt; ++ext)
hasExt = filename.hasSuffixIgnoreCase(*ext);
- if (!hasExt)
- continue;
- if (gameFile.open(*file)) {
- md5 = Common::computeStreamMD5AsString(gameFile, 5000);
+ Common::File gameFile;
+ if (!gameFile.open(*file))
+ continue;
+ Common::String md5 = Common::computeStreamMD5AsString(gameFile, 5000);
+ int32 filesize = gameFile.size();
+ gameFile.seek(0);
+ isBlorb = Blorb::isBlorb(gameFile, ID_SAAI);
+ gameFile.close();
- // Scan through the Scott game list for a match
- const ScottGame *p = SCOTT_GAMES;
- while (p->_md5 && p->_filesize != gameFile.size() && md5 != p->_md5)
- ++p;
+ if (!hasExt && !isBlorb)
+ continue;
- if (p->_filesize) {
- // Found a match
- PlainGameDescriptor gameDesc = findGame(p->_gameId);
- DetectedGame gd(p->_gameId, gameDesc.description, Common::EN_ANY, Common::kPlatformUnknown);
- gd.addExtraEntry("filename", file->getName());
+ // Scan through the Scott game list for a match
+ const ScottGame *p = SCOTT_GAMES;
+ while (p->_md5 && p->_filesize != filesize && md5 != p->_md5)
+ ++p;
- gameList.push_back(gd);
- }
+ if (p->_filesize) {
+ // Found a match
+ PlainGameDescriptor gameDesc = findGame(p->_gameId);
+ DetectedGame gd(p->_gameId, gameDesc.description, Common::EN_ANY, Common::kPlatformUnknown);
+ gd.addExtraEntry("filename", file->getName());
- gameFile.close();
+ gameList.push_back(gd);
}
}