diff options
author | Paul Gilbert | 2014-03-29 19:26:05 -0400 |
---|---|---|
committer | Paul Gilbert | 2014-03-29 19:26:05 -0400 |
commit | 32b9530789e1c308e3afe849c27c21285dfe1ab3 (patch) | |
tree | c900d5585983030c29f58730b9d8334c0f85566f | |
parent | 0f3d4c02ad6bc3e81381e0efea4c66fba7f8a018 (diff) | |
download | scummvm-rg350-32b9530789e1c308e3afe849c27c21285dfe1ab3.tar.gz scummvm-rg350-32b9530789e1c308e3afe849c27c21285dfe1ab3.tar.bz2 scummvm-rg350-32b9530789e1c308e3afe849c27c21285dfe1ab3.zip |
MADS: Fixes for the pathfinder
-rw-r--r-- | engines/mads/rails.cpp | 13 | ||||
-rw-r--r-- | engines/mads/rails.h | 2 | ||||
-rw-r--r-- | engines/mads/scene_data.h | 3 |
3 files changed, 8 insertions, 10 deletions
diff --git a/engines/mads/rails.cpp b/engines/mads/rails.cpp index 0baaa12793..4daa774023 100644 --- a/engines/mads/rails.cpp +++ b/engines/mads/rails.cpp @@ -114,7 +114,7 @@ void Rails::setupRouteNode(int *routeIndexP, int nodeIndex, int flags, int route for (int idx = _nodes.size() - 2; idx > 0; --idx) { int nodePos = idx - 1; if (!_nodes[nodePos]._active && ((currentNode._distances[nodePos] & flags) != 0)) - setupRouteNode(routeIndexP, nodePos, 0x8000, distanceVal & 0x3fff); + setupRouteNode(routeIndexP, nodePos, 0x8000, routeLength + distanceVal & 0x3fff); } } @@ -209,9 +209,10 @@ void Rails::setNodePosition(int nodeIndex, const Common::Point &pt) { hypotenuse = 0x3FFF; entry = hypotenuse | flags; - _nodes[idx]._distances[nodeIndex] = entry; - _nodes[nodeIndex]._distances[idx] = entry; } + + _nodes[idx]._distances[nodeIndex] = entry; + _nodes[nodeIndex]._distances[idx] = entry; } } @@ -223,15 +224,15 @@ int Rails::getRouteFlags(const Common::Point &src, const Common::Point &dest) { int yDiff = ABS(dest.y - src.y); int xDirection = dest.x >= src.x ? 1 : -1; int yDirection = dest.y >= src.y ? _depthSurface->w : -_depthSurface->w; - int majorDiff = 0; + int minorDiff = 0; if (dest.x < src.x) - majorDiff = MAX(xDiff, yDiff); + minorDiff = MIN(xDiff, yDiff); ++xDiff; ++yDiff; byte *srcP = _depthSurface->getBasePtr(src.x, src.y); - int totalCtr = majorDiff; + int totalCtr = minorDiff; for (int xCtr = 0; xCtr < xDiff; ++xCtr, srcP += xDirection) { totalCtr += yDiff; diff --git a/engines/mads/rails.h b/engines/mads/rails.h index 026eddae1f..55f6f8b72e 100644 --- a/engines/mads/rails.h +++ b/engines/mads/rails.h @@ -34,7 +34,7 @@ namespace MADS { class WalkNode { public: Common::Point _walkPos; - int _distances[MAX_ROUTE_NODES]; + uint16 _distances[MAX_ROUTE_NODES]; bool _active; /** diff --git a/engines/mads/scene_data.h b/engines/mads/scene_data.h index 33c053f8ec..81c24ed8ab 100644 --- a/engines/mads/scene_data.h +++ b/engines/mads/scene_data.h @@ -130,9 +130,6 @@ class SceneInfo { void load(Common::SeekableReadStream *f); }; - - - int getRouteFlags(const Common::Point &src, const Common::Point &dest, MSurface &depthSurface); protected: MADSEngine *_vm; |