diff options
author | rubidium <rubidium@openttd.org> | 2007-10-20 16:50:48 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2007-10-20 16:50:48 +0000 |
commit | 5289aa2010b5fb249ba316f6e4b67ad5f7159120 (patch) | |
tree | 30e50cebc542be694f72726e770ef47ea943f6d0 /src/landscape.cpp | |
parent | 8212088c03c0a0af451f734391699e5dab8d8608 (diff) | |
download | openttd-5289aa2010b5fb249ba316f6e4b67ad5f7159120.tar.xz |
(svn r11313) -Codechange: prepare several pieces of code so the can handle some new slopes. Patch by frosch.
Diffstat (limited to 'src/landscape.cpp')
-rw-r--r-- | src/landscape.cpp | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/src/landscape.cpp b/src/landscape.cpp index be845161a..d4e25e703 100644 --- a/src/landscape.cpp +++ b/src/landscape.cpp @@ -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) |