diff --git a/src/openrct2/paint/Paint.h b/src/openrct2/paint/Paint.h index 0dab2b06b4..508a177d12 100644 --- a/src/openrct2/paint/Paint.h +++ b/src/openrct2/paint/Paint.h @@ -210,12 +210,14 @@ struct PaintSessionCore tunnel_entry RightTunnels[TUNNEL_MAX_COUNT]; uint8_t RightTunnelCount; uint8_t VerticalTunnelHeight; - bool DidPassSurface; - uint8_t Unk141E9DB; + uint8_t Flags; uint16_t WaterHeight; uint32_t TrackColours[4]; }; +// 16544 +static constexpr size_t SizeOfPaintSessionCore = sizeof(PaintSessionCore); + struct paint_session : public PaintSessionCore { rct_drawpixelinfo DPI; 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..2cc42ef2af 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::IsPassedSurface)) { return false; } @@ -636,7 +636,7 @@ bool wooden_b_supports_paint_setup( return false; } - if (!(session.Unk141E9DB & PaintSessionFlags::IsPassedSurface)) + if (!(session.Flags & PaintSessionFlags::IsPassedSurface)) { return false; } @@ -806,7 +806,7 @@ bool metal_a_supports_paint_setup( return false; } - if (!(session.Unk141E9DB & PaintSessionFlags::IsPassedSurface)) + if (!(session.Flags & PaintSessionFlags::IsPassedSurface)) { return false; } @@ -1005,7 +1005,7 @@ bool metal_b_supports_paint_setup( return false; // AND } - if (!(session.Unk141E9DB & PaintSessionFlags::IsPassedSurface)) + if (!(session.Flags & PaintSessionFlags::IsPassedSurface)) { return false; // AND } @@ -1185,7 +1185,7 @@ bool path_a_supports_paint_setup( return false; } - if (!(session.Unk141E9DB & PaintSessionFlags::IsPassedSurface)) + if (!(session.Flags & PaintSessionFlags::IsPassedSurface)) { return false; } @@ -1335,7 +1335,7 @@ bool path_b_supports_paint_setup( return false; // AND } - if (!(session.Unk141E9DB & PaintSessionFlags::IsPassedSurface)) + if (!(session.Flags & PaintSessionFlags::IsPassedSurface)) { 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..886ee25e2c 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::IsPassedSurface) != 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::IsPassedSurface) != 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..fa841503e6 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::IsPassedSurface; 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..aa2fac1b0b 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::IsPassedSurface; + int32_t previousBaseZ = 0; do { diff --git a/src/openrct2/ride/TrackPaint.cpp b/src/openrct2/ride/TrackPaint.cpp index 9435290e54..b0093088f5 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::IsPassedSurface | PaintSessionFlags::IsTrackPiecePreview))) { return false; } diff --git a/src/openrct2/ride/gentle/MiniGolf.cpp b/src/openrct2/ride/gentle/MiniGolf.cpp index e69f5ab83a..154f828f49 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::IsPassedSurface)) { // Should be above ground (have passed surface rendering) return false;