* Applies a foundation to a slope. * * @pre Foundation and slope must be valid combined. * @param f The #Foundation. * @param s The #Slope to modify. * @return Increment to the tile Z coordinate. */
| 172 | * @return Increment to the tile Z coordinate. |
| 173 | */ |
| 174 | uint ApplyFoundationToSlope(Foundation f, Slope &s) |
| 175 | { |
| 176 | if (!IsFoundation(f)) return 0; |
| 177 | |
| 178 | if (IsLeveledFoundation(f)) { |
| 179 | uint dz = 1 + (IsSteepSlope(s) ? 1 : 0); |
| 180 | s = SLOPE_FLAT; |
| 181 | return dz; |
| 182 | } |
| 183 | |
| 184 | if (f != FOUNDATION_STEEP_BOTH && IsNonContinuousFoundation(f)) { |
| 185 | s = HalftileSlope(s, GetHalftileFoundationCorner(f)); |
| 186 | return 0; |
| 187 | } |
| 188 | |
| 189 | if (IsSpecialRailFoundation(f)) { |
| 190 | s = SlopeWithThreeCornersRaised(OppositeCorner(GetRailFoundationCorner(f))); |
| 191 | return 0; |
| 192 | } |
| 193 | |
| 194 | uint dz = IsSteepSlope(s) ? 1 : 0; |
| 195 | Corner highest_corner = GetHighestSlopeCorner(s); |
| 196 | |
| 197 | switch (f) { |
| 198 | case FOUNDATION_INCLINED_X: |
| 199 | s = (((highest_corner == CORNER_W) || (highest_corner == CORNER_S)) ? SLOPE_SW : SLOPE_NE); |
| 200 | break; |
| 201 | |
| 202 | case FOUNDATION_INCLINED_Y: |
| 203 | s = (((highest_corner == CORNER_S) || (highest_corner == CORNER_E)) ? SLOPE_SE : SLOPE_NW); |
| 204 | break; |
| 205 | |
| 206 | case FOUNDATION_STEEP_LOWER: |
| 207 | s = SlopeWithOneCornerRaised(highest_corner); |
| 208 | break; |
| 209 | |
| 210 | case FOUNDATION_STEEP_BOTH: |
| 211 | s = HalftileSlope(SlopeWithOneCornerRaised(highest_corner), highest_corner); |
| 212 | break; |
| 213 | |
| 214 | default: NOT_REACHED(); |
| 215 | } |
| 216 | return dz; |
| 217 | } |
| 218 | |
| 219 | |
| 220 | /** |