summaryrefslogtreecommitdiff
path: root/src/tile.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2007-07-25 15:45:46 +0000
committerrubidium <rubidium@openttd.org>2007-07-25 15:45:46 +0000
commite70f91a4bfb89024d754ddf436f6a5579216463e (patch)
tree7fa73f3c0eb16b6b0b664a6ec1e69ca355f7cb9f /src/tile.cpp
parent368e04520df2192f23309a39802d4a1eee48aad6 (diff)
downloadopenttd-e70f91a4bfb89024d754ddf436f6a5579216463e.tar.xz
(svn r10686) -Fix [FS#1058]: determining whether there is a tunnel going under the lowered area is only needed in two directions instead of all four, so take the directions (one for each axis) to the nearest border (along the given axis). Furthermore GetTileZ did much more than absolutely necessary.
Diffstat (limited to 'src/tile.cpp')
-rw-r--r--src/tile.cpp37
1 files changed, 19 insertions, 18 deletions
diff --git a/src/tile.cpp b/src/tile.cpp
index 128c16128..449156465 100644
--- a/src/tile.cpp
+++ b/src/tile.cpp
@@ -23,11 +23,11 @@ Slope GetTileSlope(TileIndex tile, uint *h)
min = a = TileHeight(tile);
b = TileHeight(tile + TileDiffXY(1, 0));
- if (min >= b) min = b;
+ if (min > b) min = b;
c = TileHeight(tile + TileDiffXY(0, 1));
- if (min >= c) min = c;
+ if (min > c) min = c;
d = TileHeight(tile + TileDiffXY(1, 1));
- if (min >= d) min = d;
+ if (min > d) min = d;
r = SLOPE_FLAT;
if ((a -= min) != 0) r += (--a << 4) + SLOPE_N;
@@ -42,24 +42,25 @@ Slope GetTileSlope(TileIndex tile, uint *h)
uint GetTileZ(TileIndex tile)
{
- uint h;
- GetTileSlope(tile, &h);
- return h;
+ if (TileX(tile) == MapMaxX() || TileY(tile) == MapMaxY()) return 0;
+
+ uint h = TileHeight(tile);
+ h = min(h, TileHeight(tile + TileDiffXY(1, 0)));
+ h = min(h, TileHeight(tile + TileDiffXY(0, 1)));
+ h = min(h, TileHeight(tile + TileDiffXY(1, 1)));
+
+ return h * TILE_HEIGHT;
}
uint GetTileMaxZ(TileIndex t)
{
- uint max;
- uint h;
-
- h = TileHeight(t);
- max = h;
- h = TileHeight(t + TileDiffXY(1, 0));
- if (h > max) max = h;
- h = TileHeight(t + TileDiffXY(0, 1));
- if (h > max) max = h;
- h = TileHeight(t + TileDiffXY(1, 1));
- if (h > max) max = h;
- return max * 8;
+ if (TileX(tile) == MapMaxX() || TileY(tile) == MapMaxY()) return 0;
+
+ uint h = TileHeight(t);
+ h = max(h, TileHeight(t + TileDiffXY(1, 0)));
+ h = max(h, TileHeight(t + TileDiffXY(0, 1)));
+ h = max(h, TileHeight(t + TileDiffXY(1, 1)));
+
+ return h * TILE_HEIGHT;
}