[Scummvm-cvs-logs] SF.net SVN: scummvm:[34861] scummvm/trunk/engines/parallaction

peres001 at users.sourceforge.net peres001 at users.sourceforge.net
Wed Oct 29 09:16:13 CET 2008


Revision: 34861
          http://scummvm.svn.sourceforge.net/scummvm/?rev=34861&view=rev
Author:   peres001
Date:     2008-10-29 08:16:13 +0000 (Wed, 29 Oct 2008)

Log Message:
-----------
Removed reference to Common::File in music code, and small cleanup.

Modified Paths:
--------------
    scummvm/trunk/engines/parallaction/sound.cpp
    scummvm/trunk/engines/parallaction/sound.h

Modified: scummvm/trunk/engines/parallaction/sound.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/sound.cpp	2008-10-29 07:57:48 UTC (rev 34860)
+++ scummvm/trunk/engines/parallaction/sound.cpp	2008-10-29 08:16:13 UTC (rev 34861)
@@ -47,7 +47,7 @@
 	MidiPlayer(MidiDriver *driver);
 	~MidiPlayer();
 
-	void play(const char *filename);
+	void play(Common::SeekableReadStream *stream);
 	void stop();
 	void updateTimer();
 	void adjustVolume(int diff);
@@ -93,29 +93,17 @@
 	close();
 }
 
-void MidiPlayer::play(const char *filename) {
-	stop();
-
-	if (!scumm_strnicmp(_vm->_location._name, "museo", 5)) return;
-	if (!scumm_strnicmp(_vm->_location._name, "intgrottadopo", 13)) return;
-	if (!scumm_strnicmp(_vm->_location._name, "caveau", 6)) return;
-	if (!scumm_strnicmp(_vm->_location._name, "estgrotta", 9)) return;
-	if (!scumm_strnicmp(_vm->_location._name, "plaza1", 6)) return;
-	if (!scumm_strnicmp(_vm->_location._name, "endtgz", 6)) return;
-
-	char path[PATH_LEN];
-	sprintf(path, "%s.mid", filename);
-
-	Common::File stream;
-
-	if (!stream.open(path))
+void MidiPlayer::play(Common::SeekableReadStream *stream) {
+	if (!stream) {
+		stop();
 		return;
+	}
 
-	int size = stream.size();
+	int size = stream->size();
 
 	_midiData = (uint8 *)malloc(size);
 	if (_midiData) {
-		stream.read(_midiData, size);
+		stream->read(_midiData, size);
 		_mutex.lock();
 		_parser->loadMusic(_midiData, size);
 		_parser->setTrack(0);
@@ -239,10 +227,32 @@
 	delete _midiPlayer;
 }
 
+bool DosSoundMan::isLocationSilent(const char *locationName) {
+
+	// these are the prefixes for location names with no background midi music
+	const char *noMusicPrefix[] = { "museo", "intgrottadopo", "caveau", "estgrotta", "plaza1", "endtgz", "common", 0 };
+	Common::String s(locationName);
+
+	for (int i = 0; noMusicPrefix[i]; i++) {
+		if (s.hasPrefix(noMusicPrefix[i])) {
+			return true;
+		}
+	}
+
+	return false;
+}
+
 void DosSoundMan::playMusic() {
 	debugC(1, kDebugAudio, "DosSoundMan::playMusic()");
 
-	_midiPlayer->play(_musicFile);
+	if (isLocationSilent(_vm->_location._name)) {
+		// just stop the music if this location is silent
+		_midiPlayer->stop();
+		return;
+	}
+
+	Common::SeekableReadStream *stream = _vm->_disk->loadMusic(_musicFile);
+	_midiPlayer->play(stream);
 }
 
 void DosSoundMan::stopMusic() {
@@ -291,14 +301,7 @@
 		debugC(2, kDebugExec, "changeLocation: started music 'soft'");
 	}
 
-	if (!scumm_stricmp(location, "museo") ||
-		!scumm_stricmp(location, "caveau") ||
-		!scumm_strnicmp(location, "plaza1", 6) ||
-		!scumm_stricmp(location, "estgrotta") ||
-		!scumm_stricmp(location, "intgrottadopo") ||
-		!scumm_stricmp(location, "endtgz") ||
-		!scumm_stricmp(location, "common")) {
-
+	if (isLocationSilent(location)) {
 		stopMusic();
 		_musicData1 = 1;
 

Modified: scummvm/trunk/engines/parallaction/sound.h
===================================================================
--- scummvm/trunk/engines/parallaction/sound.h	2008-10-29 07:57:48 UTC (rev 34860)
+++ scummvm/trunk/engines/parallaction/sound.h	2008-10-29 08:16:13 UTC (rev 34861)
@@ -70,6 +70,8 @@
 	MidiPlayer	*_midiPlayer;
 	int			_musicData1;
 
+	bool isLocationSilent(const char *locationName);
+
 public:
 	DosSoundMan(Parallaction *vm, MidiDriver *midiDriver);
 	~DosSoundMan();


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list