diff options
Diffstat (limited to 'engines/gob/map_v2.cpp')
-rw-r--r-- | engines/gob/map_v2.cpp | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/engines/gob/map_v2.cpp b/engines/gob/map_v2.cpp index e2f9207003..f81d3e6002 100644 --- a/engines/gob/map_v2.cpp +++ b/engines/gob/map_v2.cpp @@ -100,11 +100,11 @@ void Map_v2::loadMapObjects(const char *avjFile) { Common::SeekableReadStream &mapData = *resource->stream(); - _widthByte = mapData.readByte(); - if (_widthByte == 4) { + _mapVersion = mapData.readByte(); + if (_mapVersion == 4) { _screenWidth = 640; _screenHeight = 400; - } else if (_widthByte == 3) { + } else if (_mapVersion == 3) { _passWidth = 65; _screenWidth = 640; _screenHeight = 200; @@ -114,14 +114,14 @@ void Map_v2::loadMapObjects(const char *avjFile) { _screenHeight = 200; } - _wayPointsCount = mapData.readByte(); + _wayPointCount = mapData.readByte(); _tilesWidth = mapData.readSint16LE(); _tilesHeight = mapData.readSint16LE(); _bigTiles = !(_tilesHeight & 0xFF00); _tilesHeight &= 0xFF; - if (_widthByte == 4) { + if (_mapVersion == 4) { _screenWidth = mapData.readSint16LE(); _screenHeight = mapData.readSint16LE(); } @@ -133,19 +133,19 @@ void Map_v2::loadMapObjects(const char *avjFile) { mapData.skip(_mapWidth * _mapHeight); if (resource->getData()[0] == 1) - wayPointsCount = _wayPointsCount = 40; + wayPointsCount = _wayPointCount = 40; else - wayPointsCount = _wayPointsCount == 0 ? 1 : _wayPointsCount; + wayPointsCount = _wayPointCount == 0 ? 1 : _wayPointCount; delete[] _wayPoints; - _wayPoints = new Point[wayPointsCount]; - for (int i = 0; i < _wayPointsCount; i++) { + _wayPoints = new WayPoint[wayPointsCount]; + for (int i = 0; i < _wayPointCount; i++) { _wayPoints[i].x = mapData.readSByte(); _wayPoints[i].y = mapData.readSByte(); _wayPoints[i].notWalkable = mapData.readSByte(); } - if (_widthByte == 4) { + if (_mapVersion == 4) { _mapWidth = VAR(17); _passWidth = _mapWidth; } @@ -258,17 +258,24 @@ void Map_v2::findNearestToDest(Mult::Mult_Object *obj) { void Map_v2::optimizePoints(Mult::Mult_Object *obj, int16 x, int16 y) { if (obj->nearestWayPoint < obj->nearestDest) { + for (int i = obj->nearestWayPoint; i <= obj->nearestDest; i++) { if (checkDirectPath(obj, x, y, _wayPoints[i].x, _wayPoints[i].y) == 1) obj->nearestWayPoint = i; } + } else { - for (int i = obj->nearestWayPoint; - i >= obj->nearestDest && (_wayPoints[i].notWalkable != 1); i--) { + + for (int i = obj->nearestWayPoint; i >= obj->nearestDest; i--) { + if (_wayPoints[i].notWalkable == 1) + break; + if (checkDirectPath(obj, x, y, _wayPoints[i].x, _wayPoints[i].y) == 1) obj->nearestWayPoint = i; } + } + } } // End of namespace Gob |