diff --git a/src/openrct2/actions/WallRemoveAction.cpp b/src/openrct2/actions/WallRemoveAction.cpp index 9ac0f598c4..d3872d05a5 100644 --- a/src/openrct2/actions/WallRemoveAction.cpp +++ b/src/openrct2/actions/WallRemoveAction.cpp @@ -16,8 +16,11 @@ #include "../localisation/StringIds.h" #include "../management/Finance.h" #include "../world/Location.hpp" +#include "../world/TileElementsView.h" #include "../world/Wall.h" +using namespace OpenRCT2; + WallRemoveAction::WallRemoveAction(const CoordsXYZD& loc) : _loc(loc) { @@ -93,22 +96,16 @@ GameActions::Result::Ptr WallRemoveAction::Execute() const TileElement* WallRemoveAction::GetFirstWallElementAt(const CoordsXYZD& location, bool isGhost) const { - TileElement* tileElement = map_get_first_element_at(location); - if (!tileElement) - return nullptr; - - do + for (auto* wallElement : TileElementsView(location)) { - if (tileElement->GetType() != TILE_ELEMENT_TYPE_WALL) + if (wallElement->GetBaseZ() != location.z) continue; - if (tileElement->GetBaseZ() != location.z) + if (wallElement->GetDirection() != location.direction) continue; - if (tileElement->GetDirection() != location.direction) - continue; - if (tileElement->IsGhost() != isGhost) + if (wallElement->IsGhost() != isGhost) continue; - return tileElement; - } while (!(tileElement++)->IsLastForTile()); + return wallElement->as(); + } return nullptr; }