SCUMM: Moved _inventoryOffset to ScummEngine_v2 and save it.

Fixes bug #2828417: Zak V2: inventory position isn't reset when loading.

svn-id: r42870
This commit is contained in:
Max Horn 2009-07-28 23:19:33 +00:00
parent caacc3a6df
commit eb9600b5e9
5 changed files with 24 additions and 4 deletions

View file

@ -1382,7 +1382,7 @@ void ScummEngine::saveOrLoad(Serializer *s) {
} }
void ScummEngine_v0::saveOrLoad(Serializer *s) { void ScummEngine_v0::saveOrLoad(Serializer *s) {
ScummEngine::saveOrLoad(s); ScummEngine_v2::saveOrLoad(s);
const SaveLoadEntry v0Entrys[] = { const SaveLoadEntry v0Entrys[] = {
MKLINE(ScummEngine_v0, _currentMode, sleByte, VER(78)), MKLINE(ScummEngine_v0, _currentMode, sleByte, VER(78)),
@ -1392,6 +1392,23 @@ void ScummEngine_v0::saveOrLoad(Serializer *s) {
s->saveLoadEntries(this, v0Entrys); s->saveLoadEntries(this, v0Entrys);
} }
void ScummEngine_v2::saveOrLoad(Serializer *s) {
ScummEngine::saveOrLoad(s);
const SaveLoadEntry v2Entrys[] = {
MKLINE(ScummEngine_v2, _inventoryOffset, sleUint16, VER(79)),
MKEND()
};
s->saveLoadEntries(this, v2Entrys);
// In old saves we didn't store _inventoryOffset -> reset it to
// a sane default when loading one of those.
if (s->getVersion() < 79 && s->isLoading()) {
_inventoryOffset = 0;
}
}
void ScummEngine_v5::saveOrLoad(Serializer *s) { void ScummEngine_v5::saveOrLoad(Serializer *s) {
ScummEngine::saveOrLoad(s); ScummEngine::saveOrLoad(s);

View file

@ -50,7 +50,7 @@ namespace Scumm {
* only saves/loads those which are valid for the version of the savegame * only saves/loads those which are valid for the version of the savegame
* which is being loaded/saved currently. * which is being loaded/saved currently.
*/ */
#define CURRENT_VER 78 #define CURRENT_VER 79
/** /**
* An auxillary macro, used to specify savegame versions. We use this instead * An auxillary macro, used to specify savegame versions. We use this instead

View file

@ -217,7 +217,6 @@ ScummEngine::ScummEngine(OSystem *syst, const DetectorResult &dr)
_roomResource = 0; _roomResource = 0;
OF_OWNER_ROOM = 0; OF_OWNER_ROOM = 0;
_verbMouseOver = 0; _verbMouseOver = 0;
_inventoryOffset = 0;
_classData = NULL; _classData = NULL;
_actorToPrintStrFor = 0; _actorToPrintStrFor = 0;
_sentenceNum = 0; _sentenceNum = 0;
@ -649,6 +648,8 @@ ScummEngine_v3old::ScummEngine_v3old(OSystem *syst, const DetectorResult &dr)
ScummEngine_v2::ScummEngine_v2(OSystem *syst, const DetectorResult &dr) ScummEngine_v2::ScummEngine_v2(OSystem *syst, const DetectorResult &dr)
: ScummEngine_v3old(syst, dr) { : ScummEngine_v3old(syst, dr) {
_inventoryOffset = 0;
_activeInventory = 0; _activeInventory = 0;
_activeObject = 0; _activeObject = 0;
_activeVerb = 0; _activeVerb = 0;

View file

@ -889,7 +889,6 @@ protected:
protected: protected:
/* Should be in Verb class */ /* Should be in Verb class */
uint16 _verbMouseOver; uint16 _verbMouseOver;
int _inventoryOffset;
int8 _userPut; int8 _userPut;
uint16 _userState; uint16 _userState;

View file

@ -45,6 +45,7 @@ protected:
int8 _mouseOverBoxV2; int8 _mouseOverBoxV2;
char _sentenceBuf[256]; char _sentenceBuf[256];
uint16 _inventoryOffset;
int _activeInventory; int _activeInventory;
int _activeObject; int _activeObject;
@ -66,6 +67,8 @@ protected:
virtual void resetScummVars(); virtual void resetScummVars();
virtual void decodeParseString(); virtual void decodeParseString();
virtual void saveOrLoad(Serializer *s);
virtual void processKeyboard(Common::KeyState lastKeyHit); virtual void processKeyboard(Common::KeyState lastKeyHit);
virtual void readIndexFile(); virtual void readIndexFile();