summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoralberth <alberth@openttd.org>2010-02-12 12:14:21 +0000
committeralberth <alberth@openttd.org>2010-02-12 12:14:21 +0000
commit47295bb8b901609df05fbd9d9dcc54100edee7e9 (patch)
tree6e12a82c88102dc234ae3db43fd9c7a8b441647d /src
parentd403d826178c1c29543a7f86af869f83e35d45d0 (diff)
downloadopenttd-47295bb8b901609df05fbd9d9dcc54100edee7e9.tar.xz
(svn r19103) -Codechange: Use px/py for pixel coordinates in PixelToTile(), as promised by the documentation.
Diffstat (limited to 'src')
-rw-r--r--src/smallmap_gui.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/smallmap_gui.cpp b/src/smallmap_gui.cpp
index 1892d173a..0cdf9a4f3 100644
--- a/src/smallmap_gui.cpp
+++ b/src/smallmap_gui.cpp
@@ -563,26 +563,26 @@ class SmallMapWindow : public Window {
* @return Tile being displayed at the given position relative to #scroll_x and #scroll_y.
* @note The #subscroll offset is already accounted for.
*/
- FORCEINLINE Point PixelToTile(int dx, int dy, int *sub) const
+ FORCEINLINE Point PixelToTile(int px, int py, int *sub) const
{
- dx += this->subscroll; // Total horizontal offset.
+ px += this->subscroll; // Total horizontal offset.
/* For each two rows down, add a x and a y tile, and
* For each four pixels to the right, move a tile to the right. */
- Point pt = {((dy >> 1) - (dx >> 2)) * this->zoom, ((dy >> 1) + (dx >> 2)) * this->zoom};
- dx &= 3;
+ Point pt = {((py >> 1) - (px >> 2)) * this->zoom, ((py >> 1) + (px >> 2)) * this->zoom};
+ px &= 3;
- if (dy & 1) { // Odd number of rows, handle the 2 pixel shift.
- if (dx < 2) {
+ if (py & 1) { // Odd number of rows, handle the 2 pixel shift.
+ if (px < 2) {
pt.x += this->zoom;
- dx += 2;
+ px += 2;
} else {
pt.y += this->zoom;
- dx -= 2;
+ px -= 2;
}
}
- *sub = dx;
+ *sub = px;
return pt;
}