diff options
author | tron <tron@openttd.org> | 2006-06-25 17:39:19 +0000 |
---|---|---|
committer | tron <tron@openttd.org> | 2006-06-25 17:39:19 +0000 |
commit | f6b15f9fc446ed90212a1051852befee3975ffa3 (patch) | |
tree | 8be173cf3faba9d3725ea465a306b5929b8d7595 /tile.c | |
parent | 1423445050bc082344ad3433204372e478309cf5 (diff) | |
download | openttd-f6b15f9fc446ed90212a1051852befee3975ffa3.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.c | 42 |
1 files changed, 15 insertions, 27 deletions
@@ -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) |