mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-23 06:44:38 +01:00
Return actual entrance elements from map functions
This commit is contained in:
committed by
Gymnasiast
parent
995c6debf1
commit
a8e087b560
@@ -121,7 +121,7 @@ public:
|
||||
}
|
||||
|
||||
// Check that entrance element does not already exist at this location
|
||||
rct_tile_element* entranceElement = map_get_park_entrance_element_at(entranceLoc.x, entranceLoc.y, zLow, false);
|
||||
EntranceElement* entranceElement = map_get_park_entrance_element_at(entranceLoc.x, entranceLoc.y, zLow, false);
|
||||
if (entranceElement != nullptr)
|
||||
{
|
||||
return std::make_unique<GameActionResult>(
|
||||
|
||||
@@ -8794,36 +8794,35 @@ void determine_ride_entrance_and_exit_locations()
|
||||
TileCoordsXYZD exitLoc = ride->exits[stationIndex];
|
||||
bool fixEntrance = false;
|
||||
bool fixExit = false;
|
||||
const rct_tile_element* tileElement;
|
||||
|
||||
// Skip if the station has no entrance
|
||||
if (!entranceLoc.isNull())
|
||||
{
|
||||
tileElement = map_get_ride_entrance_element_at(entranceLoc.x * 32, entranceLoc.y * 32, entranceLoc.z, false);
|
||||
const EntranceElement* entranceElement = map_get_ride_entrance_element_at(entranceLoc.x * 32, entranceLoc.y * 32, entranceLoc.z, false);
|
||||
|
||||
if (tileElement == nullptr || tileElement->AsEntrance()->GetRideIndex() != rideIndex
|
||||
|| tileElement->AsEntrance()->GetStationIndex() != stationIndex)
|
||||
if (entranceElement == nullptr || entranceElement->GetRideIndex() != rideIndex
|
||||
|| entranceElement->GetStationIndex() != stationIndex)
|
||||
{
|
||||
fixEntrance = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
ride->entrances[stationIndex].direction = (uint8_t)tileElement->GetDirection();
|
||||
ride->entrances[stationIndex].direction = (uint8_t)entranceElement->GetDirection();
|
||||
}
|
||||
}
|
||||
|
||||
if (!exitLoc.isNull())
|
||||
{
|
||||
tileElement = map_get_ride_exit_element_at(exitLoc.x * 32, exitLoc.y * 32, entranceLoc.z, false);
|
||||
const EntranceElement* entranceElement = map_get_ride_exit_element_at(exitLoc.x * 32, exitLoc.y * 32, entranceLoc.z, false);
|
||||
|
||||
if (tileElement == nullptr || tileElement->AsEntrance()->GetRideIndex() != rideIndex
|
||||
|| tileElement->AsEntrance()->GetStationIndex() != stationIndex)
|
||||
if (entranceElement == nullptr || entranceElement->GetRideIndex() != rideIndex
|
||||
|| entranceElement->GetStationIndex() != stationIndex)
|
||||
{
|
||||
fixExit = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
ride->exits[stationIndex].direction = (uint8_t)tileElement->GetDirection();
|
||||
ride->exits[stationIndex].direction = (uint8_t)entranceElement->GetDirection();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8840,7 +8839,7 @@ void determine_ride_entrance_and_exit_locations()
|
||||
{
|
||||
for (uint8_t y = 1; y < MAXIMUM_MAP_SIZE_TECHNICAL - 1; y++)
|
||||
{
|
||||
tileElement = map_get_first_element_at(x, y);
|
||||
rct_tile_element* tileElement = map_get_first_element_at(x, y);
|
||||
|
||||
if (tileElement != nullptr)
|
||||
{
|
||||
@@ -8850,11 +8849,12 @@ void determine_ride_entrance_and_exit_locations()
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (tileElement->AsEntrance()->GetRideIndex() != rideIndex)
|
||||
const EntranceElement* entranceElement = tileElement->AsEntrance();
|
||||
if (entranceElement->GetRideIndex() != rideIndex)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (tileElement->AsEntrance()->GetStationIndex() != stationIndex)
|
||||
if (entranceElement->GetStationIndex() != stationIndex)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -8862,13 +8862,13 @@ void determine_ride_entrance_and_exit_locations()
|
||||
// The expected height is where entrances and exit reside in non-hacked parks.
|
||||
const uint8_t expectedHeight = ride->station_heights[stationIndex];
|
||||
|
||||
if (fixEntrance && tileElement->AsEntrance()->GetEntranceType() == ENTRANCE_TYPE_RIDE_ENTRANCE)
|
||||
if (fixEntrance && entranceElement->GetEntranceType() == ENTRANCE_TYPE_RIDE_ENTRANCE)
|
||||
{
|
||||
if (alreadyFoundEntrance)
|
||||
{
|
||||
if (ride->entrances[stationIndex].z == expectedHeight)
|
||||
continue;
|
||||
if (ride->entrances[stationIndex].z > tileElement->base_height)
|
||||
if (ride->entrances[stationIndex].z > entranceElement->base_height)
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -8876,35 +8876,35 @@ void determine_ride_entrance_and_exit_locations()
|
||||
TileCoordsXYZD newEntranceLoc = {
|
||||
x,
|
||||
y,
|
||||
tileElement->base_height,
|
||||
(uint8_t)tileElement->GetDirection(),
|
||||
entranceElement->base_height,
|
||||
(uint8_t)entranceElement->GetDirection(),
|
||||
};
|
||||
ride_set_entrance_location(ride, stationIndex, newEntranceLoc);
|
||||
alreadyFoundEntrance = true;
|
||||
|
||||
log_verbose(
|
||||
"Fixed disconnected entrance of ride %d, station %d to x = %d, y = %d and z = %d.",
|
||||
rideIndex, stationIndex, x, y, tileElement->base_height);
|
||||
rideIndex, stationIndex, x, y, entranceElement->base_height);
|
||||
}
|
||||
else if (fixExit && tileElement->AsEntrance()->GetEntranceType() == ENTRANCE_TYPE_RIDE_EXIT)
|
||||
else if (fixExit && entranceElement->GetEntranceType() == ENTRANCE_TYPE_RIDE_EXIT)
|
||||
{
|
||||
if (alreadyFoundExit)
|
||||
{
|
||||
if (ride->exits[stationIndex].z == expectedHeight)
|
||||
continue;
|
||||
if (ride->exits[stationIndex].z > tileElement->base_height)
|
||||
if (ride->exits[stationIndex].z > entranceElement->base_height)
|
||||
continue;
|
||||
}
|
||||
|
||||
// Found our exit
|
||||
ride_set_exit_location(
|
||||
ride, stationIndex,
|
||||
{ x, y, tileElement->base_height, (uint8_t)tileElement->GetDirection() });
|
||||
{ x, y, entranceElement->base_height, (uint8_t)entranceElement->GetDirection() });
|
||||
alreadyFoundExit = true;
|
||||
|
||||
log_verbose(
|
||||
"Fixed disconnected exit of ride %d, station %d to x = %d, y = %d and z = %d.", rideIndex,
|
||||
stationIndex, x, y, tileElement->base_height);
|
||||
stationIndex, x, y, entranceElement->base_height);
|
||||
}
|
||||
} while (!(tileElement++)->IsLastForTile());
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ uint8_t gRideEntranceExitGhostStationIndex;
|
||||
|
||||
static void ParkEntranceRemoveSegment(int32_t x, int32_t y, int32_t z)
|
||||
{
|
||||
rct_tile_element* tileElement;
|
||||
EntranceElement* tileElement;
|
||||
|
||||
tileElement = map_get_park_entrance_element_at(x, y, z, true);
|
||||
if (tileElement == nullptr)
|
||||
@@ -42,7 +42,7 @@ static void ParkEntranceRemoveSegment(int32_t x, int32_t y, int32_t z)
|
||||
}
|
||||
|
||||
map_invalidate_tile(x, y, tileElement->base_height * 8, tileElement->clearance_height * 8);
|
||||
tile_element_remove(tileElement);
|
||||
tileElement->Remove();
|
||||
update_park_fences({ x, y });
|
||||
}
|
||||
|
||||
|
||||
@@ -195,7 +195,8 @@ static constexpr const uint8_t byte_98D7EC[] = { 207, 159, 63, 111 };
|
||||
static money32 footpath_element_insert(
|
||||
int32_t type, int32_t x, int32_t y, int32_t z, int32_t slope, int32_t flags, uint8_t pathItemType)
|
||||
{
|
||||
rct_tile_element *tileElement, *entranceElement;
|
||||
rct_tile_element* tileElement;
|
||||
EntranceElement* entranceElement;
|
||||
int32_t bl, zHigh;
|
||||
bool entrancePath = false, entranceIsSamePath = false;
|
||||
|
||||
@@ -218,11 +219,11 @@ static money32 footpath_element_insert(
|
||||
|
||||
entranceElement = map_get_park_entrance_element_at(x, y, z, false);
|
||||
// Make sure the entrance part is the middle
|
||||
if (entranceElement != nullptr && (entranceElement->AsEntrance()->GetSequenceIndex()) == 0)
|
||||
if (entranceElement != nullptr && (entranceElement->GetSequenceIndex()) == 0)
|
||||
{
|
||||
entrancePath = true;
|
||||
// Make the price the same as replacing a path
|
||||
if (entranceElement->AsEntrance()->GetPathType() == (type & 0xF))
|
||||
if (entranceElement->GetPathType() == (type & 0xF))
|
||||
entranceIsSamePath = true;
|
||||
else
|
||||
gFootpathPrice -= MONEY(6, 00);
|
||||
@@ -256,7 +257,7 @@ static money32 footpath_element_insert(
|
||||
if (!(flags & GAME_COMMAND_FLAG_GHOST) && !entranceIsSamePath)
|
||||
{
|
||||
// Set the path type but make sure it's not a queue as that will not show up
|
||||
entranceElement->AsEntrance()->SetPathType(type & 0x7F);
|
||||
entranceElement->SetPathType(type & 0x7F);
|
||||
map_invalidate_tile_full(x, y);
|
||||
}
|
||||
}
|
||||
@@ -530,7 +531,8 @@ void game_command_place_footpath(
|
||||
static money32 footpath_place_from_track(
|
||||
int32_t type, int32_t x, int32_t y, int32_t z, int32_t slope, int32_t edges, int32_t flags)
|
||||
{
|
||||
rct_tile_element *tileElement, *entranceElement;
|
||||
rct_tile_element* tileElement;
|
||||
EntranceElement* entranceElement;
|
||||
bool entrancePath = false, entranceIsSamePath = false;
|
||||
|
||||
gCommandExpenditureType = RCT_EXPENDITURE_TYPE_LANDSCAPING;
|
||||
@@ -589,11 +591,11 @@ static money32 footpath_place_from_track(
|
||||
|
||||
entranceElement = map_get_park_entrance_element_at(x, y, z, false);
|
||||
// Make sure the entrance part is the middle
|
||||
if (entranceElement != nullptr && (entranceElement->AsEntrance()->GetSequenceIndex()) == 0)
|
||||
if (entranceElement != nullptr && (entranceElement->GetSequenceIndex()) == 0)
|
||||
{
|
||||
entrancePath = true;
|
||||
// Make the price the same as replacing a path
|
||||
if (entranceElement->AsEntrance()->GetPathType() == (type & 0xF))
|
||||
if (entranceElement->GetPathType() == (type & 0xF))
|
||||
entranceIsSamePath = true;
|
||||
else
|
||||
gFootpathPrice -= MONEY(6, 00);
|
||||
@@ -636,7 +638,7 @@ static money32 footpath_place_from_track(
|
||||
if (!(flags & GAME_COMMAND_FLAG_GHOST) && !entranceIsSamePath)
|
||||
{
|
||||
// Set the path type but make sure it's not a queue as that will not show up
|
||||
entranceElement->AsEntrance()->SetPathType(type & 0x7F);
|
||||
entranceElement->SetPathType(type & 0x7F);
|
||||
map_invalidate_tile_full(x, y);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3959,7 +3959,7 @@ rct_tile_element* map_get_large_scenery_segment(int32_t x, int32_t y, int32_t z,
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
rct_tile_element* map_get_park_entrance_element_at(int32_t x, int32_t y, int32_t z, bool ghost)
|
||||
EntranceElement* map_get_park_entrance_element_at(int32_t x, int32_t y, int32_t z, bool ghost)
|
||||
{
|
||||
rct_tile_element* tileElement = map_get_first_element_at(x >> 5, y >> 5);
|
||||
if (tileElement != nullptr)
|
||||
@@ -3978,13 +3978,13 @@ rct_tile_element* map_get_park_entrance_element_at(int32_t x, int32_t y, int32_t
|
||||
if ((ghost == false) && (tileElement->flags & TILE_ELEMENT_FLAG_GHOST))
|
||||
continue;
|
||||
|
||||
return tileElement;
|
||||
return tileElement->AsEntrance();
|
||||
} while (!(tileElement++)->IsLastForTile());
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
rct_tile_element* map_get_ride_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)
|
||||
{
|
||||
rct_tile_element* tileElement = map_get_first_element_at(x >> 5, y >> 5);
|
||||
if (tileElement != nullptr)
|
||||
@@ -4003,13 +4003,13 @@ rct_tile_element* map_get_ride_entrance_element_at(int32_t x, int32_t y, int32_t
|
||||
if ((ghost == false) && (tileElement->flags & TILE_ELEMENT_FLAG_GHOST))
|
||||
continue;
|
||||
|
||||
return tileElement;
|
||||
return tileElement->AsEntrance();
|
||||
} while (!(tileElement++)->IsLastForTile());
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
rct_tile_element* map_get_ride_exit_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)
|
||||
{
|
||||
rct_tile_element* tileElement = map_get_first_element_at(x >> 5, y >> 5);
|
||||
if (tileElement != nullptr)
|
||||
@@ -4028,7 +4028,7 @@ rct_tile_element* map_get_ride_exit_element_at(int32_t x, int32_t y, int32_t z,
|
||||
if ((ghost == false) && (tileElement->flags & TILE_ELEMENT_FLAG_GHOST))
|
||||
continue;
|
||||
|
||||
return tileElement;
|
||||
return tileElement->AsEntrance();
|
||||
} while (!(tileElement++)->IsLastForTile());
|
||||
}
|
||||
return nullptr;
|
||||
|
||||
@@ -141,9 +141,9 @@ rct_tile_element* map_get_surface_element_at(CoordsXY coords);
|
||||
rct_tile_element* map_get_path_element_at(int32_t x, int32_t y, int32_t z);
|
||||
rct_tile_element* map_get_wall_element_at(int32_t x, int32_t y, int32_t z, int32_t direction);
|
||||
rct_tile_element* map_get_small_scenery_element_at(int32_t x, int32_t y, int32_t z, int32_t type, uint8_t quadrant);
|
||||
rct_tile_element* map_get_park_entrance_element_at(int32_t x, int32_t y, int32_t z, bool ghost);
|
||||
rct_tile_element* map_get_ride_entrance_element_at(int32_t x, int32_t y, int32_t z, bool ghost);
|
||||
rct_tile_element* map_get_ride_exit_element_at(int32_t x, int32_t y, int32_t z, bool ghost);
|
||||
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);
|
||||
int32_t tile_element_height(int32_t x, int32_t y);
|
||||
bool map_coord_is_connected(int32_t x, int32_t y, int32_t z, uint8_t faceDirection);
|
||||
void map_remove_provisional_elements();
|
||||
|
||||
@@ -148,3 +148,8 @@ void rct_tile_element::ClearAs(uint8_t newType)
|
||||
clearance_height = 2;
|
||||
memset(pad_04, 0, sizeof(pad_04));
|
||||
}
|
||||
|
||||
void TileElementBase::Remove()
|
||||
{
|
||||
tile_element_remove((rct_tile_element*)this);
|
||||
}
|
||||
|
||||
@@ -96,6 +96,7 @@ struct TileElementBase
|
||||
uint8_t GetDirectionWithOffset(uint8_t offset) const;
|
||||
bool IsLastForTile() const;
|
||||
bool IsGhost() const;
|
||||
void Remove();
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user