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

Function TileLoop_Track

src/rail_cmd.cpp:2595–2718  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2593}
2594
2595static void TileLoop_Track(TileIndex tile)
2596{
2597 RailGroundType old_ground = GetRailGroundType(tile);
2598 RailGroundType new_ground;
2599
2600 if (old_ground == RailGroundType::HalfTileWater) {
2601 TileLoop_Water(tile);
2602 return;
2603 }
2604
2605 switch (_settings_game.game_creation.landscape) {
2606 case LandscapeType::Arctic: {
2607 auto [slope, z] = GetTileSlopeZ(tile);
2608 bool half = false;
2609
2610 /* for non-flat track, use lower part of track
2611 * in other cases, use the highest part with track */
2612 if (IsPlainRail(tile)) {
2613 TrackBits track = GetTrackBits(tile);
2614 Foundation f = GetRailFoundation(slope, track);
2615
2616 switch (f) {
2617 case FOUNDATION_NONE:
2618 /* no foundation - is the track on the upper side of three corners raised tile? */
2619 if (IsSlopeWithThreeCornersRaised(slope)) z++;
2620 break;
2621
2622 case FOUNDATION_INCLINED_X:
2623 case FOUNDATION_INCLINED_Y:
2624 /* sloped track - is it on a steep slope? */
2625 if (IsSteepSlope(slope)) z++;
2626 break;
2627
2628 case FOUNDATION_STEEP_LOWER:
2629 /* only lower part of steep slope */
2630 z++;
2631 break;
2632
2633 default:
2634 /* if it is a steep slope, then there is a track on higher part */
2635 if (IsSteepSlope(slope)) z++;
2636 z++;
2637 break;
2638 }
2639
2640 half = IsInsideMM(f, FOUNDATION_STEEP_BOTH, FOUNDATION_HALFTILE_N + 1);
2641 } else {
2642 /* is the depot on a non-flat tile? */
2643 if (slope != SLOPE_FLAT) z++;
2644 }
2645
2646 /* 'z' is now the lowest part of the highest track bit -
2647 * for sloped track, it is 'z' of lower part
2648 * for two track bits, it is 'z' of higher track bit
2649 * For non-continuous foundations (and STEEP_BOTH), 'half' is set */
2650 if (z > GetSnowLine()) {
2651 if (half && z - GetSnowLine() == 1) {
2652 /* track on non-continuous foundation, lower part is not under snow */

Callers

nothing calls this directly

Calls 15

GetRailGroundTypeFunction · 0.85
TileLoop_WaterFunction · 0.85
GetTileSlopeZFunction · 0.85
IsPlainRailFunction · 0.85
GetTrackBitsFunction · 0.85
GetRailFoundationFunction · 0.85
IsSteepSlopeFunction · 0.85
IsInsideMMFunction · 0.85
GetSnowLineFunction · 0.85
GetTropicZoneFunction · 0.85
GetTileOwnerFunction · 0.85

Tested by

no test coverage detected