1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-15 11:03:00 +01:00

Use TileElementsView for FootpathPlaceAction

This commit is contained in:
Matt
2021-02-05 16:44:05 +02:00
parent a7b8978f6e
commit dc1c3fe451

View File

@@ -20,8 +20,11 @@
#include "../world/Park.h"
#include "../world/Scenery.h"
#include "../world/Surface.h"
#include "../world/TileElementsView.h"
#include "../world/Wall.h"
using namespace OpenRCT2;
FootpathPlaceAction::FootpathPlaceAction(const CoordsXYZ& loc, uint8_t slope, ObjectEntryIndex type, Direction direction)
: _loc(loc)
, _slope(slope)
@@ -435,20 +438,19 @@ void FootpathPlaceAction::RemoveIntersectingWalls(PathElement* pathElement) cons
PathElement* FootpathPlaceAction::map_get_footpath_element_slope(const CoordsXYZ& footpathPos, int32_t slope) const
{
TileElement* tileElement;
bool isSloped = slope & FOOTPATH_PROPERTIES_FLAG_IS_SLOPED;
const bool isSloped = slope & FOOTPATH_PROPERTIES_FLAG_IS_SLOPED;
const auto slopeDirection = slope & FOOTPATH_PROPERTIES_SLOPE_DIRECTION_MASK;
tileElement = map_get_first_element_at(footpathPos);
do
for (auto* pathElement : TileElementsView<PathElement>(footpathPos))
{
if (tileElement == nullptr)
break;
if (tileElement->GetType() == TILE_ELEMENT_TYPE_PATH && tileElement->GetBaseZ() == footpathPos.z
&& (tileElement->AsPath()->IsSloped() == isSloped)
&& (tileElement->AsPath()->GetSlopeDirection() == (slope & FOOTPATH_PROPERTIES_SLOPE_DIRECTION_MASK)))
{
return tileElement->AsPath();
}
} while (!(tileElement++)->IsLastForTile());
if (pathElement->GetBaseZ() != footpathPos.z)
continue;
if (pathElement->IsSloped() == isSloped)
continue;
if (pathElement->GetSlopeDirection() != slopeDirection)
continue;
return pathElement;
}
return nullptr;
}