SCUMM: (SCUMM3) - add new walking code vars to save/load function

(also recalculate these vars when loading old savegames)
This commit is contained in:
athrxx 2021-07-16 00:49:47 +02:00
parent 0cd79e1eb1
commit e0db30fb8f
2 changed files with 23 additions and 1 deletions

View File

@ -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

View File

@ -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 -