Make Map::map_get_banner_element_at() use CoordsXYZ (#10408)

This commit is contained in:
Tulio Leao 2019-12-21 10:15:40 -03:00 committed by Michael Steenbeek
parent 228205a199
commit 9b1395bfb8
4 changed files with 8 additions and 7 deletions

View File

@ -77,8 +77,8 @@ public:
return MakeResult(GA_ERROR::NOT_OWNED, STR_CANT_POSITION_THIS_HERE, STR_LAND_NOT_OWNED_BY_PARK);
}
uint8_t baseHeight = _loc.z / 8 + 2;
BannerElement* existingBannerElement = map_get_banner_element_at(_loc.x / 32, _loc.y / 32, baseHeight, _loc.direction);
uint8_t baseHeight = _loc.z + (2 * 8);
BannerElement* existingBannerElement = map_get_banner_element_at({ _loc.x, _loc.y, baseHeight }, _loc.direction);
if (existingBannerElement != nullptr)
{
return MakeResult(GA_ERROR::ITEM_ALREADY_PLACED, STR_CANT_POSITION_THIS_HERE, STR_BANNER_SIGN_IN_THE_WAY);

View File

@ -79,7 +79,7 @@ private:
return MakeResult(GA_ERROR::NOT_OWNED, STR_CANT_REPAINT_THIS, STR_LAND_NOT_OWNED_BY_PARK);
}
auto bannerElement = map_get_banner_element_at(_loc.x / 32, _loc.y / 32, _loc.z / 8, _loc.direction);
auto bannerElement = map_get_banner_element_at(_loc, _loc.direction);
if (bannerElement == nullptr)
{

View File

@ -245,9 +245,10 @@ PathElement* map_get_path_element_at(const TileCoordsXYZ& loc)
return nullptr;
}
BannerElement* map_get_banner_element_at(int32_t x, int32_t y, int32_t z, uint8_t position)
BannerElement* map_get_banner_element_at(const CoordsXYZ& bannerPos, uint8_t position)
{
TileElement* tileElement = map_get_first_element_at(x, y);
auto bannerTilePos = TileCoordsXYZ{ bannerPos };
TileElement* tileElement = map_get_first_element_at(bannerTilePos.x, bannerTilePos.y);
if (tileElement == nullptr)
return nullptr;
@ -257,7 +258,7 @@ BannerElement* map_get_banner_element_at(int32_t x, int32_t y, int32_t z, uint8_
{
if (tileElement->GetType() != TILE_ELEMENT_TYPE_BANNER)
continue;
if (tileElement->base_height != z)
if (tileElement->base_height != bannerTilePos.z)
continue;
if (tileElement->AsBanner()->GetPosition() != position)
continue;

View File

@ -140,7 +140,7 @@ TileElement* map_get_first_element_at(int32_t x, int32_t y);
TileElement* map_get_nth_element_at(const CoordsXY& coords, int32_t n);
void map_set_tile_elements(int32_t x, int32_t y, TileElement* elements);
int32_t map_height_from_slope(const CoordsXY& coords, int32_t slope, bool isSloped);
BannerElement* map_get_banner_element_at(int32_t x, int32_t y, int32_t z, uint8_t direction);
BannerElement* map_get_banner_element_at(const CoordsXYZ& bannerPos, uint8_t direction);
SurfaceElement* map_get_surface_element_at(const CoordsXY& coords);
PathElement* map_get_path_element_at(const TileCoordsXYZ& loc);
WallElement* map_get_wall_element_at(CoordsXYZD wallCoords);