Skip to content

Commit

Permalink
NEVERHOOD: Delete all sound/music items on exit
Browse files Browse the repository at this point in the history
- Minor cleanup
  • Loading branch information
johndoe123 authored and wjp committed May 8, 2013
1 parent c96d247 commit 70fdfd9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
1 change: 0 additions & 1 deletion engines/neverhood/menumodule.cpp
Expand Up @@ -178,7 +178,6 @@ void MenuModule::updateScene() {
}

uint32 MenuModule::handleMessage(int messageNum, const MessageParam &param, Entity *sender) {
// TODO CHECKME Handles 0x101F, possibly just a debug/cache message which can be ignored?
return Module::handleMessage(messageNum, param, sender);;
}

Expand Down
22 changes: 13 additions & 9 deletions engines/neverhood/sound.cpp
Expand Up @@ -233,21 +233,18 @@ void SoundItem::setVolume(int volume) {

void SoundItem::update() {
if (_playOnceAfterCountdown) {
if (_currCountdown == 0) {
if (_currCountdown == 0)
_currCountdown = _initialCountdown;
} else if (--_currCountdown == 0) {
else if (--_currCountdown == 0)
_soundResource->play();
}
} else if (_playOnceAfterRandomCountdown) {
if (_currCountdown == 0) {
if (_minCountdown > 0 && _maxCountdown > 0 && _minCountdown < _maxCountdown)
_currCountdown = _vm->_rnd->getRandomNumberRng(_minCountdown, _maxCountdown);
} else if (--_currCountdown == 0) {
} else if (--_currCountdown == 0)
_soundResource->play();
}
} else if (_playLooping && !_soundResource->isPlaying()) {
_soundResource->play(); // TODO Looping parameter?
}
} else if (_playLooping && !_soundResource->isPlaying())
_soundResource->play();
}

// SoundMan
Expand All @@ -257,7 +254,10 @@ SoundMan::SoundMan(NeverhoodEngine *vm)
}

SoundMan::~SoundMan() {
// TODO Clean up
for (uint i = 0; i < _soundItems.size(); ++i)
delete _soundItems[i];
for (uint i = 0; i < _musicItems.size(); ++i)
delete _musicItems[i];
}

void SoundMan::addMusic(uint32 groupNameHash, uint32 musicFileHash) {
Expand Down Expand Up @@ -709,6 +709,10 @@ AudioResourceMan::AudioResourceMan(NeverhoodEngine *vm)
}

AudioResourceMan::~AudioResourceMan() {
for (uint i = 0; i < _soundItems.size(); ++i)
delete _soundItems[i];
for (uint i = 0; i < _musicItems.size(); ++i)
delete _musicItems[i];
}

int16 AudioResourceMan::addSound(uint32 fileHash) {
Expand Down

0 comments on commit 70fdfd9

Please sign in to comment.