From a4a04993f550a8d5a98278e196310b3193bce3f0 Mon Sep 17 00:00:00 2001 From: Gymnasiast Date: Thu, 8 Jan 2026 00:16:48 +0100 Subject: [PATCH 1/2] Name Sub6E1F34*, remove redundant window checks --- src/openrct2-ui/windows/Scenery.cpp | 89 +++++++---------------------- 1 file changed, 22 insertions(+), 67 deletions(-) diff --git a/src/openrct2-ui/windows/Scenery.cpp b/src/openrct2-ui/windows/Scenery.cpp index 5f72c80f5f..ed5c7485f3 100644 --- a/src/openrct2-ui/windows/Scenery.cpp +++ b/src/openrct2-ui/windows/Scenery.cpp @@ -1771,7 +1771,7 @@ namespace OpenRCT2::Ui::Windows uint8_t quadrant; Direction rotation; - Sub6E1F34SmallScenery(screenPos, selection.EntryIndex, mapTile, &quadrant, &rotation); + updatePlacementSmallScenery(screenPos, selection.EntryIndex, mapTile, &quadrant, &rotation); if (mapTile.IsNull()) { @@ -1848,7 +1848,7 @@ namespace OpenRCT2::Ui::Windows CoordsXY mapTile = {}; int32_t z; - Sub6E1F34PathItem(screenPos, selection.EntryIndex, mapTile, &z); + updatePlacementPathItem(screenPos, selection.EntryIndex, mapTile, &z); if (mapTile.IsNull()) { @@ -1888,7 +1888,7 @@ namespace OpenRCT2::Ui::Windows CoordsXY mapTile = {}; uint8_t edge; - Sub6E1F34Wall(screenPos, selection.EntryIndex, mapTile, &edge); + updatePlacementWall(screenPos, selection.EntryIndex, mapTile, &edge); if (mapTile.IsNull()) { @@ -1938,7 +1938,7 @@ namespace OpenRCT2::Ui::Windows CoordsXY mapTile = {}; Direction direction; - Sub6E1F34LargeScenery(screenPos, selection.EntryIndex, mapTile, &direction); + updatePlacementLargeScenery(screenPos, selection.EntryIndex, mapTile, &direction); if (mapTile.IsNull()) { @@ -1997,7 +1997,7 @@ namespace OpenRCT2::Ui::Windows Direction direction; int32_t z; - Sub6E1F34Banner(screenPos, selection.EntryIndex, mapTile, &z, &direction); + updatePlacementBanner(screenPos, selection.EntryIndex, mapTile, &z, &direction); if (mapTile.IsNull()) { @@ -2378,7 +2378,7 @@ namespace OpenRCT2::Ui::Windows } } - void Sub6E1F34UpdateScreenCoordsAndButtonsPressed(bool canRaiseItem, ScreenCoordsXY& screenPos) + void updatePlacementUpdateScreenCoordsAndButtonsPressed(bool canRaiseItem, ScreenCoordsXY& screenPos) { if (!canRaiseItem && !getGameState().cheats.disableSupportLimits) { @@ -2452,19 +2452,10 @@ namespace OpenRCT2::Ui::Windows } } - void Sub6E1F34SmallScenery( + void updatePlacementSmallScenery( const ScreenCoordsXY& sourceScreenPos, ObjectEntryIndex sceneryIndex, CoordsXY& gridPos, uint8_t* outQuadrant, Direction* outRotation) { - auto* windowMgr = GetWindowManager(); - auto* w = windowMgr->FindByClass(WindowClass::scenery); - - if (w == nullptr) - { - gridPos.SetNull(); - return; - } - auto screenPos = sourceScreenPos; uint16_t maxPossibleHeight = ZoomLevel::max().ApplyTo( std::numeric_limits::max() - 32); @@ -2483,7 +2474,7 @@ namespace OpenRCT2::Ui::Windows can_raise_item = true; } - Sub6E1F34UpdateScreenCoordsAndButtonsPressed(can_raise_item, screenPos); + updatePlacementUpdateScreenCoordsAndButtonsPressed(can_raise_item, screenPos); // Small scenery if (!sceneryEntry->HasFlag(SMALL_SCENERY_FLAG_FULL_TILE)) @@ -2651,22 +2642,13 @@ namespace OpenRCT2::Ui::Windows *outRotation = rotation; } - void Sub6E1F34PathItem( + void updatePlacementPathItem( const ScreenCoordsXY& sourceScreenPos, ObjectEntryIndex sceneryIndex, CoordsXY& gridPos, int32_t* outZ) { - auto* windowMgr = GetWindowManager(); - auto* w = windowMgr->FindByClass(WindowClass::scenery); - - if (w == nullptr) - { - gridPos.SetNull(); - return; - } - auto screenPos = sourceScreenPos; - Sub6E1F34UpdateScreenCoordsAndButtonsPressed(false, screenPos); + updatePlacementUpdateScreenCoordsAndButtonsPressed(false, screenPos); - // Path bits + // Path additions constexpr auto flag = EnumsToFlags(ViewportInteractionItem::footpath, ViewportInteractionItem::pathAddition); auto info = GetMapCoordinatesFromPos(screenPos, flag); gridPos = info.Loc; @@ -2685,18 +2667,9 @@ namespace OpenRCT2::Ui::Windows *outZ = info.Element->GetBaseZ(); } - void Sub6E1F34Wall( + void updatePlacementWall( const ScreenCoordsXY& sourceScreenPos, ObjectEntryIndex sceneryIndex, CoordsXY& gridPos, uint8_t* outEdges) { - auto* windowMgr = GetWindowManager(); - auto* w = windowMgr->FindByClass(WindowClass::scenery); - - if (w == nullptr) - { - gridPos.SetNull(); - return; - } - auto screenPos = sourceScreenPos; uint16_t maxPossibleHeight = ZoomLevel::max().ApplyTo( std::numeric_limits::max() - 32); @@ -2707,7 +2680,7 @@ namespace OpenRCT2::Ui::Windows maxPossibleHeight -= wallEntry->height; } - Sub6E1F34UpdateScreenCoordsAndButtonsPressed(true, screenPos); + updatePlacementUpdateScreenCoordsAndButtonsPressed(true, screenPos); // Walls uint8_t edge; @@ -2778,18 +2751,9 @@ namespace OpenRCT2::Ui::Windows *outEdges = edge; } - void Sub6E1F34LargeScenery( + void updatePlacementLargeScenery( const ScreenCoordsXY& sourceScreenPos, ObjectEntryIndex sceneryIndex, CoordsXY& gridPos, Direction* outDirection) { - auto* windowMgr = GetWindowManager(); - auto* w = windowMgr->FindByClass(WindowClass::scenery); - - if (w == nullptr) - { - gridPos.SetNull(); - return; - } - auto screenPos = sourceScreenPos; uint16_t maxPossibleHeight = ZoomLevel::max().ApplyTo( std::numeric_limits::max() - 32); @@ -2805,7 +2769,7 @@ namespace OpenRCT2::Ui::Windows maxPossibleHeight = std::max(0, maxPossibleHeight - maxClearZ); } - Sub6E1F34UpdateScreenCoordsAndButtonsPressed(true, screenPos); + updatePlacementUpdateScreenCoordsAndButtonsPressed(true, screenPos); // Large scenery // If CTRL not pressed @@ -2879,21 +2843,12 @@ namespace OpenRCT2::Ui::Windows *outDirection = rotation; } - void Sub6E1F34Banner( + void updatePlacementBanner( const ScreenCoordsXY& sourceScreenPos, ObjectEntryIndex sceneryIndex, CoordsXY& gridPos, int32_t* outZ, Direction* outDirection) { - auto* windowMgr = GetWindowManager(); - auto* w = windowMgr->FindByClass(WindowClass::scenery); - - if (w == nullptr) - { - gridPos.SetNull(); - return; - } - auto screenPos = sourceScreenPos; - Sub6E1F34UpdateScreenCoordsAndButtonsPressed(false, screenPos); + updatePlacementUpdateScreenCoordsAndButtonsPressed(false, screenPos); // Banner constexpr auto flag = EnumsToFlags(ViewportInteractionItem::footpath, ViewportInteractionItem::pathAddition); @@ -2935,7 +2890,7 @@ namespace OpenRCT2::Ui::Windows uint8_t quadrant; Direction rotation; - Sub6E1F34SmallScenery(screenCoords, selectedScenery, gridPos, &quadrant, &rotation); + updatePlacementSmallScenery(screenCoords, selectedScenery, gridPos, &quadrant, &rotation); if (gridPos.IsNull()) return; @@ -3062,7 +3017,7 @@ namespace OpenRCT2::Ui::Windows CoordsXY gridPos; int32_t z; - Sub6E1F34PathItem(screenCoords, selectedScenery, gridPos, &z); + updatePlacementPathItem(screenCoords, selectedScenery, gridPos, &z); if (gridPos.IsNull()) return; @@ -3109,7 +3064,7 @@ namespace OpenRCT2::Ui::Windows { CoordsXY gridPos; uint8_t edges; - Sub6E1F34Wall(screenCoords, selectedScenery, gridPos, &edges); + updatePlacementWall(screenCoords, selectedScenery, gridPos, &edges); if (gridPos.IsNull()) return; @@ -3310,7 +3265,7 @@ namespace OpenRCT2::Ui::Windows { CoordsXY gridPos; Direction direction; - Sub6E1F34LargeScenery(screenCoords, selectedScenery, gridPos, &direction); + updatePlacementLargeScenery(screenCoords, selectedScenery, gridPos, &direction); if (gridPos.IsNull()) return; @@ -3372,7 +3327,7 @@ namespace OpenRCT2::Ui::Windows CoordsXY gridPos; int32_t z; Direction direction; - Sub6E1F34Banner(screenCoords, selectedScenery, gridPos, &z, &direction); + updatePlacementBanner(screenCoords, selectedScenery, gridPos, &z, &direction); if (gridPos.IsNull()) return; From 7294661d13e8d35a68c9c5ed5d02ea167d95e09a Mon Sep 17 00:00:00 2001 From: Gymnasiast Date: Thu, 8 Jan 2026 00:17:33 +0100 Subject: [PATCH 2/2] Rename Sub6A3F61PathAddition() to paintPathAddition() --- src/openrct2/paint/tile_element/Paint.Path.cpp | 2 +- src/openrct2/paint/tile_element/Paint.PathAddition.cpp | 2 +- src/openrct2/paint/tile_element/Paint.PathAddition.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/openrct2/paint/tile_element/Paint.Path.cpp b/src/openrct2/paint/tile_element/Paint.Path.cpp index 676b93d143..0e52e9403c 100644 --- a/src/openrct2/paint/tile_element/Paint.Path.cpp +++ b/src/openrct2/paint/tile_element/Paint.Path.cpp @@ -623,7 +623,7 @@ static void PathPaintFencesAdditionsTunnels( { if (pathElement.HasAddition()) { - Sub6A3F61PathAddition(session, pathElement, height, sceneryImageTemplate); + paintPathAddition(session, pathElement, height, sceneryImageTemplate); } } diff --git a/src/openrct2/paint/tile_element/Paint.PathAddition.cpp b/src/openrct2/paint/tile_element/Paint.PathAddition.cpp index e5031eb454..a380d70c6a 100644 --- a/src/openrct2/paint/tile_element/Paint.PathAddition.cpp +++ b/src/openrct2/paint/tile_element/Paint.PathAddition.cpp @@ -224,7 +224,7 @@ inline bool PathAdditionIsVisible(uint32_t viewFlags, const PathAdditionEntry& p return false; } -void Sub6A3F61PathAddition(PaintSession& session, const PathElement& pathElement, uint16_t height, ImageId sceneryImageTemplate) +void paintPathAddition(PaintSession& session, const PathElement& pathElement, uint16_t height, ImageId sceneryImageTemplate) { // Path additions get drawn on edges that are not connected, so we need to flip them. const auto edges = pathElement.GetEdges() ^ 0b1111; diff --git a/src/openrct2/paint/tile_element/Paint.PathAddition.h b/src/openrct2/paint/tile_element/Paint.PathAddition.h index e58d235c32..5f1f4672ea 100644 --- a/src/openrct2/paint/tile_element/Paint.PathAddition.h +++ b/src/openrct2/paint/tile_element/Paint.PathAddition.h @@ -20,6 +20,6 @@ namespace OpenRCT2 struct PathElement; } -void Sub6A3F61PathAddition( +void paintPathAddition( PaintSession& session, const OpenRCT2::PathElement& pathElement, uint16_t height, ImageId sceneryImageTemplate); void PaintLampLightEffects(PaintSession& session, const OpenRCT2::PathElement& pathEl, uint16_t height);