From 5caa6abc858f3ac65a629feaa5e5d19cbee7dcd0 Mon Sep 17 00:00:00 2001 From: Matt Date: Fri, 5 Feb 2021 16:33:40 +0200 Subject: [PATCH] Use TileElementsView for BannerPlaceAction --- src/openrct2/actions/BannerPlaceAction.cpp | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/openrct2/actions/BannerPlaceAction.cpp b/src/openrct2/actions/BannerPlaceAction.cpp index ec506bc35d..4991d0f847 100644 --- a/src/openrct2/actions/BannerPlaceAction.cpp +++ b/src/openrct2/actions/BannerPlaceAction.cpp @@ -13,8 +13,11 @@ #include "../world/Banner.h" #include "../world/MapAnimation.h" #include "../world/Scenery.h" +#include "../world/TileElementsView.h" #include "GameAction.h" +using namespace OpenRCT2; + BannerPlaceAction::BannerPlaceAction(const CoordsXYZD& loc, uint8_t bannerType, BannerIndex bannerIndex, uint8_t primaryColour) : _loc(loc) , _bannerType(bannerType) @@ -165,17 +168,8 @@ GameActions::Result::Ptr BannerPlaceAction::Execute() const PathElement* BannerPlaceAction::GetValidPathElement() const { - TileElement* tileElement = map_get_first_element_at(_loc); - do + for (auto* pathElement : TileElementsView(_loc)) { - if (tileElement == nullptr) - break; - - if (tileElement->GetType() != TILE_ELEMENT_TYPE_PATH) - continue; - - auto pathElement = tileElement->AsPath(); - if (pathElement->GetBaseZ() != _loc.z && pathElement->GetBaseZ() != _loc.z - PATH_HEIGHT_STEP) continue; @@ -186,6 +180,7 @@ PathElement* BannerPlaceAction::GetValidPathElement() const continue; return pathElement; - } while (!(tileElement++)->IsLastForTile()); + } + return nullptr; }