1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-19 21:13:05 +01:00

Use TileElementsView for BannerRemoveAction

This commit is contained in:
Matt
2021-02-05 16:38:39 +02:00
parent 5caa6abc85
commit a7b8978f6e

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;
BannerRemoveAction::BannerRemoveAction(const CoordsXYZD& loc)
: _loc(loc)
{
@@ -124,24 +127,18 @@ GameActions::Result::Ptr BannerRemoveAction::Execute() const
BannerElement* BannerRemoveAction::GetBannerElementAt() const
{
TileElement* tileElement = map_get_first_element_at(_loc);
// Find the banner element at known z and position
do
for (auto* bannerElement : TileElementsView<BannerElement>(_loc))
{
if (tileElement == nullptr)
break;
if (tileElement->GetType() != TILE_ELEMENT_TYPE_BANNER)
if (bannerElement->GetBaseZ() != _loc.z)
continue;
if (tileElement->GetBaseZ() != _loc.z)
if (bannerElement->IsGhost() && !(GetFlags() & GAME_COMMAND_FLAG_GHOST))
continue;
if (tileElement->IsGhost() && !(GetFlags() & GAME_COMMAND_FLAG_GHOST))
continue;
if (tileElement->AsBanner()->GetPosition() != _loc.direction)
if (bannerElement->GetPosition() != _loc.direction)
continue;
return tileElement->AsBanner();
} while (!(tileElement++)->IsLastForTile());
return bannerElement;
}
return nullptr;
}