Initialize and save zones flags and follower position when a location switch occurs.

svn-id: r39064
This commit is contained in:
Nicola Mettifogo 2009-03-02 08:36:42 +00:00
parent da6315bb4c
commit 33a8fe7a7e
5 changed files with 81 additions and 16 deletions

View File

@ -233,6 +233,11 @@ struct DoorData {
DoorData() {
_location = NULL;
_startFrame = 0;
_startPos.x = -1000;
_startPos.y = -1000;
_startFrame2 = 0;
_startPos2.x = -1000;
_startPos2.y = -1000;
gfxobj = NULL;
}
};
@ -316,6 +321,7 @@ public:
// BRA specific
uint _index;
uint _locationIndex;
char *_linkedName;
AnimationPtr _linkedAnim;

View File

@ -496,6 +496,7 @@ public:
void clearSubtitles();
void testCounterCondition(const Common::String &name, int op, int value);
void restoreOrSaveZoneFlags(ZonePtr z, bool restore);
public:
bool counterExists(const Common::String &name);

View File

@ -87,6 +87,8 @@ Common::Error Parallaction_br::init() {
_subtitle[0] = -1;
_subtitle[1] = -1;
memset(_zoneFlags, 0, sizeof(_zoneFlags));
_countersNames = 0;
_saveLoad = new SaveLoad_br(this, _saveFileMan);
@ -453,4 +455,12 @@ void Parallaction_br::setFollower(const Common::String &name) {
}
}
void Parallaction_br::restoreOrSaveZoneFlags(ZonePtr z, bool restore) {
if (restore) {
z->_flags = _zoneFlags[z->_locationIndex][z->_index];
} else {
_zoneFlags[z->_locationIndex][z->_index] = z->_flags;
}
}
} // namespace Parallaction

View File

@ -308,6 +308,7 @@ protected:
virtual void parseZoneTypeBlock(ZonePtr z);
void parsePathData(ZonePtr z);
void parseGetData(ZonePtr z);
void parseDoorData(ZonePtr z);
void parseAnswerCounter(Answer *answer);
virtual Answer *parseAnswer();

View File

@ -343,37 +343,35 @@ DECLARE_LOCATION_PARSER(location) {
_vm->_disk->loadScenery(*ctxt.info, _tokens[1], 0, 0);
}
DECLARE_LOCATION_PARSER(zone) {
debugC(7, kDebugParser, "LOCATION_PARSER(zone) ");
ctxt.z.reset();
parseZone(_vm->_location._zones, _tokens[1]);
ctxt.z->_index = ctxt.numZones++;
if (_vm->getLocationFlags() & kFlagsVisited) {
ctxt.z->_flags = _vm->_zoneFlags[_vm->_currentLocationIndex][ctxt.z->_index];
} else {
_vm->_zoneFlags[_vm->_currentLocationIndex][ctxt.z->_index] = ctxt.z->_flags;
if (!ctxt.z) {
return;
}
ctxt.z->_index = ctxt.numZones++;
ctxt.z->_locationIndex = _vm->_currentLocationIndex;
_vm->restoreOrSaveZoneFlags(ctxt.z, _vm->getLocationFlags() & kFlagsVisited);
}
DECLARE_LOCATION_PARSER(animation) {
debugC(7, kDebugParser, "LOCATION_PARSER(animation) ");
ctxt.a.reset();
parseAnimation(_vm->_location._animations, _tokens[1]);
ctxt.a->_index = ctxt.numZones++;
if (_vm->getLocationFlags() & kFlagsVisited) {
ctxt.a->_flags = _vm->_zoneFlags[_vm->_currentLocationIndex][ctxt.a->_index];
} else {
_vm->_zoneFlags[_vm->_currentLocationIndex][ctxt.a->_index] = ctxt.a->_flags;
if (!ctxt.a) {
return;
}
ctxt.a->_index = ctxt.numZones++;
ctxt.a->_locationIndex = _vm->_currentLocationIndex;
_vm->restoreOrSaveZoneFlags(ctxt.a, _vm->getLocationFlags() & kFlagsVisited);
}
@ -808,6 +806,55 @@ void LocationParser_br::parseGetData(ZonePtr z) {
z->u.get = data;
}
void LocationParser_br::parseDoorData(ZonePtr z) {
DoorData *data = new DoorData;
do {
if (!scumm_stricmp(_tokens[0], "slidetext")) {
strcpy(_vm->_location._slideText[0], _tokens[1]);
// printf("%s\t", _slideText[0]);
strcpy(_vm->_location._slideText[1], _tokens[2]);
}
if (!scumm_stricmp(_tokens[0], "location")) {
data->_location = strdup(_tokens[1]);
}
if (!scumm_stricmp(_tokens[0], "file")) {
// printf("file: '%s'", _tokens[0]);
uint16 frame = (z->_flags & kFlagsClosed ? 0 : 1);
GfxObj *obj = _vm->_gfx->loadDoor(_tokens[1]);
obj->frame = frame;
obj->x = z->getX();
obj->y = z->getY();
_vm->_gfx->showGfxObj(obj, true);
data->gfxobj = obj;
}
if (!scumm_stricmp(_tokens[0], "startpos")) {
data->_startPos.x = atoi(_tokens[1]);
data->_startPos.y = atoi(_tokens[2]);
data->_startFrame = atoi(_tokens[3]);
}
if (!scumm_stricmp(_tokens[0], "startpos2")) {
data->_startPos2.x = atoi(_tokens[1]);
data->_startPos2.y = atoi(_tokens[2]);
data->_startFrame2 = atoi(_tokens[3]);
}
_script->readLineToken(true);
} while (scumm_stricmp(_tokens[0], "endzone") && scumm_stricmp(_tokens[0], "endanimation"));
z->u.door = data;
}
void LocationParser_br::parseZoneTypeBlock(ZonePtr z) {
debugC(7, kDebugParser, "parseZoneTypeBlock(name: %s, type: %x)", z->_name, z->_type);