From febf8b0d5751462e3003e7f356857e7ea64125e6 Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Sun, 31 Aug 2025 18:27:46 +0100 Subject: [PATCH] Fix #14561: Vehicle effects missing for vehicle on bridge. (#14563) --- src/vehicle.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/vehicle.cpp b/src/vehicle.cpp index b94670cbac..bc039c3321 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -2754,6 +2754,22 @@ static void SpawnAdvancedVisualEffect(const Vehicle *v) } } +/** + * Test if a bridge is above a vehicle. + * @param v Vehicle to test. + * @return true iff a bridge is above the vehicle. + */ +static bool IsBridgeAboveVehicle(const Vehicle *v) +{ + if (IsBridgeTile(v->tile)) { + /* If the vehicle is 'on' a bridge tile, check the real position of the vehicle. If it's different then the + * vehicle is on the middle of the bridge, which cannot have a bridge above. */ + TileIndex tile = TileVirtXY(v->x_pos, v->y_pos); + if (tile != v->tile) return false; + } + return IsBridgeAbove(v->tile); +} + /** * Draw visual effects (smoke and/or sparks) for a vehicle chain. * @pre this->IsPrimaryVehicle() @@ -2817,7 +2833,7 @@ void Vehicle::ShowVisualEffect() const * - The vehicle is a train engine that is currently unpowered */ if (effect_model == VESM_NONE || v->vehstatus.Test(VehState::Hidden) || - IsBridgeAbove(v->tile) || + IsBridgeAboveVehicle(v) || IsDepotTile(v->tile) || IsTunnelTile(v->tile) || (v->type == VEH_TRAIN &&