aboutsummaryrefslogtreecommitdiff
path: root/engines/neverhood
diff options
context:
space:
mode:
authorFilippos Karapetis2013-09-17 03:25:36 +0300
committerFilippos Karapetis2013-09-17 03:27:11 +0300
commitc1226b7d4a305dba7b62b046be4d3fe728a8209d (patch)
treee46dfbeeb0b38cb573f694ce1279b8ee8bc9558b /engines/neverhood
parent5fa6bb238d26b661551e45508b9c3902c85d6d01 (diff)
downloadscummvm-rg350-c1226b7d4a305dba7b62b046be4d3fe728a8209d.tar.gz
scummvm-rg350-c1226b7d4a305dba7b62b046be4d3fe728a8209d.tar.bz2
scummvm-rg350-c1226b7d4a305dba7b62b046be4d3fe728a8209d.zip
NEVERHOOD: Split the code that stops all music and sound effects
Diffstat (limited to 'engines/neverhood')
-rw-r--r--engines/neverhood/gamemodule.cpp2
-rw-r--r--engines/neverhood/sound.cpp36
-rw-r--r--engines/neverhood/sound.h2
3 files changed, 26 insertions, 14 deletions
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);