MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / ApplyFoundationToSlope

Function ApplyFoundationToSlope

src/landscape.cpp:174–217  ·  view source on GitHub ↗

* 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. */

Source from the content-addressed store, hash-verified

172 * @return Increment to the tile Z coordinate.
173 */
174uint 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/**

Callers 9

GetFoundationSlopeFunction · 0.85
FloodHalftileFunction · 0.85
TestAutoslopeOnRailTileFunction · 0.85
HasBridgeFlatRampFunction · 0.85
CheckBridgeSlopeFunction · 0.85
DrawRailCatenaryRailwayFunction · 0.85
TerraformTile_RoadFunction · 0.85
GetBridgeHeightFunction · 0.85

Calls 13

IsFoundationFunction · 0.85
IsLeveledFoundationFunction · 0.85
IsSteepSlopeFunction · 0.85
HalftileSlopeFunction · 0.85
IsSpecialRailFoundationFunction · 0.85
OppositeCornerFunction · 0.85
GetRailFoundationCornerFunction · 0.85
GetHighestSlopeCornerFunction · 0.85
SlopeWithOneCornerRaisedFunction · 0.85

Tested by 1

TestAutoslopeOnRailTileFunction · 0.68