[Scummvm-git-logs] scummvm master -> 77a348de7e1a08a63059597f09814cfb32c0d5ae

athrxx noreply at scummvm.org
Thu Feb 29 11:54:30 UTC 2024


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:
77a348de7e SCUMM: (MI1/Mac) - fix save/load code


Commit: 77a348de7e1a08a63059597f09814cfb32c0d5ae
    https://github.com/scummvm/scummvm/commit/77a348de7e1a08a63059597f09814cfb32c0d5ae
Author: athrxx (athrxx at scummvm.org)
Date: 2024-02-29T12:53:41+01:00

Commit Message:
SCUMM: (MI1/Mac) - fix save/load code

(broken by recent Loom changes)
I am not making any version changes here, since the
breaking commit is only 14 hours old...

Also add compatibility check for very old savegames to
new player.

Changed paths:
    engines/scumm/players/player_mac.cpp
    engines/scumm/players/player_mac.h
    engines/scumm/players/player_mac_loom.cpp
    engines/scumm/players/player_v3m.cpp


diff --git a/engines/scumm/players/player_mac.cpp b/engines/scumm/players/player_mac.cpp
index bb0aa54e363..514277f8718 100644
--- a/engines/scumm/players/player_mac.cpp
+++ b/engines/scumm/players/player_mac.cpp
@@ -35,7 +35,8 @@ Player_Mac::Player_Mac(ScummEngine *scumm, Audio::Mixer *mixer, int numberOfChan
 	  _soundPlaying(-1),
 	  _numberOfChannels(numberOfChannels),
 	  _channelMask(channelMask),
-	  _fadeNoteEnds(fadeNoteEnds) {
+	  _fadeNoteEnds(fadeNoteEnds),
+	  _lastVersionBeforeSaveFormatChange(Common::Serializer::kLastVersion) {
 	assert(scumm);
 	assert(mixer);
 }
@@ -119,7 +120,7 @@ void Player_Mac::saveLoadWithSerializer(Common::Serializer &s) {
 		uint32 mixerSampleRate = _sampleRate;
 		int i;
 
-		if (s.getVersion() > VER(113)) {
+		if (s.getVersion() > _lastVersionBeforeSaveFormatChange) {
 			if (s.isLoading())
 				warning ("Player_Mac::saveLoadWithSerializer(): Incompatible savegame version. Sound may glitch");
 			byte tmp[200];
@@ -131,8 +132,8 @@ void Player_Mac::saveLoadWithSerializer(Common::Serializer &s) {
 			}
 		}
 
-		s.syncAsUint32LE(_sampleRate, VER(94), VER(113));
-		s.syncAsSint16LE(_soundPlaying, VER(94), VER(113));
+		s.syncAsUint32LE(_sampleRate, VER(94), _lastVersionBeforeSaveFormatChange);
+		s.syncAsSint16LE(_soundPlaying, VER(94), _lastVersionBeforeSaveFormatChange);
 
 		if (s.isLoading() && _soundPlaying != -1) {
 			const byte *ptr = _vm->getResourceAddress(rtSound, _soundPlaying);
@@ -140,7 +141,7 @@ void Player_Mac::saveLoadWithSerializer(Common::Serializer &s) {
 			loadMusic(ptr);
 		}
 
-		s.syncArray(_channel, _numberOfChannels, syncWithSerializer, VER(94), VER(113));
+		s.syncArray(_channel, _numberOfChannels, syncWithSerializer, VER(94), _lastVersionBeforeSaveFormatChange);
 		for (i = 0; i < _numberOfChannels; i++) {
 			if (s.getVersion() >= VER(94) && s.getVersion() <= VER(103)) {
 				// It was always the intention to save the instrument entries
@@ -151,7 +152,7 @@ void Player_Mac::saveLoadWithSerializer(Common::Serializer &s) {
 
 				_channel[i]._instrument._pos = 0;
 				_channel[i]._instrument._subPos = 0;
-			} else if (s.getVersion() < VER(114)) {
+			} else if (s.getVersion() <= _lastVersionBeforeSaveFormatChange) {
 				syncWithSerializer(s, _channel[i]._instrument);
 			}
 		}
diff --git a/engines/scumm/players/player_mac.h b/engines/scumm/players/player_mac.h
index da7e2ae0eff..40e196d5785 100644
--- a/engines/scumm/players/player_mac.h
+++ b/engines/scumm/players/player_mac.h
@@ -124,6 +124,8 @@ protected:
 	Common::Path _instrumentFile;
 	Channel *_channel;
 
+	uint32 _lastVersionBeforeSaveFormatChange;
+
 	uint32 durationToSamples(uint16 duration);
 	int noteToPitchModifier(byte note, Instrument *instrument);
 	void overrideChannelMask(int newMask);
diff --git a/engines/scumm/players/player_mac_loom.cpp b/engines/scumm/players/player_mac_loom.cpp
index 0b79ca53dab..318e1f04447 100644
--- a/engines/scumm/players/player_mac_loom.cpp
+++ b/engines/scumm/players/player_mac_loom.cpp
@@ -221,6 +221,12 @@ void LoomMacSnd::setQuality(int qual) {
 }
 
 void LoomMacSnd::saveLoadWithSerializer(Common::Serializer &ser) {
+	if (ser.isLoading() && ser.getVersion() < VER(94)) {
+		memset(_soundUsage, 0, _idRangeMax);
+		_curSound = 0;
+		return;
+	}
+
 	if (ser.isLoading() && ser.getVersion() < VER(114)) {
 		memset(_soundUsage, 0, _idRangeMax);
 		// Skip over old driver savedata, since it is not needed here.
diff --git a/engines/scumm/players/player_v3m.cpp b/engines/scumm/players/player_v3m.cpp
index ea617a10430..069d4911d58 100644
--- a/engines/scumm/players/player_v3m.cpp
+++ b/engines/scumm/players/player_v3m.cpp
@@ -98,6 +98,7 @@ namespace Scumm {
 Player_V3M::Player_V3M(ScummEngine *scumm, Audio::Mixer *mixer, bool lowQuality)
 	: Player_Mac(scumm, mixer, 5, lowQuality ? 01 : 0x1E, true) {
 	assert(_vm->_game.id == GID_LOOM);
+	_lastVersionBeforeSaveFormatChange = VER(113);
 
 	// This is guesswork, but there are five music channels.
 	//




More information about the Scummvm-git-logs mailing list