From 4d3a07b4943fa173b8db93d54d89baa24b35e0c5 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Sun, 7 Nov 2010 17:16:59 +0000 Subject: COMMON: Rename and tweak MD5 functions * names now comply to our naming conventions * the function computeStreamMD5AsString which computes the MD5 as a hex string now returns it as a Common::String * add doxygen comments svn-id: r54121 --- engines/scumm/detection.cpp | 10 ++++++---- engines/scumm/file_nes.cpp | 22 ++++++++++++---------- 2 files changed, 18 insertions(+), 14 deletions(-) (limited to 'engines/scumm') diff --git a/engines/scumm/detection.cpp b/engines/scumm/detection.cpp index 467282bd43..10224d997d 100644 --- a/engines/scumm/detection.cpp +++ b/engines/scumm/detection.cpp @@ -422,7 +422,6 @@ static void composeFileHashMap(const Common::FSList &fslist, DescMap &fileMD5Map static void detectGames(const Common::FSList &fslist, Common::List &results, const char *gameid) { DescMap fileMD5Map; DetectorResult dr; - char md5str[32+1]; // Dive one level down since mac indy3/loom has its files split into directories. See Bug #1438631 composeFileHashMap(fslist, fileMD5Map, 2, directoryGlobs); @@ -479,10 +478,13 @@ static void detectGames(const Common::FSList &fslist, Common::Listopen(d.node); } - if (tmp && tmp->isOpen() && Common::md5_file_string(*tmp, md5str, kMD5FileSizeLimit)) { + Common::String md5str; + if (tmp && tmp->isOpen()) + md5str = computeStreamMD5AsString(*tmp, kMD5FileSizeLimit); + if (!md5str.empty()) { d.md5 = md5str; - d.md5Entry = findInMD5Table(md5str); + d.md5Entry = findInMD5Table(md5str.c_str()); dr.md5 = d.md5; @@ -494,7 +496,7 @@ static void detectGames(const Common::FSList &fslist, Common::Listsize(); if (d.md5Entry->filesize != filesize) debug(1, "SCUMM detector found matching file '%s' with MD5 %s, size %d\n", - file.c_str(), md5str, filesize); + file.c_str(), md5str.c_str(), filesize); // Sanity check: We *should* have found a matching gameid / variant at this point. // If not, then there's a bug in our data tables... diff --git a/engines/scumm/file_nes.cpp b/engines/scumm/file_nes.cpp index bfd45d8005..5403354830 100644 --- a/engines/scumm/file_nes.cpp +++ b/engines/scumm/file_nes.cpp @@ -1369,34 +1369,36 @@ bool ScummNESFile::generateIndex() { bool ScummNESFile::open(const Common::String &filename) { if (_ROMset == kROMsetNum) { - char md5str[32+1]; + Common::String md5str; File f; f.open(filename); - if (f.isOpen() && Common::md5_file_string(f, md5str)) { + if (f.isOpen()) + md5str = Common::computeStreamMD5AsString(f); + if (!md5str.empty()) { - if (!strcmp(md5str, "3905799e081b80a61d4460b7b733c206")) { + if (md5str == "3905799e081b80a61d4460b7b733c206") { _ROMset = kROMsetUSA; debug(1, "ROM contents verified as Maniac Mansion (USA)"); - } else if (!strcmp(md5str, "d8d07efcb88f396bee0b402b10c3b1c9")) { + } else if (md5str == "d8d07efcb88f396bee0b402b10c3b1c9") { _ROMset = kROMsetEurope; debug(1, "ROM contents verified as Maniac Mansion (Europe)"); - } else if (!strcmp(md5str, "22d07d6c386c9c25aca5dac2a0c0d94b")) { + } else if (md5str == "22d07d6c386c9c25aca5dac2a0c0d94b") { _ROMset = kROMsetSweden; debug(1, "ROM contents verified as Maniac Mansion (Sweden)"); - } else if (!strcmp(md5str, "81bbfa181184cb494e7a81dcfa94fbd9")) { + } else if (md5str == "81bbfa181184cb494e7a81dcfa94fbd9") { _ROMset = kROMsetFrance; debug(2, "ROM contents verified as Maniac Mansion (France)"); - } else if (!strcmp(md5str, "257f8c14d8c584f7ddd601bcb00920c7")) { + } else if (md5str == "257f8c14d8c584f7ddd601bcb00920c7") { _ROMset = kROMsetGermany; debug(2, "ROM contents verified as Maniac Mansion (Germany)"); - } else if (!strcmp(md5str, "f163cf53f7850e43fb482471e5c52e1a")) { + } else if (md5str == "f163cf53f7850e43fb482471e5c52e1a") { _ROMset = kROMsetSpain; debug(2, "ROM contents verified as Maniac Mansion (Spain)"); - } else if (!strcmp(md5str, "54a68a5f5e3c86da42b7ca5f51e79b1d")) { + } else if (md5str == "54a68a5f5e3c86da42b7ca5f51e79b1d") { _ROMset = kROMsetItaly; debug(2, "ROM contents verified as Maniac Mansion (Italy)"); } else { - error("Unsupported Maniac Mansion ROM, md5: %s", md5str); + error("Unsupported Maniac Mansion ROM, md5: %s", md5str.c_str()); return false; } } else { -- cgit v1.2.3