| 2055 | } |
| 2056 | |
| 2057 | static void DrawTrackBitsOverlay(TileInfo *ti, TrackBits track, const RailTypeInfo *rti) |
| 2058 | { |
| 2059 | RailGroundType rgt = GetRailGroundType(ti->tile); |
| 2060 | Foundation f = GetRailFoundation(ti->tileh, track); |
| 2061 | Corner halftile_corner = CORNER_INVALID; |
| 2062 | |
| 2063 | if (IsNonContinuousFoundation(f)) { |
| 2064 | /* Save halftile corner */ |
| 2065 | halftile_corner = (f == FOUNDATION_STEEP_BOTH ? GetHighestSlopeCorner(ti->tileh) : GetHalftileFoundationCorner(f)); |
| 2066 | /* Draw lower part first */ |
| 2067 | track &= ~CornerToTrackBits(halftile_corner); |
| 2068 | f = (f == FOUNDATION_STEEP_BOTH ? FOUNDATION_STEEP_LOWER : FOUNDATION_NONE); |
| 2069 | } |
| 2070 | |
| 2071 | DrawFoundation(ti, f); |
| 2072 | /* DrawFoundation modifies ti */ |
| 2073 | |
| 2074 | /* Draw ground */ |
| 2075 | if (rgt == RailGroundType::HalfTileWater) { |
| 2076 | if (track != TRACK_BIT_NONE || IsSteepSlope(ti->tileh)) { |
| 2077 | /* three-corner-raised slope or steep slope with track on upper part */ |
| 2078 | DrawShoreTile(ti->tileh); |
| 2079 | } else { |
| 2080 | /* single-corner-raised slope with track on upper part */ |
| 2081 | DrawGroundSprite(SPR_FLAT_WATER_TILE, PAL_NONE); |
| 2082 | } |
| 2083 | } else { |
| 2084 | SpriteID image; |
| 2085 | |
| 2086 | switch (rgt) { |
| 2087 | case RailGroundType::Barren: image = SPR_FLAT_BARE_LAND; break; |
| 2088 | case RailGroundType::SnowOrDesert: image = SPR_FLAT_SNOW_DESERT_TILE; break; |
| 2089 | default: image = SPR_FLAT_GRASS_TILE; break; |
| 2090 | } |
| 2091 | |
| 2092 | image += SlopeToSpriteOffset(ti->tileh); |
| 2093 | |
| 2094 | DrawGroundSprite(image, PAL_NONE); |
| 2095 | } |
| 2096 | |
| 2097 | bool no_combine = ti->tileh == SLOPE_FLAT && rti->flags.Test(RailTypeFlag::NoSpriteCombine); |
| 2098 | SpriteID overlay = GetCustomRailSprite(rti, ti->tile, RTSG_OVERLAY); |
| 2099 | SpriteID ground = GetCustomRailSprite(rti, ti->tile, no_combine ? RTSG_GROUND_COMPLETE : RTSG_GROUND); |
| 2100 | TrackBits pbs = _settings_client.gui.show_track_reservation ? GetRailReservationTrackBits(ti->tile) : TRACK_BIT_NONE; |
| 2101 | |
| 2102 | if (track == TRACK_BIT_NONE) { |
| 2103 | /* Half-tile foundation, no track here? */ |
| 2104 | } else if (no_combine) { |
| 2105 | /* Use trackbits as direct index from ground sprite, subtract 1 |
| 2106 | * because there is no sprite for no bits. */ |
| 2107 | DrawGroundSprite(ground + track - 1, PAL_NONE); |
| 2108 | |
| 2109 | /* Draw reserved track bits */ |
| 2110 | if (pbs & TRACK_BIT_X) DrawGroundSprite(overlay + RTO_X, PALETTE_CRASH); |
| 2111 | if (pbs & TRACK_BIT_Y) DrawGroundSprite(overlay + RTO_Y, PALETTE_CRASH); |
| 2112 | if (pbs & TRACK_BIT_UPPER) DrawTrackSprite(overlay + RTO_N, PALETTE_CRASH, ti, SLOPE_N); |
| 2113 | if (pbs & TRACK_BIT_LOWER) DrawTrackSprite(overlay + RTO_S, PALETTE_CRASH, ti, SLOPE_S); |
| 2114 | if (pbs & TRACK_BIT_RIGHT) DrawTrackSprite(overlay + RTO_E, PALETTE_CRASH, ti, SLOPE_E); |
no test coverage detected