(Re)link bounding animations after location has been completely parsed. This avoids problems due to forward references.

svn-id: r39740
This commit is contained in:
Nicola Mettifogo 2009-03-29 13:56:16 +00:00
parent 340b0e632e
commit 666f0720ab
6 changed files with 13 additions and 13 deletions

View File

@ -115,14 +115,11 @@ void Parallaction_br::clearSubtitles() {
DECLARE_COMMAND_OPCODE(location) {
warning("Parallaction_br::cmdOp_location command not yet implemented");
_vm->_location._startPosition = ctxt._cmd->_startPos;
_vm->_location._startFrame = 0; // TODO: verify this against the disassembly!f
_vm->_location._startFrame = 0;
_vm->_location._followerStartPosition = ctxt._cmd->_startPos2;
_vm->_location._followerStartFrame = 0;
// TODO: handle startPos and startPos2
_vm->scheduleLocationSwitch(ctxt._cmd->_string);
}

View File

@ -201,13 +201,9 @@ Zone::Zone() {
// BRA specific
_index = INVALID_ZONE_INDEX;
_locationIndex = INVALID_LOCATION_INDEX;
_linkedName = 0;
}
Zone::~Zone() {
// printf("~Zone(%s)\n", _name);
free(_linkedName);
}
void Zone::translate(int16 x, int16 y) {

View File

@ -281,7 +281,7 @@ public:
// BRA specific
uint _index;
uint _locationIndex;
char *_linkedName;
Common::String _linkedName;
AnimationPtr _linkedAnim;
Zone();

View File

@ -728,7 +728,9 @@ bool Parallaction::checkLinkedAnimBox(ZonePtr z, uint32 type, uint x, uint y) {
if (z->_flags & kFlagsRemove)
return false;
if ((z->_flags & kFlagsAnimLinked) == 0)
// flag kFlagsAnimLinked may be on, but the animation may not be loaded, so
// we must use the animation reference to check here
if (!z->_linkedAnim)
return false;
debugC(5, kDebugExec, "checkLinkedAnimBox for %s (type = %x, x = %i, y = %i)", z->_name, type, x, y);

View File

@ -360,8 +360,14 @@ void Parallaction_br::parseLocation(const char *filename) {
ZoneList::iterator zit = _vm->_location._zones.begin();
for ( ; zit != _vm->_location._zones.end(); ++zit) {
ZonePtr z = *zit;
// restore the flags if the location has already been visited
restoreOrSaveZoneFlags(*zit, visited);
restoreOrSaveZoneFlags(z, visited);
// (re)link the bounding animation if needed
if (z->_flags & kFlagsAnimLinked) {
z->_linkedAnim = _location.findAnimation(z->_linkedName.c_str());
}
}
debugC(1, kDebugParser, "parseLocation('%s') done", filename);

View File

@ -717,8 +717,7 @@ DECLARE_ZONE_PARSER(limits) {
if (isalpha(_tokens[1][1])) {
ctxt.z->_flags |= kFlagsAnimLinked;
ctxt.z->_linkedAnim = _vm->_location.findAnimation(_tokens[1]);
ctxt.z->_linkedName = strdup(_tokens[1]);
ctxt.z->_linkedName = _tokens[1];
} else {
ctxt.z->setRect(atoi(_tokens[1]), atoi(_tokens[2]), atoi(_tokens[3]), atoi(_tokens[4]));
}