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

Function GetRoadFoundation

src/road_cmd.cpp:1288–1308  ·  view source on GitHub ↗

* Get the foundationtype of a RoadBits Slope combination * * @param tileh The Slope part * @param bits The RoadBits part * @return The resulting Foundation */

Source from the content-addressed store, hash-verified

1286 * @return The resulting Foundation
1287 */
1288static Foundation GetRoadFoundation(Slope tileh, RoadBits bits)
1289{
1290 /* Flat land and land without a road doesn't require a foundation */
1291 if (tileh == SLOPE_FLAT || bits == ROAD_NONE) return FOUNDATION_NONE;
1292
1293 /* Steep slopes behave the same as slopes with one corner raised. */
1294 if (IsSteepSlope(tileh)) {
1295 tileh = SlopeWithOneCornerRaised(GetHighestSlopeCorner(tileh));
1296 }
1297
1298 /* Leveled RoadBits on a slope */
1299 if ((_invalid_tileh_slopes_road[0][tileh] & bits) == ROAD_NONE) return FOUNDATION_LEVELED;
1300
1301 /* Straight roads without foundation on a slope */
1302 if (!IsSlopeWithOneCornerRaised(tileh) &&
1303 (_invalid_tileh_slopes_road[1][tileh] & bits) == ROAD_NONE)
1304 return FOUNDATION_NONE;
1305
1306 /* Roads on steep Slopes or on Slopes with one corner raised */
1307 return (bits == ROAD_X ? FOUNDATION_INCLINED_X : FOUNDATION_INCLINED_Y);
1308}
1309
1310const uint8_t _road_sloped_sprites[14] = {
1311 0, 0, 2, 0,

Callers 7

RemoveRoadFunction · 0.85
CheckRoadSlopeFunction · 0.85
CmdBuildRoadFunction · 0.85
DrawRoadBitsFunction · 0.85
GetSlopePixelZ_RoadFunction · 0.85
GetFoundation_RoadFunction · 0.85
TerraformTile_RoadFunction · 0.85

Calls 4

IsSteepSlopeFunction · 0.85
SlopeWithOneCornerRaisedFunction · 0.85
GetHighestSlopeCornerFunction · 0.85

Tested by

no test coverage detected