diff --git a/src/openrct2/paint/Paint.h b/src/openrct2/paint/Paint.h index 0dab2b06b4..85a20e5633 100644 --- a/src/openrct2/paint/Paint.h +++ b/src/openrct2/paint/Paint.h @@ -185,6 +185,7 @@ public: struct PaintSessionCore { + paint_struct PaintHead; paint_struct* Quadrants[MaxPaintQuadrants]; paint_struct* LastPS; paint_string_struct* PSStringHead; @@ -194,26 +195,24 @@ struct PaintSessionCore const void* CurrentlyDrawnItem; const TileElement* PathElementOnSameHeight; const TileElement* TrackElementOnSameHeight; - paint_struct PaintHead; + paint_struct* WoodenSupportsPrependTo; + CoordsXY SpritePosition; + CoordsXY MapPosition; uint32_t ViewFlags; uint32_t QuadrantBackIndex; uint32_t QuadrantFrontIndex; - CoordsXY SpritePosition; - ViewportInteractionItem InteractionType; - uint8_t CurrentRotation; + uint32_t TrackColours[4]; support_height SupportSegments[9]; support_height Support; - paint_struct* WoodenSupportsPrependTo; - CoordsXY MapPosition; + uint16_t WaterHeight; tunnel_entry LeftTunnels[TUNNEL_MAX_COUNT]; - uint8_t LeftTunnelCount; tunnel_entry RightTunnels[TUNNEL_MAX_COUNT]; + uint8_t LeftTunnelCount; uint8_t RightTunnelCount; uint8_t VerticalTunnelHeight; - bool DidPassSurface; - uint8_t Unk141E9DB; - uint16_t WaterHeight; - uint32_t TrackColours[4]; + uint8_t CurrentRotation; + uint8_t Flags; + ViewportInteractionItem InteractionType; }; struct paint_session : public PaintSessionCore diff --git a/src/openrct2/paint/Painter.cpp b/src/openrct2/paint/Painter.cpp index 1615c7bf55..ab5a59349c 100644 --- a/src/openrct2/paint/Painter.cpp +++ b/src/openrct2/paint/Painter.cpp @@ -157,6 +157,7 @@ paint_session* Painter::CreateSession(rct_drawpixelinfo* dpi, uint32_t viewFlags session->QuadrantBackIndex = std::numeric_limits::max(); session->QuadrantFrontIndex = 0; session->PaintEntryChain = _paintStructPool.Create(); + session->Flags = 0; std::fill(std::begin(session->Quadrants), std::end(session->Quadrants), nullptr); session->LastPS = nullptr; diff --git a/src/openrct2/paint/Supports.cpp b/src/openrct2/paint/Supports.cpp index 04cd88d291..a990a7bd4a 100644 --- a/src/openrct2/paint/Supports.cpp +++ b/src/openrct2/paint/Supports.cpp @@ -477,7 +477,7 @@ bool wooden_a_supports_paint_setup( return false; } - if (!(session.Unk141E9DB & PaintSessionFlags::IsPassedSurface)) + if (!(session.Flags & PaintSessionFlags::PassedSurface)) { return false; } @@ -636,7 +636,7 @@ bool wooden_b_supports_paint_setup( return false; } - if (!(session.Unk141E9DB & PaintSessionFlags::IsPassedSurface)) + if (!(session.Flags & PaintSessionFlags::PassedSurface)) { return false; } @@ -806,7 +806,7 @@ bool metal_a_supports_paint_setup( return false; } - if (!(session.Unk141E9DB & PaintSessionFlags::IsPassedSurface)) + if (!(session.Flags & PaintSessionFlags::PassedSurface)) { return false; } @@ -1005,7 +1005,7 @@ bool metal_b_supports_paint_setup( return false; // AND } - if (!(session.Unk141E9DB & PaintSessionFlags::IsPassedSurface)) + if (!(session.Flags & PaintSessionFlags::PassedSurface)) { return false; // AND } @@ -1185,7 +1185,7 @@ bool path_a_supports_paint_setup( return false; } - if (!(session.Unk141E9DB & PaintSessionFlags::IsPassedSurface)) + if (!(session.Flags & PaintSessionFlags::PassedSurface)) { return false; } @@ -1335,7 +1335,7 @@ bool path_b_supports_paint_setup( return false; // AND } - if (!(session.Unk141E9DB & PaintSessionFlags::IsPassedSurface)) + if (!(session.Flags & PaintSessionFlags::PassedSurface)) { return false; // AND } diff --git a/src/openrct2/paint/tile_element/Paint.Path.cpp b/src/openrct2/paint/tile_element/Paint.Path.cpp index 2d109c921c..ff5881c007 100644 --- a/src/openrct2/paint/tile_element/Paint.Path.cpp +++ b/src/openrct2/paint/tile_element/Paint.Path.cpp @@ -1099,7 +1099,8 @@ void path_paint_box_support( surfaceBaseImageIndex += byte_98D6E0[edi]; } - if (!session.DidPassSurface) + const bool hasPassedSurface = (session.Flags & PaintSessionFlags::PassedSurface) != 0; + if (!hasPassedSurface) { boundBoxOffset.x = 3; boundBoxOffset.y = 3; @@ -1120,7 +1121,7 @@ void path_paint_box_support( } } - if (!hasSupports || !session.DidPassSurface) + if (!hasSupports || !hasPassedSurface) { PaintAddImageAsParent( session, imageTemplate.WithIndex(surfaceBaseImageIndex), { 0, 0, height }, { boundBoxSize, 0 }, @@ -1238,7 +1239,8 @@ void path_paint_pole_support( } // Below Surface - if (!session.DidPassSurface) + const bool hasPassedSurface = (session.Flags & PaintSessionFlags::PassedSurface) != 0; + if (!hasPassedSurface) { boundBoxOffset.x = 3; boundBoxOffset.y = 3; @@ -1259,7 +1261,7 @@ void path_paint_pole_support( } } - if (!hasSupports || !session.DidPassSurface) + if (!hasSupports || !hasPassedSurface) { PaintAddImageAsParent( session, imageTemplate.WithIndex(surfaceBaseImageIndex), { 0, 0, height }, { boundBoxSize.x, boundBoxSize.y, 0 }, diff --git a/src/openrct2/paint/tile_element/Paint.Surface.cpp b/src/openrct2/paint/tile_element/Paint.Surface.cpp index c7be8a7bd9..fe4fe52d9b 100644 --- a/src/openrct2/paint/tile_element/Paint.Surface.cpp +++ b/src/openrct2/paint/tile_element/Paint.Surface.cpp @@ -978,7 +978,7 @@ void PaintSurface(paint_session& session, uint8_t direction, uint16_t height, co rct_drawpixelinfo* dpi = &session.DPI; session.InteractionType = ViewportInteractionItem::Terrain; - session.DidPassSurface = true; + session.Flags |= PaintSessionFlags::PassedSurface; session.SurfaceElement = reinterpret_cast(&tileElement); const auto zoomLevel = dpi->zoom_level; @@ -1414,7 +1414,6 @@ void PaintSurface(paint_session& session, uint8_t direction, uint16_t height, co } session.InteractionType = ViewportInteractionItem::Terrain; - session.Unk141E9DB |= PaintSessionFlags::IsPassedSurface; switch (surfaceShape) { diff --git a/src/openrct2/paint/tile_element/Paint.TileElement.cpp b/src/openrct2/paint/tile_element/Paint.TileElement.cpp index 38c9ed9fcf..9a3e93dc7d 100644 --- a/src/openrct2/paint/tile_element/Paint.TileElement.cpp +++ b/src/openrct2/paint/tile_element/Paint.TileElement.cpp @@ -56,7 +56,7 @@ void tile_element_paint_setup(paint_session& session, const CoordsXY& mapCoords, { paint_util_set_segment_support_height(session, SEGMENTS_ALL, 0xFFFF, 0); paint_util_force_set_general_support_height(session, -1, 0); - session.Unk141E9DB = isTrackPiecePreview ? PaintSessionFlags::IsTrackPiecePreview : 0; + session.Flags = isTrackPiecePreview ? PaintSessionFlags::IsTrackPiecePreview : 0; session.WaterHeight = 0xFFFF; PaintTileElementBase(session, mapCoords); @@ -218,7 +218,8 @@ static void PaintTileElementBase(paint_session& session, const CoordsXY& origCoo session.SpritePosition.x = coords.x; session.SpritePosition.y = coords.y; - session.DidPassSurface = false; + session.Flags &= ~PaintSessionFlags::PassedSurface; + int32_t previousBaseZ = 0; do { diff --git a/src/openrct2/paint/tile_element/Paint.TileElement.h b/src/openrct2/paint/tile_element/Paint.TileElement.h index 55b2806294..264ace0807 100644 --- a/src/openrct2/paint/tile_element/Paint.TileElement.h +++ b/src/openrct2/paint/tile_element/Paint.TileElement.h @@ -73,9 +73,8 @@ enum namespace PaintSessionFlags { - // Unsure as to why this exists and DidPassSurface - constexpr uint8_t IsPassedSurface = 1; - constexpr uint8_t IsTrackPiecePreview = 2; + constexpr uint8_t PassedSurface = 1u << 0; + constexpr uint8_t IsTrackPiecePreview = 1u << 1; } // namespace PaintSessionFlags #ifdef __TESTPAINT__ diff --git a/src/openrct2/ride/TrackPaint.cpp b/src/openrct2/ride/TrackPaint.cpp index 9435290e54..f0a05a7e8c 100644 --- a/src/openrct2/ride/TrackPaint.cpp +++ b/src/openrct2/ride/TrackPaint.cpp @@ -783,7 +783,7 @@ bool track_paint_util_draw_station_covers_2( return false; } - if (!(session.Unk141E9DB & (PaintSessionFlags::IsPassedSurface | PaintSessionFlags::IsTrackPiecePreview))) + if (!(session.Flags & (PaintSessionFlags::PassedSurface | PaintSessionFlags::IsTrackPiecePreview))) { return false; } diff --git a/src/openrct2/ride/gentle/MiniGolf.cpp b/src/openrct2/ride/gentle/MiniGolf.cpp index e69f5ab83a..6e59a0cdf0 100644 --- a/src/openrct2/ride/gentle/MiniGolf.cpp +++ b/src/openrct2/ride/gentle/MiniGolf.cpp @@ -462,7 +462,7 @@ static paint_struct* mini_golf_paint_util_7c( static bool mini_golf_paint_util_should_draw_fence(paint_session& session, const TrackElement& trackElement) { - if (!session.DidPassSurface) + if (!(session.Flags & PaintSessionFlags::PassedSurface)) { // Should be above ground (have passed surface rendering) return false;