Skip to content

Commit

Permalink
SCUMM: save complete v0 state and initialize actors correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
tobigun committed Feb 11, 2012
1 parent 5d3e1dd commit 8d3b272
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 25 deletions.
19 changes: 17 additions & 2 deletions engines/scumm/actor.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -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)),
Expand Down
27 changes: 6 additions & 21 deletions engines/scumm/actor.h
Expand Up @@ -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();

Expand Down
12 changes: 11 additions & 1 deletion engines/scumm/saveload.cpp
Expand Up @@ -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;
}
}
}
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion engines/scumm/saveload.h
Expand Up @@ -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
Expand Down

0 comments on commit 8d3b272

Please sign in to comment.