--- a/src/viewport.cpp Sun Feb 03 01:34:21 2008 +0000
+++ b/src/viewport.cpp Sun Feb 03 20:34:26 2008 +0000
@@ -910,7 +910,7 @@
int offset;
FoundationPart foundation_part = FOUNDATION_PART_NORMAL;
- Slope autorail_tileh = (Slope)(ti->tileh & ~SLOPE_HALFTILE_MASK);
+ Slope autorail_tileh = RemoveHalftileSlope(ti->tileh);
if (IsHalftileSlope(ti->tileh)) {
static const uint _lower_rail[4] = { 5U, 2U, 4U, 3U };
Corner halftile_corner = GetHalftileSlopeCorner(ti->tileh);
@@ -983,7 +983,7 @@
FoundationPart foundation_part = FOUNDATION_PART_NORMAL;
if (ti->tileh & SLOPE_N) {
z += TILE_HEIGHT;
- if ((ti->tileh & ~SLOPE_HALFTILE_MASK) == SLOPE_STEEP_N) z += TILE_HEIGHT;
+ if (RemoveHalftileSlope(ti->tileh) == SLOPE_STEEP_N) z += TILE_HEIGHT;
}
if (IsHalftileSlope(ti->tileh)) {
Corner halftile_corner = GetHalftileSlopeCorner(ti->tileh);
@@ -2184,9 +2184,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)