mirror of https://github.com/OpenRCT2/OpenRCT2.git
Refactor map_is_location_owned_or_has_rights to use CoordsXY
This commit is contained in:
parent
0a1cb68328
commit
5ba9d55415
|
@ -252,6 +252,7 @@ private:
|
|||
|
||||
static bool MapCanClearAt(int32_t x, int32_t y)
|
||||
{
|
||||
return (gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || gCheatsSandboxMode || map_is_location_owned_or_has_rights(x, y);
|
||||
return (gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || gCheatsSandboxMode
|
||||
|| map_is_location_owned_or_has_rights({ x, y });
|
||||
}
|
||||
};
|
||||
|
|
|
@ -172,7 +172,7 @@ static bool staff_is_location_in_patrol_area(Peep* peep, int32_t x, int32_t y)
|
|||
bool staff_is_location_in_patrol(Peep* staff, int32_t x, int32_t y)
|
||||
{
|
||||
// Check if location is in the park
|
||||
if (!map_is_location_owned_or_has_rights(x, y))
|
||||
if (!map_is_location_owned_or_has_rights({ x, y }))
|
||||
return false;
|
||||
|
||||
// Check if staff has patrol area
|
||||
|
|
|
@ -3239,28 +3239,17 @@ void ride_check_all_reachable()
|
|||
/**
|
||||
*
|
||||
* rct2: 0x006B7C59
|
||||
* @return 1 if the coordinate is reachable or has no entrance, 0 otherwise
|
||||
* @return true if the coordinate is reachable or has no entrance, false otherwise
|
||||
*/
|
||||
static int32_t ride_entrance_exit_is_reachable(TileCoordsXYZD coordinates)
|
||||
static bool ride_entrance_exit_is_reachable(TileCoordsXYZD coordinates)
|
||||
{
|
||||
int32_t x, y, z;
|
||||
|
||||
if (coordinates.isNull())
|
||||
return 1;
|
||||
return true;
|
||||
|
||||
x = coordinates.x;
|
||||
y = coordinates.y;
|
||||
z = coordinates.z;
|
||||
uint8_t face_direction = coordinates.direction;
|
||||
TileCoordsXYZ loc{ coordinates.x, coordinates.y, coordinates.z };
|
||||
loc -= TileDirectionDelta[coordinates.z];
|
||||
|
||||
x *= 32;
|
||||
y *= 32;
|
||||
x -= CoordsDirectionDelta[face_direction].x;
|
||||
y -= CoordsDirectionDelta[face_direction].y;
|
||||
x /= 32;
|
||||
y /= 32;
|
||||
|
||||
return map_coord_is_connected(x, y, z, face_direction);
|
||||
return map_coord_is_connected(loc, coordinates.direction);
|
||||
}
|
||||
|
||||
static void ride_entrance_exit_connected(Ride* ride)
|
||||
|
@ -3299,17 +3288,14 @@ static void ride_entrance_exit_connected(Ride* ride)
|
|||
|
||||
static void ride_shop_connected(Ride* ride)
|
||||
{
|
||||
int32_t x, y, count;
|
||||
|
||||
LocationXY8 coordinates = ride->stations[0].Start;
|
||||
if (coordinates.xy == RCT_XY8_UNDEFINED)
|
||||
return;
|
||||
|
||||
x = coordinates.x;
|
||||
y = coordinates.y;
|
||||
TileCoordsXY loc = { coordinates.x, coordinates.y };
|
||||
|
||||
TrackElement* trackElement = nullptr;
|
||||
TileElement* tileElement = map_get_first_element_at(x, y);
|
||||
TileElement* tileElement = map_get_first_element_at(loc.x, loc.y);
|
||||
do
|
||||
{
|
||||
if (tileElement == nullptr)
|
||||
|
@ -3347,11 +3333,7 @@ static void ride_shop_connected(Ride* ride)
|
|||
if (entrance_directions == 0)
|
||||
return;
|
||||
|
||||
// Turn x, y from tiles into units
|
||||
x *= 32;
|
||||
y *= 32;
|
||||
|
||||
for (count = 0; entrance_directions != 0; count++)
|
||||
for (auto count = 0; entrance_directions != 0; count++)
|
||||
{
|
||||
if (!(entrance_directions & 1))
|
||||
{
|
||||
|
@ -3363,10 +3345,10 @@ static void ride_shop_connected(Ride* ride)
|
|||
// Flip direction north<->south, east<->west
|
||||
uint8_t face_direction = direction_reverse(count);
|
||||
|
||||
int32_t y2 = y - CoordsDirectionDelta[face_direction].y;
|
||||
int32_t x2 = x - CoordsDirectionDelta[face_direction].x;
|
||||
int32_t y2 = loc.y - TileDirectionDelta[face_direction].y;
|
||||
int32_t x2 = loc.x - TileDirectionDelta[face_direction].x;
|
||||
|
||||
if (map_coord_is_connected(x2 / 32, y2 / 32, tileElement->base_height, face_direction))
|
||||
if (map_coord_is_connected({ x2, y2, tileElement->base_height }, face_direction))
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -229,6 +229,12 @@ struct TileCoordsXYZ
|
|||
return *this;
|
||||
}
|
||||
|
||||
TileCoordsXYZ& operator-=(const TileCoordsXY rhs)
|
||||
{
|
||||
x -= rhs.x;
|
||||
y -= rhs.y;
|
||||
return *this;
|
||||
}
|
||||
bool operator==(const TileCoordsXYZ& other) const
|
||||
{
|
||||
return x == other.x && y == other.y && z == other.z;
|
||||
|
|
|
@ -638,9 +638,9 @@ int16_t tile_element_water_height(int32_t x, int32_t y)
|
|||
* Checks if the tile at coordinate at height counts as connected.
|
||||
* @return 1 if connected, 0 otherwise
|
||||
*/
|
||||
bool map_coord_is_connected(int32_t x, int32_t y, int32_t z, uint8_t faceDirection)
|
||||
bool map_coord_is_connected(const TileCoordsXYZ loc, uint8_t faceDirection)
|
||||
{
|
||||
TileElement* tileElement = map_get_first_element_at(x, y);
|
||||
TileElement* tileElement = map_get_first_element_at(loc.x, loc.y);
|
||||
|
||||
do
|
||||
{
|
||||
|
@ -653,17 +653,17 @@ bool map_coord_is_connected(int32_t x, int32_t y, int32_t z, uint8_t faceDirecti
|
|||
{
|
||||
if (slopeDirection == faceDirection)
|
||||
{
|
||||
if (z == tileElement->base_height + 2)
|
||||
if (loc.z == tileElement->base_height + 2)
|
||||
return true;
|
||||
}
|
||||
else if (direction_reverse(slopeDirection) == faceDirection && z == tileElement->base_height)
|
||||
else if (direction_reverse(slopeDirection) == faceDirection && loc.z == tileElement->base_height)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (z == tileElement->base_height)
|
||||
if (loc.z == tileElement->base_height)
|
||||
return true;
|
||||
}
|
||||
} while (!(tileElement++)->IsLastForTile());
|
||||
|
@ -799,11 +799,11 @@ bool map_is_location_in_park(const CoordsXY coords)
|
|||
return false;
|
||||
}
|
||||
|
||||
bool map_is_location_owned_or_has_rights(int32_t x, int32_t y)
|
||||
bool map_is_location_owned_or_has_rights(CoordsXY loc)
|
||||
{
|
||||
if (map_is_location_valid({ x, y }))
|
||||
if (map_is_location_valid(loc))
|
||||
{
|
||||
auto surfaceElement = map_get_surface_element_at({ x, y });
|
||||
auto surfaceElement = map_get_surface_element_at(loc);
|
||||
if (surfaceElement == nullptr)
|
||||
{
|
||||
return false;
|
||||
|
|
|
@ -155,7 +155,7 @@ int16_t tile_element_height(int32_t x, int32_t y);
|
|||
int16_t tile_element_water_height(int32_t x, int32_t y);
|
||||
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(int32_t x, int32_t y, int32_t z, uint8_t faceDirection);
|
||||
bool map_coord_is_connected(const TileCoordsXYZ loc, uint8_t faceDirection);
|
||||
void map_remove_provisional_elements();
|
||||
void map_restore_provisional_elements();
|
||||
void map_update_path_wide_flags();
|
||||
|
@ -164,7 +164,7 @@ bool map_is_edge(CoordsXY coords);
|
|||
bool map_can_build_at(CoordsXYZ loc);
|
||||
bool map_is_location_owned(CoordsXYZ loc);
|
||||
bool map_is_location_in_park(CoordsXY coords);
|
||||
bool map_is_location_owned_or_has_rights(int32_t x, int32_t y);
|
||||
bool map_is_location_owned_or_has_rights(CoordsXY loc);
|
||||
bool map_surface_is_blocked(int16_t x, int16_t y);
|
||||
void tile_element_remove(TileElement* tileElement);
|
||||
void map_remove_all_rides();
|
||||
|
|
Loading…
Reference in New Issue