From c1226b7d4a305dba7b62b046be4d3fe728a8209d Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 17 Sep 2013 03:25:36 +0300 Subject: NEVERHOOD: Split the code that stops all music and sound effects --- engines/neverhood/gamemodule.cpp | 2 ++ engines/neverhood/sound.cpp | 36 ++++++++++++++++++++++-------------- engines/neverhood/sound.h | 2 ++ 3 files changed, 26 insertions(+), 14 deletions(-) (limited to 'engines') diff --git a/engines/neverhood/gamemodule.cpp b/engines/neverhood/gamemodule.cpp index 47cc818fea..50c7c503d3 100644 --- a/engines/neverhood/gamemodule.cpp +++ b/engines/neverhood/gamemodule.cpp @@ -411,7 +411,9 @@ void GameModule::checkRequests() { } if (_restoreGameRequested) { _restoreGameRequested = false; + _vm->_audioResourceMan->stopAllMusic(); _vm->_audioResourceMan->stopAllSounds(); + _vm->_soundMan->stopAllMusic(); _vm->_soundMan->stopAllSounds(); delete _childObject; delete _prevChildObject; diff --git a/engines/neverhood/sound.cpp b/engines/neverhood/sound.cpp index c3bc3501b5..1fd09674a2 100644 --- a/engines/neverhood/sound.cpp +++ b/engines/neverhood/sound.cpp @@ -254,9 +254,20 @@ SoundMan::SoundMan(NeverhoodEngine *vm) } SoundMan::~SoundMan() { + stopAllMusic(); stopAllSounds(); } +void SoundMan::stopAllMusic() { + for (uint i = 0; i < _musicItems.size(); ++i) { + if (_musicItems[i]) { + _musicItems[i]->stopMusic(0, 0); + delete _musicItems[i]; + _musicItems[i] = NULL; + } + } +} + void SoundMan::stopAllSounds() { for (uint i = 0; i < _soundItems.size(); ++i) { if (_soundItems[i]) { @@ -265,13 +276,6 @@ void SoundMan::stopAllSounds() { _soundItems[i] = NULL; } } - for (uint i = 0; i < _musicItems.size(); ++i) { - if (_musicItems[i]) { - _musicItems[i]->stopMusic(0, 0); - delete _musicItems[i]; - _musicItems[i] = NULL; - } - } _soundIndex1 = _soundIndex2 = _soundIndex3 = -1; } @@ -724,6 +728,16 @@ AudioResourceMan::AudioResourceMan(NeverhoodEngine *vm) : _vm(vm) { } +void AudioResourceMan::stopAllMusic() { + for (uint i = 0; i < _musicItems.size(); ++i) { + if (_musicItems[i]) { + _musicItems[i]->stopMusic(0); + delete _musicItems[i]; + _musicItems[i] = NULL; + } + } +} + void AudioResourceMan::stopAllSounds() { for (uint i = 0; i < _soundItems.size(); ++i) { if (_soundItems[i]) { @@ -732,16 +746,10 @@ void AudioResourceMan::stopAllSounds() { _soundItems[i] = NULL; } } - for (uint i = 0; i < _musicItems.size(); ++i) { - if (_musicItems[i]) { - _musicItems[i]->stopMusic(0); - delete _musicItems[i]; - _musicItems[i] = NULL; - } - } } AudioResourceMan::~AudioResourceMan() { + stopAllMusic(); stopAllSounds(); } diff --git a/engines/neverhood/sound.h b/engines/neverhood/sound.h index 0733346daa..548fe88501 100644 --- a/engines/neverhood/sound.h +++ b/engines/neverhood/sound.h @@ -129,6 +129,7 @@ public: SoundMan(NeverhoodEngine *vm); ~SoundMan(); + void stopAllMusic(); void stopAllSounds(); // Music @@ -264,6 +265,7 @@ public: AudioResourceMan(NeverhoodEngine *vm); ~AudioResourceMan(); + void stopAllMusic(); void stopAllSounds(); int16 addSound(uint32 fileHash); -- cgit v1.2.3