diff options
author | Thierry Crozat | 2013-10-05 00:24:30 +0100 |
---|---|---|
committer | Thierry Crozat | 2013-10-05 00:25:04 +0100 |
commit | cdbee9972aca6da04ff8a1d0b564e8758782f9fb (patch) | |
tree | 18b5a3222170f16a559ab7851837131d6e657f50 /engines/sword25/sfx/soundengine.cpp | |
parent | f55259e3b103d5aa966b00fb5c574d84a4f399c0 (diff) | |
download | scummvm-rg350-cdbee9972aca6da04ff8a1d0b564e8758782f9fb.tar.gz scummvm-rg350-cdbee9972aca6da04ff8a1d0b564e8758782f9fb.tar.bz2 scummvm-rg350-cdbee9972aca6da04ff8a1d0b564e8758782f9fb.zip |
SWORD25: Fix possible error in sound engine when loading a savegame
The error occurred when the save game was saved early in the game
before all the sound handles had been used. The unused handles only had
the handle type initialised (as kFreeHandle) so all the other fields had
random values. After loading the game the sound engine could erroneously
try to play one of these sound handle resulting in an error.
Diffstat (limited to 'engines/sword25/sfx/soundengine.cpp')
-rw-r--r-- | engines/sword25/sfx/soundengine.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/engines/sword25/sfx/soundengine.cpp b/engines/sword25/sfx/soundengine.cpp index d90849e449..8ff1b0cf2a 100644 --- a/engines/sword25/sfx/soundengine.cpp +++ b/engines/sword25/sfx/soundengine.cpp @@ -339,7 +339,10 @@ bool SoundEngine::persist(OutputPersistenceBlock &writer) { _handles[i].type = kFreeHandle; writer.writeString(_handles[i].fileName); - writer.write(_handles[i].sndType); + if (_handles[i].type == kFreeHandle) + writer.write((int32)-1); + else + writer.write(_handles[i].sndType); writer.write(_handles[i].volume); writer.write(_handles[i].pan); writer.write(_handles[i].loop); @@ -381,7 +384,7 @@ bool SoundEngine::unpersist(InputPersistenceBlock &reader) { reader.read(layer); if (reader.isGood()) { - if (sndType != kFreeHandle) + if (sndType != -1) playSoundEx(fileName, (SOUND_TYPES)sndType, volume, pan, loop, loopStart, loopEnd, layer, i); } else return false; |