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

Refactor InitTileElement

Break loop when going to go outside of Tile
This commit is contained in:
Daniel Karandikar
2021-03-22 19:22:27 +00:00
parent 5ef750a879
commit d4efbdf531

View File

@@ -93,19 +93,21 @@ private:
void InitTileElement()
{
TileElement* tileElement = map_get_first_element_at(_banner->position.ToCoordsXY().ToTileCentre());
if (tileElement == nullptr)
if (tileElement != nullptr)
{
_tileElement = nullptr;
return;
while (1)
{
if ((tileElement->GetType() == TILE_ELEMENT_TYPE_BANNER) && (tileElement->AsBanner()->GetIndex() == number))
{
_tileElement = tileElement;
return;
}
if (tileElement->IsLastForTile())
break;
tileElement++;
}
}
while (1)
{
if ((tileElement->GetType() == TILE_ELEMENT_TYPE_BANNER) && (tileElement->AsBanner()->GetIndex() == number))
break;
tileElement++;
}
_tileElement = tileElement;
_tileElement = nullptr;
}
public: