1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-16 11:33:03 +01:00

Part of #13874: Avoid copies of ted

This commit is contained in:
frutiemax
2021-08-28 18:57:46 -04:00
parent 5f438535ad
commit b3744f129f
3 changed files with 27 additions and 27 deletions

View File

@@ -401,7 +401,7 @@ GameActions::Result::Ptr TrackPlaceAction::Execute() const
uint32_t rideTypeFlags = ride->GetRideTypeDescriptor().Flags;
const auto& ted = GetTrackElementDescriptor(_trackType);
auto wallEdges = ted.SequenceElementAllowedWallEdges;
const auto& wallEdges = ted.SequenceElementAllowedWallEdges;
money32 cost = 0;
const rct_preview_track* trackBlock = ted.Block;

View File

@@ -481,11 +481,11 @@ bool track_block_get_next_from_zero(
continue;
const auto& ted = GetTrackElementDescriptor(trackElement->GetTrackType());
auto nextTrackBlock = ted.Block;
const auto* nextTrackBlock = ted.Block;
if (nextTrackBlock == nullptr)
continue;
auto nextTrackCoordinate = ted.Coordinates;
const auto& nextTrackCoordinate = ted.Coordinates;
uint8_t nextRotation = tileElement->GetDirectionWithOffset(nextTrackCoordinate.rotation_begin)
| (nextTrackCoordinate.rotation_begin & TRACK_BLOCK_2);
@@ -537,7 +537,7 @@ bool track_block_get_next(CoordsXYE* input, CoordsXYE* output, int32_t* z, int32
trackBlock += inputElement->GetSequenceIndex();
auto trackCoordinate = ted.Coordinates;
const auto& trackCoordinate = ted.Coordinates;
int32_t x = input->x;
int32_t y = input->y;
@@ -599,11 +599,11 @@ bool track_block_get_previous_from_zero(
if (trackElement->GetRideIndex() != ride->id)
continue;
const auto& teDesc = GetTrackElementDescriptor(trackElement->GetTrackType());
const auto* nextTrackBlock = teDesc.Block;
const auto* ted = &GetTrackElementDescriptor(trackElement->GetTrackType());
const auto* nextTrackBlock = ted->Block;
if (nextTrackBlock == nullptr)
continue;
auto nextTrackCoordinate = teDesc.Coordinates;
const auto& nextTrackCoordinate = ted->Coordinates;
nextTrackBlock += trackElement->GetSequenceIndex();
if ((nextTrackBlock + 1)->index != 255)
@@ -635,8 +635,8 @@ bool track_block_get_previous_from_zero(
outTrackBeginEnd->begin_z = tileElement->GetBaseZ();
const auto& ted = GetTrackElementDescriptor(trackElement->GetTrackType());
const auto* nextTrackBlock2 = ted.Block;
ted = &GetTrackElementDescriptor(trackElement->GetTrackType());
const auto* nextTrackBlock2 = ted->Block;
if (nextTrackBlock2 == nullptr)
continue;
@@ -2822,8 +2822,8 @@ static bool ride_check_start_and_end_is_station(CoordsXYE* input)
// Check back of the track
track_get_back(input, &trackBack);
auto trackType = trackBack.element->AsTrack()->GetTrackType();
auto ted = GetTrackElementDescriptor(trackType);
if (!(ted.TrackSequenceProperties[0] & TRACK_SEQUENCE_FLAG_ORIGIN))
const auto* ted = &GetTrackElementDescriptor(trackType);
if (!(ted->TrackSequenceProperties[0] & TRACK_SEQUENCE_FLAG_ORIGIN))
{
return false;
}
@@ -2832,8 +2832,8 @@ static bool ride_check_start_and_end_is_station(CoordsXYE* input)
// Check front of the track
track_get_front(input, &trackFront);
trackType = trackFront.element->AsTrack()->GetTrackType();
ted = GetTrackElementDescriptor(trackType);
if (!(ted.TrackSequenceProperties[0] & TRACK_SEQUENCE_FLAG_ORIGIN))
ted = &GetTrackElementDescriptor(trackType);
if (!(ted->TrackSequenceProperties[0] & TRACK_SEQUENCE_FLAG_ORIGIN))
{
return false;
}

View File

@@ -630,7 +630,7 @@ void ride_construction_set_default_next_piece()
TileElement* tileElement;
_currentTrackPrice = MONEY32_UNDEFINED;
TrackElementDescriptor ted;
const TrackElementDescriptor* ted;
switch (_rideConstructionState)
{
case RideConstructionState::Front:
@@ -659,8 +659,8 @@ void ride_construction_set_default_next_piece()
}
}
ted = GetTrackElementDescriptor(trackType);
curve = ted.CurveChain.next;
ted = &GetTrackElementDescriptor(trackType);
curve = ted->CurveChain.next;
bank = TrackDefinitions[trackType].bank_end;
slope = TrackDefinitions[trackType].vangle_end;
@@ -705,8 +705,8 @@ void ride_construction_set_default_next_piece()
}
}
ted = GetTrackElementDescriptor(trackType);
curve = ted.CurveChain.previous;
ted = &GetTrackElementDescriptor(trackType);
curve = ted->CurveChain.previous;
bank = TrackDefinitions[trackType].bank_start;
slope = TrackDefinitions[trackType].vangle_start;
@@ -1439,7 +1439,7 @@ CoordsXYZD ride_get_entrance_or_exit_position_from_screen_position(const ScreenC
*/
void sub_6CB945(Ride* ride)
{
TrackElementDescriptor ted;
const TrackElementDescriptor* ted;
if (ride->type != RIDE_TYPE_MAZE)
{
for (StationIndex stationId = 0; stationId < MAX_STATIONS; ++stationId)
@@ -1475,8 +1475,8 @@ void sub_6CB945(Ride* ride)
if (tileElement->AsTrack()->GetSequenceIndex() != 0)
continue;
ted = GetTrackElementDescriptor(tileElement->AsTrack()->GetTrackType());
if (!(ted.TrackSequenceProperties[0] & TRACK_SEQUENCE_FLAG_ORIGIN))
ted = &GetTrackElementDescriptor(tileElement->AsTrack()->GetTrackType());
if (!(ted->TrackSequenceProperties[0] & TRACK_SEQUENCE_FLAG_ORIGIN))
continue;
trackFound = true;
@@ -1503,8 +1503,8 @@ void sub_6CB945(Ride* ride)
continue;
}
ted = GetTrackElementDescriptor(tileElement->AsTrack()->GetTrackType());
const rct_preview_track* trackBlock = ted.Block;
ted = &GetTrackElementDescriptor(tileElement->AsTrack()->GetTrackType());
const rct_preview_track* trackBlock = ted->Block;
while ((++trackBlock)->index != 0xFF)
{
CoordsXYZ blockLocation = location + CoordsXYZ{ CoordsXY{ trackBlock->x, trackBlock->y }.Rotate(direction), 0 };
@@ -1520,8 +1520,8 @@ void sub_6CB945(Ride* ride)
if (tileElement->GetType() != TILE_ELEMENT_TYPE_TRACK)
continue;
ted = GetTrackElementDescriptor(tileElement->AsTrack()->GetTrackType());
if (!(ted.TrackSequenceProperties[0] & TRACK_SEQUENCE_FLAG_ORIGIN))
ted = &GetTrackElementDescriptor(tileElement->AsTrack()->GetTrackType());
if (!(ted->TrackSequenceProperties[0] & TRACK_SEQUENCE_FLAG_ORIGIN))
continue;
trackFound = true;
@@ -1616,8 +1616,8 @@ void sub_6CB945(Ride* ride)
Direction direction = (tileElement->GetDirection() - direction_reverse(trackElement->GetDirection())) & 3;
ted = GetTrackElementDescriptor(trackType);
if (!(ted.TrackSequenceProperties[trackSequence] & (1 << direction)))
ted = &GetTrackElementDescriptor(trackType);
if (!(ted->TrackSequenceProperties[trackSequence] & (1 << direction)))
{
continue;
}