1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-27 08:45:00 +01:00

Refactor the code that uses MapGetFootpathElement

This commit is contained in:
ζeh Matt
2023-08-05 18:09:38 +03:00
parent ad2b1959c8
commit 5f515b6a73
7 changed files with 18 additions and 21 deletions

View File

@@ -493,13 +493,12 @@ void FootpathPlaceAction::RemoveIntersectingWalls(PathElement* pathElement) cons
WallRemoveIntersectingWalls({ _loc, z, z + (6 * COORDS_Z_STEP) }, DirectionReverse(direction));
WallRemoveIntersectingWalls({ _loc, z, z + (6 * COORDS_Z_STEP) }, direction);
// Removing walls may have made the pointer invalid, so find it again
auto tileElement = MapGetFootpathElement(CoordsXYZ(_loc, z));
if (tileElement == nullptr)
pathElement = MapGetFootpathElement(CoordsXYZ(_loc, z));
if (pathElement == nullptr)
{
LOG_ERROR("Something went wrong. Could not refind footpath.");
return;
}
pathElement = tileElement->AsPath();
}
if (!(GetFlags() & GAME_COMMAND_FLAG_TRACK_DESIGN))