From 7be082caccf9e5219e5abfc4a3164341961b6bc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=B6eh=20Matt?= <5415177+ZehMatt@users.noreply.github.com> Date: Sun, 18 Feb 2024 14:50:06 +0200 Subject: [PATCH] Fix ViewportAdjustForMapHeight not using the correct rotation --- src/openrct2/interface/Viewport.cpp | 3 +-- src/openrct2/interface/Viewport.h | 2 +- src/openrct2/interface/Window.cpp | 4 ++-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/openrct2/interface/Viewport.cpp b/src/openrct2/interface/Viewport.cpp index 13d7e0aeaf..bfaac7f70d 100644 --- a/src/openrct2/interface/Viewport.cpp +++ b/src/openrct2/interface/Viewport.cpp @@ -254,11 +254,10 @@ void ViewportsInvalidate(const ScreenRect& screenRect, ZoomLevel maxZoom) * edx is assumed to be (and always is) the current rotation, so it is not * needed as parameter. */ -CoordsXYZ ViewportAdjustForMapHeight(const ScreenCoordsXY& startCoords) +CoordsXYZ ViewportAdjustForMapHeight(const ScreenCoordsXY& startCoords, uint8_t rotation) { int32_t height = 0; - uint32_t rotation = GetCurrentRotation(); CoordsXY pos{}; for (int32_t i = 0; i < 6; i++) { diff --git a/src/openrct2/interface/Viewport.h b/src/openrct2/interface/Viewport.h index 7269c8c354..76ce230286 100644 --- a/src/openrct2/interface/Viewport.h +++ b/src/openrct2/interface/Viewport.h @@ -137,7 +137,7 @@ void ViewportUpdateSmartFollowStaff(WindowBase* window, const Staff* peep); void ViewportUpdateSmartFollowVehicle(WindowBase* window); void ViewportRender(DrawPixelInfo& dpi, const Viewport* viewport, const ScreenRect& screenRect); -CoordsXYZ ViewportAdjustForMapHeight(const ScreenCoordsXY& startCoords); +CoordsXYZ ViewportAdjustForMapHeight(const ScreenCoordsXY& startCoords, uint8_t rotation); CoordsXY ViewportPosToMapPos(const ScreenCoordsXY& coords, int32_t z); std::optional ScreenPosToMapPos(const ScreenCoordsXY& screenCoords, int32_t* direction); diff --git a/src/openrct2/interface/Window.cpp b/src/openrct2/interface/Window.cpp index a2e95b7f9d..4067a38ed6 100644 --- a/src/openrct2/interface/Window.cpp +++ b/src/openrct2/interface/Window.cpp @@ -924,7 +924,7 @@ void WindowRotateCamera(WindowBase& w, int32_t direction) { auto viewPos = ScreenCoordsXY{ (viewport->view_width >> 1), (viewport->view_height >> 1) } + viewport->viewPos; - coords = ViewportAdjustForMapHeight(viewPos); + coords = ViewportAdjustForMapHeight(viewPos, viewport->rotation); } else { @@ -957,7 +957,7 @@ void WindowViewportGetMapCoordsByCursor( // Compute map coordinate by mouse position. auto viewportPos = w.viewport->ScreenToViewportCoord(mouseCoords); - auto coordsXYZ = ViewportAdjustForMapHeight(viewportPos); + auto coordsXYZ = ViewportAdjustForMapHeight(viewportPos, w.viewport->rotation); auto mapCoords = ViewportPosToMapPos(viewportPos, coordsXYZ.z); *map_x = mapCoords.x; *map_y = mapCoords.y;