summaryrefslogtreecommitdiff
path: root/src/road_cmd.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/road_cmd.cpp')
-rw-r--r--src/road_cmd.cpp19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp
index 9fffa45ca..830f9dd4f 100644
--- a/src/road_cmd.cpp
+++ b/src/road_cmd.cpp
@@ -1423,8 +1423,23 @@ void DrawRoadTypeCatenary(const TileInfo *ti, RoadType rt, RoadBits rb)
* For tiles with OWNER_TOWN or OWNER_NONE, recolour CC to grey as a neutral colour. */
Owner owner = GetRoadOwner(ti->tile, GetRoadTramType(rt));
PaletteID pal = (owner == OWNER_NONE || owner == OWNER_TOWN ? GENERAL_SPRITE_COLOUR(COLOUR_GREY) : COMPANY_SPRITE_COLOUR(owner));
- if (back != 0) AddSortableSpriteToDraw(back, pal, ti->x, ti->y, 16, 16, TILE_HEIGHT + BB_HEIGHT_UNDER_BRIDGE, ti->z, IsTransparencySet(TO_CATENARY));
- if (front != 0) AddSortableSpriteToDraw(front, pal, ti->x, ti->y, 16, 16, TILE_HEIGHT + BB_HEIGHT_UNDER_BRIDGE, ti->z, IsTransparencySet(TO_CATENARY));
+ int z_wires = (ti->tileh == SLOPE_FLAT ? 0 : TILE_HEIGHT) + BB_HEIGHT_UNDER_BRIDGE;
+ if (back != 0) {
+ /* The "back" sprite contains the west, north and east pillars.
+ * We cut the sprite at 3/8 of the west/east edges to create 3 sprites.
+ * 3/8 is chosen so that sprites can somewhat graphically extend into the tile. */
+ static const int INF = 1000; ///< big number compared to sprite size
+ static const SubSprite west = { -INF, -INF, -12, INF };
+ static const SubSprite north = { -12, -INF, 12, INF };
+ static const SubSprite east = { 12, -INF, INF, INF };
+ AddSortableSpriteToDraw(back, pal, ti->x, ti->y, 16, 1, z_wires, ti->z, IsTransparencySet(TO_CATENARY), 15, 0, GetSlopePixelZInCorner(ti->tileh, CORNER_W), &west);
+ AddSortableSpriteToDraw(back, pal, ti->x, ti->y, 1, 1, z_wires, ti->z, IsTransparencySet(TO_CATENARY), 0, 0, GetSlopePixelZInCorner(ti->tileh, CORNER_N), &north);
+ AddSortableSpriteToDraw(back, pal, ti->x, ti->y, 1, 16, z_wires, ti->z, IsTransparencySet(TO_CATENARY), 0, 15, GetSlopePixelZInCorner(ti->tileh, CORNER_E), &east);
+ }
+ if (front != 0) {
+ /* Draw the "front" sprite (containing south pillar and wires) at a Z height that is both above the vehicles and above the "back" pillars. */
+ AddSortableSpriteToDraw(front, pal, ti->x, ti->y, 16, 16, z_wires + 1, ti->z, IsTransparencySet(TO_CATENARY), 0, 0, z_wires);
+ }
}
/**