AGI: Save screen object loop_flag

loop_flag was previously vt.parm1, which was shared for multiple
uses. Was split up during graphics rewrite in commit
8a595e7771aa89d06876e13d7ab6751e26da8982

Is indirectly part of bug #7046. Saving, restarting ScummVM and
restoring right after grabbing the eagle resulted in the glitch
not happening (which was of course an inaccuracy anyway). This
was caused by AGI currently not saving/restoring the loop_flag.
Needs to get further figured out what's exactly happening
internally and if this issue was just hidden by the shared
vt.parm1 in previous versions. If triggered, it would have
just set another pseudo-random flag on end-of-loop.
This commit is contained in:
Martin Kiewitz 2016-02-19 02:00:03 +01:00
parent c1dacbe65d
commit cca9fc918f
2 changed files with 23 additions and 3 deletions

View File

@ -129,7 +129,7 @@ bool AgiEngine::checkPriority(ScreenObjEntry *screenObj) {
screenPriority = _gfx->getPriority(curX, curY);
if (screenPriority == 0) { // unconditional black. no go at all!
touchedControl = 0;
touchedControl = false;
break;
}

View File

@ -45,7 +45,7 @@
#include "agi/systemui.h"
#include "agi/words.h"
#define SAVEGAME_CURRENT_VERSION 10
#define SAVEGAME_CURRENT_VERSION 11
//
// Version 0 (Sarien): view table has 64 entries
@ -266,6 +266,8 @@ int AgiEngine::saveGame(const Common::String &fileName, const Common::String &de
out->writeByte(screenObj->motionType);
out->writeByte(screenObj->cycle);
// Version 11+: loop_flag, was saved previously under vt.parm1
out->writeByte(screenObj->loop_flag);
out->writeByte(screenObj->priority);
out->writeUint16BE(screenObj->flags);
@ -344,6 +346,7 @@ int AgiEngine::loadGame(const Common::String &fileName, bool checkId) {
int16 parm[7];
Common::InSaveFile *in;
bool totalPlayTimeWasSet = false;
byte oldLoopFlag = 0;
debugC(3, kDebugLevelMain | kDebugLevelSavegame, "AgiEngine::loadGame(%s)", fileName.c_str());
@ -634,6 +637,10 @@ int AgiEngine::loadGame(const Common::String &fileName, bool checkId) {
screenObj->motionType = (MotionType)in->readByte();
screenObj->cycle = (CycleType)in->readByte();
if (saveVersion >= 11) {
// Version 11+: loop_flag, was previously vt.parm1
screenObj->loop_flag = in->readByte();
}
screenObj->priority = in->readByte();
screenObj->flags = in->readUint16BE();
@ -641,7 +648,7 @@ int AgiEngine::loadGame(const Common::String &fileName, bool checkId) {
// this was done so that saved games compatibility isn't broken
switch (screenObj->motionType) {
case kMotionNormal:
in->readByte();
oldLoopFlag = in->readByte();
in->readByte();
in->readByte();
in->readByte();
@ -651,12 +658,14 @@ int AgiEngine::loadGame(const Common::String &fileName, bool checkId) {
in->readByte();
in->readByte();
in->readByte();
oldLoopFlag = screenObj->wander_count;
break;
case kMotionFollowEgo:
screenObj->follow_stepSize = in->readByte();
screenObj->follow_flag = in->readByte();
screenObj->follow_count = in->readByte();
in->readByte();
oldLoopFlag = screenObj->follow_stepSize;
break;
case kMotionEgo:
case kMotionMoveObj:
@ -664,10 +673,21 @@ int AgiEngine::loadGame(const Common::String &fileName, bool checkId) {
screenObj->move_y = in->readByte();
screenObj->move_stepSize = in->readByte();
screenObj->move_flag = in->readByte();
oldLoopFlag = screenObj->move_x;
break;
default:
error("unknown motion-type");
}
if (saveVersion < 11) {
if (saveVersion < 7) {
// Recreate loop_flag from motion-type (was previously vt.parm1)
// vt.parm1 was shared for multiple uses
screenObj->loop_flag = oldLoopFlag;
} else {
// for Version 7-10 we can't really do anything, it was not saved
screenObj->loop_flag = 0; // set it to 0
}
}
}
for (i = vtEntries; i < SCREENOBJECTS_MAX; i++) {
memset(&_game.screenObjTable[i], 0, sizeof(ScreenObjEntry));