From e1d629dba369f4ba4353fc80096cbdbfa357b75c Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Fri, 9 Feb 2024 01:30:17 +0000 Subject: [PATCH] Also use custom sprite sorting for catenary pylons under bridges --- src/elrail.cpp | 9 +++++++-- src/viewport_func.h | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/elrail.cpp b/src/elrail.cpp index 732db18fdc..2b05835773 100644 --- a/src/elrail.cpp +++ b/src/elrail.cpp @@ -481,14 +481,19 @@ static void DrawRailCatenaryRailway(const TileInfo *ti) * Remove those (simply by ANDing with allowed, since these markers are never allowed) */ if ((PPPallowed[i] & PPPpreferred[i]) != 0) PPPallowed[i] &= PPPpreferred[i]; + ViewportSortableSpriteSpecialFlags special_flags = VSSF_NONE; + if (IsBridgeAbove(ti->tile)) { Track bridgetrack = GetBridgeAxis(ti->tile) == AXIS_X ? TRACK_X : TRACK_Y; int height = GetBridgeHeight(GetNorthernBridgeEnd(ti->tile)); - if ((height <= GetTileMaxZ(ti->tile) + 1) && + int max_z = GetTileMaxZ(ti->tile); + if ((height <= max_z + 1) && (i == PCPpositions[bridgetrack][0] || i == PCPpositions[bridgetrack][1])) { SetBit(OverridePCP, i); } + + if (height <= max_z + 1) special_flags = VSSSF_SORT_SPECIAL | VSSSF_SORT_DIAG_VEH; } if (PPPallowed[i] != 0 && HasBit(PCPstatus, i) && !HasBit(OverridePCP, i) && @@ -508,7 +513,7 @@ static void DrawRailCatenaryRailway(const TileInfo *ti) } AddSortableSpriteToDraw(pylon_base + pylon_sprites[temp], PAL_NONE, x, y, 1, 1, BB_HEIGHT_UNDER_BRIDGE, - elevation, IsTransparencySet(TO_CATENARY), -1, -1); + elevation, IsTransparencySet(TO_CATENARY), -1, -1, 0, nullptr, special_flags); break; // We already have drawn a pylon, bail out } diff --git a/src/viewport_func.h b/src/viewport_func.h index b607b20d24..84ea06d5ff 100644 --- a/src/viewport_func.h +++ b/src/viewport_func.h @@ -76,7 +76,7 @@ enum ViewportSortableSpriteSpecialFlags : uint8_t { VSSF_NONE = 0, VSSSF_SORT_SPECIAL = 0x80, ///< When sorting sprites, if both sprites have this set, special sorting rules apply VSSSF_SORT_SPECIAL_TYPE_MASK = 1, ///< Mask to use for getting the special type - VSSSF_SORT_DIAG_VEH = 0, ///< This is a vehicle moving diagonally with respect to the tile axes + VSSSF_SORT_DIAG_VEH = 0, ///< This is a vehicle moving diagonally with respect to the tile axes (also used for catenary pylons on diagonal track under bridges for similar reasons) VSSSF_SORT_SORT_BRIDGE_BB = 1, ///< This is a bridge BB helper sprite }; DECLARE_ENUM_AS_BIT_SET(ViewportSortableSpriteSpecialFlags);