mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-15 11:03:00 +01:00
Use TileElementsView for SmallSceneryRemoveAction
This commit is contained in:
@@ -21,9 +21,12 @@
|
||||
#include "../world/Park.h"
|
||||
#include "../world/SmallScenery.h"
|
||||
#include "../world/Sprite.h"
|
||||
#include "../world/TileElementsView.h"
|
||||
#include "GameAction.h"
|
||||
#include "SmallSceneryPlaceAction.h"
|
||||
|
||||
using namespace OpenRCT2;
|
||||
|
||||
SmallSceneryRemoveAction::SmallSceneryRemoveAction(const CoordsXYZ& location, uint8_t quadrant, ObjectEntryIndex sceneryType)
|
||||
: _loc(location)
|
||||
, _quadrant(quadrant)
|
||||
@@ -132,26 +135,18 @@ GameActions::Result::Ptr SmallSceneryRemoveAction::Execute() const
|
||||
|
||||
TileElement* SmallSceneryRemoveAction::FindSceneryElement() const
|
||||
{
|
||||
TileElement* tileElement = map_get_first_element_at(_loc);
|
||||
if (!tileElement)
|
||||
return nullptr;
|
||||
|
||||
do
|
||||
const bool isGhost = GetFlags() & GAME_COMMAND_FLAG_GHOST;
|
||||
for (auto* sceneryElement : TileElementsView<SmallSceneryElement>(_loc))
|
||||
{
|
||||
if (tileElement->GetType() != TILE_ELEMENT_TYPE_SMALL_SCENERY)
|
||||
if (sceneryElement->IsGhost() != isGhost)
|
||||
continue;
|
||||
if ((tileElement->AsSmallScenery()->GetSceneryQuadrant()) != _quadrant)
|
||||
if (sceneryElement->GetSceneryQuadrant() != _quadrant)
|
||||
continue;
|
||||
if (tileElement->GetBaseZ() != _loc.z)
|
||||
if (sceneryElement->GetBaseZ() != _loc.z)
|
||||
continue;
|
||||
if (tileElement->AsSmallScenery()->GetEntryIndex() != _sceneryType)
|
||||
if (sceneryElement->GetEntryIndex() != _sceneryType)
|
||||
continue;
|
||||
if ((GetFlags() & GAME_COMMAND_FLAG_GHOST) && tileElement->IsGhost() == false)
|
||||
continue;
|
||||
|
||||
return tileElement;
|
||||
|
||||
} while (!(tileElement++)->IsLastForTile());
|
||||
|
||||
return sceneryElement->as<TileElement>();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user