aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2014-04-20 17:18:06 -0400
committerPaul Gilbert2014-04-20 17:18:06 -0400
commit4559444c54a6e910f89532e899058448eb835b08 (patch)
tree5eb2103036aab5d2a82802acf49583a42d01b6b6
parentfb78efa3a798707f86e8902ce10a5370033a9b8d (diff)
downloadscummvm-rg350-4559444c54a6e910f89532e899058448eb835b08.tar.gz
scummvm-rg350-4559444c54a6e910f89532e899058448eb835b08.tar.bz2
scummvm-rg350-4559444c54a6e910f89532e899058448eb835b08.zip
MADS: Fix calculating Rails::_next
-rw-r--r--engines/mads/rails.cpp12
1 files changed, 5 insertions, 7 deletions
diff --git a/engines/mads/rails.cpp b/engines/mads/rails.cpp
index 342238ec65..105a85366a 100644
--- a/engines/mads/rails.cpp
+++ b/engines/mads/rails.cpp
@@ -81,7 +81,7 @@ void Rails::setupRoute(bool bitFlag, const Common::Point &srcPos, const Common::
_next = 0;
if (_routeIndexes.size() > 0) {
Common::Point currPos = srcPos;
- for (int routeCtr = size() - 1; (routeCtr >= 0) && (_next == 0); --routeCtr) {
+ for (int routeCtr = size() - 1; (routeCtr >= 0) && !_next; --routeCtr) {
int idx = _routeIndexes[routeCtr];
const Common::Point &pt = _nodes[idx]._walkPos;
@@ -124,7 +124,7 @@ void Rails::setupRouteNode(int *routeIndexP, int nodeIndex, int flags, int route
int Rails::scanPath(const Common::Point &srcPos, const Common::Point &destPos) {
// For compressed depth surfaces, always return 0
- if (_depthStyle != 2)
+ if (_depthStyle == 2)
return 0;
int yDiff = destPos.y - srcPos.y;
@@ -135,7 +135,7 @@ int Rails::scanPath(const Common::Point &srcPos, const Common::Point &destPos) {
yAmount = -yAmount;
}
- int xDiff = destPos.x - srcPos.y;
+ int xDiff = destPos.x - srcPos.x;
int xDirection = 1;
int xAmount = 0;
if (xDiff < 0) {
@@ -150,8 +150,8 @@ int Rails::scanPath(const Common::Point &srcPos, const Common::Point &destPos) {
const byte *srcP = _depthSurface->getBasePtr(srcPos.x, srcPos.y);
int index = xAmount;
- // Outer horizontal movement loop
- for (int yIndex = 0; yIndex < yDiff; ++yIndex) {
+ // Outer loop
+ for (int xCtr = 0; xCtr < xDiff; ++xCtr, srcP += xDirection) {
index += yDiff;
int v = (*srcP & 0x7F) >> 4;
if (v)
@@ -167,8 +167,6 @@ int Rails::scanPath(const Common::Point &srcPos, const Common::Point &destPos) {
srcP += yAmount;
}
-
- srcP += xDirection;
}
return 0;