From db33968ff605ab2c58a5ff034489532de74f39b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=B6eh=20Matt?= <5415177+ZehMatt@users.noreply.github.com> Date: Sat, 5 Aug 2023 17:11:47 +0300 Subject: [PATCH] Fix #20684: Footpath additions getting removed by ghost track elements --- src/openrct2/actions/TrackPlaceAction.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/openrct2/actions/TrackPlaceAction.cpp b/src/openrct2/actions/TrackPlaceAction.cpp index c9960a7f7b..664f709294 100644 --- a/src/openrct2/actions/TrackPlaceAction.cpp +++ b/src/openrct2/actions/TrackPlaceAction.cpp @@ -258,16 +258,6 @@ GameActions::Result TrackPlaceAction::Query() const } costs += canBuild.Cost; - // When building a level crossing, remove any pre-existing path furniture. - if (crossingMode == CREATE_CROSSING_MODE_TRACK_OVER_PATH) - { - auto footpathElement = MapGetFootpathElement(mapLoc); - if (footpathElement != nullptr && footpathElement->AsPath()->HasAddition()) - { - footpathElement->AsPath()->SetAddition(0); - } - } - const auto clearanceData = canBuild.GetData(); uint8_t mapGroundFlags = clearanceData.GroundFlags & (ELEMENT_IS_ABOVE_GROUND | ELEMENT_IS_UNDERGROUND); if (resultData.GroundFlags != 0 && (resultData.GroundFlags & mapGroundFlags) == 0) @@ -478,6 +468,16 @@ GameActions::Result TrackPlaceAction::Execute() const } costs += canBuild.Cost; + // When building a level crossing, remove any pre-existing path furniture. + if (crossingMode == CREATE_CROSSING_MODE_TRACK_OVER_PATH && !(GetFlags() & GAME_COMMAND_FLAG_GHOST)) + { + auto footpathElement = MapGetFootpathElement(mapLoc); + if (footpathElement != nullptr && footpathElement->AsPath()->HasAddition()) + { + footpathElement->AsPath()->SetAddition(0); + } + } + if (!(GetFlags() & GAME_COMMAND_FLAG_GHOST) && !gCheatsDisableClearanceChecks) { FootpathRemoveLitter(mapLoc);