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

Function DrawTile_Road

src/road_cmd.cpp:1706–1892  ·  view source on GitHub ↗

Tile callback function for rendering a road tile to the screen */

Source from the content-addressed store, hash-verified

1704
1705/** Tile callback function for rendering a road tile to the screen */
1706static void DrawTile_Road(TileInfo *ti)
1707{
1708 BridgePillarFlags blocked_pillars{};
1709 switch (GetRoadTileType(ti->tile)) {
1710 case RoadTileType::Normal:
1711 DrawRoadBits(ti);
1712
1713 if (IsBridgeAbove(ti->tile)) {
1714 RoadBits bits = GetAllRoadBits(ti->tile);
1715 if ((bits & ROAD_NE) != 0) blocked_pillars.Set(BridgePillarFlag::EdgeNE);
1716 if ((bits & ROAD_SE) != 0) blocked_pillars.Set(BridgePillarFlag::EdgeSE);
1717 if ((bits & ROAD_SW) != 0) blocked_pillars.Set(BridgePillarFlag::EdgeSW);
1718 if ((bits & ROAD_NW) != 0) blocked_pillars.Set(BridgePillarFlag::EdgeNW);
1719 }
1720 break;
1721
1722 case RoadTileType::Crossing: {
1723 if (ti->tileh != SLOPE_FLAT) DrawFoundation(ti, FOUNDATION_LEVELED);
1724
1725 Axis axis = GetCrossingRailAxis(ti->tile);
1726
1727 const RailTypeInfo *rti = GetRailTypeInfo(GetRailType(ti->tile));
1728
1729 RoadType road_rt = GetRoadTypeRoad(ti->tile);
1730 RoadType tram_rt = GetRoadTypeTram(ti->tile);
1731 const RoadTypeInfo *road_rti = road_rt == INVALID_ROADTYPE ? nullptr : GetRoadTypeInfo(road_rt);
1732 const RoadTypeInfo *tram_rti = tram_rt == INVALID_ROADTYPE ? nullptr : GetRoadTypeInfo(tram_rt);
1733
1734 PaletteID pal = PAL_NONE;
1735
1736 /* Draw base ground */
1737 if (rti->UsesOverlay()) {
1738 SpriteID image = SPR_ROAD_Y + axis;
1739
1740 Roadside roadside = GetRoadside(ti->tile);
1741 if (DrawRoadAsSnowOrDesert(IsOnSnowOrDesert(ti->tile), roadside)) {
1742 image += 19;
1743 } else {
1744 switch (roadside) {
1745 case Roadside::Barren:
1746 pal = PALETTE_TO_BARE_LAND;
1747 break;
1748
1749 case Roadside::Grass:
1750 break;
1751
1752 default:
1753 image -= 19;
1754 break; // Paved
1755 }
1756 }
1757
1758 DrawGroundSprite(image, pal);
1759 } else {
1760 SpriteID image = rti->base_sprites.crossing + axis;
1761 if (IsCrossingBarred(ti->tile)) image += 2;
1762
1763 Roadside roadside = GetRoadside(ti->tile);

Callers

nothing calls this directly

Calls 15

GetRoadTileTypeFunction · 0.85
DrawRoadBitsFunction · 0.85
IsBridgeAboveFunction · 0.85
GetAllRoadBitsFunction · 0.85
DrawFoundationFunction · 0.85
GetCrossingRailAxisFunction · 0.85
GetRailTypeInfoFunction · 0.85
GetRailTypeFunction · 0.85
GetRoadTypeRoadFunction · 0.85
GetRoadTypeTramFunction · 0.85
GetRoadTypeInfoFunction · 0.85
GetRoadsideFunction · 0.85

Tested by

no test coverage detected