diff options
author | Eugene Sandulenko | 2014-04-26 21:58:20 +0300 |
---|---|---|
committer | Eugene Sandulenko | 2014-04-26 21:58:20 +0300 |
commit | 64800b2ac286d5aebc3ae16b60f651cf92db35b6 (patch) | |
tree | cd40c4c799c0d4b08866f0d7fc293c6ac584a09f | |
parent | 533b4accb2a9eb7d421b973ac196f602618906eb (diff) | |
download | scummvm-rg350-64800b2ac286d5aebc3ae16b60f651cf92db35b6.tar.gz scummvm-rg350-64800b2ac286d5aebc3ae16b60f651cf92db35b6.tar.bz2 scummvm-rg350-64800b2ac286d5aebc3ae16b60f651cf92db35b6.zip |
FULLPIPE: Implement SoundList::getSoundItemById()
-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 |