mirror of https://github.com/OpenTTD/OpenTTD
(svn r12044) -Fix [FS#1741]: crash when centering on a vehicle (aircraft) that is outside of the map.
parent
f3663fd25c
commit
612ba5c787
|
@ -2159,9 +2159,8 @@ void PlaceObject()
|
||||||
/* scrolls the viewport in a window to a given location */
|
/* 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, Window *w, bool instant)
|
||||||
{
|
{
|
||||||
Point pt;
|
/* 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())));
|
||||||
pt = MapXYZToViewport(w->viewport, x, y, GetSlopeZ(x, y));
|
|
||||||
WP(w, vp_d).follow_vehicle = INVALID_VEHICLE;
|
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)
|
if (WP(w, vp_d).dest_scrollpos_x == pt.x && WP(w, vp_d).dest_scrollpos_y == pt.y)
|
||||||
|
|
Loading…
Reference in New Issue