* Draw ground sprite and road pieces * @param ti TileInfo */
| 1623 | * @param ti TileInfo |
| 1624 | */ |
| 1625 | static void DrawRoadBits(TileInfo *ti) |
| 1626 | { |
| 1627 | RoadBits road = GetRoadBits(ti->tile, RTT_ROAD); |
| 1628 | RoadBits tram = GetRoadBits(ti->tile, RTT_TRAM); |
| 1629 | |
| 1630 | RoadType road_rt = GetRoadTypeRoad(ti->tile); |
| 1631 | RoadType tram_rt = GetRoadTypeTram(ti->tile); |
| 1632 | const RoadTypeInfo *road_rti = road_rt == INVALID_ROADTYPE ? nullptr : GetRoadTypeInfo(road_rt); |
| 1633 | const RoadTypeInfo *tram_rti = tram_rt == INVALID_ROADTYPE ? nullptr : GetRoadTypeInfo(tram_rt); |
| 1634 | |
| 1635 | if (ti->tileh != SLOPE_FLAT) { |
| 1636 | DrawFoundation(ti, GetRoadFoundation(ti->tileh, road | tram)); |
| 1637 | /* DrawFoundation() modifies ti. */ |
| 1638 | } |
| 1639 | |
| 1640 | DrawRoadGroundSprites(ti, road, tram, road_rti, tram_rti, GetRoadside(ti->tile), IsOnSnowOrDesert(ti->tile)); |
| 1641 | |
| 1642 | /* Draw one way */ |
| 1643 | if (road_rti != nullptr) { |
| 1644 | DisallowedRoadDirections drd = GetDisallowedRoadDirections(ti->tile); |
| 1645 | if (drd != DRD_NONE) { |
| 1646 | SpriteID oneway = GetCustomRoadSprite(road_rti, ti->tile, ROTSG_ONEWAY); |
| 1647 | |
| 1648 | if (oneway == 0) oneway = SPR_ONEWAY_BASE; |
| 1649 | |
| 1650 | if ((ti->tileh == SLOPE_NE) || (ti->tileh == SLOPE_NW)) { |
| 1651 | oneway += ONEWAY_SLOPE_N_OFFSET; |
| 1652 | } else if ((ti->tileh == SLOPE_SE) || (ti->tileh == SLOPE_SW)) { |
| 1653 | oneway += ONEWAY_SLOPE_S_OFFSET; |
| 1654 | } |
| 1655 | |
| 1656 | DrawGroundSpriteAt(oneway + drd - 1 + ((road == ROAD_X) ? 0 : 3), PAL_NONE, 8, 8, GetPartialPixelZ(8, 8, ti->tileh)); |
| 1657 | } |
| 1658 | } |
| 1659 | |
| 1660 | if (HasRoadWorks(ti->tile)) { |
| 1661 | /* Road works */ |
| 1662 | DrawGroundSprite((road | tram) & ROAD_X ? SPR_EXCAVATION_X : SPR_EXCAVATION_Y, PAL_NONE); |
| 1663 | return; |
| 1664 | } |
| 1665 | |
| 1666 | /* Draw road, tram catenary */ |
| 1667 | DrawRoadCatenary(ti); |
| 1668 | |
| 1669 | /* Return if full detail is disabled, or we are zoomed fully out. */ |
| 1670 | if (!HasBit(_display_opt, DO_FULL_DETAIL) || _cur_dpi->zoom > ZoomLevel::Detail) return; |
| 1671 | |
| 1672 | /* Do not draw details (street lights, trees) under low bridge */ |
| 1673 | Roadside roadside = GetRoadside(ti->tile); |
| 1674 | if (IsBridgeAbove(ti->tile) && (roadside == Roadside::Trees || roadside == Roadside::StreetLights)) { |
| 1675 | int height = GetBridgeHeight(GetNorthernBridgeEnd(ti->tile)); |
| 1676 | int minz = GetTileMaxZ(ti->tile) + 2; |
| 1677 | |
| 1678 | if (roadside == Roadside::Trees) minz++; |
| 1679 | |
| 1680 | if (height < minz) return; |
| 1681 | } |
| 1682 |
no test coverage detected