SCI: fix regression from c2975276 (fix music handling during auto-save)

This is really a necessary fix, so recommended for merging before the release.

The negative global pause counter (that I really added only for the GMM/autosave situation) may not be used from within kDoSoundPause. It causes issues, the counter will go out of the expected range (also, the "Music also seems to randomly disappear when saving / restoring games" mentioned in ticket no. 13496 might be related to this).

I didn't see this, since we were focussed on SCI0. But it can be easily tested with e. g. LSL1 VGA. Just save right at the start and restore the game, it will call kDoSoundPause and trigger the issue...
This commit is contained in:
athrxx 2022-06-02 01:38:11 +02:00 committed by Filippos Karapetis
parent 03ae234c5e
commit cab7e386f2
2 changed files with 6 additions and 1 deletions

View File

@ -193,6 +193,7 @@ private:
public:
void clearPlayList();
void pauseAll(bool pause);
bool isAllPaused() const { return (_globalPause > 0); }
void resetGlobalPauseCounter();
void stopAll();
void stopAllSamples();

View File

@ -369,7 +369,11 @@ reg_t SoundCommandParser::kDoSoundPause(EngineState *s, int argc, reg_t *argv) {
(_soundVersion < SCI_VERSION_2 && !obj.getSegment()) ||
(_soundVersion >= SCI_VERSION_2 && obj.isNull())
) {
_music->pauseAll(shouldPause);
// Don't unpause here, if the sound is already unpaused. The negative global pause counter
// that we introduced to accomodate our special needs during GMM save/load and autosave
// operations is not meant to be used here and will cause glitches.
if (_music->isAllPaused() || shouldPause)
_music->pauseAll(shouldPause);
#ifdef ENABLE_SCI32
if (_soundVersion >= SCI_VERSION_2_1_EARLY) {
if (shouldPause) {