diff options
author | Bastien Bouclet | 2019-12-23 19:40:57 +0100 |
---|---|---|
committer | Filippos Karapetis | 2019-12-25 08:50:01 +0200 |
commit | f328ab43694b74adf56924ed9d8b4da74be4f7ac (patch) | |
tree | cb2dd393bd0652313ad419b28c4958b5e65d9b2c /engines | |
parent | d5687eb22274bf0eb2b737239738862500249390 (diff) | |
download | scummvm-rg350-f328ab43694b74adf56924ed9d8b4da74be4f7ac.tar.gz scummvm-rg350-f328ab43694b74adf56924ed9d8b4da74be4f7ac.tar.bz2 scummvm-rg350-f328ab43694b74adf56924ed9d8b4da74be4f7ac.zip |
WINTERMUTE: Fix fallback detection
Now the singleId property has been removed, the gameIds returned by the
MetaEngines when detecting games must be accepted by the `findGame`
method. Wintermute was generating gameIds based on datafiles in the
fallback detector. With this change, the gameId for fallback detected
games is always `wintermute`, the target name is generated based on the
`extra` value that contains the game caption.
The `(unknown)` mention that was previously added to the game title has
been removed. The unknown game dialog now makes it very clear that the
game version is not known to ScummVM.
Fixes #11288.
Diffstat (limited to 'engines')
-rw-r--r-- | engines/wintermute/detection.cpp | 60 |
1 files changed, 34 insertions, 26 deletions
diff --git a/engines/wintermute/detection.cpp b/engines/wintermute/detection.cpp index 3411512064..3deae26632 100644 --- a/engines/wintermute/detection.cpp +++ b/engines/wintermute/detection.cpp @@ -76,7 +76,7 @@ static const ADExtraGuiOptionsMap gameGuiOptions[] = { AD_EXTRA_GUI_OPTIONS_TERMINATOR }; -static char s_fallbackGameIdBuf[256]; +static char s_fallbackExtraBuf[256]; static const char *directoryGlobs[] = { "language", // To detect the various languages @@ -114,33 +114,41 @@ public: s_fallbackDesc.gameId = "wintermute"; s_fallbackDesc.guiOptions = GUIO0(); - if (allFiles.contains("data.dcp")) { - Common::String name, caption; - if (WintermuteEngine::getGameInfo(fslist, name, caption)) { - for (uint32 i = 0; i < name.size(); i++) { - // Replace spaces (and other non-alphanumerics) with underscores - if (!Common::isAlnum(name[(int32)i])) { - name.setChar('_', (uint32)i); - } - } - // Prefix to avoid collisions with actually known games - name = "wmeunk-" + name; - Common::strlcpy(s_fallbackGameIdBuf, name.c_str(), sizeof(s_fallbackGameIdBuf) - 1); - s_fallbackDesc.gameId = s_fallbackGameIdBuf; - if (caption != name) { - caption += " (unknown version) "; - char *offset = s_fallbackGameIdBuf + name.size() + 1; - uint32 remainingLength = (sizeof(s_fallbackGameIdBuf) - 1) - (name.size() + 1); - Common::strlcpy(offset, caption.c_str(), remainingLength); - s_fallbackDesc.extra = offset; - s_fallbackDesc.flags |= ADGF_USEEXTRAASTITLE; - } - - return ADDetectedGame(&s_fallbackDesc); - } // Fall through to return 0; + if (!allFiles.contains("data.dcp")) { + return ADDetectedGame(); } - return ADDetectedGame(); + Common::String name, caption; + if (!WintermuteEngine::getGameInfo(fslist, name, caption)) { + return ADDetectedGame(); + } + + Common::String extra = caption; + if (extra.empty()) { + extra = name; + } + + if (!extra.empty()) { + Common::strlcpy(s_fallbackExtraBuf, extra.c_str(), sizeof(s_fallbackExtraBuf) - 1); + s_fallbackDesc.extra = s_fallbackExtraBuf; + s_fallbackDesc.flags |= ADGF_USEEXTRAASTITLE; + s_fallbackDesc.flags |= ADGF_AUTOGENTARGET; + } + + ADDetectedGame game(&s_fallbackDesc); + + for (Common::FSList::const_iterator file = fslist.begin(); file != fslist.end(); ++file) { + if (file->isDirectory()) continue; + if (!file->getName().hasSuffixIgnoreCase(".dcp")) continue; + + FileProperties tmp; + if (getFileProperties(file->getParent(), allFiles, s_fallbackDesc, file->getName(), tmp)) { + game.hasUnknownFiles = true; + game.matchedFiles[file->getName()] = tmp; + } + } + + return game; } virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const { |