Fix #20684: Footpath additions getting removed by ghost track elements

This commit is contained in:
ζeh Matt 2023-08-05 17:11:47 +03:00
parent acf931360d
commit db33968ff6
No known key found for this signature in database
GPG Key ID: 18CE582C71A225B0
1 changed files with 10 additions and 10 deletions

View File

@ -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<ConstructClearResult>();
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);