aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicola Mettifogo2009-03-02 08:36:42 +0000
committerNicola Mettifogo2009-03-02 08:36:42 +0000
commit33a8fe7a7e596b13b05e091c52a0f1a2d5296394 (patch)
tree3b8353a62a615b0a931f1a58965e3747b84332a2
parentda6315bb4c0b93cfd60dbb0ad2117caa530116e7 (diff)
downloadscummvm-rg350-33a8fe7a7e596b13b05e091c52a0f1a2d5296394.tar.gz
scummvm-rg350-33a8fe7a7e596b13b05e091c52a0f1a2d5296394.tar.bz2
scummvm-rg350-33a8fe7a7e596b13b05e091c52a0f1a2d5296394.zip
Initialize and save zones flags and follower position when a location switch occurs.
svn-id: r39064
-rw-r--r--engines/parallaction/objects.h6
-rw-r--r--engines/parallaction/parallaction.h1
-rw-r--r--engines/parallaction/parallaction_br.cpp10
-rw-r--r--engines/parallaction/parser.h1
-rw-r--r--engines/parallaction/parser_br.cpp75
5 files changed, 79 insertions, 14 deletions
diff --git a/engines/parallaction/objects.h b/engines/parallaction/objects.h
index 7d09663a47..60c854661e 100644
--- a/engines/parallaction/objects.h
+++ b/engines/parallaction/objects.h
@@ -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;
diff --git a/engines/parallaction/parallaction.h b/engines/parallaction/parallaction.h
index 05aa0bc3f4..47b530ce10 100644
--- a/engines/parallaction/parallaction.h
+++ b/engines/parallaction/parallaction.h
@@ -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);
diff --git a/engines/parallaction/parallaction_br.cpp b/engines/parallaction/parallaction_br.cpp
index 3b6d36f017..24fbc1018e 100644
--- a/engines/parallaction/parallaction_br.cpp
+++ b/engines/parallaction/parallaction_br.cpp
@@ -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
diff --git a/engines/parallaction/parser.h b/engines/parallaction/parser.h
index eb0ee71648..5c47d0828e 100644
--- a/engines/parallaction/parser.h
+++ b/engines/parallaction/parser.h
@@ -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();
diff --git a/engines/parallaction/parser_br.cpp b/engines/parallaction/parser_br.cpp
index 529d87b953..37084833a8 100644
--- a/engines/parallaction/parser_br.cpp
+++ b/engines/parallaction/parser_br.cpp
@@ -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]);
+ if (!ctxt.z) {
+ return;
+ }
ctxt.z->_index = ctxt.numZones++;
+ ctxt.z->_locationIndex = _vm->_currentLocationIndex;
- 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;
- }
-
+ _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]);
+ if (!ctxt.a) {
+ return;
+ }
ctxt.a->_index = ctxt.numZones++;
+ ctxt.a->_locationIndex = _vm->_currentLocationIndex;
- 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;
- }
-
+ _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);