diff options
author | Yohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer> | 2011-03-17 19:32:41 +0100 |
---|---|---|
committer | Yohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer> | 2011-03-17 19:32:41 +0100 |
commit | 7e8d7f89c5d0aa07159e9b43ea39334907bcab1f (patch) | |
tree | e5b1671695e6f4932ffc90c11b21b0343f9a5cf9 /src | |
parent | 2a2316f720ed7f821809cff840487e992f4918d3 (diff) | |
download | mana-client-7e8d7f89c5d0aa07159e9b43ea39334907bcab1f.tar.gz mana-client-7e8d7f89c5d0aa07159e9b43ea39334907bcab1f.tar.bz2 mana-client-7e8d7f89c5d0aa07159e9b43ea39334907bcab1f.tar.xz mana-client-7e8d7f89c5d0aa07159e9b43ea39334907bcab1f.zip |
Fixed wrong comments in and optimize findTilePath() a bit.
Diffstat (limited to 'src')
-rw-r--r-- | src/map.cpp | 16 |
1 files changed, 3 insertions, 13 deletions
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; } |