From 498810cc46c474653d608137ddf8fa8d2becfb3a Mon Sep 17 00:00:00 2001 From: Timmy Weerwag Date: Mon, 23 Mar 2015 22:28:44 +0100 Subject: [PATCH] Decompiled 0x006A8388 --- src/windows/footpath.c | 45 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/src/windows/footpath.c b/src/windows/footpath.c index 260bc289a1..3374cffb24 100644 --- a/src/windows/footpath.c +++ b/src/windows/footpath.c @@ -152,6 +152,7 @@ static void window_footpath_mousedown_direction(int direction); static void window_footpath_mousedown_slope(int slope); static void window_footpath_show_footpath_types_dialog(rct_window *w, rct_widget *widget, int showQueues); static void window_footpath_set_provisional_path_at_point(int x, int y); +static void window_footpath_set_selection_start_bridge_at_point(int screenX, int screenY); static void window_footpath_place_path_at_point(int x, int y); static void window_footpath_start_bridge_at_point(int screenX, int screenY); static void window_footpath_construct(); @@ -389,7 +390,7 @@ static void window_footpath_toolupdate() if (widgetIndex == WIDX_CONSTRUCT_ON_LAND) { window_footpath_set_provisional_path_at_point(x, y); } else if (widgetIndex == WIDX_CONSTRUCT_BRIDGE_OR_TUNNEL) { - RCT2_CALLPROC_X(0x006A8388, x, y, 0, 0, (int)w, 0, 0); + window_footpath_set_selection_start_bridge_at_point(x, y); } } @@ -703,6 +704,48 @@ static void window_footpath_set_provisional_path_at_point(int x, int y) } } +/** +* +* rct2: 0x006A8388 +*/ +static void window_footpath_set_selection_start_bridge_at_point(int screenX, int screenY) +{ + int x, y, direction; + rct_map_element *mapElement; + + map_invalidate_selection_rect(); + RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) &= 0xfffa; + + sub_68A0C9(screenX, screenY, &x, &y, &direction, &mapElement); + if (x == 0x8000) + return; + + RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) |= 5; + RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_TYPE, uint16) = 4; + RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_X, uint16) = x; + RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_X, uint16) = x; + RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_A_Y, uint16) = y; + RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_B_Y, uint16) = y; + + RCT2_GLOBAL(0x009DEA4E, uint8) = direction; + RCT2_GLOBAL(0x009DEA48, uint16) = x; + RCT2_GLOBAL(0x009DEA4A, uint16) = y; + + int z = mapElement->base_height; + + if ((mapElement->type & 0x3C) == 0) { + uint8 slope = mapElement->properties.surface.slope; + if (slope & 0xf) + z += 2; // Add 2 for a slope + if (slope & 0x10) + z += 2; // Add another 2 for a steep slope + } + + RCT2_GLOBAL(0x009DEA4C, uint16) = z << 3; + + map_invalidate_selection_rect(); +} + /** * * rct2: 0x006A82C5