From 5e888747de7663e577cdfd38df7608d0f703e3ea Mon Sep 17 00:00:00 2001 From: Tulio Leao Date: Tue, 12 Nov 2019 20:13:14 -0300 Subject: [PATCH] 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;