Skip to content

Commit

Permalink
GLK: Change other sub-engines to use GlkDetectedGame
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster committed Jul 6, 2019
1 parent 0502ac4 commit 5dda48c
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 111 deletions.
21 changes: 5 additions & 16 deletions engines/glk/advsys/detection.cpp
Expand Up @@ -78,24 +78,13 @@ bool AdvSysMetaEngine::detectGames(const Common::FSList &fslist, DetectedGames &
while (p->_md5 && p->_filesize != filesize && md5 != p->_md5)
++p;

if (p->_filesize) {
if (!p->_gameId) {
const PlainGameDescriptor &desc = ADVSYS_GAME_LIST[0];
gameList.push_back(GlkDetectedGame(desc.gameId, desc.description, filename, md5, filesize));
} else {
// Found a match
PlainGameDescriptor gameDesc = findGame(p->_gameId);
DetectedGame gd(p->_gameId, gameDesc.description, Common::EN_ANY, Common::kPlatformUnknown);
gd.addExtraEntry("filename", file->getName());

gameList.push_back(gd);
} else {
const PlainGameDescriptor &desc = ADVSYS_GAME_LIST[0];
DetectedGame gd(desc.gameId, desc.description, Common::UNK_LANG, Common::kPlatformUnknown);
gd.canBeAdded = true;
gd.hasUnknownFiles = true;
FileProperties fp;
fp.md5 = md5;
fp.size = filesize;
gd.matchedFiles[file->getName()] = fp;

gameList.push_back(gd);
gameList.push_back(GlkDetectedGame(p->_gameId, gameDesc.description, filename));
}
}

Expand Down
15 changes: 2 additions & 13 deletions engines/glk/alan2/detection.cpp
Expand Up @@ -71,24 +71,13 @@ bool Alan2MetaEngine::detectGames(const Common::FSList &fslist, DetectedGames &g
while (p->_gameId && (md5 != p->_md5 || filesize != p->_filesize))
++p;

DetectedGame gd;
if (!p->_gameId) {
const PlainGameDescriptor &desc = ALAN2_GAME_LIST[0];
gd = DetectedGame(desc.gameId, desc.description, Common::UNK_LANG, Common::kPlatformUnknown);
gd.canBeAdded = true;
gd.hasUnknownFiles = true;
FileProperties fp;
fp.md5 = md5;
fp.size = filesize;
gd.matchedFiles[filename] = fp;

gameList.push_back(GlkDetectedGame(desc.gameId, desc.description, filename, md5, filesize));
} else {
PlainGameDescriptor gameDesc = findGame(p->_gameId);
gd = DetectedGame(p->_gameId, gameDesc.description, Common::EN_ANY, Common::kPlatformUnknown);
gameList.push_back(GlkDetectedGame(p->_gameId, gameDesc.description, filename));
}

gd.addExtraEntry("filename", filename);
gameList.push_back(gd);
}

return !gameList.empty();
Expand Down
6 changes: 3 additions & 3 deletions engines/glk/detection.cpp
Expand Up @@ -58,20 +58,20 @@ namespace Glk {

GlkDetectedGame::GlkDetectedGame(const char *gameId, const char *gameDesc, const Common::String &filename) :
DetectedGame(gameId, gameDesc, Common::EN_ANY, Common::kPlatformUnknown) {
setGUIOptions(GUIO2(GUIO_NOSPEECH, GUIO_NOMIDI));
setGUIOptions(GUIO4(GUIO_NOSPEECH, GUIO_NOSFX, GUIO_NOMUSIC, GUIO_NOSUBTITLES));
addExtraEntry("filename", filename);
}

GlkDetectedGame::GlkDetectedGame(const char *gameId, const char *gameDesc, const Common::String &filename,
Common::Language lang) : DetectedGame(gameId, gameDesc, lang, Common::kPlatformUnknown) {
setGUIOptions(GUIO2(GUIO_NOSPEECH, GUIO_NOMIDI));
setGUIOptions(GUIO4(GUIO_NOSPEECH, GUIO_NOSFX, GUIO_NOMUSIC, GUIO_NOSUBTITLES));
addExtraEntry("filename", filename);
}

GlkDetectedGame::GlkDetectedGame(const char *gameId, const char *gameDesc, const Common::String &filename,
const Common::String &md5, size_t filesize) :
DetectedGame(gameId, gameDesc, Common::UNK_LANG, Common::kPlatformUnknown) {
setGUIOptions(GUIO2(GUIO_NOSPEECH, GUIO_NOMIDI));
setGUIOptions(GUIO4(GUIO_NOSPEECH, GUIO_NOSFX, GUIO_NOMUSIC, GUIO_NOSUBTITLES));
addExtraEntry("filename", filename);

canBeAdded = true;
Expand Down
18 changes: 5 additions & 13 deletions engines/glk/frotz/detection.cpp
Expand Up @@ -114,29 +114,21 @@ bool FrotzMetaEngine::detectGames(const Common::FSList &fslist, DetectedGames &g
(filesize != p->_filesize && isBlorb)))
++p;

DetectedGame gd;
if (!p->_gameId) {
// Generic .dat/.zip files don't get reported as matches unless they have a known md5
if (filename.hasSuffixIgnoreCase(".dat") || filename.hasSuffixIgnoreCase(".zip") || emptyBlorb)
continue;

const PlainGameDescriptor &desc = ZCODE_GAME_LIST[0];
gd = DetectedGame(desc.gameId, desc.description, Common::UNK_LANG, Common::kPlatformUnknown);
gd.canBeAdded = true;
gd.hasUnknownFiles = true;
FileProperties fp;
fp.md5 = md5;
fp.size = filesize;
gd.matchedFiles[filename] = fp;

gameList.push_back(GlkDetectedGame(desc.gameId, desc.description, filename, md5, filesize));
} else {
GameDescriptor gameDesc = findGame(p->_gameId);
gd = DetectedGame(p->_gameId, gameDesc._description, p->_language, Common::kPlatformUnknown, p->_extra);
DetectedGame gd = DetectedGame(p->_gameId, gameDesc._description, p->_language, Common::kPlatformUnknown, p->_extra);
gd.setGUIOptions(p->_guiOptions);
}

gd.addExtraEntry("filename", filename);
gameList.push_back(gd);
gd.addExtraEntry("filename", filename);
gameList.push_back(gd);
}
}

return !gameList.empty();
Expand Down
16 changes: 2 additions & 14 deletions engines/glk/glulxe/detection.cpp
Expand Up @@ -79,25 +79,13 @@ bool GlulxeMetaEngine::detectGames(const Common::FSList &fslist, DetectedGames &
while (p->_gameId && (md5 != p->_md5 || filesize != p->_filesize))
++p;

DetectedGame gd;
if (!p->_gameId) {
const PlainGameDescriptor &desc = GLULXE_GAME_LIST[0];
gd = DetectedGame(desc.gameId, desc.description, Common::UNK_LANG, Common::kPlatformUnknown);
gd.canBeAdded = true;
gd.hasUnknownFiles = true;
FileProperties fp;
fp.md5 = md5;
fp.size = filesize;
gd.matchedFiles[filename] = fp;

gameList.push_back(GlkDetectedGame(desc.gameId, desc.description, filename, md5, filesize));
} else {
PlainGameDescriptor gameDesc = findGame(p->_gameId);
gd = DetectedGame(p->_gameId, gameDesc.description, p->_language, Common::kPlatformUnknown, p->_extra);
gd.setGUIOptions(GUIO4(GUIO_NOSPEECH, GUIO_NOSFX, GUIO_NOMUSIC, GUIO_NOSUBTITLES));
gameList.push_back(GlkDetectedGame(p->_gameId, gameDesc.description, filename));
}

gd.addExtraEntry("filename", filename);
gameList.push_back(gd);
}

return !gameList.empty();
Expand Down
16 changes: 2 additions & 14 deletions engines/glk/hugo/detection.cpp
Expand Up @@ -74,25 +74,13 @@ bool HugoMetaEngine::detectGames(const Common::FSList &fslist, DetectedGames &ga
while (p->_gameId && (md5 != p->_md5 || filesize != p->_filesize))
++p;

DetectedGame gd;
if (!p->_gameId) {
const PlainGameDescriptor &desc = HUGO_GAME_LIST[0];
gd = DetectedGame(desc.gameId, desc.description, Common::UNK_LANG, Common::kPlatformUnknown);
gd.canBeAdded = true;
gd.hasUnknownFiles = true;
FileProperties fp;
fp.md5 = md5;
fp.size = filesize;
gd.matchedFiles[filename] = fp;

gameList.push_back(GlkDetectedGame(desc.gameId, desc.description, filename, md5, filesize));
} else {
PlainGameDescriptor gameDesc = findGame(p->_gameId);
gd = DetectedGame(p->_gameId, gameDesc.description, p->_language, Common::kPlatformUnknown, p->_extra);
gd.setGUIOptions(GUIO4(GUIO_NOSPEECH, GUIO_NOSFX, GUIO_NOMUSIC, GUIO_NOSUBTITLES));
gameList.push_back(GlkDetectedGame(p->_gameId, gameDesc.description, filename));
}

gd.addExtraEntry("filename", filename);
gameList.push_back(gd);
}

return !gameList.empty();
Expand Down
16 changes: 2 additions & 14 deletions engines/glk/magnetic/detection.cpp
Expand Up @@ -79,25 +79,13 @@ bool MagneticMetaEngine::detectGames(const Common::FSList &fslist, DetectedGames
while (p->_gameId && (md5 != p->_md5 || filesize != p->_filesize))
++p;

DetectedGame gd;
if (!p->_gameId) {
const PlainGameDescriptor &desc = MAGNETIC_GAME_LIST[0];
gd = DetectedGame(desc.gameId, desc.description, Common::UNK_LANG, Common::kPlatformUnknown);
gd.canBeAdded = true;
gd.hasUnknownFiles = true;
FileProperties fp;
fp.md5 = md5;
fp.size = filesize;
gd.matchedFiles[filename] = fp;

gameList.push_back(GlkDetectedGame(desc.gameId, desc.description, filename, md5, filesize));
} else {
PlainGameDescriptor gameDesc = findGame(p->_gameId);
gd = DetectedGame(p->_gameId, gameDesc.description, p->_language, Common::kPlatformUnknown, p->_extra);
gd.setGUIOptions(GUIO4(GUIO_NOSPEECH, GUIO_NOSFX, GUIO_NOMUSIC, GUIO_NOSUBTITLES));
gameList.push_back(GlkDetectedGame(p->_gameId, gameDesc.description, filename));
}

gd.addExtraEntry("filename", filename);
gameList.push_back(gd);
}

return !gameList.empty();
Expand Down
15 changes: 2 additions & 13 deletions engines/glk/scott/detection.cpp
Expand Up @@ -77,28 +77,17 @@ bool ScottMetaEngine::detectGames(const Common::FSList &fslist, DetectedGames &g
while (p->_md5 && p->_filesize != filesize && md5 != p->_md5)
++p;

DetectedGame gd;
if (!p->_gameId) {
if (!isBlorb && filename.hasSuffixIgnoreCase(".dat"))
continue;

const PlainGameDescriptor &desc = SCOTT_GAME_LIST[0];
gd = DetectedGame(desc.gameId, desc.description, Common::UNK_LANG, Common::kPlatformUnknown);
gd.canBeAdded = true;
gd.hasUnknownFiles = true;
FileProperties fp;
fp.md5 = md5;
fp.size = filesize;
gd.matchedFiles[filename] = fp;

gameList.push_back(GlkDetectedGame(desc.gameId, desc.description, filename, md5, filesize));
} else {
// Found a match
PlainGameDescriptor gameDesc = findGame(p->_gameId);
DetectedGame gd(p->_gameId, gameDesc.description, Common::EN_ANY, Common::kPlatformUnknown);
gd.addExtraEntry("filename", file->getName());
gameList.push_back(GlkDetectedGame(p->_gameId, gameDesc.description, filename));
}

gameList.push_back(gd);
}

return !gameList.empty();
Expand Down
14 changes: 3 additions & 11 deletions engines/glk/tads/detection.cpp
Expand Up @@ -107,21 +107,13 @@ bool TADSMetaEngine::detectGames(const Common::FSList &fslist, DetectedGames &ga
DetectedGame gd;
if (!p->_gameId) {
const GameDescriptor &desc = tadsVersion == 2 ? TADS2_GAME_LIST[0] : TADS3_GAME_LIST[0];
gd = DetectedGame(desc._gameId, desc._description, Common::UNK_LANG, Common::kPlatformUnknown);
gd.canBeAdded = true;
gd.hasUnknownFiles = true;
FileProperties fp;
fp.md5 = md5;
fp.size = filesize;
gd.matchedFiles[filename] = fp;

gameList.push_back(GlkDetectedGame(desc._gameId, desc._description, filename, md5, filesize));
} 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);
}

gd.addExtraEntry("filename", filename);
gameList.push_back(gd);
}

return !gameList.empty();
Expand Down

0 comments on commit 5dda48c

Please sign in to comment.