From dc218d53ef9d9b6de11e26e1b793204d416fc9db Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 7 Nov 2014 22:09:09 -0500 Subject: ACCESS: Merge the sound resource and priority lists --- engines/access/sound.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'engines/access/sound.cpp') diff --git a/engines/access/sound.cpp b/engines/access/sound.cpp index dd8cf16189..075bfc005e 100644 --- a/engines/access/sound.cpp +++ b/engines/access/sound.cpp @@ -44,14 +44,17 @@ SoundManager::~SoundManager() { void SoundManager::clearSounds() { for (uint i = 0; i < _soundTable.size(); ++i) - delete _soundTable[i]; + delete _soundTable[i]._res; _soundTable.clear(); - _soundPriority.clear(); } void SoundManager::queueSound(int idx, int fileNum, int subfile) { - delete _soundTable[idx]; - _soundTable[idx] = _vm->_files->loadFile(fileNum, subfile); + if (idx >= (int)_soundTable.size()) + _soundTable.resize(idx + 1); + + delete _soundTable[idx]._res; + _soundTable[idx]._res = _vm->_files->loadFile(fileNum, subfile); + _soundTable[idx]._priority = 1; } Resource *SoundManager::loadSound(int fileNum, int subfile) { @@ -59,8 +62,8 @@ Resource *SoundManager::loadSound(int fileNum, int subfile) { } void SoundManager::playSound(int soundIndex) { - int priority = _soundPriority[soundIndex]; - playSound(_soundTable[soundIndex], priority); + int priority = _soundTable[soundIndex]._priority; + playSound(_soundTable[soundIndex]._res, priority); } void SoundManager::playSound(Resource *res, int priority) { @@ -76,8 +79,8 @@ void SoundManager::loadSounds(Common::Array &sounds) { clearSounds(); for (uint i = 0; i < sounds.size(); ++i) { - _soundTable.push_back(loadSound(sounds[i]._fileNum, sounds[i]._subfile)); - _soundPriority.push_back(sounds[i]._priority); + Resource *sound = loadSound(sounds[i]._fileNum, sounds[i]._subfile); + _soundTable.push_back(SoundEntry(sound, sounds[i]._priority)); } } -- cgit v1.2.3