From 0e9e6cda40ee0bf739e6c7a6320a81307df7c8b9 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 22 Apr 2014 23:00:41 -0400 Subject: MADS: Beginnings of savegame synchronisation --- engines/mads/player.cpp | 72 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 70 insertions(+), 2 deletions(-) (limited to 'engines/mads/player.cpp') diff --git a/engines/mads/player.cpp b/engines/mads/player.cpp index cc482c0608..3b727b397e 100644 --- a/engines/mads/player.cpp +++ b/engines/mads/player.cpp @@ -48,7 +48,7 @@ Player::Player(MADSEngine *vm): _vm(vm) { _priorVisible = false; _needToWalk = false; _readyToWalk = false; - _visible3 = false; + _beenVisible = false; _loadsFirst = false; _loadedFirst = false; _walkAnywhere = false; @@ -337,7 +337,7 @@ void Player::update() { } } - _visible3 = _visible; + _beenVisible |= _visible; _priorVisible = _visible; _forceRefresh = false; } @@ -691,4 +691,72 @@ void Player::releasePlayerSprites() { _spritesChanged = true; } +void Player::synchronize(Common::Serializer &s) { + s.syncAsByte(_visible); + s.syncAsByte(_priorVisible); + s.syncAsByte(_beenVisible); + s.syncAsByte(_moving); + s.syncAsByte(_stepEnabled); + s.syncAsSint16LE(_playerPos.x); + s.syncAsSint16LE(_playerPos.y); + s.syncAsSint16LE(_targetPos.x); + s.syncAsSint16LE(_targetPos.y); + s.syncAsSint16LE(_posChange.x); + s.syncAsSint16LE(_posChange.y); + s.syncAsSint16LE(_posDiff.x); + s.syncAsSint16LE(_posDiff.y); + s.syncAsSint16LE(_xDirection); + s.syncAsSint16LE(_yDirection); + s.syncAsUint16LE(_facing); + s.syncAsUint16LE(_targetFacing); + s.syncAsByte(_spritesChanged); + s.syncAsByte(_walkAnywhere); + s.syncAsByte(_walkOffScreen); + s.syncAsSint16LE(_ticksAmount); + s.syncAsSint16LE(_centerOfGravity); + s.syncAsUint16LE(_walkOffScreenSceneId); + s.syncAsByte(_needToWalk); + s.syncAsByte(_readyToWalk); + s.syncAsUint16LE(_prepareWalkFacing); + s.syncAsSint16LE(_prepareWalkPos.x); + s.syncAsSint16LE(_prepareWalkPos.y); + + s.syncAsByte(_mirror); + s.syncAsUint16LE(_frameCount); + s.syncAsSint16LE(_frameListIndex); + s.syncAsSint16LE(_distAccum); + s.syncAsSint16LE(_pixelAccum); + s.syncAsSint16LE(_deltaDistance); + + for (int i = 0; i < 12; ++i) { + s.syncAsSint16LE(_stopWalkerList[i]); + s.syncAsSint16LE(_stopWalkerTrigger[i]); + } + s.syncAsSint16LE(_stopWalkerIndex); + s.syncAsSint16LE(_totalDistance); + s.syncAsSint16LE(_frameNumber); + s.syncAsSint16LE(_special); + s.syncAsSint16LE(_velocity); + s.syncAsSint16LE(_scalingVelocity); + s.syncAsSint16LE(_upcomingTrigger); + s.syncAsSint16LE(_trigger); + s.syncAsSint16LE(_currentDepth); + s.syncAsSint16LE(_currentScale); + + int count; + char ch; + if (s.isSaving()) { + count = _spritesPrefix.size(); + s.syncAsUint16LE(count); + s.syncBytes((byte *)_spritesPrefix.c_str(), count); + } else { + s.syncAsSint16LE(count); + _spritesPrefix.clear(); + for (int i = 0; i < count; ++i) { + s.syncAsByte(ch); + _spritesPrefix += ch; + } + } +} + } // End of namespace MADS -- cgit v1.2.3