(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
This commit is contained in:
tron
2006-06-25 17:39:19 +00:00
parent 1423445050
commit f6b15f9fc4
4 changed files with 61 additions and 67 deletions

42
tile.c
View File

@@ -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;
return GetTileh(a, b, c, d, h);
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;
if (h != NULL) *h = min * TILE_HEIGHT;
return r;
}
uint GetTileZ(TileIndex tile)