mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-15 11:03:00 +01:00
Refactor tile_element_water_height to take CoordsXY
This commit is contained in:
@@ -100,7 +100,7 @@ public:
|
||||
supportsRequired = true;
|
||||
}
|
||||
int32_t landHeight = tile_element_height({ _loc.x, _loc.y });
|
||||
int16_t waterHeight = tile_element_water_height(_loc.x, _loc.y);
|
||||
int16_t waterHeight = tile_element_water_height({ _loc.x, _loc.y });
|
||||
|
||||
int32_t surfaceHeight = landHeight;
|
||||
// If on water
|
||||
@@ -160,7 +160,7 @@ public:
|
||||
y2 += ScenerySubTileOffsets[quadrant & 3].y - 1;
|
||||
}
|
||||
landHeight = tile_element_height({ x2, y2 });
|
||||
waterHeight = tile_element_water_height(x2, y2);
|
||||
waterHeight = tile_element_water_height({ x2, y2 });
|
||||
|
||||
surfaceHeight = landHeight;
|
||||
// If on water
|
||||
@@ -303,7 +303,7 @@ public:
|
||||
supportsRequired = true;
|
||||
}
|
||||
int32_t landHeight = tile_element_height({ _loc.x, _loc.y });
|
||||
int16_t waterHeight = tile_element_water_height(_loc.x, _loc.y);
|
||||
int16_t waterHeight = tile_element_water_height({ _loc.x, _loc.y });
|
||||
|
||||
int32_t surfaceHeight = landHeight;
|
||||
// If on water
|
||||
@@ -353,7 +353,7 @@ public:
|
||||
y2 += ScenerySubTileOffsets[quadrant & 3].y - 1;
|
||||
}
|
||||
landHeight = tile_element_height({ x2, y2 });
|
||||
waterHeight = tile_element_water_height(x2, y2);
|
||||
waterHeight = tile_element_water_height({ x2, y2 });
|
||||
|
||||
surfaceHeight = landHeight;
|
||||
// If on water
|
||||
|
||||
@@ -64,7 +64,7 @@ private:
|
||||
res->Position.x = ((validRange.GetLeft() + validRange.GetRight()) / 2) + 16;
|
||||
res->Position.y = ((validRange.GetTop() + validRange.GetBottom()) / 2) + 16;
|
||||
int16_t z = tile_element_height({ res->Position.x, res->Position.y });
|
||||
int16_t waterHeight = tile_element_water_height(res->Position.x, res->Position.y);
|
||||
int16_t waterHeight = tile_element_water_height({ res->Position.x, res->Position.y });
|
||||
if (waterHeight != 0)
|
||||
{
|
||||
z = waterHeight;
|
||||
|
||||
@@ -65,7 +65,7 @@ private:
|
||||
res->Position.x = ((validRange.GetLeft() + validRange.GetRight()) / 2) + 16;
|
||||
res->Position.y = ((validRange.GetTop() + validRange.GetBottom()) / 2) + 16;
|
||||
int32_t z = tile_element_height({ res->Position.x, res->Position.y });
|
||||
int16_t waterHeight = tile_element_water_height(res->Position.x, res->Position.y);
|
||||
int16_t waterHeight = tile_element_water_height({ res->Position.x, res->Position.y });
|
||||
if (waterHeight != 0)
|
||||
{
|
||||
z = waterHeight;
|
||||
|
||||
@@ -5432,7 +5432,7 @@ static void vehicle_update_crash(rct_vehicle* vehicle)
|
||||
}
|
||||
|
||||
int16_t z = tile_element_height({ curVehicle->x, curVehicle->y });
|
||||
int16_t waterHeight = tile_element_water_height(curVehicle->x, curVehicle->y);
|
||||
int16_t waterHeight = tile_element_water_height({ curVehicle->x, curVehicle->y });
|
||||
int16_t zDiff;
|
||||
if (waterHeight != 0)
|
||||
{
|
||||
|
||||
@@ -433,7 +433,7 @@ static int32_t scenario_create_ducks()
|
||||
if (!map_is_location_in_park({ x, y }))
|
||||
return 0;
|
||||
|
||||
centreWaterZ = (tile_element_water_height(x, y));
|
||||
centreWaterZ = (tile_element_water_height({ x, y }));
|
||||
if (centreWaterZ == 0)
|
||||
return 0;
|
||||
|
||||
@@ -445,7 +445,7 @@ static int32_t scenario_create_ducks()
|
||||
{
|
||||
for (j = 0; j < 7; j++)
|
||||
{
|
||||
waterZ = (tile_element_water_height(x2, y2));
|
||||
waterZ = (tile_element_water_height({ x2, y2 }));
|
||||
if (waterZ == centreWaterZ)
|
||||
c++;
|
||||
|
||||
|
||||
@@ -202,7 +202,7 @@ void rct_duck::UpdateSwim()
|
||||
{
|
||||
Invalidate();
|
||||
int16_t landZ = tile_element_height({ x, y });
|
||||
int16_t waterZ = tile_element_water_height(x, y);
|
||||
int16_t waterZ = tile_element_water_height({ x, y });
|
||||
|
||||
if (z < landZ || waterZ == 0)
|
||||
{
|
||||
@@ -223,7 +223,7 @@ void rct_duck::UpdateSwim()
|
||||
int32_t newX = x + DuckMoveOffset[direction].x;
|
||||
int32_t newY = y + DuckMoveOffset[direction].y;
|
||||
landZ = tile_element_height({ newX, newY });
|
||||
waterZ = tile_element_water_height(newX, newY);
|
||||
waterZ = tile_element_water_height({ newX, newY });
|
||||
|
||||
if (z >= landZ && z == waterZ)
|
||||
{
|
||||
|
||||
@@ -607,18 +607,14 @@ int16_t tile_element_height(const CoordsXY loc)
|
||||
return height;
|
||||
}
|
||||
|
||||
int16_t tile_element_water_height(int32_t x, int32_t y)
|
||||
int16_t tile_element_water_height(const CoordsXY loc)
|
||||
{
|
||||
// Off the map
|
||||
if ((unsigned)x >= 8192 || (unsigned)y >= 8192)
|
||||
if ((unsigned)loc.x >= 8192 || (unsigned)loc.y >= 8192)
|
||||
return 0;
|
||||
|
||||
// Truncate subtile coordinates
|
||||
int32_t x_tile = x & 0xFFFFFFE0;
|
||||
int32_t y_tile = y & 0xFFFFFFE0;
|
||||
|
||||
// Get the surface element for the tile
|
||||
auto surfaceElement = map_get_surface_element_at({ x_tile, y_tile });
|
||||
auto surfaceElement = map_get_surface_element_at(loc);
|
||||
|
||||
if (surfaceElement == nullptr)
|
||||
{
|
||||
|
||||
@@ -152,7 +152,7 @@ EntranceElement* map_get_park_entrance_element_at(int32_t x, int32_t y, int32_t
|
||||
EntranceElement* map_get_ride_entrance_element_at(int32_t x, int32_t y, int32_t z, bool ghost);
|
||||
EntranceElement* map_get_ride_exit_element_at(int32_t x, int32_t y, int32_t z, bool ghost);
|
||||
int16_t tile_element_height(const CoordsXY loc);
|
||||
int16_t tile_element_water_height(int32_t x, int32_t y);
|
||||
int16_t tile_element_water_height(const CoordsXY loc);
|
||||
uint8_t map_get_highest_land_height(int32_t xMin, int32_t xMax, int32_t yMin, int32_t yMax);
|
||||
uint8_t map_get_lowest_land_height(int32_t xMin, int32_t xMax, int32_t yMin, int32_t yMax);
|
||||
bool map_coord_is_connected(const TileCoordsXYZ loc, uint8_t faceDirection);
|
||||
|
||||
@@ -81,7 +81,7 @@ void crashed_vehicle_particle_update(rct_crashed_vehicle_particle* particle)
|
||||
|
||||
// Check collision with land / water
|
||||
int16_t landZ = tile_element_height({ x, y });
|
||||
int16_t waterZ = tile_element_water_height(x, y);
|
||||
int16_t waterZ = tile_element_water_height({ x, y });
|
||||
|
||||
if (waterZ != 0 && particle->z >= waterZ && z <= waterZ)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user