diff --git a/src/openrct2/world/Footpath.cpp b/src/openrct2/world/Footpath.cpp index c5f8eb7bd2..4de77d1397 100644 --- a/src/openrct2/world/Footpath.cpp +++ b/src/openrct2/world/Footpath.cpp @@ -126,8 +126,9 @@ PathElement* MapGetFootpathElement(const CoordsXYZ& coords) { if (tileElement == nullptr) break; - if (tileElement->GetType() == TileElementType::Path && tileElement->GetBaseZ() == coords.z) - return tileElement->AsPath(); + auto* pathElement = tileElement->AsPath(); + if (pathElement != nullptr && pathElement->GetBaseZ() == coords.z) + return pathElement; } while (!(tileElement++)->IsLastForTile()); return nullptr;