From be67479aef238d8558438ccc31da69dde67ea807 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 22 Dec 2009 00:12:59 +0000 Subject: Some bugfixes to the new music code svn-id: r46473 --- engines/sci/sfx/music.cpp | 1 + engines/sci/sfx/soundcmd.cpp | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/engines/sci/sfx/music.cpp b/engines/sci/sfx/music.cpp index 3956b0faeb..5fdf45db69 100644 --- a/engines/sci/sfx/music.cpp +++ b/engines/sci/sfx/music.cpp @@ -446,6 +446,7 @@ void SciMusic::soundKill(MusicEntry *pSnd) { // Remove sound from playlist for (i = 0; i < sz; i++) { if (_playList[i] == pSnd) { + delete _playList[i]->soundRes; _playList.remove_at(i); break; } diff --git a/engines/sci/sfx/soundcmd.cpp b/engines/sci/sfx/soundcmd.cpp index ecade498c3..297e926f7e 100644 --- a/engines/sci/sfx/soundcmd.cpp +++ b/engines/sci/sfx/soundcmd.cpp @@ -276,6 +276,11 @@ void SoundCommandParser::cmdInitHandle(reg_t obj, int16 value) { PUT_SEL32(_segMan, obj, handle, obj); #ifndef USE_OLD_MUSIC_FUNCTIONS + // Check if a track with the same sound object is already playing + int prevTrack = _music->findListSlot(obj); + if (prevTrack > -1) + _music->soundKill(_music->_playList[prevTrack]); + MusicEntry *newSound = new MusicEntry(); newSound->soundRes = 0; if (_resMan->testResource(ResourceId(kResourceTypeSound, number))) @@ -284,9 +289,6 @@ void SoundCommandParser::cmdInitHandle(reg_t obj, int16 value) { newSound->prio = GET_SEL32V(_segMan, obj, pri) & 0xFF; newSound->pStreamAud = 0; newSound->pMidiParser = 0; - - // TODO - //_music->soundKill(newSound); _music->_playList.push_back(newSound); if (newSound->soundRes) @@ -424,8 +426,6 @@ void SoundCommandParser::cmdDisposeHandle(reg_t obj, int16 value) { if (!GET_SEL32(_segMan, obj, nodePtr).isNull()) { _music->soundKill(_music->_playList[slot]); - delete _music->_playList[slot]->soundRes; - _music->_playList.remove_at(slot); PUT_SEL32(_segMan, obj, nodePtr, NULL_REG); } -- cgit v1.2.3