diff --git a/src/openrct2-ui/WindowManager.cpp b/src/openrct2-ui/WindowManager.cpp index 7e9e73d519..16466cb4a2 100644 --- a/src/openrct2-ui/WindowManager.cpp +++ b/src/openrct2-ui/WindowManager.cpp @@ -587,7 +587,7 @@ public: mainWindow->viewport_target_sprite = EntityId::GetNull(); mainWindow->savedViewPos = viewPos; viewport->zoom = zoom; - gCurrentRotation = rotation; + viewport->rotation = rotation; if (zoomDifference != ZoomLevel{ 0 }) { diff --git a/src/openrct2-ui/windows/Main.cpp b/src/openrct2-ui/windows/Main.cpp index 6b3d414c17..3484275922 100644 --- a/src/openrct2-ui/windows/Main.cpp +++ b/src/openrct2-ui/windows/Main.cpp @@ -35,8 +35,8 @@ public: if (viewport != nullptr) { SetViewportFlags(); + viewport->rotation = 0; } - gCurrentRotation = 0; gShowGridLinesRefCount = 0; gShowLandRightsRefCount = 0; gShowConstructionRightsRefCount = 0; diff --git a/src/openrct2/interface/Screenshot.cpp b/src/openrct2/interface/Screenshot.cpp index 56e27dcc61..3d6f2227b1 100644 --- a/src/openrct2/interface/Screenshot.cpp +++ b/src/openrct2/interface/Screenshot.cpp @@ -498,7 +498,7 @@ int32_t CommandLineForScreenshot(const char** argv, int32_t argc, ScreenshotOpti auto zoom = ZoomLevel{ customZoom }; auto rotation = std::atoi(argv[4]) & 3; viewport = GetGiantViewport(rotation, zoom); - gCurrentRotation = rotation; + viewport.rotation = rotation; } else { @@ -554,7 +554,7 @@ int32_t CommandLineForScreenshot(const char** argv, int32_t argc, ScreenshotOpti viewport.viewPos = { coords2d.x - ((viewport.view_width << customZoom) / 2), coords2d.y - ((viewport.view_height << customZoom) / 2) }; viewport.zoom = ZoomLevel{ static_cast(customZoom) }; - gCurrentRotation = customRotation; + viewport.rotation = customRotation; } else { @@ -562,7 +562,7 @@ int32_t CommandLineForScreenshot(const char** argv, int32_t argc, ScreenshotOpti viewport.viewPos = { gameState.SavedView - ScreenCoordsXY{ (viewport.view_width / 2), (viewport.view_height / 2) } }; viewport.zoom = gameState.SavedViewZoom; - gCurrentRotation = gameState.SavedViewRotation; + viewport.rotation = gameState.SavedViewRotation; } } @@ -656,8 +656,7 @@ void CaptureImage(const CaptureOptions& options) viewport = GetGiantViewport(options.Rotation, options.Zoom); } - auto backupRotation = gCurrentRotation; - gCurrentRotation = options.Rotation; + viewport.rotation = options.Rotation; if (options.Transparent) { @@ -669,6 +668,4 @@ void CaptureImage(const CaptureOptions& options) RenderViewport(nullptr, viewport, dpi); WriteDpiToFile(outputPath, dpi, gPalette); ReleaseDPI(dpi); - - gCurrentRotation = backupRotation; } diff --git a/src/openrct2/interface/Viewport.cpp b/src/openrct2/interface/Viewport.cpp index a6e2382adb..242d7fd643 100644 --- a/src/openrct2/interface/Viewport.cpp +++ b/src/openrct2/interface/Viewport.cpp @@ -65,8 +65,6 @@ Viewport* g_music_tracking_viewport; static std::unique_ptr _paintJobs; static std::vector _paintColumns; -uint8_t gCurrentRotation; - static uint32_t _currentImageType; InteractionInfo::InteractionInfo(const PaintStruct* ps) : Loc(ps->MapPos) @@ -2055,7 +2053,13 @@ std::optional ScreenGetMapXYSideWithZ(const ScreenCoordsXY& screenCoor */ uint8_t GetCurrentRotation() { - uint8_t rotation = gCurrentRotation; + auto* viewport = ViewportGetMain(); + if (viewport == nullptr) + { + LOG_ERROR("No viewport found! Will return 0."); + return 0; + } + uint8_t rotation = viewport->rotation; uint8_t rotation_masked = rotation & 3; #if defined(DEBUG_LEVEL_1) && DEBUG_LEVEL_1 if (rotation != rotation_masked) diff --git a/src/openrct2/interface/Viewport.h b/src/openrct2/interface/Viewport.h index 70e6aacd34..7269c8c354 100644 --- a/src/openrct2/interface/Viewport.h +++ b/src/openrct2/interface/Viewport.h @@ -123,8 +123,6 @@ extern uint8_t gShowConstructionRightsRefCount; // rct2: 0x014234BC extern Viewport* g_music_tracking_viewport; -extern uint8_t gCurrentRotation; - void ViewportInitAll(); std::optional centre_2d_coordinates(const CoordsXYZ& loc, Viewport* viewport); void ViewportCreate(WindowBase* w, const ScreenCoordsXY& screenCoords, int32_t width, int32_t height, const Focus& focus); diff --git a/src/openrct2/interface/Window.cpp b/src/openrct2/interface/Window.cpp index 52dac802eb..787835eb75 100644 --- a/src/openrct2/interface/Window.cpp +++ b/src/openrct2/interface/Window.cpp @@ -933,7 +933,7 @@ void WindowRotateCamera(WindowBase& w, int32_t direction) coords.z = TileElementHeight(coords); } - gCurrentRotation = (GetCurrentRotation() + direction) & 3; + viewport->rotation = (viewport->rotation + direction) & 3; auto centreLoc = centre_2d_coordinates(coords, viewport); diff --git a/src/openrct2/ride/TrackDesign.cpp b/src/openrct2/ride/TrackDesign.cpp index b571d7ce17..df37b689a5 100644 --- a/src/openrct2/ride/TrackDesign.cpp +++ b/src/openrct2/ride/TrackDesign.cpp @@ -2081,9 +2081,8 @@ void TrackDesignDrawPreview(TrackDesign* td6, uint8_t* pixels) const ScreenCoordsXY offset = { size_x / 2, size_y / 2 }; for (uint8_t i = 0; i < 4; i++) { - gCurrentRotation = i; - view.viewPos = Translate3DTo2DWithZ(i, centre) - offset; + view.rotation = i; ViewportRender(dpi, &view, { {}, ScreenCoordsXY{ size_x, size_y } }); dpi.bits += TRACK_PREVIEW_IMAGE_SIZE; diff --git a/src/openrct2/world/Map.cpp b/src/openrct2/world/Map.cpp index cf0cff8579..a5f4066fef 100644 --- a/src/openrct2/world/Map.cpp +++ b/src/openrct2/world/Map.cpp @@ -111,7 +111,6 @@ static std::vector _tileElementsStash; static size_t _tileElementsInUse; static size_t _tileElementsInUseStash; static TileCoordsXY _mapSizeStash; -static int32_t _currentRotationStash; void StashMap() { @@ -119,7 +118,6 @@ void StashMap() _tileIndexStash = std::move(_tileIndex); _tileElementsStash = std::move(gameState.TileElements); _mapSizeStash = GetGameState().MapSize; - _currentRotationStash = gCurrentRotation; _tileElementsInUseStash = _tileElementsInUse; } @@ -129,7 +127,6 @@ void UnstashMap() _tileIndex = std::move(_tileIndexStash); gameState.TileElements = std::move(_tileElementsStash); GetGameState().MapSize = _mapSizeStash; - gCurrentRotation = _currentRotationStash; _tileElementsInUse = _tileElementsInUseStash; }