From 8d3b27293965ea17a4a34a1258688f9eeb3410d1 Mon Sep 17 00:00:00 2001 From: Tobias Gunkel Date: Sat, 4 Feb 2012 17:35:59 +0100 Subject: [PATCH] SCUMM: save complete v0 state and initialize actors correctly --- engines/scumm/actor.cpp | 19 +++++++++++++++++-- engines/scumm/actor.h | 27 ++++++--------------------- engines/scumm/saveload.cpp | 12 +++++++++++- engines/scumm/saveload.h | 2 +- 4 files changed, 35 insertions(+), 25 deletions(-) diff --git a/engines/scumm/actor.cpp b/engines/scumm/actor.cpp index f58d3fde4ed..59c41103482 100644 --- a/engines/scumm/actor.cpp +++ b/engines/scumm/actor.cpp @@ -175,6 +175,21 @@ void Actor_v2::initActor(int mode) { _talkStopFrame = 4; } +void ActorC64::initActor(int mode) { + Actor_v2::initActor(mode); + + _costCommandNew = 0xFF; + _costCommand = 0xFF; + _miscflags = 0; + _speaking = 0; + + _animFrameRepeat = 0; + for(int i = 0; i < 8; ++i) { + _limbFrameRepeatNew[i] = 0; + _limbFrameRepeat[i] = 0; + _limb_flipped[i] = false; + } +} void Actor::setBox(int box) { _walkbox = box; @@ -2812,11 +2827,11 @@ void ActorC64::saveLoadWithSerializer(Serializer *ser) { static const SaveLoadEntry actorEntries[] = { MKLINE(ActorC64, _costCommand, sleByte, VER(84)), - MKLINE_OLD(ActorC64, _costFrame, sleByte, VER(84), VER(89)), + MK_OBSOLETE(ActorC64, _costFrame, sleByte, VER(84), VER(89)), MKLINE(ActorC64, _miscflags, sleByte, VER(84)), MKLINE(ActorC64, _speaking, sleByte, VER(84)), MK_OBSOLETE(ActorC64, _speakingPrev, sleByte, VER(84), VER(89)), - MK_OBSOLETE(ActorC64, _byte_FD0A, sleByte, VER(89), VER(89)), + MK_OBSOLETE(ActorC64, _limbTemp, sleByte, VER(89), VER(89)), MKLINE(ActorC64, _animFrameRepeat, sleByte, VER(89)), MKARRAY(ActorC64, _limbFrameRepeatNew[0], sleInt8, 8, VER(89)), MKARRAY(ActorC64, _limbFrameRepeat[0], sleInt8, 8, VER(90)), diff --git a/engines/scumm/actor.h b/engines/scumm/actor.h index c2ffcf12751..9e4955c0794 100644 --- a/engines/scumm/actor.h +++ b/engines/scumm/actor.h @@ -348,36 +348,21 @@ enum ActorC64MiscFlags { class ActorC64 : public Actor_v2 { public: - byte _costCommandNew, _costCommand, _costFrame; + byte _costCommandNew; + byte _costCommand; byte _miscflags; byte _speaking; int8 _animFrameRepeat; - int8 _limbFrameRepeatNew[8], _limbFrameRepeat[8]; + int8 _limbFrameRepeatNew[8]; + int8 _limbFrameRepeat[8]; bool _limb_flipped[8]; public: - ActorC64(ScummEngine *scumm, int id) : Actor_v2(scumm, id) { - _costCommand = 0xFF; - _speaking = 0; - _animFrameRepeat = 0; - _costCommandNew = 0xFF; - - for(int i = 0; i < 8; ++i) { - _limbFrameRepeatNew[i] = 0; - _limbFrameRepeat[i] = 0; - _limb_flipped[i] = false; - } - } - - virtual void initActor(int mode) { - Actor_v2::initActor(mode); - if (mode == -1) { - _miscflags = 0; - } - } + ActorC64(ScummEngine *scumm, int id) : Actor_v2(scumm, id) {} + virtual void initActor(int mode); virtual void animateActor(int anim); virtual void animateCostume(); diff --git a/engines/scumm/saveload.cpp b/engines/scumm/saveload.cpp index a1b2fafa86b..6e543771994 100644 --- a/engines/scumm/saveload.cpp +++ b/engines/scumm/saveload.cpp @@ -1210,10 +1210,12 @@ void ScummEngine::saveOrLoad(Serializer *s) { // Since roughly v13 of the save games, the objs storage has changed a bit for (i = _numObjectsInRoom; i < _numLocalObjects; i++) _objs[i].obj_nr = 0; - } else if (_game.version == 0) { // TODO: handle this correctly + } else if (_game.version == 0 && s->getVersion() < VER(91)) { for (i = 0; i < _numLocalObjects; i++) { + // Merge object id and type (previously stored in flags) if (_objs[i].obj_nr != 0 && OBJECT_V0_TYPE(_objs[i].obj_nr) == 0 && _objs[i].flags != 0) _objs[i].obj_nr = OBJECT_V0(_objs[i].obj_nr, _objs[i].flags); + _objs[i].flags = 0; } } } @@ -1502,6 +1504,14 @@ void ScummEngine_v0::saveOrLoad(Serializer *s) { const SaveLoadEntry v0Entrys[] = { MKLINE(ScummEngine_v0, _currentMode, sleByte, VER(78)), MKLINE(ScummEngine_v0, _currentLights, sleByte, VER(78)), + MKLINE(ScummEngine_v0, _activeVerb, sleByte, VER(92)), + MKLINE(ScummEngine_v0, _activeObject, sleUint16, VER(92)), + MKLINE(ScummEngine_v0, _activeObject2, sleUint16, VER(92)), + MKLINE(ScummEngine_v0, _cmdVerb, sleByte, VER(92)), + MKLINE(ScummEngine_v0, _cmdObject, sleUint16, VER(92)), + MKLINE(ScummEngine_v0, _cmdObject2, sleUint16, VER(92)), + MKLINE(ScummEngine_v0, _walkToObject, sleUint16, VER(92)), + MKLINE(ScummEngine_v0, _walkToObjectState, sleByte, VER(92)), MKEND() }; s->saveLoadEntries(this, v0Entrys); diff --git a/engines/scumm/saveload.h b/engines/scumm/saveload.h index a316670e3d2..90feee6dc0c 100644 --- a/engines/scumm/saveload.h +++ b/engines/scumm/saveload.h @@ -47,7 +47,7 @@ namespace Scumm { * only saves/loads those which are valid for the version of the savegame * which is being loaded/saved currently. */ -#define CURRENT_VER 91 +#define CURRENT_VER 92 /** * An auxillary macro, used to specify savegame versions. We use this instead