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

Function DrawRoadOverlays

src/road_cmd.cpp:1505–1541  ·  view source on GitHub ↗

* Draw road underlay and overlay sprites. * @param ti TileInfo * @param road_rti Road road type information * @param tram_rti Tram road type information * @param road_offset Road sprite offset (based on road bits) * @param tram_offset Tram sprite offset (based on road bits) * @param draw_underlay Whether to draw underlays */

Source from the content-addressed store, hash-verified

1503 * @param draw_underlay Whether to draw underlays
1504 */
1505void DrawRoadOverlays(const TileInfo *ti, PaletteID pal, const RoadTypeInfo *road_rti, const RoadTypeInfo *tram_rti, uint road_offset, uint tram_offset, bool draw_underlay)
1506{
1507 if (draw_underlay) {
1508 /* Road underlay takes precedence over tram */
1509 if (road_rti != nullptr) {
1510 if (road_rti->UsesOverlay()) {
1511 SpriteID ground = GetCustomRoadSprite(road_rti, ti->tile, ROTSG_GROUND);
1512 DrawGroundSprite(ground + road_offset, pal);
1513 }
1514 } else {
1515 if (tram_rti->UsesOverlay()) {
1516 SpriteID ground = GetCustomRoadSprite(tram_rti, ti->tile, ROTSG_GROUND);
1517 DrawGroundSprite(ground + tram_offset, pal);
1518 } else {
1519 DrawGroundSprite(SPR_TRAMWAY_TRAM + tram_offset, pal);
1520 }
1521 }
1522 }
1523
1524 /* Draw road overlay */
1525 if (road_rti != nullptr) {
1526 if (road_rti->UsesOverlay()) {
1527 SpriteID ground = GetCustomRoadSprite(road_rti, ti->tile, ROTSG_OVERLAY);
1528 if (ground != 0) DrawGroundSprite(ground + road_offset, pal);
1529 }
1530 }
1531
1532 /* Draw tram overlay */
1533 if (tram_rti != nullptr) {
1534 if (tram_rti->UsesOverlay()) {
1535 SpriteID ground = GetCustomRoadSprite(tram_rti, ti->tile, ROTSG_OVERLAY);
1536 if (ground != 0) DrawGroundSprite(ground + tram_offset, pal);
1537 } else if (road_rti != nullptr) {
1538 DrawGroundSprite(SPR_TRAMWAY_OVERLAY + tram_offset, pal);
1539 }
1540 }
1541}
1542
1543/**
1544 * Get ground sprite to draw for a road tile.

Callers 4

DrawTile_TunnelBridgeFunction · 0.85
DrawTile_StationFunction · 0.85
DrawRoadGroundSpritesFunction · 0.85
DrawTile_RoadFunction · 0.85

Calls 3

GetCustomRoadSpriteFunction · 0.85
DrawGroundSpriteFunction · 0.85
UsesOverlayMethod · 0.45

Tested by

no test coverage detected