From 892c084cd8d40f1d8129a7a8651ebdd469b6592d Mon Sep 17 00:00:00 2001 From: Tulio Leao Date: Mon, 11 Nov 2019 23:10:51 -0300 Subject: [PATCH 1/3] Use ScreenCoordsXY for windows/Footpath --- src/openrct2-ui/windows/Footpath.cpp | 59 ++++++++++++++------------- src/openrct2-ui/windows/Guest.cpp | 6 ++- src/openrct2-ui/windows/Map.cpp | 4 +- src/openrct2-ui/windows/Staff.cpp | 10 +++-- src/openrct2-ui/windows/StaffList.cpp | 3 +- src/openrct2/world/Footpath.cpp | 21 +++++----- src/openrct2/world/Footpath.h | 4 +- 7 files changed, 56 insertions(+), 51 deletions(-) diff --git a/src/openrct2-ui/windows/Footpath.cpp b/src/openrct2-ui/windows/Footpath.cpp index 89677b3401..3902d97a23 100644 --- a/src/openrct2-ui/windows/Footpath.cpp +++ b/src/openrct2-ui/windows/Footpath.cpp @@ -176,10 +176,10 @@ static constexpr const uint8_t ConstructionPreviewImages[][4] = { static void window_footpath_mousedown_direction(int32_t direction); static void window_footpath_mousedown_slope(int32_t slope); static void window_footpath_show_footpath_types_dialog(rct_window* w, rct_widget* widget, bool showQueues); -static void window_footpath_set_provisional_path_at_point(int32_t x, int32_t y); -static void window_footpath_set_selection_start_bridge_at_point(int32_t screenX, int32_t screenY); -static void window_footpath_place_path_at_point(int32_t x, int32_t y); -static void window_footpath_start_bridge_at_point(int32_t screenX, int32_t screenY); +static void window_footpath_set_provisional_path_at_point(ScreenCoordsXY screenCoords); +static void window_footpath_set_selection_start_bridge_at_point(ScreenCoordsXY screenCoords); +static void window_footpath_place_path_at_point(ScreenCoordsXY screenCoords); +static void window_footpath_start_bridge_at_point(ScreenCoordsXY screenCoords); static void window_footpath_construct(); static void window_footpath_remove(); static void window_footpath_set_enabled_and_pressed_widgets(); @@ -409,11 +409,11 @@ static void window_footpath_toolupdate(rct_window* w, rct_widgetindex widgetInde { if (widgetIndex == WIDX_CONSTRUCT_ON_LAND) { - window_footpath_set_provisional_path_at_point(screenCoords.x, screenCoords.y); + window_footpath_set_provisional_path_at_point(screenCoords); } else if (widgetIndex == WIDX_CONSTRUCT_BRIDGE_OR_TUNNEL) { - window_footpath_set_selection_start_bridge_at_point(screenCoords.x, screenCoords.y); + window_footpath_set_selection_start_bridge_at_point(screenCoords); } } @@ -425,11 +425,11 @@ static void window_footpath_tooldown(rct_window* w, rct_widgetindex widgetIndex, { if (widgetIndex == WIDX_CONSTRUCT_ON_LAND) { - window_footpath_place_path_at_point(screenCoords.x, screenCoords.y); + window_footpath_place_path_at_point(screenCoords); } else if (widgetIndex == WIDX_CONSTRUCT_BRIDGE_OR_TUNNEL) { - window_footpath_start_bridge_at_point(screenCoords.x, screenCoords.y); + window_footpath_start_bridge_at_point(screenCoords); } } @@ -441,7 +441,7 @@ static void window_footpath_tooldrag(rct_window* w, rct_widgetindex widgetIndex, { if (widgetIndex == WIDX_CONSTRUCT_ON_LAND) { - window_footpath_place_path_at_point(screenCoords.x, screenCoords.y); + window_footpath_place_path_at_point(screenCoords); } } @@ -708,7 +708,7 @@ static void window_footpath_mousedown_slope(int32_t slope) * * rct2: 0x006A81FB */ -static void window_footpath_set_provisional_path_at_point(int32_t x, int32_t y) +static void window_footpath_set_provisional_path_at_point(ScreenCoordsXY screenCoords) { map_invalidate_selection_rect(); gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW; @@ -717,10 +717,11 @@ static void window_footpath_set_provisional_path_at_point(int32_t x, int32_t y) TileElement* tileElement{}; LocationXY16 mapCoord = {}; get_map_coordinates_from_pos( - x, y, VIEWPORT_INTERACTION_MASK_FOOTPATH & VIEWPORT_INTERACTION_MASK_TERRAIN, &mapCoord.x, &mapCoord.y, + screenCoords.x, screenCoords.y, VIEWPORT_INTERACTION_MASK_FOOTPATH & VIEWPORT_INTERACTION_MASK_TERRAIN, &mapCoord.x, + &mapCoord.y, &interactionType, &tileElement, nullptr); - x = mapCoord.x; - y = mapCoord.y; + screenCoords.x = mapCoord.x; + screenCoords.y = mapCoord.y; if (interactionType == VIEWPORT_INTERACTION_ITEM_NONE || tileElement == nullptr) { @@ -730,8 +731,8 @@ static void window_footpath_set_provisional_path_at_point(int32_t x, int32_t y) else { // Check for change - if ((gFootpathProvisionalFlags & PROVISIONAL_PATH_FLAG_1) && gFootpathProvisionalPosition.x == x - && gFootpathProvisionalPosition.y == y && gFootpathProvisionalPosition.z == tileElement->base_height) + if ((gFootpathProvisionalFlags & PROVISIONAL_PATH_FLAG_1) && gFootpathProvisionalPosition.x == screenCoords.x + && gFootpathProvisionalPosition.y == screenCoords.y && gFootpathProvisionalPosition.z == tileElement->base_height) { return; } @@ -739,10 +740,10 @@ static void window_footpath_set_provisional_path_at_point(int32_t x, int32_t y) // Set map selection gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE; gMapSelectType = MAP_SELECT_TYPE_FULL; - gMapSelectPositionA.x = x; - gMapSelectPositionA.y = y; - gMapSelectPositionB.x = x; - gMapSelectPositionB.y = y; + gMapSelectPositionA.x = screenCoords.x; + gMapSelectPositionA.y = screenCoords.y; + gMapSelectPositionB.x = screenCoords.x; + gMapSelectPositionB.y = screenCoords.y; footpath_provisional_update(); @@ -781,7 +782,7 @@ static void window_footpath_set_provisional_path_at_point(int32_t x, int32_t y) } int32_t pathType = (gFootpathSelectedType << 7) + (gFootpathSelectedId & 0xFF); - _window_footpath_cost = footpath_provisional_set(pathType, x, y, z, slope); + _window_footpath_cost = footpath_provisional_set(pathType, screenCoords.x, screenCoords.y, z, slope); window_invalidate_by_class(WC_FOOTPATH); } } @@ -790,7 +791,7 @@ static void window_footpath_set_provisional_path_at_point(int32_t x, int32_t y) * * rct2: 0x006A8388 */ -static void window_footpath_set_selection_start_bridge_at_point(int32_t screenX, int32_t screenY) +static void window_footpath_set_selection_start_bridge_at_point(ScreenCoordsXY screenCoords) { int32_t x, y, direction; TileElement* tileElement; @@ -799,7 +800,7 @@ static void window_footpath_set_selection_start_bridge_at_point(int32_t screenX, gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE; gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW; - footpath_bridge_get_info_from_pos(screenX, screenY, &x, &y, &direction, &tileElement); + footpath_bridge_get_info_from_pos(screenCoords, &x, &y, &direction, &tileElement); if (x == LOCATION_NULL) { return; @@ -839,7 +840,7 @@ static void window_footpath_set_selection_start_bridge_at_point(int32_t screenX, * * rct2: 0x006A82C5 */ -static void window_footpath_place_path_at_point(int32_t x, int32_t y) +static void window_footpath_place_path_at_point(ScreenCoordsXY screenCoords) { int32_t interactionType, currentType, selectedType, z; TileElement* tileElement; @@ -853,10 +854,10 @@ static void window_footpath_place_path_at_point(int32_t x, int32_t y) LocationXY16 mapCoord = {}; get_map_coordinates_from_pos( - x, y, VIEWPORT_INTERACTION_MASK_FOOTPATH & VIEWPORT_INTERACTION_MASK_TERRAIN, &mapCoord.x, &mapCoord.y, + screenCoords.x, screenCoords.y, VIEWPORT_INTERACTION_MASK_FOOTPATH & VIEWPORT_INTERACTION_MASK_TERRAIN, &mapCoord.x, &mapCoord.y, &interactionType, &tileElement, nullptr); - x = mapCoord.x; - y = mapCoord.y; + screenCoords.x = mapCoord.x; + screenCoords.y = mapCoord.y; if (interactionType == VIEWPORT_INTERACTION_ITEM_NONE) { @@ -888,7 +889,7 @@ static void window_footpath_place_path_at_point(int32_t x, int32_t y) // Try and place path gGameCommandErrorTitle = STR_CANT_BUILD_FOOTPATH_HERE; - auto footpathPlaceAction = FootpathPlaceAction({ x, y, z * 8 }, currentType, selectedType); + auto footpathPlaceAction = FootpathPlaceAction({ screenCoords.x, screenCoords.y, z * 8 }, currentType, selectedType); footpathPlaceAction.SetCallback([](const GameAction* ga, const GameActionResult* result) { if (result->Error == GA_ERROR::OK) { @@ -910,12 +911,12 @@ static void window_footpath_place_path_at_point(int32_t x, int32_t y) * * rct2: 0x006A840F */ -static void window_footpath_start_bridge_at_point(int32_t screenX, int32_t screenY) +static void window_footpath_start_bridge_at_point(ScreenCoordsXY screenCoords) { int32_t x, y, z, direction; TileElement* tileElement; - footpath_bridge_get_info_from_pos(screenX, screenY, &x, &y, &direction, &tileElement); + footpath_bridge_get_info_from_pos(screenCoords, &x, &y, &direction, &tileElement); if (x == LOCATION_NULL) { return; diff --git a/src/openrct2-ui/windows/Guest.cpp b/src/openrct2-ui/windows/Guest.cpp index a68c372f4d..c88cbf024d 100644 --- a/src/openrct2-ui/windows/Guest.cpp +++ b/src/openrct2-ui/windows/Guest.cpp @@ -1231,7 +1231,8 @@ void window_guest_overview_tool_update(rct_window* w, rct_widgetindex widgetInde gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE; int32_t map_x, map_y; - footpath_get_coordinates_from_pos(screenCoords.x, screenCoords.y + 16, &map_x, &map_y, nullptr, nullptr); + screenCoords.y += 16; + footpath_get_coordinates_from_pos(screenCoords, &map_x, &map_y, nullptr, nullptr); if (map_x != LOCATION_NULL) { gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE; @@ -1282,7 +1283,8 @@ void window_guest_overview_tool_down(rct_window* w, rct_widgetindex widgetIndex, int32_t dest_x, dest_y; TileElement* tileElement; - footpath_get_coordinates_from_pos(screenCoords.x, screenCoords.y + 16, &dest_x, &dest_y, nullptr, &tileElement); + screenCoords.y += 16; + footpath_get_coordinates_from_pos(screenCoords, &dest_x, &dest_y, nullptr, &tileElement); if (dest_x == LOCATION_NULL) return; diff --git a/src/openrct2-ui/windows/Map.cpp b/src/openrct2-ui/windows/Map.cpp index 5fcbd7fa07..a2ca7947e0 100644 --- a/src/openrct2-ui/windows/Map.cpp +++ b/src/openrct2-ui/windows/Map.cpp @@ -1271,7 +1271,7 @@ static void window_map_set_peep_spawn_tool_update(int32_t x, int32_t y) map_invalidate_selection_rect(); gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE; gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW; - footpath_bridge_get_info_from_pos(x, y, &mapX, &mapY, &direction, &tileElement); + footpath_bridge_get_info_from_pos({ x, y }, &mapX, &mapY, &direction, &tileElement); if ((mapX & 0xFFFF) == 0x8000) return; @@ -1329,7 +1329,7 @@ static void window_map_set_peep_spawn_tool_down(int32_t x, int32_t y) int32_t mapX, mapY, mapZ, direction; // Verify footpath exists at location, and retrieve coordinates - footpath_get_coordinates_from_pos(x, y, &mapX, &mapY, &direction, &tileElement); + footpath_get_coordinates_from_pos({ x, y }, &mapX, &mapY, &direction, &tileElement); if (mapX == LOCATION_NULL) return; diff --git a/src/openrct2-ui/windows/Staff.cpp b/src/openrct2-ui/windows/Staff.cpp index 62b0227b1d..63e59817d6 100644 --- a/src/openrct2-ui/windows/Staff.cpp +++ b/src/openrct2-ui/windows/Staff.cpp @@ -1147,7 +1147,8 @@ void window_staff_overview_tool_update(rct_window* w, rct_widgetindex widgetInde gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE; int32_t map_x, map_y; - footpath_get_coordinates_from_pos(screenCoords.x, screenCoords.y + 16, &map_x, &map_y, nullptr, nullptr); + screenCoords.y += 16; + footpath_get_coordinates_from_pos(screenCoords, &map_x, &map_y, nullptr, nullptr); if (map_x != LOCATION_NULL) { gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE; @@ -1197,7 +1198,8 @@ void window_staff_overview_tool_down(rct_window* w, rct_widgetindex widgetIndex, { int32_t dest_x, dest_y; TileElement* tileElement; - footpath_get_coordinates_from_pos(screenCoords.x, screenCoords.y + 16, &dest_x, &dest_y, nullptr, &tileElement); + screenCoords.y += 16; + footpath_get_coordinates_from_pos(screenCoords, &dest_x, &dest_y, nullptr, &tileElement); if (dest_x == LOCATION_NULL) return; @@ -1216,7 +1218,7 @@ void window_staff_overview_tool_down(rct_window* w, rct_widgetindex widgetIndex, else if (widgetIndex == WIDX_PATROL) { int32_t dest_x, dest_y; - footpath_get_coordinates_from_pos(screenCoords.x, screenCoords.y, &dest_x, &dest_y, nullptr, nullptr); + footpath_get_coordinates_from_pos(screenCoords, &dest_x, &dest_y, nullptr, nullptr); if (dest_x == LOCATION_NULL) return; @@ -1257,7 +1259,7 @@ void window_staff_overview_tool_drag(rct_window* w, rct_widgetindex widgetIndex, return; // Do nothing if we do not have a paintvalue(this should never happen) int32_t dest_x, dest_y; - footpath_get_coordinates_from_pos(screenCoords.x, screenCoords.y, &dest_x, &dest_y, nullptr, nullptr); + footpath_get_coordinates_from_pos(screenCoords, &dest_x, &dest_y, nullptr, nullptr); if (dest_x == LOCATION_NULL) return; diff --git a/src/openrct2-ui/windows/StaffList.cpp b/src/openrct2-ui/windows/StaffList.cpp index 0747509dbd..9f0d95ba31 100644 --- a/src/openrct2-ui/windows/StaffList.cpp +++ b/src/openrct2-ui/windows/StaffList.cpp @@ -343,8 +343,7 @@ static void window_staff_list_tooldown(rct_window* w, rct_widgetindex widgetInde int32_t direction; TileElement* tileElement; CoordsXY footpathCoords; - footpath_get_coordinates_from_pos( - screenCoords.x, screenCoords.y, &footpathCoords.x, &footpathCoords.y, &direction, &tileElement); + footpath_get_coordinates_from_pos(screenCoords, &footpathCoords.x, &footpathCoords.y, &direction, &tileElement); if (footpathCoords.x == LOCATION_NULL) return; diff --git a/src/openrct2/world/Footpath.cpp b/src/openrct2/world/Footpath.cpp index 396f9f4288..77c4d2c44f 100644 --- a/src/openrct2/world/Footpath.cpp +++ b/src/openrct2/world/Footpath.cpp @@ -247,7 +247,7 @@ void footpath_provisional_update() * tileElement: edx */ void footpath_get_coordinates_from_pos( - int32_t screenX, int32_t screenY, int32_t* x, int32_t* y, int32_t* direction, TileElement** tileElement) + ScreenCoordsXY screenCoords, int32_t* x, int32_t* y, int32_t* direction, TileElement** tileElement) { int32_t z = 0, interactionType; TileElement* myTileElement; @@ -255,14 +255,14 @@ void footpath_get_coordinates_from_pos( LocationXY16 position16 = {}; get_map_coordinates_from_pos( - screenX, screenY, VIEWPORT_INTERACTION_MASK_FOOTPATH, &position16.x, &position16.y, &interactionType, &myTileElement, - &viewport); + screenCoords.x, screenCoords.y, VIEWPORT_INTERACTION_MASK_FOOTPATH, &position16.x, &position16.y, &interactionType, + &myTileElement, &viewport); if (interactionType != VIEWPORT_INTERACTION_ITEM_FOOTPATH || !(viewport->flags & (VIEWPORT_FLAG_UNDERGROUND_INSIDE | VIEWPORT_FLAG_HIDE_BASE | VIEWPORT_FLAG_HIDE_VERTICAL))) { get_map_coordinates_from_pos( - screenX, screenY, VIEWPORT_INTERACTION_MASK_FOOTPATH & VIEWPORT_INTERACTION_MASK_TERRAIN, &position16.x, - &position16.y, &interactionType, &myTileElement, &viewport); + screenCoords.x, screenCoords.y, VIEWPORT_INTERACTION_MASK_FOOTPATH & VIEWPORT_INTERACTION_MASK_TERRAIN, + &position16.x, &position16.y, &interactionType, &myTileElement, &viewport); if (interactionType == VIEWPORT_INTERACTION_ITEM_NONE) { if (x != nullptr) @@ -286,7 +286,7 @@ void footpath_get_coordinates_from_pos( } } - LocationXY16 start_vp_pos = screen_coord_to_viewport_coord(viewport, screenX, screenY); + LocationXY16 start_vp_pos = screen_coord_to_viewport_coord(viewport, screenCoords.x, screenCoords.y); for (int32_t i = 0; i < 5; i++) { @@ -346,7 +346,7 @@ void footpath_get_coordinates_from_pos( * tileElement: edx */ void footpath_bridge_get_info_from_pos( - int32_t screenX, int32_t screenY, int32_t* x, int32_t* y, int32_t* direction, TileElement** tileElement) + ScreenCoordsXY screenCoords, int32_t* x, int32_t* y, int32_t* direction, TileElement** tileElement) { // First check if we point at an entrance or exit. In that case, we would want the path coming from the entrance/exit. int32_t interactionType; @@ -354,7 +354,8 @@ void footpath_bridge_get_info_from_pos( LocationXY16 map_pos = {}; get_map_coordinates_from_pos( - screenX, screenY, VIEWPORT_INTERACTION_MASK_RIDE, &map_pos.x, &map_pos.y, &interactionType, tileElement, &viewport); + screenCoords.x, screenCoords.y, VIEWPORT_INTERACTION_MASK_RIDE, &map_pos.x, &map_pos.y, &interactionType, tileElement, + &viewport); *x = map_pos.x; *y = map_pos.y; @@ -375,7 +376,7 @@ void footpath_bridge_get_info_from_pos( } get_map_coordinates_from_pos( - screenX, screenY, + screenCoords.x, screenCoords.y, VIEWPORT_INTERACTION_MASK_RIDE & VIEWPORT_INTERACTION_MASK_FOOTPATH & VIEWPORT_INTERACTION_MASK_TERRAIN, &map_pos.x, &map_pos.y, &interactionType, tileElement, &viewport); *x = map_pos.x; @@ -393,7 +394,7 @@ void footpath_bridge_get_info_from_pos( } // We point at something else - footpath_get_coordinates_from_pos(screenX, screenY, x, y, direction, tileElement); + footpath_get_coordinates_from_pos(screenCoords, x, y, direction, tileElement); } /** diff --git a/src/openrct2/world/Footpath.h b/src/openrct2/world/Footpath.h index 0feee82a0b..6694159858 100644 --- a/src/openrct2/world/Footpath.h +++ b/src/openrct2/world/Footpath.h @@ -181,9 +181,9 @@ money32 footpath_provisional_set(int32_t type, int32_t x, int32_t y, int32_t z, void footpath_provisional_remove(); void footpath_provisional_update(); void footpath_get_coordinates_from_pos( - int32_t screenX, int32_t screenY, int32_t* x, int32_t* y, int32_t* direction, TileElement** tileElement); + ScreenCoordsXY screenCoords, int32_t* x, int32_t* y, int32_t* direction, TileElement** tileElement); void footpath_bridge_get_info_from_pos( - int32_t screenX, int32_t screenY, int32_t* x, int32_t* y, int32_t* direction, TileElement** tileElement); + ScreenCoordsXY screenCoords, int32_t* x, int32_t* y, int32_t* direction, TileElement** tileElement); void footpath_remove_litter(int32_t x, int32_t y, int32_t z); void footpath_connect_edges(int32_t x, int32_t y, TileElement* tileElement, int32_t flags); void footpath_update_queue_chains(); From 3fa4b7b964bdbfbed0f3ad1a3a0d15ac6207ff5e Mon Sep 17 00:00:00 2001 From: Tulio Leao Date: Tue, 12 Nov 2019 00:27:59 -0300 Subject: [PATCH 2/3] Fix clang-format --- src/openrct2-ui/windows/Footpath.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/openrct2-ui/windows/Footpath.cpp b/src/openrct2-ui/windows/Footpath.cpp index 3902d97a23..9c18ea01d3 100644 --- a/src/openrct2-ui/windows/Footpath.cpp +++ b/src/openrct2-ui/windows/Footpath.cpp @@ -718,8 +718,7 @@ static void window_footpath_set_provisional_path_at_point(ScreenCoordsXY screenC LocationXY16 mapCoord = {}; get_map_coordinates_from_pos( screenCoords.x, screenCoords.y, VIEWPORT_INTERACTION_MASK_FOOTPATH & VIEWPORT_INTERACTION_MASK_TERRAIN, &mapCoord.x, - &mapCoord.y, - &interactionType, &tileElement, nullptr); + &mapCoord.y, &interactionType, &tileElement, nullptr); screenCoords.x = mapCoord.x; screenCoords.y = mapCoord.y; @@ -854,8 +853,8 @@ static void window_footpath_place_path_at_point(ScreenCoordsXY screenCoords) LocationXY16 mapCoord = {}; get_map_coordinates_from_pos( - screenCoords.x, screenCoords.y, VIEWPORT_INTERACTION_MASK_FOOTPATH & VIEWPORT_INTERACTION_MASK_TERRAIN, &mapCoord.x, &mapCoord.y, - &interactionType, &tileElement, nullptr); + screenCoords.x, screenCoords.y, VIEWPORT_INTERACTION_MASK_FOOTPATH & VIEWPORT_INTERACTION_MASK_TERRAIN, &mapCoord.x, + &mapCoord.y, &interactionType, &tileElement, nullptr); screenCoords.x = mapCoord.x; screenCoords.y = mapCoord.y; From 5e888747de7663e577cdfd38df7608d0f703e3ea Mon Sep 17 00:00:00 2001 From: Tulio Leao Date: Tue, 12 Nov 2019 20:13:14 -0300 Subject: [PATCH 3/3] Use mapCoords instead of ScreenCoords --- src/openrct2-ui/windows/Footpath.cpp | 20 ++++++++------------ src/openrct2-ui/windows/Guest.cpp | 6 ++---- src/openrct2-ui/windows/Staff.cpp | 6 ++---- 3 files changed, 12 insertions(+), 20 deletions(-) diff --git a/src/openrct2-ui/windows/Footpath.cpp b/src/openrct2-ui/windows/Footpath.cpp index 9c18ea01d3..d64ddd965e 100644 --- a/src/openrct2-ui/windows/Footpath.cpp +++ b/src/openrct2-ui/windows/Footpath.cpp @@ -719,8 +719,6 @@ static void window_footpath_set_provisional_path_at_point(ScreenCoordsXY screenC get_map_coordinates_from_pos( screenCoords.x, screenCoords.y, VIEWPORT_INTERACTION_MASK_FOOTPATH & VIEWPORT_INTERACTION_MASK_TERRAIN, &mapCoord.x, &mapCoord.y, &interactionType, &tileElement, nullptr); - screenCoords.x = mapCoord.x; - screenCoords.y = mapCoord.y; if (interactionType == VIEWPORT_INTERACTION_ITEM_NONE || tileElement == nullptr) { @@ -730,8 +728,8 @@ static void window_footpath_set_provisional_path_at_point(ScreenCoordsXY screenC else { // Check for change - if ((gFootpathProvisionalFlags & PROVISIONAL_PATH_FLAG_1) && gFootpathProvisionalPosition.x == screenCoords.x - && gFootpathProvisionalPosition.y == screenCoords.y && gFootpathProvisionalPosition.z == tileElement->base_height) + if ((gFootpathProvisionalFlags & PROVISIONAL_PATH_FLAG_1) && gFootpathProvisionalPosition.x == mapCoord.x + && gFootpathProvisionalPosition.y == mapCoord.y && gFootpathProvisionalPosition.z == tileElement->base_height) { return; } @@ -739,10 +737,10 @@ static void window_footpath_set_provisional_path_at_point(ScreenCoordsXY screenC // Set map selection gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE; gMapSelectType = MAP_SELECT_TYPE_FULL; - gMapSelectPositionA.x = screenCoords.x; - gMapSelectPositionA.y = screenCoords.y; - gMapSelectPositionB.x = screenCoords.x; - gMapSelectPositionB.y = screenCoords.y; + gMapSelectPositionA.x = mapCoord.x; + gMapSelectPositionA.y = mapCoord.y; + gMapSelectPositionB.x = mapCoord.x; + gMapSelectPositionB.y = mapCoord.y; footpath_provisional_update(); @@ -781,7 +779,7 @@ static void window_footpath_set_provisional_path_at_point(ScreenCoordsXY screenC } int32_t pathType = (gFootpathSelectedType << 7) + (gFootpathSelectedId & 0xFF); - _window_footpath_cost = footpath_provisional_set(pathType, screenCoords.x, screenCoords.y, z, slope); + _window_footpath_cost = footpath_provisional_set(pathType, mapCoord.x, mapCoord.y, z, slope); window_invalidate_by_class(WC_FOOTPATH); } } @@ -855,8 +853,6 @@ static void window_footpath_place_path_at_point(ScreenCoordsXY screenCoords) get_map_coordinates_from_pos( screenCoords.x, screenCoords.y, VIEWPORT_INTERACTION_MASK_FOOTPATH & VIEWPORT_INTERACTION_MASK_TERRAIN, &mapCoord.x, &mapCoord.y, &interactionType, &tileElement, nullptr); - screenCoords.x = mapCoord.x; - screenCoords.y = mapCoord.y; if (interactionType == VIEWPORT_INTERACTION_ITEM_NONE) { @@ -888,7 +884,7 @@ static void window_footpath_place_path_at_point(ScreenCoordsXY screenCoords) // Try and place path gGameCommandErrorTitle = STR_CANT_BUILD_FOOTPATH_HERE; - auto footpathPlaceAction = FootpathPlaceAction({ screenCoords.x, screenCoords.y, z * 8 }, currentType, selectedType); + auto footpathPlaceAction = FootpathPlaceAction({ mapCoord.x, mapCoord.y, z * 8 }, currentType, selectedType); footpathPlaceAction.SetCallback([](const GameAction* ga, const GameActionResult* result) { if (result->Error == GA_ERROR::OK) { diff --git a/src/openrct2-ui/windows/Guest.cpp b/src/openrct2-ui/windows/Guest.cpp index c88cbf024d..6c7552861b 100644 --- a/src/openrct2-ui/windows/Guest.cpp +++ b/src/openrct2-ui/windows/Guest.cpp @@ -1231,8 +1231,7 @@ void window_guest_overview_tool_update(rct_window* w, rct_widgetindex widgetInde gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE; int32_t map_x, map_y; - screenCoords.y += 16; - footpath_get_coordinates_from_pos(screenCoords, &map_x, &map_y, nullptr, nullptr); + footpath_get_coordinates_from_pos({ screenCoords.x, screenCoords.y + 16 }, &map_x, &map_y, nullptr, nullptr); if (map_x != LOCATION_NULL) { gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE; @@ -1283,8 +1282,7 @@ void window_guest_overview_tool_down(rct_window* w, rct_widgetindex widgetIndex, int32_t dest_x, dest_y; TileElement* tileElement; - screenCoords.y += 16; - footpath_get_coordinates_from_pos(screenCoords, &dest_x, &dest_y, nullptr, &tileElement); + footpath_get_coordinates_from_pos({ screenCoords.x, screenCoords.y + 16 }, &dest_x, &dest_y, nullptr, &tileElement); if (dest_x == LOCATION_NULL) return; diff --git a/src/openrct2-ui/windows/Staff.cpp b/src/openrct2-ui/windows/Staff.cpp index 63e59817d6..2d938d58fb 100644 --- a/src/openrct2-ui/windows/Staff.cpp +++ b/src/openrct2-ui/windows/Staff.cpp @@ -1147,8 +1147,7 @@ void window_staff_overview_tool_update(rct_window* w, rct_widgetindex widgetInde gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE; int32_t map_x, map_y; - screenCoords.y += 16; - footpath_get_coordinates_from_pos(screenCoords, &map_x, &map_y, nullptr, nullptr); + footpath_get_coordinates_from_pos({ screenCoords.x, screenCoords.y + 16 }, &map_x, &map_y, nullptr, nullptr); if (map_x != LOCATION_NULL) { gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE; @@ -1198,8 +1197,7 @@ void window_staff_overview_tool_down(rct_window* w, rct_widgetindex widgetIndex, { int32_t dest_x, dest_y; TileElement* tileElement; - screenCoords.y += 16; - footpath_get_coordinates_from_pos(screenCoords, &dest_x, &dest_y, nullptr, &tileElement); + footpath_get_coordinates_from_pos({ screenCoords.x, screenCoords.y + 16 }, &dest_x, &dest_y, nullptr, &tileElement); if (dest_x == LOCATION_NULL) return;