mirror of https://github.com/OpenRCT2/OpenRCT2.git
Make map entrance/exit fetching functions use Coords objects
This commit is contained in:
parent
18ba9b27a3
commit
03e7e29b21
|
@ -221,7 +221,7 @@ private:
|
|||
zHigh += 2;
|
||||
}
|
||||
|
||||
auto entranceElement = map_get_park_entrance_element_at(_loc.x, _loc.y, zLow, false);
|
||||
auto entranceElement = map_get_park_entrance_element_at(_loc, false);
|
||||
// Make sure the entrance part is the middle
|
||||
if (entranceElement != nullptr && (entranceElement->GetSequenceIndex()) == 0)
|
||||
{
|
||||
|
@ -286,7 +286,7 @@ private:
|
|||
zHigh += 2;
|
||||
}
|
||||
|
||||
auto entranceElement = map_get_park_entrance_element_at(_loc.x, _loc.y, zLow, false);
|
||||
auto entranceElement = map_get_park_entrance_element_at(_loc, false);
|
||||
// Make sure the entrance part is the middle
|
||||
if (entranceElement != nullptr && (entranceElement->GetSequenceIndex()) == 0)
|
||||
{
|
||||
|
|
|
@ -130,7 +130,7 @@ private:
|
|||
zHigh += 2;
|
||||
}
|
||||
|
||||
auto entranceElement = map_get_park_entrance_element_at(_loc.x, _loc.y, zLow, false);
|
||||
auto entranceElement = map_get_park_entrance_element_at(_loc, false);
|
||||
// Make sure the entrance part is the middle
|
||||
if (entranceElement != nullptr && (entranceElement->GetSequenceIndex()) == 0)
|
||||
{
|
||||
|
@ -198,7 +198,7 @@ private:
|
|||
zHigh += 2;
|
||||
}
|
||||
|
||||
auto entranceElement = map_get_park_entrance_element_at(_loc.x, _loc.y, zLow, false);
|
||||
auto entranceElement = map_get_park_entrance_element_at(_loc, false);
|
||||
// Make sure the entrance part is the middle
|
||||
if (entranceElement != nullptr && (entranceElement->GetSequenceIndex()) == 0)
|
||||
{
|
||||
|
|
|
@ -95,7 +95,7 @@ public:
|
|||
private:
|
||||
void ParkEntranceRemoveSegment(CoordsXYZ loc) const
|
||||
{
|
||||
auto entranceElement = map_get_park_entrance_element_at(loc.x, loc.y, loc.z / 8, true);
|
||||
auto entranceElement = map_get_park_entrance_element_at(loc, true);
|
||||
if (entranceElement == nullptr)
|
||||
{
|
||||
return;
|
||||
|
|
|
@ -79,13 +79,12 @@ public:
|
|||
|
||||
int8_t zLow = _loc.z / 8;
|
||||
int8_t zHigh = zLow + 12;
|
||||
LocationXY16 entranceLoc = { (int16_t)_loc.x, (int16_t)_loc.y };
|
||||
CoordsXYZ entranceLoc = _loc;
|
||||
for (uint8_t index = 0; index < 3; index++)
|
||||
{
|
||||
if (index == 1)
|
||||
{
|
||||
entranceLoc.x += CoordsDirectionDelta[(_loc.direction - 1) & 0x3].x;
|
||||
entranceLoc.y += CoordsDirectionDelta[(_loc.direction - 1) & 0x3].y;
|
||||
entranceLoc += CoordsDirectionDelta[(_loc.direction - 1) & 0x3];
|
||||
}
|
||||
else if (index == 2)
|
||||
{
|
||||
|
@ -100,7 +99,7 @@ public:
|
|||
}
|
||||
|
||||
// Check that entrance element does not already exist at this location
|
||||
EntranceElement* entranceElement = map_get_park_entrance_element_at(entranceLoc.x, entranceLoc.y, zLow, false);
|
||||
EntranceElement* entranceElement = map_get_park_entrance_element_at(entranceLoc, false);
|
||||
if (entranceElement != nullptr)
|
||||
{
|
||||
return std::make_unique<GameActionResult>(
|
||||
|
|
|
@ -2971,9 +2971,9 @@ private:
|
|||
ride->stations[0].Exit = exitCoords;
|
||||
|
||||
auto entranceElement = map_get_ride_exit_element_at(
|
||||
entranceCoords.x * 32, entranceCoords.y * 32, entranceCoords.z, false);
|
||||
{ entranceCoords.x, entranceCoords.y, entranceCoords.z }, false);
|
||||
entranceElement->SetEntranceType(ENTRANCE_TYPE_RIDE_ENTRANCE);
|
||||
auto exitElement = map_get_ride_entrance_element_at(exitCoords.x * 32, exitCoords.y * 32, exitCoords.z, false);
|
||||
auto exitElement = map_get_ride_entrance_element_at({ exitCoords.x, exitCoords.y, exitCoords.z }, false);
|
||||
exitElement->SetEntranceType(ENTRANCE_TYPE_RIDE_EXIT);
|
||||
|
||||
// Trigger footpath update
|
||||
|
|
|
@ -7678,7 +7678,7 @@ void determine_ride_entrance_and_exit_locations()
|
|||
if (!entranceLoc.isNull())
|
||||
{
|
||||
const EntranceElement* entranceElement = map_get_ride_entrance_element_at(
|
||||
entranceLoc.x * 32, entranceLoc.y * 32, entranceLoc.z, false);
|
||||
{ entranceLoc.x, entranceLoc.y, entranceLoc.z }, false);
|
||||
|
||||
if (entranceElement == nullptr || entranceElement->GetRideIndex() != ride.id
|
||||
|| entranceElement->GetStationIndex() != stationIndex)
|
||||
|
@ -7694,7 +7694,7 @@ void determine_ride_entrance_and_exit_locations()
|
|||
if (!exitLoc.isNull())
|
||||
{
|
||||
const EntranceElement* entranceElement = map_get_ride_exit_element_at(
|
||||
exitLoc.x * 32, exitLoc.y * 32, exitLoc.z, false);
|
||||
{ exitLoc.x, exitLoc.y, exitLoc.z }, false);
|
||||
|
||||
if (entranceElement == nullptr || entranceElement->GetRideIndex() != ride.id
|
||||
|| entranceElement->GetStationIndex() != stationIndex)
|
||||
|
|
|
@ -215,7 +215,7 @@ void fix_park_entrance_locations(void)
|
|||
std::remove_if(
|
||||
gParkEntrances.begin(), gParkEntrances.end(),
|
||||
[](const auto& entrance) {
|
||||
return map_get_park_entrance_element_at(entrance.x, entrance.y, entrance.z >> 3, false) == nullptr;
|
||||
return map_get_park_entrance_element_at(entrance, false) == nullptr;
|
||||
}),
|
||||
gParkEntrances.end());
|
||||
}
|
||||
|
|
|
@ -1765,9 +1765,10 @@ LargeSceneryElement* map_get_large_scenery_segment(int32_t x, int32_t y, int32_t
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
EntranceElement* map_get_park_entrance_element_at(int32_t x, int32_t y, int32_t z, bool ghost)
|
||||
EntranceElement* map_get_park_entrance_element_at(const CoordsXYZ& entranceCoords, bool ghost)
|
||||
{
|
||||
TileElement* tileElement = map_get_first_element_at(x / 32, y / 32);
|
||||
auto entranceTileCoords = TileCoordsXYZ(entranceCoords);
|
||||
TileElement* tileElement = map_get_first_element_at(entranceTileCoords.x, entranceTileCoords.y);
|
||||
if (tileElement != nullptr)
|
||||
{
|
||||
do
|
||||
|
@ -1775,7 +1776,7 @@ EntranceElement* map_get_park_entrance_element_at(int32_t x, int32_t y, int32_t
|
|||
if (tileElement->GetType() != TILE_ELEMENT_TYPE_ENTRANCE)
|
||||
continue;
|
||||
|
||||
if (tileElement->base_height != z)
|
||||
if (tileElement->base_height != entranceTileCoords.z)
|
||||
continue;
|
||||
|
||||
if (tileElement->AsEntrance()->GetEntranceType() != ENTRANCE_TYPE_PARK_ENTRANCE)
|
||||
|
@ -1790,9 +1791,9 @@ EntranceElement* map_get_park_entrance_element_at(int32_t x, int32_t y, int32_t
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
EntranceElement* map_get_ride_entrance_element_at(int32_t x, int32_t y, int32_t z, bool ghost)
|
||||
EntranceElement* map_get_ride_entrance_element_at(const TileCoordsXYZ& entranceTileCoords, bool ghost)
|
||||
{
|
||||
TileElement* tileElement = map_get_first_element_at(x / 32, y / 32);
|
||||
TileElement* tileElement = map_get_first_element_at(entranceTileCoords.x, entranceTileCoords.y);
|
||||
if (tileElement != nullptr)
|
||||
{
|
||||
do
|
||||
|
@ -1800,7 +1801,7 @@ EntranceElement* map_get_ride_entrance_element_at(int32_t x, int32_t y, int32_t
|
|||
if (tileElement->GetType() != TILE_ELEMENT_TYPE_ENTRANCE)
|
||||
continue;
|
||||
|
||||
if (tileElement->base_height != z)
|
||||
if (tileElement->base_height != entranceTileCoords.z)
|
||||
continue;
|
||||
|
||||
if (tileElement->AsEntrance()->GetEntranceType() != ENTRANCE_TYPE_RIDE_ENTRANCE)
|
||||
|
@ -1815,9 +1816,9 @@ EntranceElement* map_get_ride_entrance_element_at(int32_t x, int32_t y, int32_t
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
EntranceElement* map_get_ride_exit_element_at(int32_t x, int32_t y, int32_t z, bool ghost)
|
||||
EntranceElement* map_get_ride_exit_element_at(const TileCoordsXYZ& exitTileCoords, bool ghost)
|
||||
{
|
||||
TileElement* tileElement = map_get_first_element_at(x / 32, y / 32);
|
||||
TileElement* tileElement = map_get_first_element_at(exitTileCoords.x, exitTileCoords.y);
|
||||
if (tileElement != nullptr)
|
||||
{
|
||||
do
|
||||
|
@ -1825,7 +1826,7 @@ EntranceElement* map_get_ride_exit_element_at(int32_t x, int32_t y, int32_t z, b
|
|||
if (tileElement->GetType() != TILE_ELEMENT_TYPE_ENTRANCE)
|
||||
continue;
|
||||
|
||||
if (tileElement->base_height != z)
|
||||
if (tileElement->base_height != exitTileCoords.z)
|
||||
continue;
|
||||
|
||||
if (tileElement->AsEntrance()->GetEntranceType() != ENTRANCE_TYPE_RIDE_EXIT)
|
||||
|
|
|
@ -148,9 +148,9 @@ SurfaceElement* map_get_surface_element_at(const CoordsXY& coords);
|
|||
PathElement* map_get_path_element_at(const TileCoordsXYZ& loc);
|
||||
WallElement* map_get_wall_element_at(int32_t x, int32_t y, int32_t z, int32_t direction);
|
||||
SmallSceneryElement* map_get_small_scenery_element_at(int32_t x, int32_t y, int32_t z, int32_t type, uint8_t quadrant);
|
||||
EntranceElement* map_get_park_entrance_element_at(int32_t x, int32_t y, int32_t z, bool ghost);
|
||||
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);
|
||||
EntranceElement* map_get_park_entrance_element_at(const CoordsXYZ& entranceCoords, bool ghost);
|
||||
EntranceElement* map_get_ride_entrance_element_at(const TileCoordsXYZ& entranceTileCoords, bool ghost);
|
||||
EntranceElement* map_get_ride_exit_element_at(const TileCoordsXYZ& exitTileCoords, bool ghost);
|
||||
int16_t tile_element_height(const CoordsXY& loc);
|
||||
int16_t tile_element_water_height(const CoordsXY& loc);
|
||||
uint8_t map_get_highest_land_height(const MapRange& range);
|
||||
|
|
|
@ -94,7 +94,7 @@ TEST_F(TileElementWantsFootpathConnection, Stall)
|
|||
TEST_F(TileElementWantsFootpathConnection, RideEntrance)
|
||||
{
|
||||
// Ride entrances and exits want a connection in one direction
|
||||
const EntranceElement* const entranceElement = map_get_ride_entrance_element_at(18 << 5, 8 << 5, 14, false);
|
||||
const EntranceElement* const entranceElement = map_get_ride_entrance_element_at({ 18, 8, 14 }, false);
|
||||
ASSERT_NE(entranceElement, nullptr);
|
||||
EXPECT_TRUE(tile_element_wants_path_connection_towards({ 18, 8, 14, 0 }, nullptr));
|
||||
EXPECT_FALSE(tile_element_wants_path_connection_towards({ 18, 8, 14, 1 }, nullptr));
|
||||
|
@ -106,7 +106,7 @@ TEST_F(TileElementWantsFootpathConnection, RideEntrance)
|
|||
TEST_F(TileElementWantsFootpathConnection, RideExit)
|
||||
{
|
||||
// The exit has been rotated; it wants a path connection in direction 1, but not 0 like the entrance
|
||||
const EntranceElement* const exitElement = map_get_ride_exit_element_at(18 << 5, 10 << 5, 14, false);
|
||||
const EntranceElement* const exitElement = map_get_ride_exit_element_at({ 18, 10, 14 }, false);
|
||||
ASSERT_NE(exitElement, nullptr);
|
||||
EXPECT_FALSE(tile_element_wants_path_connection_towards({ 18, 10, 14, 0 }, nullptr));
|
||||
EXPECT_TRUE(tile_element_wants_path_connection_towards({ 18, 10, 14, 1 }, nullptr));
|
||||
|
|
Loading…
Reference in New Issue