[Scummvm-cvs-logs] scummvm master -> 4892bd806693693f0d82c4855c57a9745516cab5

m-kiewitz m_kiewitz at users.sourceforge.net
Sat Jan 2 22:43:58 CET 2016


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
4892bd8066 SCI: fix sciAudio not doing loops correctly


Commit: 4892bd806693693f0d82c4855c57a9745516cab5
    https://github.com/scummvm/scummvm/commit/4892bd806693693f0d82c4855c57a9745516cab5
Author: Martin Kiewitz (m_kiewitz at users.sourceforge.net)
Date: 2016-01-02T22:43:27+01:00

Commit Message:
SCI: fix sciAudio not doing loops correctly

Changed paths:
    engines/sci/sound/audio.cpp



diff --git a/engines/sci/sound/audio.cpp b/engines/sci/sound/audio.cpp
index 8c029cf..7b9a8e0 100644
--- a/engines/sci/sound/audio.cpp
+++ b/engines/sci/sound/audio.cpp
@@ -83,11 +83,20 @@ void AudioPlayer::handleFanmadeSciAudio(reg_t sciAudioObject, SegManager *segMan
 		reg_t fileNameReg = readSelector(segMan, sciAudioObject, kernel->findSelector("fileName"));
 		Common::String fileName = segMan->getString(fileNameReg);
 
-		int16 loopCount = (int16)readSelectorValue(segMan, sciAudioObject, kernel->findSelector("loopCount"));
-		// When loopCount is -1, we treat it as infinite looping, else no looping is done.
-		// This is observed by game scripts, which can set loopCount to all sorts of random values.
+		reg_t loopCountReg = readSelector(segMan, sciAudioObject, kernel->findSelector("loopCount"));
+		Common::String loopCountStr = segMan->getString(loopCountReg);
+		int16 loopCount = atoi(loopCountStr.c_str());
+
 		// Adjust loopCount for ScummVM's LoopingAudioStream semantics
-		loopCount = (loopCount == -1) ? 0 : 1;
+		if (loopCount == -1) {
+			loopCount = 0; // loop endlessly
+		} else if (loopCount >= 0) {
+			// sciAudio loopCount == 0 -> play 1 time  -> ScummVM's loopCount should be 1
+			// sciAudio loopCount == 1 -> play 2 times -> ScummVM's loopCount should be 2
+			loopCount++;
+		} else {
+			loopCount = 1; // play once in case the value makes no sense
+		}
 
 		// Determine sound type
 		Audio::Mixer::SoundType soundType = Audio::Mixer::kSFXSoundType;






More information about the Scummvm-git-logs mailing list