From e0db30fb8f0b83ad9f994fb83f9f56982fc171ec Mon Sep 17 00:00:00 2001 From: athrxx Date: Fri, 16 Jul 2021 00:49:47 +0200 Subject: [PATCH] SCUMM: (SCUMM3) - add new walking code vars to save/load function (also recalculate these vars when loading old savegames) --- engines/scumm/actor.cpp | 22 ++++++++++++++++++++++ engines/scumm/saveload.cpp | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/engines/scumm/actor.cpp b/engines/scumm/actor.cpp index aaf78297574..6dc5ca1f4d3 100644 --- a/engines/scumm/actor.cpp +++ b/engines/scumm/actor.cpp @@ -3744,6 +3744,28 @@ void Actor::saveLoadWithSerializer(Common::Serializer &s) { setDirection(_facing); } + + if (_vm->_game.version == 3) { + if (s.isLoading() && s.getVersion() < VER(101)) { + int diffX = _walkdata.next.x - _pos.x; + int diffY = _walkdata.next.y - _pos.y; + _v3stepX = ((ABS(diffY) / (int)_speedy) >> 1) >(ABS(diffX) / (int)_speedx) ? _speedy + 1 : _speedx; + _v3stepThreshold = MAX(ABS(diffY) / _speedy, ABS(diffX) / _v3stepX); + _walkdata.deltaXFactor = (int32)_v3stepX; + if (diffX < 0) + _walkdata.deltaXFactor = -_walkdata.deltaXFactor; + _walkdata.deltaYFactor = (int32)_speedy; + if (diffY < 0) + _walkdata.deltaYFactor = -_walkdata.deltaYFactor; + _walkdata.xfrac = _walkdata.v3XAdd = diffX / _walkdata.deltaXFactor; + _walkdata.yfrac = _walkdata.v3YAdd = diffY / _walkdata.deltaYFactor; + } else { + s.syncAsUint16LE(_walkdata.v3XAdd, VER(101)); + s.syncAsUint16LE(_walkdata.v3YAdd, VER(101)); + s.syncAsUint16LE(_v3stepX, VER(101)); + s.syncAsUint16LE(_v3stepThreshold, VER(101)); + } + } } } // End of namespace Scumm diff --git a/engines/scumm/saveload.cpp b/engines/scumm/saveload.cpp index 4e576e1698d..4dd13977d84 100644 --- a/engines/scumm/saveload.cpp +++ b/engines/scumm/saveload.cpp @@ -68,7 +68,7 @@ struct SaveInfoSection { #define SaveInfoSectionSize (4+4+4 + 4+4 + 4+2) -#define CURRENT_VER 100 +#define CURRENT_VER 101 #define INFOSECTION_VERSION 2 #pragma mark -