summaryrefslogtreecommitdiff
path: root/tile.c
diff options
context:
space:
mode:
authortron <tron@openttd.org>2006-06-25 17:39:19 +0000
committertron <tron@openttd.org>2006-06-25 17:39:19 +0000
commitef4b0ab5b68c7ce4904eeaec2945682f99dac138 (patch)
tree8be173cf3faba9d3725ea465a306b5929b8d7595 /tile.c
parent5f29205e94cd1802d3b7c8e40815023620cc5240 (diff)
downloadopenttd-ef4b0ab5b68c7ce4904eeaec2945682f99dac138.tar.xz
(svn r5363) Revert 5312, 5288, 5248, 3992, 3249, 3228
They were all aimed at fixing the terraform-into-tunnel problem, but introduced new sideeffects while doing so
Diffstat (limited to 'tile.c')
-rw-r--r--tile.c42
1 files changed, 15 insertions, 27 deletions
diff --git a/tile.c b/tile.c
index 98fb5f0bd..ba6900a36 100644
--- a/tile.c
+++ b/tile.c
@@ -3,37 +3,14 @@
#include "stdafx.h"
#include "tile.h"
-/** Converts the heights of 4 corners into a tileh, and returns the minimum height of the tile
- * @param n,w,e,s the four corners
- * @param h uint pointer to write the height to
- * @return the tileh
-*/
-Slope GetTileh(uint n, uint w, uint e, uint s, uint *h)
-{
- uint min = n;
- Slope r;
-
- if (min >= w) min = w;
- if (min >= e) min = e;
- if (min >= s) min = s;
-
- r = SLOPE_FLAT;
- if ((n -= min) != 0) r += (--n << 4) + SLOPE_N;
- if ((e -= min) != 0) r += (--e << 4) + SLOPE_E;
- if ((s -= min) != 0) r += (--s << 4) + SLOPE_S;
- if ((w -= min) != 0) r += (--w << 4) + SLOPE_W;
-
- if (h != NULL) *h = min * TILE_HEIGHT;
-
- return r;
-}
-
Slope GetTileSlope(TileIndex tile, uint *h)
{
uint a;
uint b;
uint c;
uint d;
+ uint min;
+ uint r;
assert(tile < MapSize());
@@ -42,12 +19,23 @@ Slope GetTileSlope(TileIndex tile, uint *h)
return 0;
}
- a = TileHeight(tile);
+ min = a = TileHeight(tile);
b = TileHeight(tile + TileDiffXY(1, 0));
+ if (min >= b) min = b;
c = TileHeight(tile + TileDiffXY(0, 1));
+ if (min >= c) min = c;
d = TileHeight(tile + TileDiffXY(1, 1));
+ if (min >= d) min = d;
+
+ r = SLOPE_FLAT;
+ if ((a -= min) != 0) r += (--a << 4) + SLOPE_N;
+ if ((c -= min) != 0) r += (--c << 4) + SLOPE_E;
+ if ((d -= min) != 0) r += (--d << 4) + SLOPE_S;
+ if ((b -= min) != 0) r += (--b << 4) + SLOPE_W;
- return GetTileh(a, b, c, d, h);
+ if (h != NULL) *h = min * TILE_HEIGHT;
+
+ return r;
}
uint GetTileZ(TileIndex tile)