forked from mirror/OpenTTD
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
This commit is contained in:
@@ -104,9 +104,31 @@ uint ApplyFoundationToSlope(Foundation f, Slope *s)
|
||||
|
||||
uint GetPartialZ(int x, int y, Slope corners)
|
||||
{
|
||||
if (IsHalftileSlope(corners)) {
|
||||
switch (GetHalftileSlopeCorner(corners)) {
|
||||
case CORNER_W:
|
||||
if (x - y >= 0) return GetSlopeMaxZ(corners);
|
||||
break;
|
||||
|
||||
case CORNER_S:
|
||||
if (x - (y ^ 0xF) >= 0) return GetSlopeMaxZ(corners);
|
||||
break;
|
||||
|
||||
case CORNER_E:
|
||||
if (y - x >= 0) return GetSlopeMaxZ(corners);
|
||||
break;
|
||||
|
||||
case CORNER_N:
|
||||
if ((y ^ 0xF) - x >= 0) return GetSlopeMaxZ(corners);
|
||||
break;
|
||||
|
||||
default: NOT_REACHED();
|
||||
}
|
||||
}
|
||||
|
||||
int z = 0;
|
||||
|
||||
switch (corners) {
|
||||
switch (corners & ~SLOPE_HALFTILE_MASK) {
|
||||
case SLOPE_W:
|
||||
if (x - y >= 0)
|
||||
z = (x - y) >> 1;
|
||||
@@ -209,6 +231,8 @@ uint GetSlopeZ(int x, int y)
|
||||
/**
|
||||
* Determine the Z height of the corners of a specific tile edge
|
||||
*
|
||||
* @note If a tile has a non-continuous halftile foundation, a corner can have different heights wrt. it's edges.
|
||||
*
|
||||
* @pre z1 and z2 must be initialized (typ. with TileZ). The corner heights just get added.
|
||||
*
|
||||
* @param tileh The slope of the tile.
|
||||
@@ -227,10 +251,14 @@ void GetSlopeZOnEdge(Slope tileh, DiagDirection edge, int *z1, int *z2)
|
||||
{SLOPE_W, SLOPE_N, SLOPE_STEEP_W, SLOPE_STEEP_N}, // DIAGDIR_NW, z1 = W, z2 = N
|
||||
};
|
||||
|
||||
int halftile_test = (IsHalftileSlope(tileh) ? SlopeWithOneCornerRaised(GetHalftileSlopeCorner(tileh)) : 0);
|
||||
if (halftile_test == corners[edge][0]) *z2 += TILE_HEIGHT; // The slope is non-continuous in z2. z2 is on the upper side.
|
||||
if (halftile_test == corners[edge][1]) *z1 += TILE_HEIGHT; // The slope is non-continuous in z1. z1 is on the upper side.
|
||||
|
||||
if ((tileh & corners[edge][0]) != 0) *z1 += TILE_HEIGHT; // z1 is raised
|
||||
if ((tileh & corners[edge][1]) != 0) *z2 += TILE_HEIGHT; // z2 is raised
|
||||
if (tileh == corners[edge][2]) *z1 += TILE_HEIGHT; // z1 is highest corner of a steep slope
|
||||
if (tileh == corners[edge][3]) *z2 += TILE_HEIGHT; // z2 is highest corner of a steep slope
|
||||
if ((tileh & ~SLOPE_HALFTILE_MASK) == corners[edge][2]) *z1 += TILE_HEIGHT; // z1 is highest corner of a steep slope
|
||||
if ((tileh & ~SLOPE_HALFTILE_MASK) == corners[edge][3]) *z2 += TILE_HEIGHT; // z2 is highest corner of a steep slope
|
||||
}
|
||||
|
||||
static Slope GetFoundationSlope(TileIndex tile, uint* z)
|
||||
|
Reference in New Issue
Block a user