aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/resource_audio.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/sci/resource_audio.cpp')
-rw-r--r--engines/sci/resource_audio.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/engines/sci/resource_audio.cpp b/engines/sci/resource_audio.cpp
index f3a3c8dd5b..a3cf1b0c84 100644
--- a/engines/sci/resource_audio.cpp
+++ b/engines/sci/resource_audio.cpp
@@ -915,18 +915,23 @@ bool ResourceManager::addAudioSources() {
void ResourceManager::changeAudioDirectory(Common::String path) {
// Remove all of the audio map resource sources, as well as the audio resource sources
- for (Common::List<ResourceSource *>::iterator it = _sources.begin(); it != _sources.end(); ++it) {
+ for (Common::List<ResourceSource *>::iterator it = _sources.begin(); it != _sources.end();) {
ResourceSource *source = *it;
ResSourceType sourceType = source->getSourceType();
// Remove the resource source, if it's an audio map or an audio file
if (sourceType == kSourceIntMap || sourceType == kSourceAudioVolume) {
// Don't remove 65535.map (the SFX map) or resource.sfx
- if (source->_volumeNumber == 65535 || source->getLocationName() == "RESOURCE.SFX")
+ if (source->_volumeNumber == 65535 || source->getLocationName() == "RESOURCE.SFX") {
+ ++it;
continue;
+ }
+ // erase() will move the iterator to the next element
it = _sources.erase(it);
delete source;
+ } else {
+ ++it;
}
}