Mercurial > hg > openttd
changeset 8473:75c79ef760e8 draft
(svn r12044) -Fix [FS#1741]: crash when centering on a vehicle (aircraft) that is outside of the map.
author | rubidium <rubidium@openttd.org> |
---|---|
date | Sat, 02 Feb 2008 21:09:05 +0000 |
parents | 99388386f8d8 |
children | f4825ac7e246 |
files | src/viewport.cpp |
diffstat | 1 files changed, 2 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/src/viewport.cpp +++ b/src/viewport.cpp @@ -2159,9 +2159,8 @@ /* 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)