diff options
| -rw-r--r-- | common/advancedDetector.cpp | 17 | ||||
| -rw-r--r-- | engines/lure/lure.cpp | 13 | ||||
| -rw-r--r-- | engines/scumm/file.cpp | 8 | ||||
| -rw-r--r-- | engines/scumm/plugin.cpp | 13 | ||||
| -rw-r--r-- | engines/scumm/plugin.h | 1 | ||||
| -rw-r--r-- | engines/scumm/scumm.cpp | 11 | 
6 files changed, 20 insertions, 43 deletions
| diff --git a/common/advancedDetector.cpp b/common/advancedDetector.cpp index 6447005c58..9ced59659a 100644 --- a/common/advancedDetector.cpp +++ b/common/advancedDetector.cpp @@ -258,7 +258,6 @@ static ADGameDescList detectGame(const FSList *fslist, const Common::ADParams &p  	uint i;  	char md5str[32+1]; -	uint8 md5sum[16];  	bool fileMissing;  	const ADGameFileDescription *fileDesc; @@ -295,12 +294,9 @@ static ADGameDescList detectGame(const FSList *fslist, const Common::ADParams &p  			if (!filesList.contains(tstr) && !filesList.contains(tstr2)) continue; -			if (!md5_file(*file, md5sum, params.md5Bytes)) continue; -			for (i = 0; i < 16; i++) { -				sprintf(md5str + i*2, "%02x", (int)md5sum[i]); -			} -			filesMD5[tstr] = String(md5str); -			filesMD5[tstr2] = String(md5str); +			if (!md5_file_string(*file, md5str, params.md5Bytes)) +				continue; +			filesMD5[tstr] = filesMD5[tstr2] = md5str;  			debug(3, "> %s: %s", tstr.c_str(), md5str); @@ -322,11 +318,8 @@ static ADGameDescList detectGame(const FSList *fslist, const Common::ADParams &p  					filesSize[tstr] = filesSize[tstr2] = (int32)testFile.size();  					testFile.close(); -					if (md5_file(file->_key.c_str(), md5sum, params.md5Bytes)) { -						for (i = 0; i < 16; i++) { -							sprintf(md5str + i*2, "%02x", (int)md5sum[i]); -						} -						filesMD5[tstr] = String(md5str); +					if (md5_file_string(file->_key.c_str(), md5str, params.md5Bytes)) { +						filesMD5[tstr] = md5str;  						debug(3, "> %s: %s", tstr.c_str(), md5str);  					}  				} 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; | 
