summaryrefslogtreecommitdiff
path: root/src/viewport.cpp
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2009-03-15 15:25:18 +0000
committersmatz <smatz@openttd.org>2009-03-15 15:25:18 +0000
commitaf293142fede91cc31e98c7e05d9ecfef752b077 (patch)
treec041152a492c41b5020c575b6fde72be6dc3a5b8 /src/viewport.cpp
parent4f8eeca437a57c160364cdb97182ae1566e6c693 (diff)
downloadopenttd-af293142fede91cc31e98c7e05d9ecfef752b077.tar.xz
(svn r15725) -Fix: centering on a vehicle didn't respect its z coordinate
Diffstat (limited to 'src/viewport.cpp')
-rw-r--r--src/viewport.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/viewport.cpp b/src/viewport.cpp
index 01dbe2f6b..60cecb03c 100644
--- a/src/viewport.cpp
+++ b/src/viewport.cpp
@@ -137,7 +137,7 @@ TileHighlightData _thd;
static TileInfo *_cur_ti;
bool _draw_bounding_boxes = false;
-static Point MapXYZToViewport(const ViewPort *vp, uint x, uint y, uint z)
+static Point MapXYZToViewport(const ViewPort *vp, int x, int y, int z)
{
Point p = RemapCoords(x, y, z);
p.x -= vp->virtual_width / 2;
@@ -2065,10 +2065,12 @@ void PlaceObject()
/* scrolls the viewport in a window to a given location */
-bool ScrollWindowTo(int x , int y, Window *w, bool instant)
+bool ScrollWindowTo(int x, int y, int z, Window *w, bool instant)
{
/* The slope cannot be acquired outside of the map, so make sure we are always within the map. */
- Point pt = MapXYZToViewport(w->viewport, x, y, GetSlopeZ(Clamp(x, 0, MapSizeX() * TILE_SIZE - 1), Clamp(y, 0, MapSizeY() * TILE_SIZE - 1)));
+ if (z == -1) z = GetSlopeZ(Clamp(x, 0, MapSizeX() * TILE_SIZE - 1), Clamp(y, 0, MapSizeY() * TILE_SIZE - 1));
+
+ Point pt = MapXYZToViewport(w->viewport, x, y, z);
w->viewport->follow_vehicle = INVALID_VEHICLE;
if (w->viewport->dest_scrollpos_x == pt.x && w->viewport->dest_scrollpos_y == pt.y)
@@ -2086,7 +2088,7 @@ bool ScrollWindowTo(int x , int y, Window *w, bool instant)
bool ScrollMainWindowToTile(TileIndex tile, bool instant)
{
- return ScrollMainWindowTo(TileX(tile) * TILE_SIZE + TILE_SIZE / 2, TileY(tile) * TILE_SIZE + TILE_SIZE / 2, instant);
+ return ScrollMainWindowTo(TileX(tile) * TILE_SIZE + TILE_SIZE / 2, TileY(tile) * TILE_SIZE + TILE_SIZE / 2, -1, instant);
}
void SetRedErrorSquare(TileIndex tile)