Changeset - r7323:a531c9f4c784
[Not reviewed]
master
0 2 0
rubidium - 17 years ago 2007-07-25 15:45:46
rubidium@openttd.org
(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.
2 files changed with 20 insertions and 21 deletions:
0 comments (0 inline, 0 general)
src/tile.cpp
Show inline comments
 
@@ -20,17 +20,17 @@ Slope GetTileSlope(TileIndex tile, uint 
 
		if (h != NULL) *h = 0;
 
		return SLOPE_FLAT;
 
	}
 

	
 
	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;
 
	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;
 
@@ -39,27 +39,28 @@ Slope GetTileSlope(TileIndex tile, uint 
 

	
 
	return (Slope)r;
 
}
 

	
 
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;
 
	if (TileX(tile) == MapMaxX() || TileY(tile) == MapMaxY()) return 0;
 

	
 
	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;
 
	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;
 
}
src/tunnel_map.cpp
Show inline comments
 
@@ -61,11 +61,9 @@ bool IsTunnelInWayDir(TileIndex tile, ui
 
 * @param z the 'z' to search on.
 
 * @return true if and only if there is a tunnel.
 
 */
 
bool IsTunnelInWay(TileIndex tile, uint z)
 
{
 
	return
 
		IsTunnelInWayDir(tile, z, DIAGDIR_NE) ||
 
		IsTunnelInWayDir(tile, z, DIAGDIR_SE) ||
 
		IsTunnelInWayDir(tile, z, DIAGDIR_SW) ||
 
		IsTunnelInWayDir(tile, z, DIAGDIR_NW);
 
		IsTunnelInWayDir(tile, z, (TileX(tile) > (MapMaxX() / 2)) ? DIAGDIR_NE : DIAGDIR_SW) ||
 
		IsTunnelInWayDir(tile, z, (TileY(tile) > (MapMaxY() / 2)) ? DIAGDIR_NW : DIAGDIR_SE);
 
}
0 comments (0 inline, 0 general)