aboutsummaryrefslogtreecommitdiff
path: root/engines/glk/magnetic/detection.cpp
diff options
context:
space:
mode:
authorPaul Gilbert2019-05-07 15:27:14 +1000
committerPaul Gilbert2019-05-07 15:27:14 +1000
commit5f5ac6b475599da5c11df98852f1dbd1e62db8b5 (patch)
tree1862c8e4bddca445b7620407022ea093f36f3b49 /engines/glk/magnetic/detection.cpp
parent1f956a216475947335d2967f9a2f795976abf050 (diff)
downloadscummvm-rg350-5f5ac6b475599da5c11df98852f1dbd1e62db8b5.tar.gz
scummvm-rg350-5f5ac6b475599da5c11df98852f1dbd1e62db8b5.tar.bz2
scummvm-rg350-5f5ac6b475599da5c11df98852f1dbd1e62db8b5.zip
GLK: MAGNETIC: Hook up Magnetic sub-engine
Diffstat (limited to 'engines/glk/magnetic/detection.cpp')
-rw-r--r--engines/glk/magnetic/detection.cpp32
1 files changed, 15 insertions, 17 deletions
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] = "";