diff --git a/src/elrail.cpp b/src/elrail.cpp index 03adb0c8c9..6f238ee515 100644 --- a/src/elrail.cpp +++ b/src/elrail.cpp @@ -485,10 +485,11 @@ static void DrawRailCatenaryRailway(const TileInfo *ti) /* * The "wire"-sprite position is inside the tile, i.e. 0 <= sss->?_offset < TILE_SIZE. * Therefore it is safe to use GetSlopePixelZ() for the elevation. - * Also note that the result of GetSlopePixelZ() is very special for bridge-ramps. + * Also note that the result of GetSlopePixelZ() is very special for bridge-ramps, so we round the result up or + * down to the nearest full height change. */ AddSortableSpriteToDraw(wire_base + sss->image_offset, PAL_NONE, ti->x + sss->x_offset, ti->y + sss->y_offset, - sss->x_size, sss->y_size, sss->z_size, GetSlopePixelZ(ti->x + sss->x_offset, ti->y + sss->y_offset) + sss->z_offset, + sss->x_size, sss->y_size, sss->z_size, (GetSlopePixelZ(ti->x + sss->x_offset, ti->y + sss->y_offset) + 4) / 8 * 8 + sss->z_offset, IsTransparencySet(TO_CATENARY)); } } diff --git a/src/table/elrail_data.h b/src/table/elrail_data.h index 12132848b8..5e1b9e792f 100644 --- a/src/table/elrail_data.h +++ b/src/table/elrail_data.h @@ -327,7 +327,9 @@ struct SortableSpriteStruct { /** Distance between wire and rail */ static const uint ELRAIL_ELEVATION = 10; /** Wires that a draw one level higher than the north corner. */ -static const uint ELRAIL_ELEVRAISE = ELRAIL_ELEVATION + TILE_HEIGHT; +static const uint ELRAIL_ELEVRAISE = ELRAIL_ELEVATION + TILE_HEIGHT + 1; +/** Wires that a draw one level lower than the north corner. */ +static const uint ELRAIL_ELEVLOWER = ELRAIL_ELEVATION - 1; static const SortableSpriteStruct RailCatenarySpriteData[] = { /* X direction @@ -345,9 +347,9 @@ static const SortableSpriteStruct RailCatenarySpriteData[] = { /* "down" tiles * Wires */ - { WSO_X_SW_DOWN, 0, 7, 15, 8, 1, ELRAIL_ELEVATION }, //! 6: Wire in X pitch down, pylon on the SW end - { WSO_X_NE_DOWN, 0, 7, 15, 8, 1, ELRAIL_ELEVATION }, //! 7: Wire in X pitch down, pylon on the NE end - { WSO_X_SHORT_DOWN, 0, 7, 15, 8, 1, ELRAIL_ELEVATION }, //! 8: Wire in X pitch down, pylon on both ends + { WSO_X_SW_DOWN, 0, 7, 15, 8, 1, ELRAIL_ELEVLOWER }, //! 6: Wire in X pitch down, pylon on the SW end + { WSO_X_NE_DOWN, 0, 7, 15, 8, 1, ELRAIL_ELEVLOWER }, //! 7: Wire in X pitch down, pylon on the NE end + { WSO_X_SHORT_DOWN, 0, 7, 15, 8, 1, ELRAIL_ELEVLOWER }, //! 8: Wire in X pitch down, pylon on both ends /* Y direction @@ -365,9 +367,9 @@ static const SortableSpriteStruct RailCatenarySpriteData[] = { /* "down" tiles * Wires */ - { WSO_Y_SE_DOWN, 7, 0, 8, 15, 1, ELRAIL_ELEVATION }, //!15: Wire in Y pitch down, pylon on the SE end - { WSO_Y_NW_DOWN, 7, 0, 8, 15, 1, ELRAIL_ELEVATION }, //!16: Wire in Y pitch down, pylon on the NW end - { WSO_Y_SHORT_DOWN, 7, 0, 8, 15, 1, ELRAIL_ELEVATION }, //!17: Wire in Y pitch down, pylon on both ends + { WSO_Y_SE_DOWN, 7, 0, 8, 15, 1, ELRAIL_ELEVLOWER }, //!15: Wire in Y pitch down, pylon on the SE end + { WSO_Y_NW_DOWN, 7, 0, 8, 15, 1, ELRAIL_ELEVLOWER }, //!16: Wire in Y pitch down, pylon on the NW end + { WSO_Y_SHORT_DOWN, 7, 0, 8, 15, 1, ELRAIL_ELEVLOWER }, //!17: Wire in Y pitch down, pylon on both ends /* NS Direction */ { WSO_NS_SHORT, 8, 0, 8, 8, 1, ELRAIL_ELEVATION }, //!18: LEFT trackbit wire, pylon on both ends