From 7e8d7f89c5d0aa07159e9b43ea39334907bcab1f Mon Sep 17 00:00:00 2001 From: Yohann Ferreira Date: Thu, 17 Mar 2011 19:32:41 +0100 Subject: Fixed wrong comments in and optimize findTilePath() a bit. --- src/map.cpp | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) (limited to 'src/map.cpp') diff --git a/src/map.cpp b/src/map.cpp index 69793299..78171ca9 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -721,26 +721,16 @@ Path Map::findTilePath(int startPixelX, int startPixelY, int endPixelX, if (myPath.empty()) return myPath; - // Convert the map path to pixels over tiles - // And add interpolation between the starting and ending offsets + // Convert the map path to pixels from the tile position Path::iterator it = myPath.begin(); while (it != myPath.end()) { - // A position that is valid on the start and end tile is not - // necessarily valid on all the tiles in between, so check the offsets. + // The new pixel position will be the tile center. *it = Position(it->x * mTileWidth + mTileWidth / 2, it->y * mTileHeight + mTileHeight / 2); - it++; + ++it; } - // Remove the last path node, as it's more clever to go to the destination. - // It also permit to avoid zigzag at the end of the path, - // especially with mouse. - Position destination((endPixelX / mTileWidth) * mTileWidth + mTileWidth / 2, - (endPixelY / mTileHeight) * mTileHeight + mTileHeight / 2); - myPath.pop_back(); - myPath.push_back(destination); - return myPath; } -- cgit v1.2.3-60-g2f50