From 85e35943fe27b99a91d97eace3072117c2073f69 Mon Sep 17 00:00:00 2001 From: Colin Snover Date: Wed, 7 Jun 2017 20:59:34 -0500 Subject: SCI32: Implement kLock & kDoAudio(1) for SCI32 1. Unlocking all resources of a type using a resource ID of -1 is gone in SCI32; 2. Audio locks need to be serialized starting in GK2 for the game's modified kDoAudio(1) call; 3. Audio locks in SCI3 must work more like SSCI, since at least Lighthouse's `BackMusic::fade` method will attempt to unlock audio that was never locked by a script. In SSCI (and now in ScummVM too) this is a no-op; previously in ScummVM, it would remove Audio32's own lock on the audio resource, resulting in a use-after-free; 4. kDoAudio(1) starting in GK2 returns the number of active *not-in-memory* channels being played, not the total number of active channels. Fixes Trac#9675. --- engines/sci/engine/savegame.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'engines/sci/engine/savegame.cpp') diff --git a/engines/sci/engine/savegame.cpp b/engines/sci/engine/savegame.cpp index c8e8813470..e0f9ec34db 100644 --- a/engines/sci/engine/savegame.cpp +++ b/engines/sci/engine/savegame.cpp @@ -435,6 +435,10 @@ void EngineState::saveLoadWithSerializer(Common::Serializer &s) { g_sci->_gfxPalette32->saveLoadWithSerializer(s); g_sci->_gfxRemap32->saveLoadWithSerializer(s); g_sci->_gfxCursor32->saveLoadWithSerializer(s); + // TODO: SCI2 should be using Audio32 too, but is not yet. + if (g_sci->_audio32) { + g_sci->_audio32->saveLoadWithSerializer(s); + } g_sci->_video32->saveLoadWithSerializer(s); } else #endif @@ -1017,6 +1021,14 @@ void GfxCursor32::saveLoadWithSerializer(Common::Serializer &s) { } } +void Audio32::saveLoadWithSerializer(Common::Serializer &s) { + if (!g_sci->_features->hasSci3Audio() || s.getVersion() < 44) { + return; + } + + syncArray(s, _lockedResourceIds); +} + void Video32::beforeSaveLoadWithSerializer(Common::Serializer &s) { if (getSciVersion() < SCI_VERSION_3 || s.isSaving()) { return; -- cgit v1.2.3