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

Use TileElementsView for BannerPlaceAction

This commit is contained in:
Matt
2021-02-05 16:33:40 +02:00
parent c0ab9e8a3b
commit 5caa6abc85

View File

@@ -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<PathElement>(_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;
}