diff --git a/src/openrct2/libopenrct2.vcxproj b/src/openrct2/libopenrct2.vcxproj index 34bb1b2990..fa8c26e3d8 100644 --- a/src/openrct2/libopenrct2.vcxproj +++ b/src/openrct2/libopenrct2.vcxproj @@ -392,6 +392,7 @@ + diff --git a/src/openrct2/paint/Paint.h b/src/openrct2/paint/Paint.h index 5f6141d90c..c24bd8006b 100644 --- a/src/openrct2/paint/Paint.h +++ b/src/openrct2/paint/Paint.h @@ -233,18 +233,6 @@ struct PaintSession : public PaintSessionCore } }; -struct FootpathPaintInfo -{ - uint32_t SurfaceImageId{}; - uint32_t BridgeImageId{}; - uint32_t RailingsImageId{}; - uint32_t SurfaceFlags{}; - uint32_t RailingFlags{}; - uint8_t ScrollingMode{}; - RailingEntrySupportType SupportType{}; - colour_t SupportColour = 255; -}; - extern PaintSession gPaintSession; // Globals for paint clipping diff --git a/src/openrct2/paint/support/MetalSupports.cpp b/src/openrct2/paint/support/MetalSupports.cpp index 27046b534a..11181f0ad5 100644 --- a/src/openrct2/paint/support/MetalSupports.cpp +++ b/src/openrct2/paint/support/MetalSupports.cpp @@ -513,7 +513,7 @@ void DrawSupportsSideBySide( */ bool PathPoleSupportsPaintSetup( PaintSession& session, const MetalSupportPlace supportPlace, const bool isSloped, const int32_t height, - ImageId imageTemplate, const FootpathPaintInfo& pathPaintInfo) + ImageId imageTemplate, const PathRailingsDescriptor& railings) { auto segment = EnumValue(supportPlace); @@ -541,7 +541,7 @@ bool PathPoleSupportsPaintSetup( uint16_t baseHeight; if ((supportSegments[segment].slope & kTileSlopeAboveTrackOrScenery) || (height - supportSegments[segment].height < 6) - || !(pathPaintInfo.RailingFlags & RAILING_ENTRY_FLAG_HAS_SUPPORT_BASE_SPRITE)) + || !(railings.flags & RAILING_ENTRY_FLAG_HAS_SUPPORT_BASE_SPRITE)) { baseHeight = supportSegments[segment].height; } @@ -551,7 +551,7 @@ bool PathPoleSupportsPaintSetup( baseHeight = supportSegments[segment].height; PaintAddImageAsParent( - session, imageTemplate.WithIndex(pathPaintInfo.BridgeImageId + 37 + imageOffset), + session, imageTemplate.WithIndex(railings.bridgeImage + 37 + imageOffset), { kMetalSupportBoundBoxOffsets[segment].x, kMetalSupportBoundBoxOffsets[segment].y, baseHeight }, { 0, 0, 5 }); baseHeight += 6; } @@ -570,7 +570,7 @@ bool PathPoleSupportsPaintSetup( if (heightDiff > 0) { PaintAddImageAsParent( - session, imageTemplate.WithIndex(pathPaintInfo.BridgeImageId + 20 + (heightDiff - 1)), + session, imageTemplate.WithIndex(railings.bridgeImage + 20 + (heightDiff - 1)), { kMetalSupportBoundBoxOffsets[segment], baseHeight }, { 0, 0, heightDiff - 1 }); } @@ -603,7 +603,7 @@ bool PathPoleSupportsPaintSetup( } PaintAddImageAsParent( - session, imageTemplate.WithIndex(pathPaintInfo.BridgeImageId + 20 + (z - 1)), + session, imageTemplate.WithIndex(railings.bridgeImage + 20 + (z - 1)), { kMetalSupportBoundBoxOffsets[segment], baseHeight }, { 0, 0, (z - 1) }); baseHeight += z; @@ -614,7 +614,7 @@ bool PathPoleSupportsPaintSetup( break; } - ImageIndex imageIndex = pathPaintInfo.BridgeImageId + 20 + (z - 1); + ImageIndex imageIndex = railings.bridgeImage + 20 + (z - 1); if (z == kMetalSupportMaxSectionHeight) { imageIndex += 1; @@ -649,7 +649,7 @@ bool PathPoleSupportsPaintSetup( break; } - ImageIndex imageIndex = pathPaintInfo.BridgeImageId + 20 + (z - 1); + ImageIndex imageIndex = railings.bridgeImage + 20 + (z - 1); PaintAddImageAsParent( session, imageTemplate.WithIndex(imageIndex), { kMetalSupportBoundBoxOffsets[segment], baseHeight }, { 0, 0, 0 }); diff --git a/src/openrct2/paint/support/MetalSupports.h b/src/openrct2/paint/support/MetalSupports.h index adf271b9ef..8345a1d185 100644 --- a/src/openrct2/paint/support/MetalSupports.h +++ b/src/openrct2/paint/support/MetalSupports.h @@ -86,8 +86,8 @@ enum class MetalSupportPlace : uint8_t none = 255, }; -struct FootpathPaintInfo; struct PaintSession; +struct PathRailingsDescriptor; /** @deprecated */ bool MetalASupportsPaintSetup( @@ -108,4 +108,4 @@ void DrawSupportsSideBySide( int32_t heightExtra = 0); bool PathPoleSupportsPaintSetup( PaintSession& session, MetalSupportPlace supportPlace, bool isSloped, int32_t height, ImageId imageTemplate, - const FootpathPaintInfo& pathPaintInfo); + const PathRailingsDescriptor& railings); diff --git a/src/openrct2/paint/support/WoodenSupports.cpp b/src/openrct2/paint/support/WoodenSupports.cpp index 65240cf76a..48fa7aa002 100644 --- a/src/openrct2/paint/support/WoodenSupports.cpp +++ b/src/openrct2/paint/support/WoodenSupports.cpp @@ -12,6 +12,7 @@ #include "../../SpriteIds.h" #include "../../interface/Viewport.h" #include "../../ride/TrackData.h" +#include "../../world/Footpath.h" #include "../../world/tile_element/Slope.h" #include "../Boundbox.h" #include "../Paint.SessionFlags.h" @@ -625,17 +626,17 @@ bool WoodenBSupportsPaintSetupRotated( */ bool PathBoxSupportsPaintSetup( PaintSession& session, WoodenSupportSubType supportType, bool isSloped, Direction slopeRotation, int32_t height, - ImageId imageTemplate, const FootpathPaintInfo& pathPaintInfo) + ImageId imageTemplate, const PathRailingsDescriptor& railings) { auto supportOrientationOffset = (supportType == WoodenSupportSubType::nwSe) ? 24 : 0; uint16_t baseHeight = 0; bool hasSupports = false; SupportsIdDescriptor supportIds = { - .Full = pathPaintInfo.BridgeImageId + 22 + supportOrientationOffset, - .Half = pathPaintInfo.BridgeImageId + 23 + supportOrientationOffset, - .Flat = pathPaintInfo.BridgeImageId + 48, - .Slope = pathPaintInfo.BridgeImageId + supportOrientationOffset, + .Full = railings.bridgeImage + 22 + supportOrientationOffset, + .Half = railings.bridgeImage + 23 + supportOrientationOffset, + .Flat = railings.bridgeImage + 48, + .Slope = railings.bridgeImage + supportOrientationOffset, }; if (!WoodenSupportsPaintSetupCommon<11, false>(session, supportIds, height, imageTemplate, hasSupports, baseHeight)) @@ -645,7 +646,7 @@ bool PathBoxSupportsPaintSetup( if (isSloped) { - ImageIndex imageIndex = pathPaintInfo.BridgeImageId + 55 + slopeRotation; + ImageIndex imageIndex = railings.bridgeImage + 55 + slopeRotation; PaintSlopeTransitions(kSlopedPathSupportsDescriptor, imageIndex, session, imageTemplate, baseHeight); hasSupports = true; diff --git a/src/openrct2/paint/support/WoodenSupports.h b/src/openrct2/paint/support/WoodenSupports.h index f619ebfbea..dee40b48fe 100644 --- a/src/openrct2/paint/support/WoodenSupports.h +++ b/src/openrct2/paint/support/WoodenSupports.h @@ -64,8 +64,8 @@ enum class WoodenSupportTransitionType : uint8_t }; constexpr int32_t kWoodenSupportTransitionTypeCount = 21; -struct FootpathPaintInfo; struct PaintSession; +struct PathRailingsDescriptor; bool WoodenASupportsPaintSetup( PaintSession& session, WoodenSupportType supportType, WoodenSupportSubType subType, int32_t height, ImageId imageTemplate, @@ -81,7 +81,7 @@ bool WoodenBSupportsPaintSetupRotated( ImageId imageTemplate, WoodenSupportTransitionType transitionType = WoodenSupportTransitionType::none); bool PathBoxSupportsPaintSetup( PaintSession& session, WoodenSupportSubType supportType, bool isSloped, Direction slopeRotation, int32_t height, - ImageId imageTemplate, const FootpathPaintInfo& pathPaintInfo); + ImageId imageTemplate, const PathRailingsDescriptor& pathPaintInfo); bool DrawSupportForSequenceA( PaintSession& session, WoodenSupportType supportType, OpenRCT2::TrackElemType trackType, uint8_t sequence, Direction direction, int32_t height, ImageId imageTemplate); diff --git a/src/openrct2/paint/tile_element/Paint.Path.cpp b/src/openrct2/paint/tile_element/Paint.Path.cpp index fcfbf82a12..c58366e2f5 100644 --- a/src/openrct2/paint/tile_element/Paint.Path.cpp +++ b/src/openrct2/paint/tile_element/Paint.Path.cpp @@ -7,15 +7,12 @@ * OpenRCT2 is licensed under the GNU General Public License version 3. *****************************************************************************/ -#include "../Paint.h" +#include "Paint.Path.h" #include "../../Context.h" -#include "../../Game.h" #include "../../GameState.h" #include "../../config/Config.h" -#include "../../core/Numerics.hpp" #include "../../drawing/Drawing.h" -#include "../../entity/PatrolArea.h" #include "../../interface/Viewport.h" #include "../../localisation/Formatter.h" #include "../../localisation/Formatting.h" @@ -28,11 +25,8 @@ #include "../../ride/Ride.h" #include "../../ride/Track.h" #include "../../ride/TrackDesign.h" -#include "../../ride/TrackPaint.h" #include "../../world/Footpath.h" #include "../../world/Map.h" -#include "../../world/Scenery.h" -#include "../../world/TileInspector.h" #include "../../world/tile_element/PathElement.h" #include "../../world/tile_element/Slope.h" #include "../../world/tile_element/SurfaceElement.h" @@ -50,6 +44,12 @@ using namespace OpenRCT2; using namespace OpenRCT2::Drawing; +struct FootpathPaintInfo +{ + PathSurfaceDescriptor surface{}; + PathRailingsDescriptor railings{}; +}; + bool gPaintWidePathsAsGhost = false; const uint8_t kPathSlopeToLandSlope[] = { @@ -110,18 +110,18 @@ static constexpr WoodenSupportSubType PathSupportOrientation[] = { }; // clang-format on -void PathPaintBoxSupport( +static void PathPaintBoxSupport( PaintSession& session, const PathElement& pathElement, int32_t height, const FootpathPaintInfo& pathPaintInfo, bool hasSupports, ImageId imageTemplate, ImageId sceneryImageTemplate); -void PathPaintPoleSupport( +static void PathPaintPoleSupport( PaintSession& session, const PathElement& pathElement, int16_t height, const FootpathPaintInfo& pathPaintInfo, bool hasSupports, ImageId imageTemplate, ImageId sceneryImageTemplate); static void PathPaintQueueBanner( - PaintSession& session, const PathElement& pathElement, uint16_t height, const FootpathPaintInfo& pathPaintInfo, + PaintSession& session, const PathElement& pathElement, uint16_t height, const PathRailingsDescriptor& railings, ImageId imageTemplate) { - auto imageId = imageTemplate.WithIndex(pathPaintInfo.RailingsImageId); + auto imageId = imageTemplate.WithIndex(railings.railingsImage); uint8_t direction = pathElement.GetQueueBannerDirection(); // Draw ride sign @@ -152,7 +152,7 @@ static void PathPaintQueueBanner( auto ride = GetRide(pathElement.GetRideIndex()); if (direction < 2 && ride != nullptr && !imageTemplate.IsRemap()) { - uint16_t scrollingMode = pathPaintInfo.ScrollingMode; + uint16_t scrollingMode = railings.scrollingMode; scrollingMode += direction; auto ft = Formatter(); @@ -227,9 +227,9 @@ static void PathPaintSlopedFences( static void PathPaintFencesAndQueueBannersQueue( PaintSession& session, const PathElement& pathElement, uint16_t height, uint32_t connectedEdges, bool hasSupports, - const FootpathPaintInfo& pathPaintInfo, ImageId imageTemplate) + const PathRailingsDescriptor& railings, ImageId imageTemplate) { - auto imageId = imageTemplate.WithIndex(pathPaintInfo.RailingsImageId); + auto imageId = imageTemplate.WithIndex(railings.railingsImage); if (pathElement.IsSloped()) { @@ -367,9 +367,9 @@ static void PathPaintFencesAndQueueBannersQueue( } } - if (pathElement.HasQueueBanner() && !(pathPaintInfo.RailingFlags & RAILING_ENTRY_FLAG_NO_QUEUE_BANNER)) + if (pathElement.HasQueueBanner() && !(railings.flags & RAILING_ENTRY_FLAG_NO_QUEUE_BANNER)) { - PathPaintQueueBanner(session, pathElement, height, pathPaintInfo, imageTemplate); + PathPaintQueueBanner(session, pathElement, height, railings, imageTemplate); } } @@ -377,17 +377,17 @@ static void PathPaintFencesAndQueueBannersNonQueue( PaintSession& session, const PathElement& pathElement, uint16_t height, uint32_t connectedEdges, bool hasSupports, const FootpathPaintInfo& pathPaintInfo, ImageId imageTemplate) { - auto imageId = imageTemplate.WithIndex(pathPaintInfo.RailingsImageId); + auto imageId = imageTemplate.WithIndex(pathPaintInfo.railings.railingsImage); uint32_t drawnCorners = 0; // If the path is not drawn over the supports, then no corner sprites will be drawn (making double-width paths // look like connected series of intersections). - if (pathPaintInfo.RailingFlags & RAILING_ENTRY_FLAG_DRAW_PATH_OVER_SUPPORTS) + if (pathPaintInfo.railings.flags & RAILING_ENTRY_FLAG_DRAW_PATH_OVER_SUPPORTS) { drawnCorners = (connectedEdges & FOOTPATH_PROPERTIES_EDGES_CORNERS_MASK) >> 4; } - auto slopeRailingsSupported = !(pathPaintInfo.SurfaceFlags & FOOTPATH_ENTRY_FLAG_NO_SLOPE_RAILINGS); + auto slopeRailingsSupported = !(pathPaintInfo.surface.flags & FOOTPATH_ENTRY_FLAG_NO_SLOPE_RAILINGS); if ((hasSupports || slopeRailingsSupported) && pathElement.IsSloped()) { PathPaintSlopedFences(session, pathElement, height, imageId, false); @@ -582,7 +582,7 @@ static void PathPaintFencesAndQueueBanners( if (pathElement.IsQueue()) { PathPaintFencesAndQueueBannersQueue( - session, pathElement, height, connectedEdges, hasSupports, pathPaintInfo, imageTemplate); + session, pathElement, height, connectedEdges, hasSupports, pathPaintInfo.railings, imageTemplate); } else { @@ -681,24 +681,8 @@ static void PathPaintFencesAdditionsTunnels( static FootpathPaintInfo GetFootpathPaintInfo(const PathElement& pathEl) { FootpathPaintInfo pathPaintInfo; - - const auto* surfaceDescriptor = pathEl.GetSurfaceDescriptor(); - if (surfaceDescriptor != nullptr) - { - pathPaintInfo.SurfaceImageId = surfaceDescriptor->image; - pathPaintInfo.SurfaceFlags = surfaceDescriptor->flags; - } - - const auto* railingsDescriptor = pathEl.GetRailingsDescriptor(); - if (railingsDescriptor != nullptr) - { - pathPaintInfo.BridgeImageId = railingsDescriptor->bridgeImage; - pathPaintInfo.RailingsImageId = railingsDescriptor->railingsImage; - pathPaintInfo.RailingFlags = railingsDescriptor->flags; - pathPaintInfo.ScrollingMode = railingsDescriptor->scrollingMode; - pathPaintInfo.SupportType = railingsDescriptor->supportType; - pathPaintInfo.SupportColour = railingsDescriptor->supportColour; - } + pathPaintInfo.surface = pathEl.GetSurfaceDescriptor(); + pathPaintInfo.railings = pathEl.GetRailingsDescriptor(); return pathPaintInfo; } @@ -834,7 +818,7 @@ void PaintPath(PaintSession& session, uint16_t height, const PathElement& tileEl auto hasSupports = ShouldDrawSupports(session, tileElement, height); auto pathPaintInfo = GetFootpathPaintInfo(tileElement); - if (pathPaintInfo.SupportType == RailingEntrySupportType::pole) + if (pathPaintInfo.railings.supportType == RailingEntrySupportType::pole) { PathPaintPoleSupport(session, tileElement, height, pathPaintInfo, hasSupports, imageTemplate, sceneryImageTemplate); } @@ -863,7 +847,7 @@ static ImageIndex PathPaintGetBaseImage( const PaintSession& session, const PathElement& pathElement, const FootpathPaintInfo& pathPaintInfo, const uint8_t rotatedEdgesAndCorners) { - ImageIndex surfaceBaseImageIndex = pathPaintInfo.SurfaceImageId; + ImageIndex surfaceBaseImageIndex = pathPaintInfo.surface.image; if (pathElement.IsSloped()) { auto directionOffset = (pathElement.GetSlopeDirection() + session.CurrentRotation) % kNumOrthogonalDirections; @@ -952,7 +936,7 @@ static void PathPaintSegmentSupportHeight( } } -void PathPaintBoxSupport( +static void PathPaintBoxSupport( PaintSession& session, const PathElement& pathElement, int32_t height, const FootpathPaintInfo& pathPaintInfo, bool hasSupports, ImageId imageTemplate, ImageId sceneryImageTemplate) { @@ -975,16 +959,16 @@ void PathPaintBoxSupport( if (pathElement.IsSloped()) { auto directionOffset = (pathElement.GetSlopeDirection() + session.CurrentRotation) % kNumOrthogonalDirections; - bridgeBaseImageIndex = pathPaintInfo.BridgeImageId + 51 + directionOffset; + bridgeBaseImageIndex = pathPaintInfo.railings.bridgeImage + 51 + directionOffset; } else { - bridgeBaseImageIndex = EnumValue(PathSupportOrientation[edges]) + pathPaintInfo.BridgeImageId + 49; + bridgeBaseImageIndex = EnumValue(PathSupportOrientation[edges]) + pathPaintInfo.railings.bridgeImage + 49; } PaintAddImageAsParent(session, imageTemplate.WithIndex(bridgeBaseImageIndex), { 0, 0, height }, boundbox); - if (pathElement.IsQueue() || (pathPaintInfo.RailingFlags & RAILING_ENTRY_FLAG_DRAW_PATH_OVER_SUPPORTS)) + if (pathElement.IsQueue() || (pathPaintInfo.railings.flags & RAILING_ENTRY_FLAG_DRAW_PATH_OVER_SUPPORTS)) { PaintAddImageAsChild(session, imageTemplate.WithIndex(surfaceBaseImageIndex), { 0, 0, height }, boundbox); } @@ -1000,12 +984,13 @@ void PathPaintBoxSupport( } PathBoxSupportsPaintSetup( - session, PathSupportOrientation[edges], pathElement.IsSloped(), slopeDirection, height, imageTemplate, pathPaintInfo); + session, PathSupportOrientation[edges], pathElement.IsSloped(), slopeDirection, height, imageTemplate, + pathPaintInfo.railings); PathPaintSegmentSupportHeight(session, pathElement, height, edges, hasSupports); } -void PathPaintPoleSupport( +static void PathPaintPoleSupport( PaintSession& session, const PathElement& pathElement, int16_t height, const FootpathPaintInfo& pathPaintInfo, bool hasSupports, ImageId imageTemplate, ImageId sceneryImageTemplate) { @@ -1029,16 +1014,16 @@ void PathPaintPoleSupport( if (pathElement.IsSloped()) { bridgeBaseImageIndex = ((pathElement.GetSlopeDirection() + session.CurrentRotation) % kNumOrthogonalDirections) - + pathPaintInfo.BridgeImageId + 16; + + pathPaintInfo.railings.bridgeImage + 16; } else { - bridgeBaseImageIndex = edges + pathPaintInfo.BridgeImageId; + bridgeBaseImageIndex = edges + pathPaintInfo.railings.bridgeImage; } PaintAddImageAsParent(session, imageTemplate.WithIndex(bridgeBaseImageIndex), { 0, 0, height }, boundbox); - if (pathElement.IsQueue() || (pathPaintInfo.RailingFlags & RAILING_ENTRY_FLAG_DRAW_PATH_OVER_SUPPORTS)) + if (pathElement.IsQueue() || (pathPaintInfo.railings.flags & RAILING_ENTRY_FLAG_DRAW_PATH_OVER_SUPPORTS)) { PaintAddImageAsChild(session, imageTemplate.WithIndex(surfaceBaseImageIndex), { 0, 0, height }, boundbox); } @@ -1060,12 +1045,13 @@ void PathPaintPoleSupport( if (!(edges & (1 << i))) { // Only colour the supports if not already remapped (e.g. ghost remap) - auto supportColour = pathPaintInfo.SupportColour; + auto supportColour = pathPaintInfo.railings.supportColour; if (supportColour != COLOUR_NULL && !imageTemplate.IsRemap()) { imageTemplate = ImageId().WithPrimary(supportColour); } - PathPoleSupportsPaintSetup(session, supports[i], pathElement.IsSloped(), height, imageTemplate, pathPaintInfo); + PathPoleSupportsPaintSetup( + session, supports[i], pathElement.IsSloped(), height, imageTemplate, pathPaintInfo.railings); } } diff --git a/src/openrct2/paint/tile_element/Paint.Path.h b/src/openrct2/paint/tile_element/Paint.Path.h new file mode 100644 index 0000000000..a4dda09f47 --- /dev/null +++ b/src/openrct2/paint/tile_element/Paint.Path.h @@ -0,0 +1,21 @@ +/***************************************************************************** + * Copyright (c) 2014-2026 OpenRCT2 developers + * + * For a complete list of all authors, please refer to contributors.md + * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 + * + * OpenRCT2 is licensed under the GNU General Public License version 3. + *****************************************************************************/ + +#pragma once + +#include + +struct PaintSession; + +namespace OpenRCT2 +{ + struct PathElement; +} + +void PaintPath(PaintSession& session, uint16_t height, const OpenRCT2::PathElement& tileElement); diff --git a/src/openrct2/paint/tile_element/Paint.TileElement.cpp b/src/openrct2/paint/tile_element/Paint.TileElement.cpp index 761a26db7d..a79af845b6 100644 --- a/src/openrct2/paint/tile_element/Paint.TileElement.cpp +++ b/src/openrct2/paint/tile_element/Paint.TileElement.cpp @@ -30,6 +30,7 @@ #include "../Paint.SessionFlags.h" #include "../Paint.h" #include "../VirtualFloor.h" +#include "Paint.Path.h" #include "Paint.Surface.h" #include "Segment.h" diff --git a/src/openrct2/paint/tile_element/Paint.TileElement.h b/src/openrct2/paint/tile_element/Paint.TileElement.h index a782a05a4e..5f2a28e808 100644 --- a/src/openrct2/paint/tile_element/Paint.TileElement.h +++ b/src/openrct2/paint/tile_element/Paint.TileElement.h @@ -55,7 +55,6 @@ void TileElementPaintSetup(PaintSession& session, const CoordsXY& mapCoords, boo void PaintEntrance(PaintSession& session, uint8_t direction, int32_t height, const OpenRCT2::EntranceElement& entranceElement); void PaintBanner(PaintSession& session, uint8_t direction, int32_t height, const OpenRCT2::BannerElement& bannerElement); void PaintSurface(PaintSession& session, uint8_t direction, uint16_t height, const OpenRCT2::SurfaceElement& tileElement); -void PaintPath(PaintSession& session, uint16_t height, const OpenRCT2::PathElement& tileElement); void PaintSmallScenery( PaintSession& session, uint8_t direction, int32_t height, const OpenRCT2::SmallSceneryElement& sceneryElement); void PaintWall(PaintSession& session, uint8_t direction, int32_t height, const OpenRCT2::WallElement& tileElement); diff --git a/src/openrct2/world/Footpath.h b/src/openrct2/world/Footpath.h index e19246545e..1c93b5477b 100644 --- a/src/openrct2/world/Footpath.h +++ b/src/openrct2/world/Footpath.h @@ -12,6 +12,7 @@ #include "../Identifiers.h" #include "../actions/CommandFlag.h" #include "../drawing/ImageIndexType.h" +#include "../drawing/ScrollingText.h" #include "../interface/Colour.h" #include "../localisation/StringIdType.h" #include "../object/ObjectTypes.h" @@ -44,23 +45,25 @@ enum class RailingEntrySupportType : uint8_t struct PathSurfaceDescriptor { - StringId name; - ImageIndex image; - ImageIndex previewImage; - uint8_t flags; + StringId name = kStringIdNone; + ImageIndex image{}; + ImageIndex previewImage{}; + uint8_t flags{}; }; +constexpr PathSurfaceDescriptor kPathSurfaceDescriptorDummy{}; struct PathRailingsDescriptor { - StringId name; - ImageIndex previewImage; - ImageIndex bridgeImage; - ImageIndex railingsImage; - RailingEntrySupportType supportType; - colour_t supportColour; - uint8_t flags; - uint8_t scrollingMode; + StringId name = kStringIdNone; + ImageIndex previewImage{}; + ImageIndex bridgeImage{}; + ImageIndex railingsImage{}; + RailingEntrySupportType supportType{}; + colour_t supportColour = COLOUR_NULL; + uint8_t flags{}; + uint8_t scrollingMode = kScrollingModeNone; }; +constexpr PathRailingsDescriptor kPathRailingsDescriptorDummy{}; using PathConstructFlags = uint8_t; namespace OpenRCT2::PathConstructFlag diff --git a/src/openrct2/world/tile_element/PathElement.cpp b/src/openrct2/world/tile_element/PathElement.cpp index e900908316..41861ec4e3 100644 --- a/src/openrct2/world/tile_element/PathElement.cpp +++ b/src/openrct2/world/tile_element/PathElement.cpp @@ -206,43 +206,43 @@ namespace OpenRCT2 return (Flags2 & FOOTPATH_ELEMENT_FLAGS2_LEGACY_PATH_ENTRY) != 0; } - const PathSurfaceDescriptor* PathElement::GetSurfaceDescriptor() const + const PathSurfaceDescriptor& PathElement::GetSurfaceDescriptor() const { if (HasLegacyPathEntry()) { const auto* legacyPathEntry = GetLegacyPathEntry(); if (legacyPathEntry == nullptr) - return nullptr; + return kPathSurfaceDescriptorDummy; if (IsQueue()) - return &legacyPathEntry->GetQueueSurfaceDescriptor(); + return legacyPathEntry->GetQueueSurfaceDescriptor(); - return &legacyPathEntry->GetPathSurfaceDescriptor(); + return legacyPathEntry->GetPathSurfaceDescriptor(); } const auto* surfaceEntry = GetSurfaceEntry(); if (surfaceEntry == nullptr) - return nullptr; + return kPathSurfaceDescriptorDummy; - return &surfaceEntry->GetDescriptor(); + return surfaceEntry->GetDescriptor(); } - const PathRailingsDescriptor* PathElement::GetRailingsDescriptor() const + const PathRailingsDescriptor& PathElement::GetRailingsDescriptor() const { if (HasLegacyPathEntry()) { const auto* legacyPathEntry = GetLegacyPathEntry(); if (legacyPathEntry == nullptr) - return nullptr; + return kPathRailingsDescriptorDummy; - return &legacyPathEntry->GetPathRailingsDescriptor(); + return legacyPathEntry->GetPathRailingsDescriptor(); } const auto* railingsEntry = GetRailingsEntry(); if (railingsEntry == nullptr) - return nullptr; + return kPathRailingsDescriptorDummy; - return &railingsEntry->GetDescriptor(); + return railingsEntry->GetDescriptor(); } ObjectEntryIndex PathElement::GetSurfaceEntryIndex() const @@ -299,7 +299,7 @@ namespace OpenRCT2 bool PathElement::ShouldDrawPathOverSupports() const { // TODO: make this an actual decision of the tile element. - return (GetRailingsDescriptor()->flags & RAILING_ENTRY_FLAG_DRAW_PATH_OVER_SUPPORTS); + return (GetRailingsDescriptor().flags & RAILING_ENTRY_FLAG_DRAW_PATH_OVER_SUPPORTS); } void PathElement::SetShouldDrawPathOverSupports(bool on) diff --git a/src/openrct2/world/tile_element/PathElement.h b/src/openrct2/world/tile_element/PathElement.h index e88fa34d7f..ef1f618f45 100644 --- a/src/openrct2/world/tile_element/PathElement.h +++ b/src/openrct2/world/tile_element/PathElement.h @@ -83,8 +83,8 @@ namespace OpenRCT2 const FootpathRailingsObject* GetRailingsEntry() const; void SetRailingsEntryIndex(ObjectEntryIndex newIndex); - const PathSurfaceDescriptor* GetSurfaceDescriptor() const; - const PathRailingsDescriptor* GetRailingsDescriptor() const; + const PathSurfaceDescriptor& GetSurfaceDescriptor() const; + const PathRailingsDescriptor& GetRailingsDescriptor() const; uint8_t GetQueueBannerDirection() const; void SetQueueBannerDirection(uint8_t direction);