aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorMax Horn2007-02-14 21:59:57 +0000
committerMax Horn2007-02-14 21:59:57 +0000
commit62bd2a1544ef01896ad10565a2a9e96a5a873bfe (patch)
treed5a2977c9d1e53a7d892a5a313e9de4ae495884c /engines
parent80f799a2b25a5ff353dd572c5aeeb469688102c2 (diff)
downloadscummvm-rg350-62bd2a1544ef01896ad10565a2a9e96a5a873bfe.tar.gz
scummvm-rg350-62bd2a1544ef01896ad10565a2a9e96a5a873bfe.tar.bz2
scummvm-rg350-62bd2a1544ef01896ad10565a2a9e96a5a873bfe.zip
Make use of md5_file_string
svn-id: r25593
Diffstat (limited to 'engines')
-rw-r--r--engines/lure/lure.cpp13
-rw-r--r--engines/scumm/file.cpp8
-rw-r--r--engines/scumm/plugin.cpp13
-rw-r--r--engines/scumm/plugin.h1
-rw-r--r--engines/scumm/scumm.cpp11
5 files changed, 15 insertions, 31 deletions
diff --git a/engines/lure/lure.cpp b/engines/lure/lure.cpp
index 5d2bb06b7a..5154a07175 100644
--- a/engines/lure/lure.cpp
+++ b/engines/lure/lure.cpp
@@ -128,13 +128,9 @@ GameList Engine_LURE_detectGames(const FSList &fslist) {
if (file == fslist.end())
return detectedGames;
- uint8 md5sum[16];
char md5str[32 + 1];
- if (Common::md5_file(*file, md5sum, kMD5FileSizeLimit)) {
- for (int i = 0; i < 16; i++) {
- sprintf(md5str + i * 2, "%02x", (int)md5sum[i]);
- }
+ if (Common::md5_file_string(*file, md5str, kMD5FileSizeLimit)) {
for (g = lure_games; g->gameid; g++) {
if (strcmp(g->md5sum, (char *)md5str) == 0) {
GameDescriptor dg(g->gameid, g->description, g->language);
@@ -224,7 +220,6 @@ void LureEngine::detectGame() {
// Do an md5 check
- uint8 md5sum[16];
char md5str[32 + 1];
const GameSettings *g;
bool found = false;
@@ -235,11 +230,7 @@ void LureEngine::detectGame() {
if (!Common::File::exists(g->checkFile))
continue;
- if (Common::md5_file(g->checkFile, md5sum, kMD5FileSizeLimit)) {
- for (int j = 0; j < 16; j++) {
- sprintf(md5str + j * 2, "%02x", (int)md5sum[j]);
- }
- } else
+ if (!Common::md5_file_string(g->checkFile, md5str, kMD5FileSizeLimit))
continue;
if (strcmp(g->md5sum, (char *)md5str) == 0) {
diff --git a/engines/scumm/file.cpp b/engines/scumm/file.cpp
index 63e7ee48e1..0d580a327c 100644
--- a/engines/scumm/file.cpp
+++ b/engines/scumm/file.cpp
@@ -1383,14 +1383,10 @@ bool ScummNESFile::generateIndex() {
}
bool ScummNESFile::open(const Common::String &filename, AccessMode mode) {
- uint8 md5sum[16];
if (_ROMset == kROMsetNum) {
- if (Common::md5_file(filename.c_str(), md5sum)) {
- char md5str[32+1];
- for (int j = 0; j < 16; j++) {
- sprintf(md5str + j*2, "%02x", (int)md5sum[j]);
- }
+ char md5str[32+1];
+ if (Common::md5_file_string(filename.c_str(), md5str)) {
if (!strcmp(md5str, "3905799e081b80a61d4460b7b733c206")) {
_ROMset = kROMsetUSA;
diff --git a/engines/scumm/plugin.cpp b/engines/scumm/plugin.cpp
index ce01388925..250787eaf6 100644
--- a/engines/scumm/plugin.cpp
+++ b/engines/scumm/plugin.cpp
@@ -971,7 +971,6 @@ static Common::String generateFilenameForDetection(const GameFilenamePattern &gf
struct DetectorDesc {
FilesystemNode node;
Common::String md5;
- uint8 md5sum[16];
const MD5Table *md5Entry; // Entry of the md5 table corresponding to this file, if any.
};
@@ -1013,7 +1012,6 @@ static void detectGames(const FSList &fslist, Common::List<DetectorResult> &resu
dr.game.gameid = 0;
dr.language = gfp->language;
dr.md5.clear();
- memset(dr.md5sum, 0, 16);
dr.extra = 0;
// ____ _ _
@@ -1034,19 +1032,13 @@ static void detectGames(const FSList &fslist, Common::List<DetectorResult> &resu
//
DetectorDesc &d = fileMD5Map[file];
if (d.md5.empty()) {
- uint8 md5sum[16];
- if (Common::md5_file(d.node, md5sum, kMD5FileSizeLimit)) {
- char md5str[32+1];
- for (int j = 0; j < 16; j++) {
- sprintf(md5str + j*2, "%02x", (int)md5sum[j]);
- }
+ char md5str[32+1];
+ if (Common::md5_file_string(d.node, md5str, kMD5FileSizeLimit)) {
d.md5 = md5str;
- memcpy(d.md5sum, md5sum, 16);
d.md5Entry = findInMD5Table(md5str);
dr.md5 = d.md5;
- memcpy(dr.md5sum, d.md5sum, 16);
if (d.md5Entry) {
// Exact match found
@@ -1117,7 +1109,6 @@ static void detectGames(const FSList &fslist, Common::List<DetectorResult> &resu
// the gfp record. We then try to decide for each whether it could be
// appropriate or not.
dr.md5 = d.md5;
- memcpy(dr.md5sum, d.md5sum, 16);
for (g = gameVariantsTable; g->gameid; ++g) {
// Skip over entries with a different gameid.
if (g->gameid[0] == 0 || scumm_stricmp(gfp->gameid, g->gameid))
diff --git a/engines/scumm/plugin.h b/engines/scumm/plugin.h
index 905b785315..3b0ddabd54 100644
--- a/engines/scumm/plugin.h
+++ b/engines/scumm/plugin.h
@@ -116,7 +116,6 @@ struct DetectorResult {
GameSettings game;
Common::Language language;
Common::String md5;
- uint8 md5sum[16];
const char *extra;
};
diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp
index 64bdf42f0f..8d07538638 100644
--- a/engines/scumm/scumm.cpp
+++ b/engines/scumm/scumm.cpp
@@ -119,8 +119,15 @@ ScummEngine::ScummEngine(OSystem *syst, const DetectorResult &dr)
}
_res = new ResourceManager(this);
- // Copy MD5 checksum
- memcpy(_gameMD5, dr.md5sum, 16);
+ // Convert MD5 checksum back into a digest
+ for (int i = 0; i < 16; ++i) {
+ char tmpStr[3] = "00";
+ uint tmpVal;
+ tmpStr[0] = dr.md5[2*i];
+ tmpStr[1] = dr.md5[2*i+1];
+ sscanf(tmpStr, "%x", &tmpVal);
+ _gameMD5[i] = (byte)tmpVal;
+ }
_fileHandle = 0;