Fix (I hope) for bug #1032964 (INDY3-VGA: actors walking in wrong places)

svn-id: r15335
This commit is contained in:
Max Horn 2004-09-28 23:05:45 +00:00
parent 21d2a6ec55
commit ad3062ab93
3 changed files with 40 additions and 35 deletions

View file

@ -1663,6 +1663,12 @@ void Actor::walkActorOld() {
break;
next_box = _vm->getPathToDestBox(_walkbox, walkdata.destbox);
// WORKAROUND: To fully fix bug #774783, we add a special case
// here, resulting in a different next_box value for Hitler.
if ((_vm->_gameId == GID_INDY3) && _vm->_roomResource == 46 && _walkbox == 1 && walkdata.destbox == 0 && number == 9)
next_box = 1;
if (next_box < 0) {
moving |= MF_LAST_LEG;
return;
@ -1701,18 +1707,11 @@ void Actor::walkActorOld() {
if (calcMovementFactor(p3))
return;
// FIXME: Fingolfin changed the destbox to curbox, matching walkActor.
// Motivation for this was comparision with some MI EGA disasm...
// However, that caused a regression in Indy3 (bug #809547).
// On the other hand, curbox is needed to fix bug #830106... <sigh>
if (_vm->_version >= 3)
setBox(walkdata.destbox);
else
setBox(walkdata.curbox);
// FIXME: Ender added this recursion counter as a hack around
// a infinite loop in Maniac V1 - see bug #862245
if (loopCtr > 10000) {
if (loopCtr > 100) {
moving |= MF_LAST_LEG;
return;
}

View file

@ -37,12 +37,15 @@ enum MoveFlags {
};
struct ActorWalkData {
Common::Point dest; // Final destination
byte destbox;
int16 destdir;
Common::Point cur; // Current position
byte curbox;
Common::Point next; // Next position on our way to the destination
Common::Point dest; // Final destination point
byte destbox; // Final destination box
int16 destdir; // Final destination, direction to face at
Common::Point cur; // Last position
byte curbox; // Last box
Common::Point next; // Next position on our way to the destination, i.e. our intermediate destination
Common::Point point3;
int32 deltaXFactor, deltaYFactor;
uint16 xfrac, yfrac;

View file

@ -735,10 +735,9 @@ int ScummEngine::getPathToDestBox(byte from, byte to) {
// WORKAROUND #2: In addition to the above, we have to add this special
// case to fix the scene in Indy3 where Indy meets Hitler in Berlin.
// It's one of the places (or maybe even the only one?). See bug #770690
// and also bug #774783.
// See bug #770690 and also bug #774783.
if ((_gameId == GID_INDY3) && _roomResource == 46 && from == 1 && to == 0)
return 1;
return 0;
// Skip up to the matrix data for box 'from'
for (i = 0; i < from && boxm < end; i++) {
@ -1137,18 +1136,21 @@ bool ScummEngine::areBoxesNeighbours(int box1nr, int box2nr) {
return result;
}
void Actor::findPathTowardsOld(byte trap1, byte trap2, byte final_trap, Common::Point &p2, Common::Point &p3) {
void Actor::findPathTowardsOld(byte box1, byte box2, byte finalBox, Common::Point &p2, Common::Point &p3) {
Common::Point pt;
Common::Point gateA[2];
Common::Point gateB[2];
_vm->getGates(trap1, trap2, gateA, gateB);
_vm->getGates(box1, box2, gateA, gateB);
p2.x = 32000;
p3.x = 32000;
// next box (trap2) = final box?
if (trap2 == final_trap) {
// next box (box2) = final box?
if (box2 == finalBox) {
// In Indy3, the masks (= z-level) have to match, too -- needed for the
// 'maze' in the zeppeling (see bug #1032964).
if (_vm->_gameId != GID_INDY3 || _vm->getMaskFromBox(box1) == _vm->getMaskFromBox(box2)) {
// Is the actor (x,y) between both gates?
if (compareSlope(_pos.x, _pos.y, walkdata.dest.x, walkdata.dest.y, gateA[0].x, gateA[0].y) !=
compareSlope(_pos.x, _pos.y, walkdata.dest.x, walkdata.dest.y, gateB[0].x, gateB[0].y) &&
@ -1157,6 +1159,7 @@ void Actor::findPathTowardsOld(byte trap1, byte trap2, byte final_trap, Common::
return;
}
}
}
pt = closestPtOnLine(gateA[1].x, gateA[1].y, gateB[1].x, gateB[1].y, _pos.x, _pos.y);
p3.x = pt.x;
@ -1172,13 +1175,13 @@ void Actor::findPathTowardsOld(byte trap1, byte trap2, byte final_trap, Common::
/**
* Compute the "gate" between two boxes. The gate is a pair of two lines which
* both start on box 'trap1' and end on 'trap2'. For both lines, one of its
* both start on box 'box1' and end on 'box2'. For both lines, one of its
* end points is the corner point of one of the two boxes. The other end point
* is a point on the other point closest to first end point.
* This way the lines bound a 'corridor' between the two boxes, through which
* the actor has to walk to get from trap1 to trap2.
* the actor has to walk to get from box1 to box2.
*/
void ScummEngine::getGates(int trap1, int trap2, Common::Point gateA[2], Common::Point gateB[2]) {
void ScummEngine::getGates(int box1, int box2, Common::Point gateA[2], Common::Point gateB[2]) {
int i, j;
int dist[8];
int minDist[3];
@ -1191,23 +1194,23 @@ void ScummEngine::getGates(int trap1, int trap2, Common::Point gateA[2], Common:
// For all corner coordinates of the first box, compute the point closest
// to them on the second box (and also compute the distance of these points).
getBoxCoordinates(trap1, &coords);
getBoxCoordinates(box1, &coords);
boxCorner[0] = coords.ul;
boxCorner[1] = coords.ur;
boxCorner[2] = coords.lr;
boxCorner[3] = coords.ll;
for (i = 0; i < 4; i++) {
dist[i] = getClosestPtOnBox(trap2, boxCorner[i].x, boxCorner[i].y, closestPoint[i].x, closestPoint[i].y);
dist[i] = getClosestPtOnBox(box2, boxCorner[i].x, boxCorner[i].y, closestPoint[i].x, closestPoint[i].y);
}
// Now do the same but with the roles of the first and second box swapped.
getBoxCoordinates(trap2, &coords);
getBoxCoordinates(box2, &coords);
boxCorner[4] = coords.ul;
boxCorner[5] = coords.ur;
boxCorner[6] = coords.lr;
boxCorner[7] = coords.ll;
for (i = 4; i < 8; i++) {
dist[i] = getClosestPtOnBox(trap1, boxCorner[i].x, boxCorner[i].y, closestPoint[i].x, closestPoint[i].y);
dist[i] = getClosestPtOnBox(box1, boxCorner[i].x, boxCorner[i].y, closestPoint[i].x, closestPoint[i].y);
}
// Find the three closest "close" points between the two boxes.