Index: src/water_cmd.cpp =================================================================== --- src/water_cmd.cpp (revision 8496) +++ src/water_cmd.cpp (working copy) @@ -40,6 +40,7 @@ }; +static Vehicle *FindFloodableVehicleOnTile(TileIndex tile); static void FloodVehicle(Vehicle *v); /** Build a ship depot. @@ -565,7 +566,7 @@ } else { _current_player = OWNER_WATER; { - Vehicle *v = FindVehicleOnTileZ(target, 0); + Vehicle *v = FindFloodableVehicleOnTile(target); if (v != NULL) FloodVehicle(v); } @@ -576,6 +577,25 @@ } } +static Vehicle *FindFloodableVehicleOnTile(TileIndex tile) { + if (IsBridgeTile(tile)) { + TileIndex end = GetOtherBridgeEnd(tile); + byte z = GetBridgeHeight(tile); + Vehicle *v; + + //check the start tile first since as this is closest to the water + v = FindVehicleOnTileZ(tile, z); + if (v != NULL) return v; + + v = FindVehicleBetween(tile, end, z); + if (v != NULL) return v; + + //check the end tile last to give fleeing vehicles a chance to escape + return FindVehicleOnTileZ(end, z); + } + return FindVehicleOnTileZ(tile, 0); +} + static void FloodVehicle(Vehicle *v) { if (!(v->vehstatus & VS_CRASHED)) {