[Scummvm-cvs-logs] CVS: scummvm/saga music.cpp,1.46,1.47 music.h,1.18,1.19

Torbjörn Andersson eriktorbjorn at users.sourceforge.net
Mon Jan 17 06:20:06 CET 2005


Update of /cvsroot/scummvm/scummvm/saga
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28239

Modified Files:
	music.cpp music.h 
Log Message:
If the game tries to start a piece of music that happens to be playing
already, let it continue playing rather than restarting it. (I've been
meaning to make this change for some time, but now it appeared on the TODO
list as well. :-)


Index: music.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/music.cpp,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -d -r1.46 -r1.47
--- music.cpp	11 Jan 2005 21:10:20 -0000	1.46
+++ music.cpp	17 Jan 2005 14:19:17 -0000	1.47
@@ -349,6 +349,10 @@
 	delete _player;
 }
 
+bool Music::isPlaying() {
+	return _musicHandle.isActive() || _player->isPlaying();
+}
+
 // The Wyrmkeep release of Inherit The Earth features external MIDI files, so
 // we need a mapping from resource number to filename.
 //
@@ -397,6 +401,12 @@
 		return SUCCESS;
 	}
 
+	if (isPlaying() && _trackNumber == music_rn) {
+		return SUCCESS;
+	}
+
+	_trackNumber = music_rn;
+
 	_player->stopMusic();
 
 	if (_musicHandle.isActive())

Index: music.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/music.h,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- music.h	1 Jan 2005 16:18:36 -0000	1.18
+++ music.h	17 Jan 2005 14:19:17 -0000	1.19
@@ -51,6 +51,9 @@
 public:
 	MusicPlayer(MidiDriver *driver);
 	~MusicPlayer();
+
+	bool isPlaying() { return _isPlaying; }
+
 	void setVolume(int volume);
 	int getVolume() { return _masterVolume; }
 
@@ -59,7 +62,7 @@
 	void playMusic();
 	void stopMusic();
 	void setLoop(bool loop) { _looping = loop; }
-	void setPassThrough(bool b)		{ _passThrough = b; }
+	void setPassThrough(bool b) { _passThrough = b; }
 
 	void setGM(bool isGM) { _isGM = isGM; }
 
@@ -110,6 +113,7 @@
 	void setAdlib(bool b)		{ _adlib = b; }
 	bool hasAdlib()			{ return _adlib; }
 	void setPassThrough(bool b)	{ _player->setPassThrough(b); }
+	bool isPlaying(void);
 
 	int play(uint32 music_rn, uint16 flags = MUSIC_DEFAULT);
 	int pause(void);
@@ -122,6 +126,7 @@
 
 	MusicPlayer *_player;
 	PlayingSoundHandle _musicHandle;
+	uint32 _trackNumber;
 
 	static const MUSIC_MIDITABLE _midiTableITECD[26];
 	MUSIC_DIGITABLE _digiTableITECD[27];





More information about the Scummvm-git-logs mailing list