mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-15 11:03:00 +01:00
Remove map_get_surface_element_at operating with TileCoordsXY
This commit is contained in:
@@ -490,7 +490,7 @@ void game_fix_save_vars()
|
||||
{
|
||||
for (int32_t x = 0; x < MAXIMUM_MAP_SIZE_TECHNICAL; x++)
|
||||
{
|
||||
auto* surfaceElement = map_get_surface_element_at(TileCoordsXY{ x, y });
|
||||
auto* surfaceElement = map_get_surface_element_at(TileCoordsXY{ x, y }.ToCoordsXY());
|
||||
|
||||
if (surfaceElement == nullptr)
|
||||
{
|
||||
|
||||
@@ -364,7 +364,7 @@ private:
|
||||
{
|
||||
for (x = 0; x < MAXIMUM_MAP_SIZE_TECHNICAL; x++)
|
||||
{
|
||||
auto surfaceElement = map_get_surface_element_at(TileCoordsXY{ x, y });
|
||||
auto surfaceElement = map_get_surface_element_at(TileCoordsXY{ x, y }.ToCoordsXY());
|
||||
if (surfaceElement == nullptr)
|
||||
continue;
|
||||
|
||||
|
||||
@@ -765,7 +765,8 @@ bool Peep::Place(TileCoordsXYZ location, bool apply)
|
||||
TileElement* tileElement = reinterpret_cast<TileElement*>(pathElement);
|
||||
if (!pathElement)
|
||||
{
|
||||
tileElement = reinterpret_cast<TileElement*>(map_get_surface_element_at(TileCoordsXY{ location.x, location.y }));
|
||||
tileElement = reinterpret_cast<TileElement*>(
|
||||
map_get_surface_element_at(TileCoordsXY{ location.x, location.y }.ToCoordsXY()));
|
||||
}
|
||||
|
||||
if (!tileElement)
|
||||
|
||||
@@ -177,6 +177,11 @@ struct TileCoordsXY
|
||||
return *this;
|
||||
}
|
||||
|
||||
CoordsXY ToCoordsXY() const
|
||||
{
|
||||
return { x * 32, y * 32 };
|
||||
}
|
||||
|
||||
TileCoordsXY Rotate(int32_t direction) const
|
||||
{
|
||||
TileCoordsXY rotatedCoords;
|
||||
|
||||
@@ -203,8 +203,9 @@ void map_set_tile_elements(int32_t x, int32_t y, TileElement* elements)
|
||||
gTileElementTilePointers[x + y * MAXIMUM_MAP_SIZE_TECHNICAL] = elements;
|
||||
}
|
||||
|
||||
SurfaceElement* map_get_surface_element_at(const TileCoordsXY& tileCoords)
|
||||
SurfaceElement* map_get_surface_element_at(const CoordsXY& coords)
|
||||
{
|
||||
auto tileCoords = TileCoordsXY{ coords };
|
||||
TileElement* tileElement = map_get_first_element_at(tileCoords.x, tileCoords.y);
|
||||
|
||||
if (tileElement == nullptr)
|
||||
@@ -222,11 +223,6 @@ SurfaceElement* map_get_surface_element_at(const TileCoordsXY& tileCoords)
|
||||
return tileElement->AsSurface();
|
||||
}
|
||||
|
||||
SurfaceElement* map_get_surface_element_at(const CoordsXY& coords)
|
||||
{
|
||||
return map_get_surface_element_at(TileCoordsXY(coords));
|
||||
}
|
||||
|
||||
PathElement* map_get_path_element_at(const TileCoordsXYZ& loc)
|
||||
{
|
||||
TileElement* tileElement = map_get_first_element_at(loc.x, loc.y);
|
||||
@@ -327,7 +323,7 @@ void map_count_remaining_land_rights()
|
||||
{
|
||||
for (int32_t y = 0; y < MAXIMUM_MAP_SIZE_TECHNICAL; y++)
|
||||
{
|
||||
auto* surfaceElement = map_get_surface_element_at(TileCoordsXY{ x, y });
|
||||
auto* surfaceElement = map_get_surface_element_at(TileCoordsXY{ x, y }.ToCoordsXY());
|
||||
// Surface elements are sometimes hacked out to save some space for other map elements
|
||||
if (surfaceElement == nullptr)
|
||||
{
|
||||
@@ -1474,7 +1470,7 @@ void map_update_tiles()
|
||||
interleaved_xy >>= 1;
|
||||
}
|
||||
|
||||
auto* surfaceElement = map_get_surface_element_at(TileCoordsXY{ x, y });
|
||||
auto* surfaceElement = map_get_surface_element_at(TileCoordsXY{ x, y }.ToCoordsXY());
|
||||
if (surfaceElement != nullptr)
|
||||
{
|
||||
surfaceElement->UpdateGrassLength({ x * 32, y * 32 });
|
||||
@@ -1617,8 +1613,8 @@ void map_extend_boundary_surface()
|
||||
y = gMapSize - 2;
|
||||
for (x = 0; x < MAXIMUM_MAP_SIZE_TECHNICAL; x++)
|
||||
{
|
||||
existingTileElement = map_get_surface_element_at(TileCoordsXY{ x, y - 1 });
|
||||
newTileElement = map_get_surface_element_at(TileCoordsXY{ x, y });
|
||||
existingTileElement = map_get_surface_element_at(TileCoordsXY{ x, y - 1 }.ToCoordsXY());
|
||||
newTileElement = map_get_surface_element_at(TileCoordsXY{ x, y }.ToCoordsXY());
|
||||
|
||||
if (existingTileElement && newTileElement)
|
||||
{
|
||||
@@ -1631,8 +1627,8 @@ void map_extend_boundary_surface()
|
||||
x = gMapSize - 2;
|
||||
for (y = 0; y < MAXIMUM_MAP_SIZE_TECHNICAL; y++)
|
||||
{
|
||||
existingTileElement = map_get_surface_element_at(TileCoordsXY{ x - 1, y });
|
||||
newTileElement = map_get_surface_element_at(TileCoordsXY{ x, y });
|
||||
existingTileElement = map_get_surface_element_at(TileCoordsXY{ x - 1, y }.ToCoordsXY());
|
||||
newTileElement = map_get_surface_element_at(TileCoordsXY{ x, y }.ToCoordsXY());
|
||||
|
||||
if (existingTileElement && newTileElement)
|
||||
{
|
||||
@@ -2398,7 +2394,7 @@ void FixLandOwnershipTilesWithOwnership(std::initializer_list<TileCoordsXY> tile
|
||||
{
|
||||
for (const TileCoordsXY* tile = tiles.begin(); tile != tiles.end(); ++tile)
|
||||
{
|
||||
auto surfaceElement = map_get_surface_element_at(*tile);
|
||||
auto surfaceElement = map_get_surface_element_at(tile->ToCoordsXY());
|
||||
if (surfaceElement != nullptr)
|
||||
{
|
||||
surfaceElement->SetOwnership(ownership);
|
||||
|
||||
@@ -143,7 +143,6 @@ TileElement* map_get_nth_element_at(int32_t x, int32_t y, 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);
|
||||
SurfaceElement* map_get_surface_element_at(const TileCoordsXY& tileCoords);
|
||||
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);
|
||||
|
||||
@@ -116,7 +116,7 @@ void mapgen_generate_blank(mapgen_settings* settings)
|
||||
{
|
||||
for (x = 1; x < settings->mapSize - 1; x++)
|
||||
{
|
||||
auto surfaceElement = map_get_surface_element_at(TileCoordsXY{ x, y });
|
||||
auto surfaceElement = map_get_surface_element_at(TileCoordsXY{ x, y }.ToCoordsXY());
|
||||
if (surfaceElement != nullptr)
|
||||
{
|
||||
surfaceElement->SetSurfaceStyle(settings->floor);
|
||||
@@ -167,7 +167,7 @@ void mapgen_generate(mapgen_settings* settings)
|
||||
{
|
||||
for (x = 1; x < mapSize - 1; x++)
|
||||
{
|
||||
auto surfaceElement = map_get_surface_element_at(TileCoordsXY{ x, y });
|
||||
auto surfaceElement = map_get_surface_element_at(TileCoordsXY{ x, y }.ToCoordsXY());
|
||||
if (surfaceElement != nullptr)
|
||||
{
|
||||
surfaceElement->SetSurfaceStyle(floorTexture);
|
||||
@@ -216,7 +216,7 @@ void mapgen_generate(mapgen_settings* settings)
|
||||
{
|
||||
for (x = 1; x < mapSize - 1; x++)
|
||||
{
|
||||
auto surfaceElement = map_get_surface_element_at(TileCoordsXY{ x, y });
|
||||
auto surfaceElement = map_get_surface_element_at(TileCoordsXY{ x, y }.ToCoordsXY());
|
||||
|
||||
if (surfaceElement != nullptr && surfaceElement->base_height < waterLevel + 6)
|
||||
surfaceElement->SetSurfaceStyle(beachTexture);
|
||||
@@ -304,16 +304,16 @@ static void mapgen_place_trees()
|
||||
}
|
||||
}
|
||||
|
||||
CoordsXY tmp, pos;
|
||||
TileCoordsXY tmp, pos;
|
||||
|
||||
std::vector<CoordsXY> availablePositions;
|
||||
std::vector<TileCoordsXY> availablePositions;
|
||||
|
||||
// Create list of available tiles
|
||||
for (int32_t y = 1; y < gMapSize - 1; y++)
|
||||
{
|
||||
for (int32_t x = 1; x < gMapSize - 1; x++)
|
||||
{
|
||||
auto* surfaceElement = map_get_surface_element_at(TileCoordsXY{ x, y });
|
||||
auto* surfaceElement = map_get_surface_element_at(TileCoordsXY{ x, y }.ToCoordsXY());
|
||||
if (surfaceElement == nullptr)
|
||||
continue;
|
||||
|
||||
@@ -399,7 +399,7 @@ static void mapgen_set_water_level(int32_t waterLevel)
|
||||
{
|
||||
for (x = 1; x < mapSize - 1; x++)
|
||||
{
|
||||
auto surfaceElement = map_get_surface_element_at(TileCoordsXY{ x, y });
|
||||
auto surfaceElement = map_get_surface_element_at(TileCoordsXY{ x, y }.ToCoordsXY());
|
||||
if (surfaceElement != nullptr && surfaceElement->base_height < waterLevel)
|
||||
surfaceElement->SetWaterHeight(waterLevel / 2);
|
||||
}
|
||||
@@ -461,7 +461,7 @@ static void mapgen_set_height()
|
||||
|
||||
uint8_t baseHeight = (q00 + q01 + q10 + q11) / 4;
|
||||
|
||||
auto surfaceElement = map_get_surface_element_at(TileCoordsXY{ x, y });
|
||||
auto surfaceElement = map_get_surface_element_at(TileCoordsXY{ x, y }.ToCoordsXY());
|
||||
if (surfaceElement == nullptr)
|
||||
continue;
|
||||
surfaceElement->base_height = std::max(2, baseHeight * 2);
|
||||
@@ -823,7 +823,7 @@ void mapgen_generate_from_heightmap(mapgen_settings* settings)
|
||||
{
|
||||
// The x and y axis are flipped in the world, so this uses y for x and x for y.
|
||||
auto* const surfaceElement = map_get_surface_element_at(
|
||||
TileCoordsXY{ static_cast<int32_t>(y + 1), static_cast<int32_t>(x + 1) });
|
||||
TileCoordsXY{ static_cast<int32_t>(y + 1), static_cast<int32_t>(x + 1) }.ToCoordsXY());
|
||||
if (surfaceElement == nullptr)
|
||||
continue;
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
static uint8_t getBaseHeightOrZero(int32_t x, int32_t y)
|
||||
{
|
||||
auto surfaceElement = map_get_surface_element_at(TileCoordsXY{ x, y });
|
||||
auto surfaceElement = map_get_surface_element_at(TileCoordsXY{ x, y }.ToCoordsXY());
|
||||
return surfaceElement ? surfaceElement->base_height : 0;
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ int32_t map_smooth(int32_t l, int32_t t, int32_t r, int32_t b)
|
||||
{
|
||||
for (x = l; x < r; x++)
|
||||
{
|
||||
auto surfaceElement = map_get_surface_element_at(TileCoordsXY{ x, y });
|
||||
auto surfaceElement = map_get_surface_element_at(TileCoordsXY{ x, y }.ToCoordsXY());
|
||||
if (surfaceElement == nullptr)
|
||||
continue;
|
||||
surfaceElement->SetSlope(TILE_ELEMENT_SLOPE_FLAT);
|
||||
@@ -146,36 +146,36 @@ int32_t map_smooth(int32_t l, int32_t t, int32_t r, int32_t b)
|
||||
{
|
||||
uint8_t slope = surfaceElement->GetSlope();
|
||||
// Corners
|
||||
auto surfaceElement2 = map_get_surface_element_at(TileCoordsXY{ x + 1, y + 1 });
|
||||
auto surfaceElement2 = map_get_surface_element_at(TileCoordsXY{ x + 1, y + 1 }.ToCoordsXY());
|
||||
if (surfaceElement2 != nullptr && surfaceElement2->base_height > surfaceElement->base_height)
|
||||
slope |= TILE_ELEMENT_SLOPE_N_CORNER_UP;
|
||||
|
||||
surfaceElement2 = map_get_surface_element_at(TileCoordsXY{ x - 1, y + 1 });
|
||||
surfaceElement2 = map_get_surface_element_at(TileCoordsXY{ x - 1, y + 1 }.ToCoordsXY());
|
||||
if (surfaceElement2 != nullptr && surfaceElement2->base_height > surfaceElement->base_height)
|
||||
slope |= TILE_ELEMENT_SLOPE_W_CORNER_UP;
|
||||
|
||||
surfaceElement2 = map_get_surface_element_at(TileCoordsXY{ x + 1, y - 1 });
|
||||
surfaceElement2 = map_get_surface_element_at(TileCoordsXY{ x + 1, y - 1 }.ToCoordsXY());
|
||||
if (surfaceElement2 != nullptr && surfaceElement2->base_height > surfaceElement->base_height)
|
||||
slope |= TILE_ELEMENT_SLOPE_E_CORNER_UP;
|
||||
|
||||
surfaceElement2 = map_get_surface_element_at(TileCoordsXY{ x - 1, y - 1 });
|
||||
surfaceElement2 = map_get_surface_element_at(TileCoordsXY{ x - 1, y - 1 }.ToCoordsXY());
|
||||
if (surfaceElement2 != nullptr && surfaceElement2->base_height > surfaceElement->base_height)
|
||||
slope |= TILE_ELEMENT_SLOPE_S_CORNER_UP;
|
||||
|
||||
// Sides
|
||||
surfaceElement2 = map_get_surface_element_at(TileCoordsXY{ x + 1, y + 0 });
|
||||
surfaceElement2 = map_get_surface_element_at(TileCoordsXY{ x + 1, y + 0 }.ToCoordsXY());
|
||||
if (surfaceElement2 != nullptr && surfaceElement2->base_height > surfaceElement->base_height)
|
||||
slope |= TILE_ELEMENT_SLOPE_NE_SIDE_UP;
|
||||
|
||||
surfaceElement2 = map_get_surface_element_at(TileCoordsXY{ x - 1, y + 0 });
|
||||
surfaceElement2 = map_get_surface_element_at(TileCoordsXY{ x - 1, y + 0 }.ToCoordsXY());
|
||||
if (surfaceElement2 != nullptr && surfaceElement2->base_height > surfaceElement->base_height)
|
||||
slope |= TILE_ELEMENT_SLOPE_SW_SIDE_UP;
|
||||
|
||||
surfaceElement2 = map_get_surface_element_at(TileCoordsXY{ x + 0, y - 1 });
|
||||
surfaceElement2 = map_get_surface_element_at(TileCoordsXY{ x + 0, y - 1 }.ToCoordsXY());
|
||||
if (surfaceElement2 != nullptr && surfaceElement2->base_height > surfaceElement->base_height)
|
||||
slope |= TILE_ELEMENT_SLOPE_SE_SIDE_UP;
|
||||
|
||||
surfaceElement2 = map_get_surface_element_at(TileCoordsXY{ x + 0, y + 1 });
|
||||
surfaceElement2 = map_get_surface_element_at(TileCoordsXY{ x + 0, y + 1 }.ToCoordsXY());
|
||||
if (surfaceElement2 != nullptr && surfaceElement2->base_height > surfaceElement->base_height)
|
||||
slope |= TILE_ELEMENT_SLOPE_NW_SIDE_UP;
|
||||
|
||||
@@ -200,7 +200,7 @@ int32_t map_smooth(int32_t l, int32_t t, int32_t r, int32_t b)
|
||||
*/
|
||||
int32_t tile_smooth(int32_t x, int32_t y)
|
||||
{
|
||||
auto* const surfaceElement = map_get_surface_element_at(TileCoordsXY{ x, y });
|
||||
auto* const surfaceElement = map_get_surface_element_at(TileCoordsXY{ x, y }.ToCoordsXY());
|
||||
if (surfaceElement == nullptr)
|
||||
return 0;
|
||||
|
||||
@@ -241,7 +241,7 @@ int32_t tile_smooth(int32_t x, int32_t y)
|
||||
continue;
|
||||
|
||||
// Get neighbour height. If the element is not valid (outside of map) assume the same height
|
||||
auto* neighbourSurfaceElement = map_get_surface_element_at(TileCoordsXY{ x + x_offset, y + y_offset });
|
||||
auto* neighbourSurfaceElement = map_get_surface_element_at(TileCoordsXY{ x + x_offset, y + y_offset }.ToCoordsXY());
|
||||
neighbourHeightOffset.baseheight[index] = neighbourSurfaceElement != nullptr ? neighbourSurfaceElement->base_height
|
||||
: surfaceElement->base_height;
|
||||
|
||||
|
||||
@@ -136,7 +136,8 @@ protected:
|
||||
static ::testing::AssertionResult AssertIsStartPosition(const char*, const TileCoordsXYZ& location)
|
||||
{
|
||||
const uint32_t expectedSurfaceStyle = 11u;
|
||||
const uint32_t style = map_get_surface_element_at(TileCoordsXY{ location.x, location.y })->GetSurfaceStyle();
|
||||
const uint32_t style = map_get_surface_element_at(TileCoordsXY{ location.x, location.y }.ToCoordsXY())
|
||||
->GetSurfaceStyle();
|
||||
|
||||
if (style != expectedSurfaceStyle)
|
||||
return ::testing::AssertionFailure()
|
||||
@@ -151,7 +152,8 @@ protected:
|
||||
{
|
||||
const uint32_t forbiddenSurfaceStyle = 8u;
|
||||
|
||||
const uint32_t style = map_get_surface_element_at(TileCoordsXY{ location.x, location.y })->GetSurfaceStyle();
|
||||
const uint32_t style = map_get_surface_element_at(TileCoordsXY{ location.x, location.y }.ToCoordsXY())
|
||||
->GetSurfaceStyle();
|
||||
|
||||
if (style == forbiddenSurfaceStyle)
|
||||
return ::testing::AssertionFailure()
|
||||
|
||||
Reference in New Issue
Block a user