diff options
-rw-r--r-- | engines/fullpipe/sound.cpp | 16 | ||||
-rw-r--r-- | engines/fullpipe/sound.h | 8 |
2 files changed, 15 insertions, 9 deletions
diff --git a/engines/fullpipe/sound.cpp b/engines/fullpipe/sound.cpp index 9126fdb7ea..8c71446438 100644 --- a/engines/fullpipe/sound.cpp +++ b/engines/fullpipe/sound.cpp @@ -74,6 +74,18 @@ bool SoundList::loadFile(const char *fname, char *libname) { return load(archive, libname); } +Sound *SoundList::getSoundItemById(int id) { + if (_soundItemsCount == 0) { + return _soundItems[0]->getId() != id ? 0 : _soundItems[0]; + } + + for (int i = 0; i < _soundItemsCount; i++) { + if (_soundItems[i]->getId() == id) + return _soundItems[i]; + } + return NULL; +} + Sound::Sound() { _id = 0; _directSoundBuffer = 0; @@ -301,7 +313,7 @@ void FullpipeEngine::playSound(int id, int flag) { Sound *sound = 0; for (int i = 0; i < _currSoundListCount; i++) { - sound = _currSoundList1[i]->getSoundById(id); + sound = _currSoundList1[i]->getSoundItemById(id); if (sound) break; @@ -383,7 +395,7 @@ void global_messageHandler_handleSound(ExCommand *cmd) { Sound *snd = 0; for (int i = 0; i < g_fp->_currSoundListCount; i++) - snd = g_fp->_currSoundList1[i]->getSoundByIndex(i); + snd = g_fp->_currSoundList1[i]->getSoundItemById(cmd->_messageNum); if (!snd) return; diff --git a/engines/fullpipe/sound.h b/engines/fullpipe/sound.h index 21d9d825a0..14e766f5bb 100644 --- a/engines/fullpipe/sound.h +++ b/engines/fullpipe/sound.h @@ -69,13 +69,7 @@ class SoundList : public CObject { int getCount() { return _soundItemsCount; } Sound *getSoundByIndex(int idx) { return _soundItems[idx]; } - Sound *getSoundById(int id) { - for (int i = 0; i < _soundItemsCount; i++) { - if (_soundItems[i]->getId() == id) - return _soundItems[i]; - } - return NULL; - } + Sound *getSoundItemById(int id); }; } // End of namespace Fullpipe |