summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2008-02-02 21:09:05 +0000
committerrubidium <rubidium@openttd.org>2008-02-02 21:09:05 +0000
commit612ba5c7874ceaf4c5201950ea2932e9e43fa916 (patch)
tree1ada2fc65058f258bfaf7b3f6a6d06ada2941425 /src
parentf3663fd25cecb43c93bd783973bb322c597a2064 (diff)
downloadopenttd-612ba5c7874ceaf4c5201950ea2932e9e43fa916.tar.xz
(svn r12044) -Fix [FS#1741]: crash when centering on a vehicle (aircraft) that is outside of the map.
Diffstat (limited to 'src')
-rw-r--r--src/viewport.cpp5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/viewport.cpp b/src/viewport.cpp
index 03207e1fa..0a8893978 100644
--- a/src/viewport.cpp
+++ b/src/viewport.cpp
@@ -2159,9 +2159,8 @@ void PlaceObject()
/* scrolls the viewport in a window to a given location */
bool ScrollWindowTo(int x , int y, Window *w, bool instant)
{
- Point pt;
-
- pt = MapXYZToViewport(w->viewport, x, y, GetSlopeZ(x, y));
+ /* 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()), Clamp(y, 0, MapSizeY())));
WP(w, vp_d).follow_vehicle = INVALID_VEHICLE;
if (WP(w, vp_d).dest_scrollpos_x == pt.x && WP(w, vp_d).dest_scrollpos_y == pt.y)