aboutsummaryrefslogtreecommitdiff
path: root/engines/glk/magnetic
diff options
context:
space:
mode:
Diffstat (limited to 'engines/glk/magnetic')
-rw-r--r--engines/glk/magnetic/detection.cpp32
-rw-r--r--engines/glk/magnetic/detection.h22
-rw-r--r--engines/glk/magnetic/detection_tables.h2
3 files changed, 20 insertions, 36 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] = "";
diff --git a/engines/glk/magnetic/detection.h b/engines/glk/magnetic/detection.h
index 3ea881075e..28ea70ffc2 100644
--- a/engines/glk/magnetic/detection.h
+++ b/engines/glk/magnetic/detection.h
@@ -20,32 +20,18 @@
*
*/
-#ifndef GLK_GLULXE_DETECTION
-#define GLK_GLULXE_DETECTION
+#ifndef GLK_MAGNETIC_DETECTION
+#define GLK_MAGNETIC_DETECTION
#include "common/fs.h"
#include "common/hash-str.h"
#include "engines/game.h"
+#include "glk/detection.h"
namespace Glk {
namespace Magnetic {
/**
- * Magnetic game descriptior
- */
-struct MagneticDescriptor {
- const char *gameId;
- const char *description;
-
- operator PlainGameDescriptor() const {
- PlainGameDescriptor pd;
- pd.gameId = gameId;
- pd.description = description;
- return pd;
- }
-};
-
-/**
* Meta engine for Magnetic interpreter
*/
class MagneticMetaEngine {
@@ -58,7 +44,7 @@ public:
/**
* Returns a game description for the given game Id, if it's supported
*/
- static MagneticDescriptor findGame(const char *gameId);
+ static GameDescriptor findGame(const char *gameId);
/**
* Detect supported games
diff --git a/engines/glk/magnetic/detection_tables.h b/engines/glk/magnetic/detection_tables.h
index a67d2a9a77..18d3b84b33 100644
--- a/engines/glk/magnetic/detection_tables.h
+++ b/engines/glk/magnetic/detection_tables.h
@@ -38,7 +38,7 @@ struct MagneticGameDescription {
Common::Language _language;
};
-const MagneticDescriptor MAGNETIC_GAME_LIST[] = {
+const PlainGameDescriptor MAGNETIC_GAME_LIST[] = {
{ "magnetic", "Magnetic Scrolls Game" },
{ nullptr, nullptr }