Make Map::map_get_large_scenery_segment() use CoordsXYZD

This commit is contained in:
Tulio Leao 2019-12-23 09:53:21 -03:00
parent a2c7ecc6e5
commit 00e1030d09
4 changed files with 13 additions and 12 deletions

View File

@ -83,7 +83,7 @@ private:
return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_REPAINT_THIS);
}
auto largeElement = map_get_large_scenery_segment(_loc.x, _loc.y, _loc.z / 8, _loc.direction, _tileIndex);
auto largeElement = map_get_large_scenery_segment(_loc, _tileIndex);
if (largeElement == nullptr)
{
@ -129,7 +129,7 @@ private:
}
}
auto tileElement = map_get_large_scenery_segment(currentTile.x, currentTile.y, _loc.z / 8, _loc.direction, i);
auto tileElement = map_get_large_scenery_segment({ currentTile.x, currentTile.y, _loc.z, _loc.direction }, i);
if (tileElement == nullptr)
{

View File

@ -248,7 +248,7 @@ static void track_design_save_add_large_scenery(CoordsXY loc, LargeSceneryElemen
auto rotatedOffsetPos = offsetPos.Rotate(direction);
CoordsXYZ tileLoc = { x0 + rotatedOffsetPos.x, y0 + rotatedOffsetPos.y, (z0 + tile->z_offset) };
auto largeElement = map_get_large_scenery_segment(tileLoc.x, tileLoc.y, tileLoc.z / 8, direction, sequence);
auto largeElement = map_get_large_scenery_segment({ tileLoc, static_cast<Direction>(direction) }, sequence);
if (largeElement != nullptr)
{
if (sequence == 0)
@ -422,7 +422,7 @@ static void track_design_save_remove_large_scenery(CoordsXY loc, LargeSceneryEle
auto rotatedOffsetPos = offsetPos.Rotate(direction);
CoordsXYZ tileLoc = { x0 + rotatedOffsetPos.x, y0 + rotatedOffsetPos.y, z0 + tile->z_offset };
auto largeElement = map_get_large_scenery_segment(tileLoc.x, tileLoc.y, tileLoc.z / 8, direction, sequence);
auto largeElement = map_get_large_scenery_segment({ tileLoc, static_cast<Direction>(direction) }, sequence);
if (largeElement != nullptr)
{
if (sequence == 0)

View File

@ -1749,22 +1749,23 @@ int32_t map_get_highest_z(const CoordsXY& loc)
return z;
}
LargeSceneryElement* map_get_large_scenery_segment(int32_t x, int32_t y, int32_t z, int32_t direction, int32_t sequence)
LargeSceneryElement* map_get_large_scenery_segment(const CoordsXYZD& sceneryPos, int32_t sequence)
{
TileElement* tileElement = map_get_first_element_at({ x, y });
TileElement* tileElement = map_get_first_element_at(sceneryPos);
if (tileElement == nullptr)
{
return nullptr;
}
auto sceneryTilePos = TileCoordsXYZ{ sceneryPos };
do
{
if (tileElement->GetType() != TILE_ELEMENT_TYPE_LARGE_SCENERY)
continue;
if (tileElement->base_height != z)
if (tileElement->base_height != sceneryTilePos.z)
continue;
if (tileElement->AsLargeScenery()->GetSequenceIndex() != sequence)
continue;
if ((tileElement->GetDirection()) != direction)
if ((tileElement->GetDirection()) != sceneryPos.direction)
continue;
return tileElement->AsLargeScenery();
@ -1880,7 +1881,7 @@ bool map_large_scenery_get_origin(
rct_scenery_entry* sceneryEntry;
rct_large_scenery_tile* tile;
auto tileElement = map_get_large_scenery_segment(x, y, z, direction, sequence);
auto tileElement = map_get_large_scenery_segment({ x, y, z << 3, static_cast<Direction>(direction) }, sequence);
if (tileElement == nullptr)
return false;
@ -1927,8 +1928,8 @@ bool sign_set_colour(
x = x0 + rotatedOffsetPos.x;
y = y0 + rotatedOffsetPos.y;
z = (z0 + tile->z_offset) / 8;
tileElement = map_get_large_scenery_segment(x, y, z, direction, sequence);
z = z0 + tile->z_offset;
tileElement = map_get_large_scenery_segment({ x, y, z, static_cast<Direction>(direction) }, sequence);
if (tileElement != nullptr)
{
tileElement->SetPrimaryColour(mainColour);

View File

@ -222,7 +222,7 @@ int32_t tile_element_get_corner_height(const SurfaceElement* surfaceElement, int
void map_clear_all_elements();
LargeSceneryElement* map_get_large_scenery_segment(int32_t x, int32_t y, int32_t z, int32_t direction, int32_t sequence);
LargeSceneryElement* map_get_large_scenery_segment(const CoordsXYZD& sceneryPos, int32_t sequence);
bool map_large_scenery_get_origin(
int32_t x, int32_t y, int32_t z, int32_t direction, int32_t sequence, int32_t* outX, int32_t* outY, int32_t* outZ,
LargeSceneryElement** outElement);