mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-23 15:52:55 +01:00
Refactor out all uses of gCurrentRotation, remove gCurrentRotation
This commit is contained in:
@@ -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 })
|
||||
{
|
||||
|
||||
@@ -35,8 +35,8 @@ public:
|
||||
if (viewport != nullptr)
|
||||
{
|
||||
SetViewportFlags();
|
||||
viewport->rotation = 0;
|
||||
}
|
||||
gCurrentRotation = 0;
|
||||
gShowGridLinesRefCount = 0;
|
||||
gShowLandRightsRefCount = 0;
|
||||
gShowConstructionRightsRefCount = 0;
|
||||
|
||||
@@ -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<int8_t>(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;
|
||||
}
|
||||
|
||||
@@ -65,8 +65,6 @@ Viewport* g_music_tracking_viewport;
|
||||
static std::unique_ptr<JobPool> _paintJobs;
|
||||
static std::vector<PaintSession*> _paintColumns;
|
||||
|
||||
uint8_t gCurrentRotation;
|
||||
|
||||
static uint32_t _currentImageType;
|
||||
InteractionInfo::InteractionInfo(const PaintStruct* ps)
|
||||
: Loc(ps->MapPos)
|
||||
@@ -2055,7 +2053,13 @@ std::optional<CoordsXY> 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)
|
||||
|
||||
@@ -123,8 +123,6 @@ extern uint8_t gShowConstructionRightsRefCount;
|
||||
// rct2: 0x014234BC
|
||||
extern Viewport* g_music_tracking_viewport;
|
||||
|
||||
extern uint8_t gCurrentRotation;
|
||||
|
||||
void ViewportInitAll();
|
||||
std::optional<ScreenCoordsXY> centre_2d_coordinates(const CoordsXYZ& loc, Viewport* viewport);
|
||||
void ViewportCreate(WindowBase* w, const ScreenCoordsXY& screenCoords, int32_t width, int32_t height, const Focus& focus);
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -111,7 +111,6 @@ static std::vector<TileElement> _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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user