Use custom sprite sorting rules for vehicles diagonally under bridges

Extend bb sprite south for comparisons, but only for vehicles underneath
This is to avoid creating sprite sorting problems for vehicles
on top of the bridge

Adjust ParentSpriteToDraw struct
This commit is contained in:
Jonathan G Rennison
2024-02-08 20:44:15 +00:00
parent ea8aa47832
commit a484a5eb77
6 changed files with 152 additions and 43 deletions

View File

@@ -2495,7 +2495,12 @@ void DrawBridgeMiddle(const TileInfo *ti)
int z = bridge_z - BRIDGE_Z_START;
/* Add a bounding box that separates the bridge from things below it. */
AddSortableSpriteToDraw(SPR_EMPTY_BOUNDING_BOX, PAL_NONE, x, y, 16, 16, 1, bridge_z - TILE_HEIGHT + BB_Z_SEPARATOR);
ViewportSortableSpriteSpecialFlags special_flags = VSSF_NONE;
if (IsPlainRailTile(ti->tile) && (GetTrackBits(ti->tile) & (TRACK_BIT_LEFT | TRACK_BIT_RIGHT | TRACK_BIT_LOWER)) != 0) {
/* Problematic diagonal rail track is underneath this bridge */
special_flags = VSSSF_SORT_SPECIAL | VSSSF_SORT_SORT_BRIDGE_BB;
}
AddSortableSpriteToDraw(SPR_EMPTY_BOUNDING_BOX, PAL_NONE, x, y, 16, 16, 1, bridge_z - TILE_HEIGHT + BB_Z_SEPARATOR, false, 0, 0, 0, nullptr, special_flags);
/* Draw Trambits as SpriteCombine */
if (transport_type == TRANSPORT_ROAD || transport_type == TRANSPORT_RAIL) StartSpriteCombine();