mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-24 00:03:11 +01:00
Improve coords assignments
This commit is contained in:
@@ -1222,8 +1222,8 @@ static void window_tile_inspector_tool_update(rct_window* w, rct_widgetindex wid
|
||||
|
||||
gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE;
|
||||
|
||||
int16_t mapX = screenCoords.x;
|
||||
int16_t mapY = screenCoords.y;
|
||||
int16_t mapX = 0;
|
||||
int16_t mapY = 0;
|
||||
TileElement* clickedElement = nullptr;
|
||||
if (input_test_place_object_modifier(PLACE_OBJECT_MODIFIER_COPY_Z))
|
||||
{
|
||||
@@ -1234,7 +1234,7 @@ static void window_tile_inspector_tool_update(rct_window* w, rct_widgetindex wid
|
||||
// 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({ mapX, mapY }, nullptr);
|
||||
CoordsXY mapCoords = screen_pos_to_map_pos(screenCoords, nullptr);
|
||||
mapX = mapCoords.x;
|
||||
mapY = mapCoords.y;
|
||||
}
|
||||
@@ -1273,8 +1273,8 @@ static void window_tile_inspector_update_selected_tile(rct_window* w, int32_t x,
|
||||
windowTileInspectorToolMouseY = y;
|
||||
windowTileInspectorToolCtrlDown = ctrlIsHeldDown;
|
||||
|
||||
int16_t mapX = x;
|
||||
int16_t mapY = y;
|
||||
int16_t mapX = 0;
|
||||
int16_t mapY = 0;
|
||||
TileElement* clickedElement = nullptr;
|
||||
if (ctrlIsHeldDown)
|
||||
{
|
||||
@@ -1284,7 +1284,7 @@ static void window_tile_inspector_update_selected_tile(rct_window* w, int32_t x,
|
||||
// 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({ mapX, mapY }, nullptr);
|
||||
CoordsXY mapCoords = screen_pos_to_map_pos({ x, y }, nullptr);
|
||||
|
||||
if (mapCoords.x == LOCATION_NULL)
|
||||
{
|
||||
|
||||
@@ -2091,8 +2091,7 @@ static void top_toolbar_tool_update_land(int16_t x, int16_t y)
|
||||
{
|
||||
int32_t selectionType;
|
||||
// Get selection type and map coordinates from mouse x,y position
|
||||
CoordsXY mapCoords = screen_pos_to_map_pos({ x, y }, &selectionType);
|
||||
mapTile = { static_cast<int16_t>(mapCoords.x), static_cast<int16_t>(mapCoords.y) };
|
||||
screen_pos_to_map_pos({ x, y }, &selectionType);
|
||||
mapTile = screen_get_map_xy_side({ x, y }, &side);
|
||||
|
||||
if (mapTile.x == LOCATION_NULL)
|
||||
|
||||
@@ -917,27 +917,26 @@ void window_rotate_camera(rct_window* w, int32_t direction)
|
||||
// has something to do with checking if middle of the viewport is obstructed
|
||||
rct_viewport* other;
|
||||
CoordsXY coords = screen_get_map_xy({ x, y }, &other);
|
||||
x = coords.x;
|
||||
y = coords.y;
|
||||
|
||||
// other != viewport probably triggers on viewports in ride or guest window?
|
||||
// x is LOCATION_NULL if middle of viewport is obstructed by another window?
|
||||
if (x == LOCATION_NULL || other != viewport)
|
||||
if (coords.x == LOCATION_NULL || other != viewport)
|
||||
{
|
||||
x = (viewport->view_width >> 1) + viewport->view_x;
|
||||
y = (viewport->view_height >> 1) + viewport->view_y;
|
||||
coords.x = (viewport->view_width >> 1) + viewport->view_x;
|
||||
coords.y = (viewport->view_height >> 1) + viewport->view_y;
|
||||
|
||||
viewport_adjust_for_map_height(&x, &y, &z);
|
||||
coords = { x, y };
|
||||
}
|
||||
else
|
||||
{
|
||||
z = tile_element_height({ x, y });
|
||||
z = tile_element_height({ coords.x, coords.y });
|
||||
}
|
||||
|
||||
gCurrentRotation = (get_current_rotation() + direction) & 3;
|
||||
|
||||
int32_t new_x, new_y;
|
||||
centre_2d_coordinates(x, y, z, &new_x, &new_y, viewport);
|
||||
centre_2d_coordinates(coords.x, coords.y, z, &new_x, &new_y, viewport);
|
||||
|
||||
w->saved_view_x = new_x;
|
||||
w->saved_view_y = new_y;
|
||||
|
||||
@@ -77,7 +77,7 @@ void rct_money_effect::CreateAt(money32 value, int32_t x, int32_t y, int32_t z,
|
||||
*/
|
||||
void rct_money_effect::Create(money32 value)
|
||||
{
|
||||
LocationXYZ16 mapPosition = { gCommandPosition.x, gCommandPosition.y, gCommandPosition.z };
|
||||
CoordsXYZ mapPosition = { gCommandPosition.x, gCommandPosition.y, gCommandPosition.z };
|
||||
|
||||
if (mapPosition.x == LOCATION_NULL)
|
||||
{
|
||||
@@ -96,12 +96,10 @@ void rct_money_effect::Create(money32 value)
|
||||
rct_viewport* mainViewport = window_get_viewport(mainWindow);
|
||||
CoordsXY mapPositionXY = screen_get_map_xy(
|
||||
{ mainViewport->x + (mainViewport->width / 2), mainViewport->y + (mainViewport->height / 2) }, nullptr);
|
||||
mapPosition.x = mapPositionXY.x;
|
||||
mapPosition.y = mapPositionXY.y;
|
||||
if (mapPosition.x == LOCATION_NULL)
|
||||
if (mapPositionXY.x == LOCATION_NULL)
|
||||
return;
|
||||
|
||||
mapPosition.z = tile_element_height({ mapPosition.x, mapPosition.y });
|
||||
mapPosition = { mapPositionXY, tile_element_height(mapPositionXY) };
|
||||
}
|
||||
mapPosition.z += 10;
|
||||
CreateAt(-value, mapPosition.x, mapPosition.y, mapPosition.z, false);
|
||||
|
||||
Reference in New Issue
Block a user