diff options
author | Eugene Sandulenko | 2007-10-28 16:29:31 +0000 |
---|---|---|
committer | Eugene Sandulenko | 2007-10-28 16:29:31 +0000 |
commit | ef23e9b0af9422bf90d36b41cec8beda1e9f118c (patch) | |
tree | 11c2dc6f70fc1ea928382f0854d14c9076d6b4fe /common | |
parent | 3b005ab88fd974e453a752b3ece26e2b9538bede (diff) | |
download | scummvm-rg350-ef23e9b0af9422bf90d36b41cec8beda1e9f118c.tar.gz scummvm-rg350-ef23e9b0af9422bf90d36b41cec8beda1e9f118c.tar.bz2 scummvm-rg350-ef23e9b0af9422bf90d36b41cec8beda1e9f118c.zip |
Patch #1814831: "Unify the way to report unknown versions of games"
svn-id: r29293
Diffstat (limited to 'common')
-rw-r--r-- | common/advancedDetector.cpp | 56 | ||||
-rw-r--r-- | common/advancedDetector.h | 3 |
2 files changed, 44 insertions, 15 deletions
diff --git a/common/advancedDetector.cpp b/common/advancedDetector.cpp index 1a3ae13a9e..b15477c5a2 100644 --- a/common/advancedDetector.cpp +++ b/common/advancedDetector.cpp @@ -301,6 +301,45 @@ PluginError detectGameForEngineCreation( return kNoGameDataFoundError; } +void reportUnknown(StringMap &filesMD5, HashMap<String, int32, Common::CaseSensitiveString_Hash, Common::CaseSensitiveString_EqualTo> &filesSize) { + // TODO: This message should be cleaned up / made more specific. + // For example, we should specify at least which engine triggered this. + // + // Might also be helpful to display the full path (for when this is used + // from the mass detector). + printf("Your game version appears to be unknown. Please, report the following\n"); + printf("data to the ScummVM team along with name of the game you tried to add\n"); + printf("and its version/language/etc.:\n"); + + for (StringMap::const_iterator file = filesMD5.begin(); file != filesMD5.end(); ++file) + printf(" \"%s\", \"%s\", %d\n", file->_key.c_str(), file->_value.c_str(), filesSize[file->_key]); + + printf("\n"); +} + +void reportUnknown(StringList &files, int md5Bytes) { + StringMap filesMD5; + HashMap<String, int32, Common::CaseSensitiveString_Hash, Common::CaseSensitiveString_EqualTo> filesSize; + + char md5str[32+1]; + File testFile; + + // Fill the data structures for the requested files + for (StringList::iterator file = files.begin(); file != files.end(); file++) { + + if (testFile.open(*file)) { + filesSize[*file] = (int32)testFile.size(); + + if (md5_file_string(testFile, md5str, md5Bytes)) + filesMD5[*file] = md5str; + + testFile.close(); + } + } + + reportUnknown(filesMD5, filesSize); +} + static ADGameDescList detectGame(const FSList *fslist, const Common::ADParams ¶ms, Language language, Platform platform) { typedef HashMap<String, bool, CaseSensitiveString_Hash, CaseSensitiveString_EqualTo> StringSet; StringSet filesList; @@ -460,21 +499,8 @@ static ADGameDescList detectGame(const FSList *fslist, const Common::ADParams &p if (!matched.empty()) return matched; - if (!filesMD5.empty()) { - // TODO: This message should be cleaned up / made more specific. - // For example, we should specify at least which engine triggered this. - // - // Might also be helpful to display the full path (for when this is used - // from the mass detector). - printf("Your game version appears to be unknown. Please, report the following\n"); - printf("data to the ScummVM team along with name of the game you tried to add\n"); - printf("and its version/language/etc.:\n"); - - for (StringMap::const_iterator file = filesMD5.begin(); file != filesMD5.end(); ++file) - printf(" \"%s\", \"%s\", %d\n", file->_key.c_str(), file->_value.c_str(), filesSize[file->_key]); - - printf("\n"); - } + if (!filesMD5.empty()) + reportUnknown(filesMD5, filesSize); // Filename based fallback if (params.fileBasedFallback != 0) { diff --git a/common/advancedDetector.h b/common/advancedDetector.h index 1817f634a6..b98b7a45ff 100644 --- a/common/advancedDetector.h +++ b/common/advancedDetector.h @@ -240,6 +240,9 @@ EncapsulatedADGameDesc detectBestMatchingGame(const Common::ADParams ¶ms); // Only used by ADVANCED_DETECTOR_DEFINE_PLUGIN_WITH_FUNC PluginError detectGameForEngineCreation(const Common::ADParams ¶ms); +// Helper function to announce an unknown version of the game (useful for +// fallback detection functions). +void reportUnknown(StringList &files, int md5Bytes); // FIXME: It would probably be good to merge detectBestMatchingGame // and detectGameForEngineCreation into a single function. Right now, the |