From 3c3e179e7fbf8f9e944b7c9efc2ba31f5f74ff11 Mon Sep 17 00:00:00 2001 From: Tulio Leao Date: Tue, 24 Dec 2019 16:48:50 -0300 Subject: [PATCH 1/6] Remove LocationXY usage on openrct2-ui\windows\RideConstruction.cpp --- src/openrct2-ui/windows/RideConstruction.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/openrct2-ui/windows/RideConstruction.cpp b/src/openrct2-ui/windows/RideConstruction.cpp index 67c0ce1448..d5f030d223 100644 --- a/src/openrct2-ui/windows/RideConstruction.cpp +++ b/src/openrct2-ui/windows/RideConstruction.cpp @@ -3622,7 +3622,7 @@ void ride_construction_toolupdate_construct(ScreenCoordsXY screenCoords) && ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_IS_SHOP)) { TileElement* pathsByDir[4]; - constexpr sLocationXY8 DirOffsets[4] = { { -1, 0 }, { 0, 1 }, { 1, 0 }, { 0, -1 } }; + constexpr TileCoordsXY DirOffsets[4] = { { -1, 0 }, { 0, 1 }, { 1, 0 }, { 0, -1 } }; bool keepOrientation = false; for (int8_t i = 0; i < 4; i++) From 05ef277cbdad4db1bcf5e470eea85d0f3a4341b0 Mon Sep 17 00:00:00 2001 From: Tulio Leao Date: Tue, 24 Dec 2019 17:09:22 -0300 Subject: [PATCH 2/6] Remove LocationXY usage on openrct2-ui\windows\TopToolbar.cpp --- src/openrct2-ui/windows/TopToolbar.cpp | 116 +++++++++++-------------- 1 file changed, 53 insertions(+), 63 deletions(-) diff --git a/src/openrct2-ui/windows/TopToolbar.cpp b/src/openrct2-ui/windows/TopToolbar.cpp index 3fb8e35618..b87cf43690 100644 --- a/src/openrct2-ui/windows/TopToolbar.cpp +++ b/src/openrct2-ui/windows/TopToolbar.cpp @@ -1210,14 +1210,14 @@ static void scenery_eyedropper_tool_down(int16_t x, int16_t y, rct_widgetindex w * edi : parameter_3 */ static void sub_6E1F34( - int16_t x, int16_t y, uint16_t selected_scenery, int16_t* grid_x, int16_t* grid_y, uint32_t* parameter_1, - uint32_t* parameter_2, uint32_t* parameter_3) + int16_t x, int16_t y, uint16_t selected_scenery, CoordsXY& gridPos, uint32_t* parameter_1, uint32_t* parameter_2, + uint32_t* parameter_3) { rct_window* w = window_find_by_class(WC_SCENERY); if (w == nullptr) { - *grid_x = LOCATION_NULL; + gridPos.x = LOCATION_NULL; return; } @@ -1349,22 +1349,21 @@ static void sub_6E1F34( auto gridCoords = screen_get_map_xy_quadrant({ x, y }, &cl); if (!gridCoords) { - *grid_x = LOCATION_NULL; + gridPos.x = LOCATION_NULL; return; } - *grid_x = gridCoords->x; - *grid_y = gridCoords->y; + gridPos = *gridCoords; gSceneryPlaceZ = 0; // If SHIFT pressed if (gSceneryShiftPressed) { - auto* surfaceElement = map_get_surface_element_at(CoordsXY{ *grid_x, *grid_y }); + auto* surfaceElement = map_get_surface_element_at(gridPos); if (surfaceElement == nullptr) { - *grid_x = LOCATION_NULL; + gridPos.x = LOCATION_NULL; return; } @@ -1383,11 +1382,11 @@ static void sub_6E1F34( auto mapCoords = screen_get_map_xy_quadrant_with_z({ x, y }, z, &cl); if (!mapCoords) { - *grid_x = LOCATION_NULL; + gridPos.x = LOCATION_NULL; return; } - *grid_x = mapCoords->x; - *grid_y = mapCoords->y; + gridPos = *mapCoords; + // If SHIFT pressed if (gSceneryShiftPressed) { @@ -1399,7 +1398,7 @@ static void sub_6E1F34( gSceneryPlaceZ = z; } - if (*grid_x == LOCATION_NULL) + if (gridPos.x == LOCATION_NULL) return; uint8_t rotation = gWindowSceneryRotation; @@ -1434,12 +1433,11 @@ static void sub_6E1F34( CoordsXY gridCoords; get_map_coordinates_from_pos({ x, y }, flags, gridCoords, &interaction_type, &tile_element, nullptr); - *grid_x = gridCoords.x; - *grid_y = gridCoords.y; + gridPos = gridCoords; if (interaction_type == VIEWPORT_INTERACTION_ITEM_NONE) { - *grid_x = LOCATION_NULL; + gridPos.x = LOCATION_NULL; return; } @@ -1449,11 +1447,11 @@ static void sub_6E1F34( // If SHIFT pressed if (gSceneryShiftPressed) { - auto surfaceElement = map_get_surface_element_at(CoordsXY{ *grid_x, *grid_y }); + auto surfaceElement = map_get_surface_element_at(gridPos); if (surfaceElement == nullptr) { - *grid_x = LOCATION_NULL; + gridPos.x = LOCATION_NULL; return; } @@ -1471,12 +1469,11 @@ static void sub_6E1F34( auto coords = screen_get_map_xy_with_z({ x, y }, z); if (coords) { - *grid_x = coords->x; - *grid_y = coords->y; + gridPos = *coords; } else { - *grid_x = LOCATION_NULL; + gridPos.x = LOCATION_NULL; } // If SHIFT pressed if (gSceneryShiftPressed) @@ -1489,11 +1486,10 @@ static void sub_6E1F34( gSceneryPlaceZ = z; } - if (*grid_x == LOCATION_NULL) + if (gridPos.x == LOCATION_NULL) return; - *grid_x &= 0xFFE0; - *grid_y &= 0xFFE0; + gridPos = gridPos.ToTileStart(); uint8_t rotation = gWindowSceneryRotation; if (!scenery_small_entry_has_flag(scenery, SMALL_SCENERY_FLAG_ROTATABLE)) @@ -1519,12 +1515,11 @@ static void sub_6E1F34( CoordsXY gridCoords; get_map_coordinates_from_pos({ x, y }, flags, gridCoords, &interaction_type, &tile_element, nullptr); - *grid_x = gridCoords.x; - *grid_y = gridCoords.y; + gridPos = gridCoords; if (interaction_type == VIEWPORT_INTERACTION_ITEM_NONE) { - *grid_x = LOCATION_NULL; + gridPos.x = LOCATION_NULL; return; } @@ -1550,22 +1545,21 @@ static void sub_6E1F34( auto gridCoords = screen_get_map_xy_side({ x, y }, &cl); if (!gridCoords) { - *grid_x = LOCATION_NULL; + gridPos.x = LOCATION_NULL; return; } - *grid_x = gridCoords->x; - *grid_y = gridCoords->y; + gridPos = *gridCoords; gSceneryPlaceZ = 0; // If SHIFT pressed if (gSceneryShiftPressed) { - auto* surfaceElement = map_get_surface_element_at(CoordsXY{ *grid_x, *grid_y }); + auto* surfaceElement = map_get_surface_element_at(gridPos); if (surfaceElement == nullptr) { - *grid_x = LOCATION_NULL; + gridPos.x = LOCATION_NULL; return; } @@ -1583,11 +1577,10 @@ static void sub_6E1F34( auto mapCoords = screen_get_map_xy_side_with_z({ x, y }, z, &cl); if (!mapCoords) { - *grid_x = LOCATION_NULL; + gridPos.x = LOCATION_NULL; return; } - *grid_x = mapCoords->x; - *grid_y = mapCoords->y; + gridPos = *mapCoords; // If SHIFT pressed if (gSceneryShiftPressed) @@ -1600,7 +1593,7 @@ static void sub_6E1F34( gSceneryPlaceZ = z; } - if (*grid_x == LOCATION_NULL) + if (gridPos.x == LOCATION_NULL) return; _secondaryColour = gWindowScenerySecondaryColour; @@ -1618,10 +1611,9 @@ static void sub_6E1F34( if (!gSceneryCtrlPressed) { const CoordsXY mapCoords = sub_68A15E({ x, y }); - *grid_x = mapCoords.x; - *grid_y = mapCoords.y; + gridPos = mapCoords; - if (*grid_x == LOCATION_NULL) + if (gridPos.x == LOCATION_NULL) return; gSceneryPlaceZ = 0; @@ -1629,11 +1621,11 @@ static void sub_6E1F34( // If SHIFT pressed if (gSceneryShiftPressed) { - auto* surfaceElement = map_get_surface_element_at(CoordsXY{ *grid_x, *grid_y }); + auto* surfaceElement = map_get_surface_element_at(gridPos); if (surfaceElement == nullptr) { - *grid_x = LOCATION_NULL; + gridPos.x = LOCATION_NULL; return; } @@ -1651,12 +1643,11 @@ static void sub_6E1F34( auto coords = screen_get_map_xy_with_z({ x, y }, z); if (coords) { - *grid_x = coords->x; - *grid_y = coords->y; + gridPos = *coords; } else { - *grid_x = LOCATION_NULL; + gridPos.x = LOCATION_NULL; } // If SHIFT pressed @@ -1670,11 +1661,11 @@ static void sub_6E1F34( gSceneryPlaceZ = z; } - if (*grid_x == LOCATION_NULL) + if (gridPos.x == LOCATION_NULL) return; - *grid_x &= 0xFFE0; - *grid_y &= 0xFFE0; + gridPos.x &= 0xFFE0; + gridPos.y &= 0xFFE0; uint8_t rotation = gWindowSceneryRotation; rotation -= get_current_rotation(); @@ -1694,12 +1685,11 @@ static void sub_6E1F34( CoordsXY gridCoords; get_map_coordinates_from_pos({ x, y }, flags, gridCoords, &interaction_type, &tile_element, nullptr); - *grid_x = gridCoords.x; - *grid_y = gridCoords.y; + gridPos = gridCoords; if (interaction_type == VIEWPORT_INTERACTION_ITEM_NONE) { - *grid_x = LOCATION_NULL; + gridPos.x = LOCATION_NULL; return; } @@ -1757,12 +1747,12 @@ static void window_top_toolbar_scenery_tool_down(int16_t x, int16_t y, rct_windo if (selectedTab == WINDOW_SCENERY_TAB_SELECTION_UNDEFINED) return; - int16_t gridX, gridY; + CoordsXY gridPos; uint32_t parameter_1, parameter_2, parameter_3; - sub_6E1F34(x, y, selectedTab, &gridX, &gridY, ¶meter_1, ¶meter_2, ¶meter_3); + sub_6E1F34(x, y, selectedTab, gridPos, ¶meter_1, ¶meter_2, ¶meter_3); - if (gridX == LOCATION_NULL) + if (gridPos.x == LOCATION_NULL) return; switch (sceneryType) @@ -1784,8 +1774,8 @@ static void window_top_toolbar_scenery_tool_down(int16_t x, int16_t y, rct_windo int32_t zCoordinate = gSceneryPlaceZ; rct_scenery_entry* scenery = get_small_scenery_entry((parameter_1 >> 8) & 0xFF); - int16_t cur_grid_x = gridX; - int16_t cur_grid_y = gridY; + int16_t cur_grid_x = gridPos.x; + int16_t cur_grid_y = gridPos.y; if (isCluster) { @@ -1870,7 +1860,7 @@ static void window_top_toolbar_scenery_tool_down(int16_t x, int16_t y, rct_windo { auto pathItemType = parameter_3 & 0xFF; int32_t z = (parameter_2 & 0xFF) * 8; - auto footpathSceneryPlaceAction = FootpathSceneryPlaceAction({ gridX, gridY, z }, pathItemType); + auto footpathSceneryPlaceAction = FootpathSceneryPlaceAction({ gridPos, z }, pathItemType); footpathSceneryPlaceAction.SetCallback([](const GameAction* ga, const GameActionResult* result) { if (result->Error != GA_ERROR::OK) @@ -1896,7 +1886,7 @@ static void window_top_toolbar_scenery_tool_down(int16_t x, int16_t y, rct_windo auto edges = parameter_2 & 0xFF; auto type = (parameter_1 >> 8) & 0xFF; auto wallPlaceAction = WallPlaceAction( - type, { gridX, gridY, gSceneryPlaceZ }, edges, primaryColour, _secondaryColour, _tertiaryColour); + type, { gridPos, gSceneryPlaceZ }, edges, primaryColour, _secondaryColour, _tertiaryColour); auto res = GameActions::Query(&wallPlaceAction); if (res->Error == GA_ERROR::OK) @@ -1919,7 +1909,7 @@ static void window_top_toolbar_scenery_tool_down(int16_t x, int16_t y, rct_windo auto edges = parameter_2 & 0xFF; auto type = (parameter_1 >> 8) & 0xFF; auto wallPlaceAction = WallPlaceAction( - type, { gridX, gridY, gSceneryPlaceZ }, edges, primaryColour, _secondaryColour, _tertiaryColour); + type, { gridPos, gSceneryPlaceZ }, edges, primaryColour, _secondaryColour, _tertiaryColour); wallPlaceAction.SetCallback([](const GameAction* ga, const GameActionResult* result) { if (result->Error == GA_ERROR::OK) @@ -1944,7 +1934,7 @@ static void window_top_toolbar_scenery_tool_down(int16_t x, int16_t y, rct_windo auto secondaryColour = (parameter_2 >> 8) & 0xFF; auto largeSceneryType = parameter_3 & 0xFF; uint8_t direction = (parameter_1 & 0xFF00) >> 8; - CoordsXYZD loc = { gridX, gridY, gSceneryPlaceZ, direction }; + CoordsXYZD loc = { gridPos, gSceneryPlaceZ, direction }; auto sceneryPlaceAction = LargeSceneryPlaceAction(loc, largeSceneryType, primaryColour, secondaryColour); @@ -1968,7 +1958,7 @@ static void window_top_toolbar_scenery_tool_down(int16_t x, int16_t y, rct_windo auto secondaryColour = (parameter_2 >> 8) & 0xFF; auto largeSceneryType = parameter_3 & 0xFF; uint8_t direction = (parameter_1 & 0xFF00) >> 8; - CoordsXYZD loc = { gridX, gridY, gSceneryPlaceZ, direction }; + CoordsXYZD loc = { gridPos, gSceneryPlaceZ, direction }; auto sceneryPlaceAction = LargeSceneryPlaceAction(loc, largeSceneryType, primaryColour, secondaryColour); sceneryPlaceAction.SetCallback([=](const GameAction* ga, const GameActionResult* result) { @@ -1988,7 +1978,7 @@ static void window_top_toolbar_scenery_tool_down(int16_t x, int16_t y, rct_windo { uint8_t direction = (parameter_2 >> 8) & 0xFF; int32_t z = (parameter_2 & 0xFF) * 16; - CoordsXYZD loc{ gridX, gridY, z, direction }; + CoordsXYZD loc{ gridPos, z, direction }; auto primaryColour = gWindowSceneryPrimaryColour; auto bannerType = (parameter_1 & 0xFF00) >> 8; auto bannerIndex = create_new_banner(0); @@ -2473,7 +2463,7 @@ static void top_toolbar_tool_update_water(int16_t x, int16_t y) * On success places ghost scenery and returns cost to place proper */ static money32 try_place_ghost_scenery( - LocationXY16 map_tile, uint32_t parameter_1, uint32_t parameter_2, uint32_t parameter_3, uint16_t selected_tab) + CoordsXY map_tile, uint32_t parameter_1, uint32_t parameter_2, uint32_t parameter_3, uint16_t selected_tab) { scenery_remove_ghost_tool_placement(); @@ -2686,10 +2676,10 @@ static void top_toolbar_tool_update_scenery(int16_t x, int16_t y) uint8_t scenery_type = (selected_tab & 0xFF00) >> 8; uint8_t selected_scenery = selected_tab & 0xFF; - LocationXY16 mapTile = {}; + CoordsXY mapTile = {}; uint32_t parameter1, parameter2, parameter3; - sub_6E1F34(x, y, selected_tab, &mapTile.x, &mapTile.y, ¶meter1, ¶meter2, ¶meter3); + sub_6E1F34(x, y, selected_tab, mapTile, ¶meter1, ¶meter2, ¶meter3); if (mapTile.x == LOCATION_NULL) { From 15f873c018e1550c22eed38b1ea5ab7970edd1f0 Mon Sep 17 00:00:00 2001 From: Tulio Leao Date: Tue, 24 Dec 2019 17:21:26 -0300 Subject: [PATCH 3/6] Remove LocationXY usage on openrct2-ui\windows\ViewClipping.cpp --- src/openrct2-ui/windows/ViewClipping.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/openrct2-ui/windows/ViewClipping.cpp b/src/openrct2-ui/windows/ViewClipping.cpp index bc58ca2533..f16891a3d9 100644 --- a/src/openrct2-ui/windows/ViewClipping.cpp +++ b/src/openrct2-ui/windows/ViewClipping.cpp @@ -66,9 +66,9 @@ static rct_widget window_view_clipping_widgets[] = { #pragma region Members -static LocationXY16 _selectionStart; -static LocationXY8 _previousClipSelectionA; -static LocationXY8 _previousClipSelectionB; +static CoordsXY _selectionStart; +static TileCoordsXY _previousClipSelectionA; +static TileCoordsXY _previousClipSelectionB; static bool _toolActive; static bool _dragging; @@ -239,8 +239,8 @@ static void window_view_clipping_mouseup(rct_window* w, rct_widgetindex widgetIn _dragging = false; // Reset clip selection to show all tiles - _previousClipSelectionA = gClipSelectionA; - _previousClipSelectionB = gClipSelectionB; + _previousClipSelectionA = TileCoordsXY{ gClipSelectionA.x, gClipSelectionA.y }; + _previousClipSelectionB = TileCoordsXY{ gClipSelectionB.x, gClipSelectionB.y }; gClipSelectionA = { 0, 0 }; gClipSelectionB = { MAXIMUM_MAP_SIZE_TECHNICAL - 1, MAXIMUM_MAP_SIZE_TECHNICAL - 1 }; gfx_invalidate_screen(); @@ -303,8 +303,8 @@ static void window_view_clipping_update(rct_window* w) if (_toolActive && !window_view_clipping_tool_is_active()) { _toolActive = false; - gClipSelectionA = _previousClipSelectionA; - gClipSelectionB = _previousClipSelectionB; + gClipSelectionA = { static_cast(_previousClipSelectionA.x), static_cast(_previousClipSelectionA.y) }; + gClipSelectionB = { static_cast(_previousClipSelectionB.x), static_cast(_previousClipSelectionB.y) }; } widget_invalidate(w, WIDX_CLIP_HEIGHT_SLIDER); @@ -336,7 +336,7 @@ static void window_view_clipping_tool_down(rct_window* w, rct_widgetindex widget if (mapCoords) { _dragging = true; - _selectionStart = { static_cast(mapCoords->x), static_cast(mapCoords->y) }; + _selectionStart = *mapCoords; } } @@ -353,10 +353,10 @@ static void window_view_clipping_tool_drag(rct_window* w, rct_widgetindex widget { map_invalidate_selection_rect(); gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE; - gMapSelectPositionA.x = std::min(_selectionStart.x, static_cast(mapCoords->x)); - gMapSelectPositionB.x = std::max(_selectionStart.x, static_cast(mapCoords->x)); - gMapSelectPositionA.y = std::min(_selectionStart.y, static_cast(mapCoords->y)); - gMapSelectPositionB.y = std::max(_selectionStart.y, static_cast(mapCoords->y)); + gMapSelectPositionA.x = std::min(_selectionStart.x, mapCoords->x); + gMapSelectPositionB.x = std::max(_selectionStart.x, mapCoords->x); + gMapSelectPositionA.y = std::min(_selectionStart.y, mapCoords->y); + gMapSelectPositionB.y = std::max(_selectionStart.y, mapCoords->y); gMapSelectType = MAP_SELECT_TYPE_FULL; map_invalidate_selection_rect(); } From 4f58fd55689952d0fd39513fed1fabd41c57f882 Mon Sep 17 00:00:00 2001 From: Tulio Leao Date: Tue, 24 Dec 2019 17:22:13 -0300 Subject: [PATCH 4/6] Remove LocationXY usage on openrct2\actions\LandSmoothAction.hpp --- src/openrct2/actions/LandSmoothAction.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/openrct2/actions/LandSmoothAction.hpp b/src/openrct2/actions/LandSmoothAction.hpp index 23796fc71b..baf0524c9d 100644 --- a/src/openrct2/actions/LandSmoothAction.hpp +++ b/src/openrct2/actions/LandSmoothAction.hpp @@ -587,7 +587,7 @@ private: { 1, 2, 0, 3 }, // MAP_SELECT_TYPE_EDGE_3 }; // Big coordinate offsets for the neigbouring tile for the given edge selection - static constexpr sLocationXY8 stepOffsets[] = { + static constexpr CoordsXY stepOffsets[] = { { -32, 0 }, { 0, 32 }, { 32, 0 }, From 48c2dc31bc1d34e365eafa31531eedcc7553c2ff Mon Sep 17 00:00:00 2001 From: Tulio Leao Date: Tue, 24 Dec 2019 17:23:09 -0300 Subject: [PATCH 5/6] Remove LocationXY usage on openrct2\actions\RideDemolishAction.hpp --- src/openrct2/actions/RideDemolishAction.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/openrct2/actions/RideDemolishAction.hpp b/src/openrct2/actions/RideDemolishAction.hpp index 0872539d1a..ec0f5f518d 100644 --- a/src/openrct2/actions/RideDemolishAction.hpp +++ b/src/openrct2/actions/RideDemolishAction.hpp @@ -330,7 +330,7 @@ private: continue; } - static constexpr const LocationXY16 DirOffsets[] = { + static constexpr const CoordsXY DirOffsets[] = { { 0, 0 }, { 0, 16 }, { 16, 16 }, @@ -339,7 +339,7 @@ private: for (Direction dir : ALL_DIRECTIONS) { - const LocationXY16& off = DirOffsets[dir]; + const CoordsXY& off = DirOffsets[dir]; money32 removePrice = MazeRemoveTrack(x + off.x, y + off.y, z, dir); if (removePrice != MONEY32_UNDEFINED) refundPrice += removePrice; From 109a90269ce89622c5ae2a629d7731bb822bca13 Mon Sep 17 00:00:00 2001 From: Tulio Leao Date: Fri, 27 Dec 2019 09:33:08 -0300 Subject: [PATCH 6/6] Prefer setNull/isNull on TopToolbar over LOCATION_NULL --- src/openrct2-ui/windows/TopToolbar.cpp | 45 +++++++++++++------------- src/openrct2/world/Location.hpp | 5 +++ 2 files changed, 27 insertions(+), 23 deletions(-) diff --git a/src/openrct2-ui/windows/TopToolbar.cpp b/src/openrct2-ui/windows/TopToolbar.cpp index b87cf43690..ce7f62fefd 100644 --- a/src/openrct2-ui/windows/TopToolbar.cpp +++ b/src/openrct2-ui/windows/TopToolbar.cpp @@ -1217,7 +1217,7 @@ static void sub_6E1F34( if (w == nullptr) { - gridPos.x = LOCATION_NULL; + gridPos.setNull(); return; } @@ -1349,7 +1349,7 @@ static void sub_6E1F34( auto gridCoords = screen_get_map_xy_quadrant({ x, y }, &cl); if (!gridCoords) { - gridPos.x = LOCATION_NULL; + gridPos.setNull(); return; } gridPos = *gridCoords; @@ -1363,7 +1363,7 @@ static void sub_6E1F34( if (surfaceElement == nullptr) { - gridPos.x = LOCATION_NULL; + gridPos.setNull(); return; } @@ -1382,7 +1382,7 @@ static void sub_6E1F34( auto mapCoords = screen_get_map_xy_quadrant_with_z({ x, y }, z, &cl); if (!mapCoords) { - gridPos.x = LOCATION_NULL; + gridPos.setNull(); return; } gridPos = *mapCoords; @@ -1398,7 +1398,7 @@ static void sub_6E1F34( gSceneryPlaceZ = z; } - if (gridPos.x == LOCATION_NULL) + if (gridPos.isNull()) return; uint8_t rotation = gWindowSceneryRotation; @@ -1437,7 +1437,7 @@ static void sub_6E1F34( if (interaction_type == VIEWPORT_INTERACTION_ITEM_NONE) { - gridPos.x = LOCATION_NULL; + gridPos.setNull(); return; } @@ -1451,7 +1451,7 @@ static void sub_6E1F34( if (surfaceElement == nullptr) { - gridPos.x = LOCATION_NULL; + gridPos.setNull(); return; } @@ -1473,7 +1473,7 @@ static void sub_6E1F34( } else { - gridPos.x = LOCATION_NULL; + gridPos.setNull(); } // If SHIFT pressed if (gSceneryShiftPressed) @@ -1486,7 +1486,7 @@ static void sub_6E1F34( gSceneryPlaceZ = z; } - if (gridPos.x == LOCATION_NULL) + if (gridPos.isNull()) return; gridPos = gridPos.ToTileStart(); @@ -1519,7 +1519,7 @@ static void sub_6E1F34( if (interaction_type == VIEWPORT_INTERACTION_ITEM_NONE) { - gridPos.x = LOCATION_NULL; + gridPos.setNull(); return; } @@ -1545,7 +1545,7 @@ static void sub_6E1F34( auto gridCoords = screen_get_map_xy_side({ x, y }, &cl); if (!gridCoords) { - gridPos.x = LOCATION_NULL; + gridPos.setNull(); return; } gridPos = *gridCoords; @@ -1559,7 +1559,7 @@ static void sub_6E1F34( if (surfaceElement == nullptr) { - gridPos.x = LOCATION_NULL; + gridPos.setNull(); return; } @@ -1577,7 +1577,7 @@ static void sub_6E1F34( auto mapCoords = screen_get_map_xy_side_with_z({ x, y }, z, &cl); if (!mapCoords) { - gridPos.x = LOCATION_NULL; + gridPos.setNull(); return; } gridPos = *mapCoords; @@ -1593,7 +1593,7 @@ static void sub_6E1F34( gSceneryPlaceZ = z; } - if (gridPos.x == LOCATION_NULL) + if (gridPos.isNull()) return; _secondaryColour = gWindowScenerySecondaryColour; @@ -1613,7 +1613,7 @@ static void sub_6E1F34( const CoordsXY mapCoords = sub_68A15E({ x, y }); gridPos = mapCoords; - if (gridPos.x == LOCATION_NULL) + if (gridPos.isNull()) return; gSceneryPlaceZ = 0; @@ -1625,7 +1625,7 @@ static void sub_6E1F34( if (surfaceElement == nullptr) { - gridPos.x = LOCATION_NULL; + gridPos.setNull(); return; } @@ -1647,7 +1647,7 @@ static void sub_6E1F34( } else { - gridPos.x = LOCATION_NULL; + gridPos.setNull(); } // If SHIFT pressed @@ -1661,11 +1661,10 @@ static void sub_6E1F34( gSceneryPlaceZ = z; } - if (gridPos.x == LOCATION_NULL) + if (gridPos.isNull()) return; - gridPos.x &= 0xFFE0; - gridPos.y &= 0xFFE0; + gridPos = gridPos.ToTileStart(); uint8_t rotation = gWindowSceneryRotation; rotation -= get_current_rotation(); @@ -1689,7 +1688,7 @@ static void sub_6E1F34( if (interaction_type == VIEWPORT_INTERACTION_ITEM_NONE) { - gridPos.x = LOCATION_NULL; + gridPos.setNull(); return; } @@ -1752,7 +1751,7 @@ static void window_top_toolbar_scenery_tool_down(int16_t x, int16_t y, rct_windo sub_6E1F34(x, y, selectedTab, gridPos, ¶meter_1, ¶meter_2, ¶meter_3); - if (gridPos.x == LOCATION_NULL) + if (gridPos.isNull()) return; switch (sceneryType) @@ -2681,7 +2680,7 @@ static void top_toolbar_tool_update_scenery(int16_t x, int16_t y) sub_6E1F34(x, y, selected_tab, mapTile, ¶meter1, ¶meter2, ¶meter3); - if (mapTile.x == LOCATION_NULL) + if (mapTile.isNull()) { scenery_remove_ghost_tool_placement(); return; diff --git a/src/openrct2/world/Location.hpp b/src/openrct2/world/Location.hpp index 0031961394..c60a0837fa 100644 --- a/src/openrct2/world/Location.hpp +++ b/src/openrct2/world/Location.hpp @@ -160,6 +160,11 @@ struct CoordsXY { return x == COORDS_NULL; }; + + void setNull() + { + x = COORDS_NULL; + } }; struct TileCoordsXY