From 071ef2c88fbcfc9d1c9db111ec0ff628efc4002a Mon Sep 17 00:00:00 2001 From: Timmy Weerwag Date: Mon, 23 Mar 2015 00:34:00 +0100 Subject: [PATCH] Fixed an original bug in bridge footpath building Affects starting to build a footpath bridge on a sloped tile. The original code was horribly broken. I think this is the most intuitive solution considering the height of the arrow when selecting the tile. --- src/windows/footpath.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/windows/footpath.c b/src/windows/footpath.c index d60ab4d6ed..5bf53d8c8c 100644 --- a/src/windows/footpath.c +++ b/src/windows/footpath.c @@ -756,14 +756,18 @@ static void window_footpath_start_bridge_at_point(int screenX, int screenY) return; if (map_element_get_type(mapElement) == MAP_ELEMENT_TYPE_SURFACE) { - // ? - uint8 dl = ((mapElement->properties.surface.slope & 0x0F) << direction) & 0xFF; - uint8 dh = dl; - dl = (dl >> 4) & 0x0F; - dh = (dh & 0x0F) | dl; + // If we start the path on a slope, the arrow is slightly raised, so we + // expect the path to be slightly raised as well. + uint8_t slope = mapElement->properties.surface.slope; z = mapElement->base_height; - if ((dh & 0x0C) == 0x0C) + if (slope & 0x10) { + // Steep diagonal slope + z += 4; + } + else if (slope & 0x0f) { + // Normal slope z += 2; + } } else { z = mapElement->base_height; if (map_element_get_type(mapElement) == MAP_ELEMENT_TYPE_PATH) {