[Scummvm-cvs-logs] scummvm master -> c021759ad2f0fdb723f98a62739bdf6d5de9c350

dreammaster dreammaster at scummvm.org
Thu Oct 23 03:06:46 CEST 2014


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
c021759ad2 MADS: Add md5 checks for the asound.00* sound drivers


Commit: c021759ad2f0fdb723f98a62739bdf6d5de9c350
    https://github.com/scummvm/scummvm/commit/c021759ad2f0fdb723f98a62739bdf6d5de9c350
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-10-22T20:43:22-04:00

Commit Message:
MADS: Add md5 checks for the asound.00* sound drivers

The implementation of the sound driver code relies on the data for each
sound being at specific locations in the files, so this ensures that
if any language version changes the sound files, we'll know about it

Changed paths:
    engines/mads/nebular/sound_nebular.cpp
    engines/mads/nebular/sound_nebular.h
    engines/mads/sound.cpp



diff --git a/engines/mads/nebular/sound_nebular.cpp b/engines/mads/nebular/sound_nebular.cpp
index c540eb4..a6dce74 100644
--- a/engines/mads/nebular/sound_nebular.cpp
+++ b/engines/mads/nebular/sound_nebular.cpp
@@ -24,6 +24,7 @@
 #include "audio/decoders/raw.h"
 #include "common/algorithm.h"
 #include "common/debug.h"
+#include "common/md5.h"
 #include "common/memstream.h"
 #include "mads/sound.h"
 #include "mads/nebular/sound_nebular.h"
@@ -218,6 +219,33 @@ ASound::~ASound() {
 	_mixer->stopHandle(_soundHandle);
 }
 
+void ASound::validate() {
+	byte digest[16];
+	Common::File f;
+	static const char *const MD5[] = {
+		"205398468de2c8873b7d4d73d5be8ddc",
+		"f9b2d944a2fb782b1af5c0ad592306d3",
+		"7431f8dad77d6ddfc24e6f3c0c4ac7df",
+		"eb1f3f5a4673d3e73d8ac1818c957cf4",
+		"f936dd853073fa44f3daac512e91c476",
+		"3dc139d3e02437a6d9b732072407c366",
+		"af0edab2934947982e9a405476702e03",
+		"8cbc25570b50ba41c9b5361cad4fbedc",
+		"a31e4783e098f633cbb6689adb41dd4f"
+	};
+
+	for (int i = 1; i <= 9; ++i) {
+		Common::String filename = Common::String::format("ASOUND.00%d", i);
+		if (!f.open(filename))
+			error("Could not process - %s", filename.c_str());
+		Common::String md5str = Common::computeStreamMD5AsString(f, 8192);
+		f.close();
+
+		if (md5str != MD5[i - 1])
+			error("Invalid sound file - %s", filename.c_str());
+	}
+}
+
 void ASound::adlibInit() {
 	write(4, 0x60);
 	write(4, 0x80);
diff --git a/engines/mads/nebular/sound_nebular.h b/engines/mads/nebular/sound_nebular.h
index abb6516..ccfd40a 100644
--- a/engines/mads/nebular/sound_nebular.h
+++ b/engines/mads/nebular/sound_nebular.h
@@ -318,6 +318,11 @@ public:
 	virtual ~ASound();
 
 	/**
+	 * Validates the Adlib sound files
+	 */
+	static void validate();
+
+	/**
 	 * Execute a player command. Most commands represent sounds to play, but some
 	 * low number commands also provide control operations.
 	 * @param commandId		Player ommand to execute.
diff --git a/engines/mads/sound.cpp b/engines/mads/sound.cpp
index d0aa770..1652550 100644
--- a/engines/mads/sound.cpp
+++ b/engines/mads/sound.cpp
@@ -39,6 +39,15 @@ SoundManager::SoundManager(MADSEngine *vm, Audio::Mixer *mixer) {
 
 	_opl = OPL::Config::create();
 	_opl->init(11025);
+
+	// Validate sound files
+	switch (_vm->getGameID()) {
+	case GType_RexNebular:
+		Nebular::ASound::validate();
+		break;
+	default:
+		break;
+	}
 }
 
 SoundManager::~SoundManager() {






More information about the Scummvm-git-logs mailing list