mirror of https://github.com/OpenRCT2/OpenRCT2.git
Merge pull request #11628 from Gymnasiast/fix/11624
Fix #11624 and clean up loc_6B4F6B()
This commit is contained in:
commit
ff46481453
|
@ -3918,7 +3918,14 @@ static int32_t ride_check_block_brakes(CoordsXYE* input, CoordsXYE* output)
|
|||
*/
|
||||
static bool ride_check_track_contains_inversions(CoordsXYE* input, CoordsXYE* output)
|
||||
{
|
||||
ride_id_t rideIndex = input->element->AsTrack()->GetRideIndex();
|
||||
if (input->element == nullptr)
|
||||
return false;
|
||||
|
||||
const auto* trackElement = input->element->AsTrack();
|
||||
if (trackElement == nullptr)
|
||||
return false;
|
||||
|
||||
ride_id_t rideIndex = trackElement->GetRideIndex();
|
||||
auto ride = get_ride(rideIndex);
|
||||
if (ride != nullptr && ride->type == RIDE_TYPE_MAZE)
|
||||
return true;
|
||||
|
@ -3966,7 +3973,14 @@ static bool ride_check_track_contains_inversions(CoordsXYE* input, CoordsXYE* ou
|
|||
*/
|
||||
static bool ride_check_track_contains_banked(CoordsXYE* input, CoordsXYE* output)
|
||||
{
|
||||
auto rideIndex = input->element->AsTrack()->GetRideIndex();
|
||||
if (input->element == nullptr)
|
||||
return false;
|
||||
|
||||
const auto* trackElement = input->element->AsTrack();
|
||||
if (trackElement == nullptr)
|
||||
return false;
|
||||
|
||||
auto rideIndex = trackElement->GetRideIndex();
|
||||
auto ride = get_ride(rideIndex);
|
||||
if (ride == nullptr)
|
||||
return false;
|
||||
|
@ -5028,13 +5042,10 @@ static void ride_scroll_to_track_error(CoordsXYE* trackElement)
|
|||
*
|
||||
* rct2: 0x006B4F6B
|
||||
*/
|
||||
static TileElement* loc_6B4F6B(ride_id_t rideIndex, int32_t x, int32_t y)
|
||||
TrackElement* Ride::GetOriginElement(StationIndex stationIndex) const
|
||||
{
|
||||
auto ride = get_ride(rideIndex);
|
||||
if (ride == nullptr)
|
||||
return nullptr;
|
||||
|
||||
TileElement* tileElement = map_get_first_element_at({ x, y });
|
||||
auto stationLoc = stations[stationIndex].Start;
|
||||
TileElement* tileElement = map_get_first_element_at(stationLoc);
|
||||
if (tileElement == nullptr)
|
||||
return nullptr;
|
||||
do
|
||||
|
@ -5042,19 +5053,21 @@ static TileElement* loc_6B4F6B(ride_id_t rideIndex, int32_t x, int32_t y)
|
|||
if (tileElement->GetType() != TILE_ELEMENT_TYPE_TRACK)
|
||||
continue;
|
||||
|
||||
if (RideTypeDescriptors[ride->type].Flags & RIDE_TYPE_FLAG_FLAT_RIDE)
|
||||
auto* trackElement = tileElement->AsTrack();
|
||||
|
||||
if (RideTypeDescriptors[type].Flags & RIDE_TYPE_FLAG_FLAT_RIDE)
|
||||
{
|
||||
if (!(FlatRideTrackSequenceProperties[tileElement->AsTrack()->GetTrackType()][0] & TRACK_SEQUENCE_FLAG_ORIGIN))
|
||||
if (!(FlatRideTrackSequenceProperties[trackElement->GetTrackType()][0] & TRACK_SEQUENCE_FLAG_ORIGIN))
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!(TrackSequenceProperties[tileElement->AsTrack()->GetTrackType()][0] & TRACK_SEQUENCE_FLAG_ORIGIN))
|
||||
if (!(TrackSequenceProperties[trackElement->GetTrackType()][0] & TRACK_SEQUENCE_FLAG_ORIGIN))
|
||||
continue;
|
||||
}
|
||||
|
||||
if (tileElement->AsTrack()->GetRideIndex() == rideIndex)
|
||||
return tileElement;
|
||||
if (trackElement->GetRideIndex() == id)
|
||||
return trackElement;
|
||||
} while (!(tileElement++)->IsLastForTile());
|
||||
|
||||
return nullptr;
|
||||
|
@ -5098,7 +5111,7 @@ int32_t ride_is_valid_for_test(Ride* ride, int32_t status, bool isApplying)
|
|||
auto startLoc = ride->stations[stationIndex].Start;
|
||||
trackElement.x = startLoc.x;
|
||||
trackElement.y = startLoc.y;
|
||||
trackElement.element = loc_6B4F6B(ride->id, trackElement.x, trackElement.y);
|
||||
trackElement.element = reinterpret_cast<TileElement*>(ride->GetOriginElement(stationIndex));
|
||||
if (trackElement.element == nullptr)
|
||||
{
|
||||
// Maze is strange, station start is 0... investigation required
|
||||
|
@ -5234,7 +5247,7 @@ int32_t ride_is_valid_for_open(Ride* ride, int32_t goingToBeOpen, bool isApplyin
|
|||
auto startLoc = ride->stations[stationIndex].Start;
|
||||
trackElement.x = startLoc.x;
|
||||
trackElement.y = startLoc.y;
|
||||
trackElement.element = loc_6B4F6B(ride->id, trackElement.x, trackElement.y);
|
||||
trackElement.element = reinterpret_cast<TileElement*>(ride->GetOriginElement(stationIndex));
|
||||
if (trackElement.element == nullptr)
|
||||
{
|
||||
// Maze is strange, station start is 0... investigation required
|
||||
|
@ -5264,8 +5277,8 @@ int32_t ride_is_valid_for_open(Ride* ride, int32_t goingToBeOpen, bool isApplyin
|
|||
|
||||
if (ride->subtype != RIDE_ENTRY_INDEX_NULL)
|
||||
{
|
||||
rct_ride_entry* rideType = get_ride_entry(ride->subtype);
|
||||
if (rideType->flags & RIDE_ENTRY_FLAG_NO_INVERSIONS)
|
||||
rct_ride_entry* rideEntry = get_ride_entry(ride->subtype);
|
||||
if (rideEntry->flags & RIDE_ENTRY_FLAG_NO_INVERSIONS)
|
||||
{
|
||||
gGameCommandErrorText = STR_TRACK_UNSUITABLE_FOR_TYPE_OF_TRAIN;
|
||||
if (ride_check_track_contains_inversions(&trackElement, &problematicTrackElement))
|
||||
|
@ -5274,7 +5287,7 @@ int32_t ride_is_valid_for_open(Ride* ride, int32_t goingToBeOpen, bool isApplyin
|
|||
return 0;
|
||||
}
|
||||
}
|
||||
if (rideType->flags & RIDE_ENTRY_FLAG_NO_BANKED_TRACK)
|
||||
if (rideEntry->flags & RIDE_ENTRY_FLAG_NO_BANKED_TRACK)
|
||||
{
|
||||
gGameCommandErrorText = STR_TRACK_UNSUITABLE_FOR_TYPE_OF_TRAIN;
|
||||
if (ride_check_track_contains_banked(&trackElement, &problematicTrackElement))
|
||||
|
|
|
@ -431,6 +431,7 @@ public:
|
|||
|
||||
uint64_t GetAvailableModes() const;
|
||||
const RideTypeDescriptor& GetRideTypeDescriptor() const;
|
||||
TrackElement* GetOriginElement(StationIndex stationIndex) const;
|
||||
};
|
||||
|
||||
#pragma pack(push, 1)
|
||||
|
|
Loading…
Reference in New Issue