diff --git a/src/openrct2-ui/interface/ViewportInteraction.cpp b/src/openrct2-ui/interface/ViewportInteraction.cpp
index bd4d02ac52..d44e1988cb 100644
--- a/src/openrct2-ui/interface/ViewportInteraction.cpp
+++ b/src/openrct2-ui/interface/ViewportInteraction.cpp
@@ -660,16 +660,15 @@ static Peep* viewport_interaction_get_closest_peep(ScreenCoordsXY screenCoords,
*/
CoordsXY sub_68A15E(ScreenCoordsXY screenCoords)
{
- int16_t mapX, mapY;
+ CoordsXY mapCoords;
CoordsXY initialPos{};
int32_t interactionType;
TileElement* tileElement;
rct_viewport* viewport;
get_map_coordinates_from_pos(
- screenCoords.x, screenCoords.y, VIEWPORT_INTERACTION_MASK_TERRAIN & VIEWPORT_INTERACTION_MASK_WATER, &mapX, &mapY,
- &interactionType, &tileElement, &viewport);
- initialPos.x = mapX;
- initialPos.y = mapY;
+ screenCoords, VIEWPORT_INTERACTION_MASK_TERRAIN & VIEWPORT_INTERACTION_MASK_WATER, mapCoords, &interactionType,
+ &tileElement, &viewport);
+ initialPos = mapCoords;
if (interactionType == VIEWPORT_INTERACTION_ITEM_NONE)
{
diff --git a/src/openrct2-ui/windows/Footpath.cpp b/src/openrct2-ui/windows/Footpath.cpp
index d64ddd965e..f78662d7aa 100644
--- a/src/openrct2-ui/windows/Footpath.cpp
+++ b/src/openrct2-ui/windows/Footpath.cpp
@@ -715,10 +715,10 @@ static void window_footpath_set_provisional_path_at_point(ScreenCoordsXY screenC
int32_t interactionType{};
TileElement* tileElement{};
- LocationXY16 mapCoord = {};
+ CoordsXY 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, VIEWPORT_INTERACTION_MASK_FOOTPATH & VIEWPORT_INTERACTION_MASK_TERRAIN, mapCoord, &interactionType,
+ &tileElement, nullptr);
if (interactionType == VIEWPORT_INTERACTION_ITEM_NONE || tileElement == nullptr)
{
@@ -849,10 +849,10 @@ static void window_footpath_place_path_at_point(ScreenCoordsXY screenCoords)
footpath_provisional_update();
- LocationXY16 mapCoord = {};
+ CoordsXY 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, VIEWPORT_INTERACTION_MASK_FOOTPATH & VIEWPORT_INTERACTION_MASK_TERRAIN, mapCoord, &interactionType,
+ &tileElement, nullptr);
if (interactionType == VIEWPORT_INTERACTION_ITEM_NONE)
{
diff --git a/src/openrct2-ui/windows/Guest.cpp b/src/openrct2-ui/windows/Guest.cpp
index 0e991917e7..a0ff3b520f 100644
--- a/src/openrct2-ui/windows/Guest.cpp
+++ b/src/openrct2-ui/windows/Guest.cpp
@@ -1246,8 +1246,9 @@ void window_guest_overview_tool_update(rct_window* w, rct_widgetindex widgetInde
gPickupPeepImage = UINT32_MAX;
int32_t interactionType;
+ CoordsXY unusedCoords;
get_map_coordinates_from_pos(
- screenCoords.x, screenCoords.y, VIEWPORT_INTERACTION_MASK_NONE, nullptr, nullptr, &interactionType, nullptr, nullptr);
+ screenCoords, VIEWPORT_INTERACTION_MASK_NONE, unusedCoords, &interactionType, nullptr, nullptr);
if (interactionType == VIEWPORT_INTERACTION_ITEM_NONE)
return;
diff --git a/src/openrct2-ui/windows/Ride.cpp b/src/openrct2-ui/windows/Ride.cpp
index 66e0ae8b0c..6113602bbb 100644
--- a/src/openrct2-ui/windows/Ride.cpp
+++ b/src/openrct2-ui/windows/Ride.cpp
@@ -4397,9 +4397,8 @@ static void window_ride_set_track_colour_scheme(rct_window* w, int32_t x, int32_
newColourScheme = (uint8_t)w->ride_colour;
- LocationXY16 mapCoord = {};
- get_map_coordinates_from_pos(
- x, y, VIEWPORT_INTERACTION_MASK_RIDE, &mapCoord.x, &mapCoord.y, &interactionType, &tileElement, nullptr);
+ CoordsXY mapCoord = {};
+ get_map_coordinates_from_pos({ x, y }, VIEWPORT_INTERACTION_MASK_RIDE, mapCoord, &interactionType, &tileElement, nullptr);
x = mapCoord.x;
y = mapCoord.y;
@@ -5574,14 +5573,14 @@ static void window_ride_measurements_update(rct_window* w)
static void window_ride_measurements_tooldown(rct_window* w, rct_widgetindex widgetIndex, ScreenCoordsXY screenCoords)
{
TileElement* tileElement;
- int16_t mapX, mapY;
+ CoordsXY mapCoords;
int32_t interactionType;
_lastSceneryX = screenCoords.x;
_lastSceneryY = screenCoords.y;
_collectTrackDesignScenery = true; // Default to true in case user does not select anything valid
- get_map_coordinates_from_pos(screenCoords.x, screenCoords.y, 0xFCCF, &mapX, &mapY, &interactionType, &tileElement, nullptr);
+ get_map_coordinates_from_pos(screenCoords, 0xFCCF, mapCoords, &interactionType, &tileElement, nullptr);
switch (interactionType)
{
case VIEWPORT_INTERACTION_ITEM_SCENERY:
@@ -5589,7 +5588,7 @@ static void window_ride_measurements_tooldown(rct_window* w, rct_widgetindex wid
case VIEWPORT_INTERACTION_ITEM_WALL:
case VIEWPORT_INTERACTION_ITEM_FOOTPATH:
_collectTrackDesignScenery = !track_design_save_contains_tile_element(tileElement);
- track_design_save_select_tile_element(interactionType, { mapX, mapY }, tileElement, _collectTrackDesignScenery);
+ track_design_save_select_tile_element(interactionType, mapCoords, tileElement, _collectTrackDesignScenery);
break;
}
}
@@ -5602,17 +5601,17 @@ static void window_ride_measurements_tooldrag(rct_window* w, rct_widgetindex wid
_lastSceneryY = screenCoords.y;
TileElement* tileElement;
- int16_t mapX, mapY;
+ CoordsXY mapCoords;
int32_t interactionType;
- get_map_coordinates_from_pos(screenCoords.x, screenCoords.y, 0xFCCF, &mapX, &mapY, &interactionType, &tileElement, nullptr);
+ get_map_coordinates_from_pos(screenCoords, 0xFCCF, mapCoords, &interactionType, &tileElement, nullptr);
switch (interactionType)
{
case VIEWPORT_INTERACTION_ITEM_SCENERY:
case VIEWPORT_INTERACTION_ITEM_LARGE_SCENERY:
case VIEWPORT_INTERACTION_ITEM_WALL:
case VIEWPORT_INTERACTION_ITEM_FOOTPATH:
- track_design_save_select_tile_element(interactionType, { mapX, mapY }, tileElement, _collectTrackDesignScenery);
+ track_design_save_select_tile_element(interactionType, mapCoords, tileElement, _collectTrackDesignScenery);
break;
}
}
diff --git a/src/openrct2-ui/windows/Staff.cpp b/src/openrct2-ui/windows/Staff.cpp
index 2d938d58fb..deef0e72ad 100644
--- a/src/openrct2-ui/windows/Staff.cpp
+++ b/src/openrct2-ui/windows/Staff.cpp
@@ -1162,8 +1162,9 @@ void window_staff_overview_tool_update(rct_window* w, rct_widgetindex widgetInde
gPickupPeepImage = UINT32_MAX;
int32_t interactionType;
+ CoordsXY unusedCoords;
get_map_coordinates_from_pos(
- screenCoords.x, screenCoords.y, VIEWPORT_INTERACTION_MASK_NONE, nullptr, nullptr, &interactionType, nullptr, nullptr);
+ screenCoords, VIEWPORT_INTERACTION_MASK_NONE, unusedCoords, &interactionType, nullptr, nullptr);
if (interactionType == VIEWPORT_INTERACTION_ITEM_NONE)
return;
diff --git a/src/openrct2-ui/windows/TileInspector.cpp b/src/openrct2-ui/windows/TileInspector.cpp
index cb9749e91b..99ee1fa44f 100644
--- a/src/openrct2-ui/windows/TileInspector.cpp
+++ b/src/openrct2-ui/windows/TileInspector.cpp
@@ -1222,27 +1222,23 @@ static void window_tile_inspector_tool_update(rct_window* w, rct_widgetindex wid
gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE;
- int16_t mapX = 0;
- int16_t mapY = 0;
+ CoordsXY mapCoords;
TileElement* clickedElement = nullptr;
if (input_test_place_object_modifier(PLACE_OBJECT_MODIFIER_COPY_Z))
{
- get_map_coordinates_from_pos(
- screenCoords.x, screenCoords.y, ViewportInteractionFlags, &mapX, &mapY, nullptr, &clickedElement, nullptr);
+ get_map_coordinates_from_pos(screenCoords, ViewportInteractionFlags, mapCoords, nullptr, &clickedElement, nullptr);
}
// Even if Ctrl was pressed, fall back to normal selection when there was nothing under the cursor
if (clickedElement == nullptr)
{
- CoordsXY mapCoords = screen_pos_to_map_pos(screenCoords, nullptr);
- mapX = mapCoords.x;
- mapY = mapCoords.y;
+ mapCoords = screen_pos_to_map_pos(screenCoords, nullptr);
}
- if (mapX != LOCATION_NULL)
+ if (mapCoords.x != LOCATION_NULL)
{
- gMapSelectPositionA.x = gMapSelectPositionB.x = mapX;
- gMapSelectPositionA.y = gMapSelectPositionB.y = mapY;
+ gMapSelectPositionA.x = gMapSelectPositionB.x = mapCoords.x;
+ gMapSelectPositionA.y = gMapSelectPositionB.y = mapCoords.y;
}
else if (windowTileInspectorTileSelected)
{
@@ -1273,19 +1269,17 @@ static void window_tile_inspector_update_selected_tile(rct_window* w, ScreenCoor
windowTileInspectorToolMouseY = screenCoords.y;
windowTileInspectorToolCtrlDown = ctrlIsHeldDown;
- int16_t mapX = 0;
- int16_t mapY = 0;
+ CoordsXY mapCoords{};
TileElement* clickedElement = nullptr;
if (ctrlIsHeldDown)
{
- get_map_coordinates_from_pos(
- screenCoords.x, screenCoords.y, ViewportInteractionFlags, &mapX, &mapY, nullptr, &clickedElement, nullptr);
+ get_map_coordinates_from_pos(screenCoords, ViewportInteractionFlags, mapCoords, nullptr, &clickedElement, nullptr);
}
// Even if Ctrl was pressed, fall back to normal selection when there was nothing under the cursor
if (clickedElement == nullptr)
{
- CoordsXY mapCoords = screen_pos_to_map_pos(screenCoords, nullptr);
+ mapCoords = screen_pos_to_map_pos(screenCoords, nullptr);
if (mapCoords.x == LOCATION_NULL)
{
@@ -1298,15 +1292,12 @@ static void window_tile_inspector_update_selected_tile(rct_window* w, ScreenCoor
{
return;
}
- mapX = mapCoords.x;
- mapY = mapCoords.y;
}
windowTileInspectorTileSelected = true;
- windowTileInspectorToolMap.x = mapX;
- windowTileInspectorToolMap.y = mapY;
- windowTileInspectorTileX = mapX >> 5;
- windowTileInspectorTileY = mapY >> 5;
+ windowTileInspectorToolMap = mapCoords;
+ windowTileInspectorTileX = mapCoords.x >> 5;
+ windowTileInspectorTileY = mapCoords.y >> 5;
window_tile_inspector_load_tile(w, clickedElement);
}
diff --git a/src/openrct2-ui/windows/TopToolbar.cpp b/src/openrct2-ui/windows/TopToolbar.cpp
index 65c64ea582..5110f791c1 100644
--- a/src/openrct2-ui/windows/TopToolbar.cpp
+++ b/src/openrct2-ui/windows/TopToolbar.cpp
@@ -1017,7 +1017,6 @@ static void window_top_toolbar_paint(rct_window* w, rct_drawpixelinfo* dpi)
static void repaint_scenery_tool_down(int16_t x, int16_t y, rct_widgetindex widgetIndex)
{
// ax, cx, bl
- int16_t grid_x, grid_y;
int32_t type;
// edx
TileElement* tile_element;
@@ -1027,7 +1026,8 @@ static void repaint_scenery_tool_down(int16_t x, int16_t y, rct_widgetindex widg
// not used
rct_viewport* viewport;
- get_map_coordinates_from_pos(x, y, flags, &grid_x, &grid_y, &type, &tile_element, &viewport);
+ CoordsXY gridCoords;
+ get_map_coordinates_from_pos({ x, y }, flags, gridCoords, &type, &tile_element, &viewport);
switch (type)
{
@@ -1042,8 +1042,8 @@ static void repaint_scenery_tool_down(int16_t x, int16_t y, rct_widgetindex widg
uint8_t quadrant = tile_element->AsSmallScenery()->GetSceneryQuadrant();
auto repaintScenery = SmallScenerySetColourAction(
- { grid_x, grid_y, tile_element->base_height * 8 }, quadrant, tile_element->AsSmallScenery()->GetEntryIndex(),
- gWindowSceneryPrimaryColour, gWindowScenerySecondaryColour);
+ { gridCoords.x, gridCoords.y, tile_element->base_height * 8 }, quadrant,
+ tile_element->AsSmallScenery()->GetEntryIndex(), gWindowSceneryPrimaryColour, gWindowScenerySecondaryColour);
GameActions::Execute(&repaintScenery);
break;
@@ -1057,8 +1057,8 @@ static void repaint_scenery_tool_down(int16_t x, int16_t y, rct_widgetindex widg
return;
auto repaintScenery = WallSetColourAction(
- { grid_x, grid_y, tile_element->base_height * 8, tile_element->GetDirection() }, gWindowSceneryPrimaryColour,
- gWindowScenerySecondaryColour, gWindowSceneryTertiaryColour);
+ { gridCoords.x, gridCoords.y, tile_element->base_height * 8, tile_element->GetDirection() },
+ gWindowSceneryPrimaryColour, gWindowScenerySecondaryColour, gWindowSceneryTertiaryColour);
GameActions::Execute(&repaintScenery);
break;
@@ -1072,7 +1072,7 @@ static void repaint_scenery_tool_down(int16_t x, int16_t y, rct_widgetindex widg
return;
auto repaintScenery = LargeScenerySetColourAction(
- { grid_x, grid_y, tile_element->base_height * 8, tile_element->GetDirection() },
+ { gridCoords.x, gridCoords.y, tile_element->base_height * 8, tile_element->GetDirection() },
tile_element->AsLargeScenery()->GetSequenceIndex(), gWindowSceneryPrimaryColour, gWindowScenerySecondaryColour);
GameActions::Execute(&repaintScenery);
@@ -1087,7 +1087,7 @@ static void repaint_scenery_tool_down(int16_t x, int16_t y, rct_widgetindex widg
if (scenery_entry->banner.flags & BANNER_ENTRY_FLAG_HAS_PRIMARY_COLOUR)
{
auto repaintScenery = BannerSetColourAction(
- { grid_x, grid_y, tile_element->base_height * 8, tile_element->AsBanner()->GetPosition() },
+ { gridCoords.x, gridCoords.y, tile_element->base_height * 8, tile_element->AsBanner()->GetPosition() },
gWindowSceneryPrimaryColour);
GameActions::Execute(&repaintScenery);
@@ -1105,11 +1105,11 @@ static void scenery_eyedropper_tool_down(int16_t x, int16_t y, rct_widgetindex w
auto flags = VIEWPORT_INTERACTION_MASK_SCENERY & VIEWPORT_INTERACTION_MASK_WALL & VIEWPORT_INTERACTION_MASK_LARGE_SCENERY
& VIEWPORT_INTERACTION_MASK_BANNER & VIEWPORT_INTERACTION_MASK_FOOTPATH_ITEM;
- int16_t gridX, gridY;
int32_t type;
TileElement* tileElement;
rct_viewport* viewport;
- get_map_coordinates_from_pos(x, y, flags, &gridX, &gridY, &type, &tileElement, &viewport);
+ CoordsXY unusedCoords;
+ get_map_coordinates_from_pos({ x, y }, flags, unusedCoords, &type, &tileElement, &viewport);
switch (type)
{
@@ -1278,7 +1278,8 @@ static void sub_6E1F34(
& VIEWPORT_INTERACTION_MASK_SCENERY & VIEWPORT_INTERACTION_MASK_FOOTPATH & VIEWPORT_INTERACTION_MASK_WALL
& VIEWPORT_INTERACTION_MASK_LARGE_SCENERY;
int32_t interaction_type;
- get_map_coordinates_from_pos(x, y, flags, nullptr, nullptr, &interaction_type, &tile_element, nullptr);
+ CoordsXY unusedCoords;
+ get_map_coordinates_from_pos({ x, y }, flags, unusedCoords, &interaction_type, &tile_element, nullptr);
if (interaction_type != VIEWPORT_INTERACTION_ITEM_NONE)
{
@@ -1428,8 +1429,11 @@ static void sub_6E1F34(
auto flags = VIEWPORT_INTERACTION_MASK_TERRAIN & VIEWPORT_INTERACTION_MASK_WATER;
int32_t interaction_type = 0;
TileElement* tile_element;
+ CoordsXY gridCoords;
- get_map_coordinates_from_pos(x, y, flags, grid_x, grid_y, &interaction_type, &tile_element, nullptr);
+ get_map_coordinates_from_pos({ x, y }, flags, gridCoords, &interaction_type, &tile_element, nullptr);
+ *grid_x = gridCoords.x;
+ *grid_y = gridCoords.y;
if (interaction_type == VIEWPORT_INTERACTION_ITEM_NONE)
{
@@ -1503,8 +1507,11 @@ static void sub_6E1F34(
auto flags = VIEWPORT_INTERACTION_MASK_FOOTPATH & VIEWPORT_INTERACTION_MASK_FOOTPATH_ITEM;
int32_t interaction_type = 0;
TileElement* tile_element;
+ CoordsXY gridCoords;
- get_map_coordinates_from_pos(x, y, flags, grid_x, grid_y, &interaction_type, &tile_element, nullptr);
+ get_map_coordinates_from_pos({ x, y }, flags, gridCoords, &interaction_type, &tile_element, nullptr);
+ *grid_x = gridCoords.x;
+ *grid_y = gridCoords.y;
if (interaction_type == VIEWPORT_INTERACTION_ITEM_NONE)
{
@@ -1666,8 +1673,11 @@ static void sub_6E1F34(
auto flags = VIEWPORT_INTERACTION_MASK_FOOTPATH & VIEWPORT_INTERACTION_MASK_FOOTPATH_ITEM;
int32_t interaction_type = 0;
TileElement* tile_element;
+ CoordsXY gridCoords;
- get_map_coordinates_from_pos(x, y, flags, grid_x, grid_y, &interaction_type, &tile_element, nullptr);
+ get_map_coordinates_from_pos({ x, y }, flags, gridCoords, &interaction_type, &tile_element, nullptr);
+ *grid_x = gridCoords.x;
+ *grid_y = gridCoords.y;
if (interaction_type == VIEWPORT_INTERACTION_ITEM_NONE)
{
@@ -2347,11 +2357,11 @@ static void top_toolbar_tool_update_water(int16_t x, int16_t y)
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE;
- LocationXY16 mapTile = {};
+ CoordsXY mapTile = {};
int32_t interaction_type = 0;
get_map_coordinates_from_pos(
- x, y, VIEWPORT_INTERACTION_MASK_TERRAIN & VIEWPORT_INTERACTION_MASK_WATER, &mapTile.x, &mapTile.y, &interaction_type,
- nullptr, nullptr);
+ { x, y }, VIEWPORT_INTERACTION_MASK_TERRAIN & VIEWPORT_INTERACTION_MASK_WATER, mapTile, &interaction_type, nullptr,
+ nullptr);
if (interaction_type == VIEWPORT_INTERACTION_ITEM_NONE)
{
diff --git a/src/openrct2-ui/windows/Viewport.cpp b/src/openrct2-ui/windows/Viewport.cpp
index c36c6954b7..3eac76e2dc 100644
--- a/src/openrct2-ui/windows/Viewport.cpp
+++ b/src/openrct2-ui/windows/Viewport.cpp
@@ -124,7 +124,6 @@ static void window_viewport_anchor_border_widgets(rct_window* w)
static void window_viewport_mouseup(rct_window* w, rct_widgetindex widgetIndex)
{
rct_window* mainWindow;
- int16_t x, y;
switch (widgetIndex)
{
@@ -149,10 +148,11 @@ static void window_viewport_mouseup(rct_window* w, rct_widgetindex widgetIndex)
mainWindow = window_get_main();
if (mainWindow != nullptr)
{
+ CoordsXY mapCoords;
get_map_coordinates_from_pos(
- w->x + (w->width / 2), w->y + (w->height / 2), VIEWPORT_INTERACTION_MASK_NONE, &x, &y, nullptr, nullptr,
- nullptr);
- window_scroll_to_location(mainWindow, x, y, tile_element_height({ x, y }));
+ { w->x + (w->width / 2), w->y + (w->height / 2) }, VIEWPORT_INTERACTION_MASK_NONE, mapCoords, nullptr,
+ nullptr, nullptr);
+ window_scroll_to_location(mainWindow, mapCoords.x, mapCoords.y, tile_element_height(mapCoords));
}
break;
}
diff --git a/src/openrct2/interface/InteractiveConsole.cpp b/src/openrct2/interface/InteractiveConsole.cpp
index d167a80a99..f4599bd1e0 100644
--- a/src/openrct2/interface/InteractiveConsole.cpp
+++ b/src/openrct2/interface/InteractiveConsole.cpp
@@ -649,11 +649,11 @@ static int32_t cc_get(InteractiveConsole& console, const arguments_t& argv)
{
int32_t interactionType;
TileElement* tileElement;
- LocationXY16 mapCoord = {};
+ CoordsXY mapCoord = {};
rct_viewport* viewport = window_get_viewport(w);
get_map_coordinates_from_pos(
- viewport->view_width / 2, viewport->view_height / 2, VIEWPORT_INTERACTION_MASK_TERRAIN, &mapCoord.x,
- &mapCoord.y, &interactionType, &tileElement, nullptr);
+ { viewport->view_width / 2, viewport->view_height / 2 }, VIEWPORT_INTERACTION_MASK_TERRAIN, mapCoord,
+ &interactionType, &tileElement, nullptr);
mapCoord.x -= 16;
mapCoord.x /= 32;
mapCoord.y -= 16;
@@ -1689,7 +1689,7 @@ static constexpr const console_command console_command_table[] = {
{ "replay_stop", cc_replay_stop, "Stops the replay", "replay_stop"},
{ "replay_normalise", cc_replay_normalise, "Normalises the replay to remove all gaps", "replay_normalise