aboutsummaryrefslogtreecommitdiff
path: root/scumm
diff options
context:
space:
mode:
authorMax Horn2003-05-20 19:35:40 +0000
committerMax Horn2003-05-20 19:35:40 +0000
commitffadd452a91a379c4fc64b2516f20088c056893a (patch)
tree6be6d6d8d7e267cb5573944e96a8ab90e0e4779f /scumm
parent1f859e592f278f3fd4746ce4b65b5a12ea0453d5 (diff)
downloadscummvm-rg350-ffadd452a91a379c4fc64b2516f20088c056893a.tar.gz
scummvm-rg350-ffadd452a91a379c4fc64b2516f20088c056893a.tar.bz2
scummvm-rg350-ffadd452a91a379c4fc64b2516f20088c056893a.zip
got rid of the evil locked-box hack in adjustXYToBeInBox; instead check for locked boxes in walkActorOld, which seems to work just as well (and hopefully better)
svn-id: r7750
Diffstat (limited to 'scumm')
-rw-r--r--scumm/actor.cpp48
-rw-r--r--scumm/actor.h2
-rw-r--r--scumm/object.cpp2
3 files changed, 17 insertions, 35 deletions
diff --git a/scumm/actor.cpp b/scumm/actor.cpp
index 41ad08ea9f..4be44f161d 100644
--- a/scumm/actor.cpp
+++ b/scumm/actor.cpp
@@ -593,7 +593,7 @@ int Actor::getActorXYPos(int &xPos, int &yPos) {
return 0;
}
-AdjustBoxResult Actor::adjustXYToBeInBox(int dstX, int dstY, int pathfrom) {
+AdjustBoxResult Actor::adjustXYToBeInBox(int dstX, int dstY) {
const uint thresholdTable[] = { 30, 80, 0 };
AdjustBoxResult abr, tmp;
uint threshold;
@@ -628,32 +628,6 @@ AdjustBoxResult Actor::adjustXYToBeInBox(int dstX, int dstY, int pathfrom) {
if (flags & kBoxInvisible && (!(flags & kBoxPlayerOnly) || isInClass(31)))
continue;
- // FIXME: the following is essentially a hack to fix issues in Zak256
- // and possibly elsewhere; but it seems the original did nothing like this
- // so hopefully one day we'll find a 'proper' solution and can remove
- // this hack.
- if (pathfrom >= firstValidBox) {
-
- if (flags & kBoxLocked && (!(flags & kBoxPlayerOnly)))
- continue;
-
- int i = _vm->getPathToDestBox(pathfrom, box);
- if (i == -1)
- continue;
-
- if (_vm->_features & GF_OLD256) {
- // FIXME - we check here if the box suggested by getPathToDestBox
- // is locked or not. This prevents us from walking thru
- // closed doors in some cases in Zak256. However a better fix
- // would be to recompute the box matrix whenever flags change.
- flags = _vm->getBoxFlags(i);
- if (flags & kBoxLocked && (!(flags & kBoxPlayerOnly)))
- continue;
- if (flags & kBoxInvisible && (!(flags & kBoxPlayerOnly) || isInClass(31)))
- continue;
- }
- }
-
// For increased performance, we perform a quick test if
// the coordinates can even be within a distance of 'threshold'
// pixels of the box.
@@ -700,7 +674,7 @@ AdjustBoxResult Actor::adjustXYToBeInBox(int dstX, int dstY, int pathfrom) {
void Actor::adjustActorPos() {
AdjustBoxResult abr;
- abr = adjustXYToBeInBox(x, y, -1);
+ abr = adjustXYToBeInBox(x, y);
x = abr.x;
y = abr.y;
@@ -1196,7 +1170,7 @@ void Actor::startWalkActor(int destX, int destY, int dir) {
abr.x = destX;
abr.y = destY;
} else {
- abr = adjustXYToBeInBox(destX, destY, walkbox);
+ abr = adjustXYToBeInBox(destX, destY);
}
if (!isInCurrentRoom()) {
@@ -1214,7 +1188,7 @@ void Actor::startWalkActor(int destX, int destY, int dir) {
if (_vm->checkXYInBoxBounds(walkdata.destbox, abr.x, abr.y)) {
abr.dist = walkdata.destbox;
} else {
- abr = adjustXYToBeInBox(abr.x, abr.y, walkbox);
+ abr = adjustXYToBeInBox(abr.x, abr.y);
}
if (moving && walkdata.destdir == dir && walkdata.destx == abr.x && walkdata.desty == abr.y)
return;
@@ -1290,7 +1264,7 @@ void Actor::walkActor() {
}
}
- if (moving == 0)
+ if (!moving)
return;
if (!(moving & MF_NEW_LEG)) {
@@ -1319,6 +1293,7 @@ void Actor::walkActor() {
do {
moving &= ~MF_NEW_LEG;
+
if (walkbox == INVALID_BOX) {
setBox(walkdata.destbox);
walkdata.curbox = walkdata.destbox;
@@ -1358,7 +1333,6 @@ void Actor::walkActorOld() {
return;
if (!(moving & MF_NEW_LEG)) {
-
if (moving & MF_IN_LEG && actorWalkStep())
return;
@@ -1387,7 +1361,6 @@ void Actor::walkActorOld() {
walkbox = walkdata.curbox;
moving &= MF_IN_LEG;
- moving |= MF_NEW_LEG;
}
do {
@@ -1409,6 +1382,15 @@ void Actor::walkActorOld() {
return;
}
+ // FIXME: not sure if this is needed in non-Zak games, but I think it shouldn't
+ // hurt there either.
+ int flags = _vm->getBoxFlags(next_box);
+ if (flags & kBoxLocked && (!(flags & kBoxPlayerOnly) || isInClass(31))) {
+ moving |= MF_LAST_LEG;
+ return;
+ }
+
+
walkdata.curbox = next_box;
_vm->findPathTowardsOld(this, walkbox, next_box, walkdata.destbox, gateLoc);
diff --git a/scumm/actor.h b/scumm/actor.h
index c397799732..eac1557d7e 100644
--- a/scumm/actor.h
+++ b/scumm/actor.h
@@ -151,7 +151,7 @@ protected:
public:
void adjustActorPos();
- AdjustBoxResult adjustXYToBeInBox(int dstX, int dstY, int pathfrom);
+ AdjustBoxResult adjustXYToBeInBox(int dstX, int dstY);
void setDirection(int direction);
void faceToObject(int obj);
diff --git a/scumm/object.cpp b/scumm/object.cpp
index bbaa764cb2..ab1a952504 100644
--- a/scumm/object.cpp
+++ b/scumm/object.cpp
@@ -237,7 +237,7 @@ int Scumm::getObjActToObjActDist(int a, int b) {
return 0xFF;
if (acta) {
- AdjustBoxResult r = acta->adjustXYToBeInBox(x2, y2, -1);
+ AdjustBoxResult r = acta->adjustXYToBeInBox(x2, y2);
x2 = r.x;
y2 = r.y;
}