From 37ef48890ff4966bc193a7fae5367251123f1a15 Mon Sep 17 00:00:00 2001 From: duncanspumpkin Date: Sun, 18 Aug 2019 08:32:20 +0100 Subject: [PATCH] Move various to use CoordsXYZ funcs instead of LocationXYZ --- src/openrct2/drawing/LightFX.cpp | 12 ++++++------ src/openrct2/interface/Viewport.cpp | 5 +++-- src/openrct2/interface/Window.cpp | 8 ++++---- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/openrct2/drawing/LightFX.cpp b/src/openrct2/drawing/LightFX.cpp index 7691bd9c6e..3970cb8a1b 100644 --- a/src/openrct2/drawing/LightFX.cpp +++ b/src/openrct2/drawing/LightFX.cpp @@ -187,14 +187,14 @@ void lightfx_prepare_light_list() continue; } - LocationXYZ16 coord_3d = { /* .x = */ entry->x, - /* .y = */ entry->y, - /* .z = */ entry->z }; + CoordsXYZ coord_3d = { /* .x = */ entry->x, + /* .y = */ entry->y, + /* .z = */ entry->z }; - LocationXY16 coord_2d = coordinate_3d_to_2d(&coord_3d, _current_view_rotation_front); + auto screenCoords = translate_3d_to_2d_with_z(_current_view_rotation_front, coord_3d); - entry->x = coord_2d.x; // - (_current_view_x_front); - entry->y = coord_2d.y; // - (_current_view_y_front); + entry->x = screenCoords.x; // - (_current_view_x_front); + entry->y = screenCoords.y; // - (_current_view_y_front); int32_t posOnScreenX = entry->x - _current_view_x_front; int32_t posOnScreenY = entry->y - _current_view_y_front; diff --git a/src/openrct2/interface/Viewport.cpp b/src/openrct2/interface/Viewport.cpp index 0548b20e6b..7da0c10969 100644 --- a/src/openrct2/interface/Viewport.cpp +++ b/src/openrct2/interface/Viewport.cpp @@ -95,6 +95,7 @@ void viewport_init_all() textinput_cancel(); } +// TODO: Return ScreenCoords, takein CoordsXYZ /** * Converts between 3d point of a sprite to 2d coordinates for centring on that * sprite @@ -109,9 +110,9 @@ void centre_2d_coordinates(int32_t x, int32_t y, int32_t z, int32_t* out_x, int3 { int32_t start_x = x; - LocationXYZ16 coord_3d = { (int16_t)x, (int16_t)y, (int16_t)z }; + CoordsXYZ coord_3d = { x, y, z }; - LocationXY16 coord_2d = coordinate_3d_to_2d(&coord_3d, get_current_rotation()); + auto coord_2d = translate_3d_to_2d_with_z(get_current_rotation(), coord_3d); // If the start location was invalid // propagate the invalid location to the output. diff --git a/src/openrct2/interface/Window.cpp b/src/openrct2/interface/Window.cpp index 31fbb4f877..7cd59fc263 100644 --- a/src/openrct2/interface/Window.cpp +++ b/src/openrct2/interface/Window.cpp @@ -808,7 +808,7 @@ rct_window* window_get_main() */ void window_scroll_to_location(rct_window* w, int32_t x, int32_t y, int32_t z) { - LocationXYZ16 location_3d = { (int16_t)x, (int16_t)y, (int16_t)z }; + CoordsXYZ location_3d = { x, y, z }; assert(w != nullptr); @@ -834,7 +834,7 @@ void window_scroll_to_location(rct_window* w, int32_t x, int32_t y, int32_t z) } } - LocationXY16 map_coordinate = coordinate_3d_to_2d(&location_3d, get_current_rotation()); + auto screenCoords = translate_3d_to_2d_with_z(get_current_rotation(), location_3d); int32_t i = 0; if (!(gScreenFlags & SCREEN_FLAGS_TITLE_DEMO)) @@ -878,8 +878,8 @@ void window_scroll_to_location(rct_window* w, int32_t x, int32_t y, int32_t z) { if (!(w->flags & WF_NO_SCROLLING)) { - w->saved_view_x = map_coordinate.x - (int16_t)(w->viewport->view_width * window_scroll_locations[i][0]); - w->saved_view_y = map_coordinate.y - (int16_t)(w->viewport->view_height * window_scroll_locations[i][1]); + w->saved_view_x = screenCoords.x - (int16_t)(w->viewport->view_width * window_scroll_locations[i][0]); + w->saved_view_y = screenCoords.y - (int16_t)(w->viewport->view_height * window_scroll_locations[i][1]); w->flags |= WF_SCROLLING_TO_LOCATION; } }