From 706ef61e041850e47405507e349f665a02ad83d7 Mon Sep 17 00:00:00 2001 From: Gymnasiast Date: Mon, 29 Jan 2024 22:28:42 +0100 Subject: [PATCH] Extract PathPaintGetRotatedEdgesAndCorners() --- .../paint/tile_element/Paint.Path.cpp | 29 ++++++++++--------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/src/openrct2/paint/tile_element/Paint.Path.cpp b/src/openrct2/paint/tile_element/Paint.Path.cpp index 3762ba0379..a88cd43689 100644 --- a/src/openrct2/paint/tile_element/Paint.Path.cpp +++ b/src/openrct2/paint/tile_element/Paint.Path.cpp @@ -819,6 +819,19 @@ void PaintPath(PaintSession& session, uint16_t height, const PathElement& tileEl PaintLampLightEffects(session, tileElement, height); } +static std::pair PathPaintGetRotatedEdgesAndCorners( + const PaintSession& session, const PathElement& pathElement) +{ + // Rol edges around rotation + uint8_t edges = ((pathElement.GetEdges() << session.CurrentRotation) & 0xF) + | (((pathElement.GetEdges()) << session.CurrentRotation) >> 4); + + uint8_t corners = (((pathElement.GetCorners()) << session.CurrentRotation) & 0xF) + | (((pathElement.GetCorners()) << session.CurrentRotation) >> 4); + + return std::make_pair(edges, corners); +} + static BoundBoxXYZ PathPaintGetBoundbox(const PaintSession& session, int32_t height, uint8_t edges) { CoordsXY boundBoxOffset = stru_98D804[edges].offset; @@ -901,13 +914,7 @@ void PathPaintBoxSupport( { PROFILED_FUNCTION(); - // Rol edges around rotation - uint8_t edges = ((pathElement.GetEdges() << session.CurrentRotation) & 0xF) - | (((pathElement.GetEdges()) << session.CurrentRotation) >> 4); - - uint8_t corners = (((pathElement.GetCorners()) << session.CurrentRotation) & 0xF) - | (((pathElement.GetCorners()) << session.CurrentRotation) >> 4); - + auto [edges, corners] = PathPaintGetRotatedEdgesAndCorners(session, pathElement); uint16_t edi = edges | (corners << 4); ImageIndex surfaceBaseImageIndex = pathPaintInfo.SurfaceImageId; @@ -971,13 +978,7 @@ void PathPaintPoleSupport( { PROFILED_FUNCTION(); - // Rol edges around rotation - uint8_t edges = ((pathElement.GetEdges() << session.CurrentRotation) & 0xF) - | (((pathElement.GetEdges()) << session.CurrentRotation) >> 4); - - uint8_t corners = (((pathElement.GetCorners()) << session.CurrentRotation) & 0xF) - | (((pathElement.GetCorners()) << session.CurrentRotation) >> 4); - + auto [edges, corners] = PathPaintGetRotatedEdgesAndCorners(session, pathElement); uint16_t edi = edges | (corners << 4); ImageIndex surfaceBaseImageIndex = pathPaintInfo.SurfaceImageId;