diff options
author | frosch <frosch@openttd.org> | 2021-03-10 22:49:56 +0100 |
---|---|---|
committer | frosch <github@elsenhans.name> | 2021-03-11 00:21:09 +0100 |
commit | f580ab4ba460c307cd9d4037815e69e7a8185541 (patch) | |
tree | 3aef3010a37437e678c633c50efa76ae4cc47d49 /src | |
parent | 28589db66473c73583d4b862bc9990e51af1521b (diff) | |
download | openttd-f580ab4ba460c307cd9d4037815e69e7a8185541.tar.xz |
Fix #8647: draw tram catenary using 4 bounding boxes.
The back sprite is now supposed to contain west, north and east pillars.
The front sprite is supposed to contain the south pillar and the wires.
Diffstat (limited to 'src')
-rw-r--r-- | src/road_cmd.cpp | 19 |
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); + } } /** |