Finish move to a TrackElementDescriptor per element

This commit is contained in:
Gymnasiast committed 2026-03-02 20:39:35 +01:00
1 parent ef7e765631
commit da7272dec9
25 files changed
+5578 -5171

No files matched your search

+3 -2
View File
@@ -381,7 +381,7 @@ namespace OpenRCT2
if (trackElement->GetRideIndex() == gRideEntranceExitPlaceRideIndex)
{
const auto& ted = GetTrackElementDescriptor(trackElement->GetTrackType());
if (ted.sequences[0].flags.has(SequenceFlag::trackOrigin))
if (ted.sequenceData.sequences[0].flags.has(SequenceFlag::trackOrigin))
{
if (trackElement->GetTrackType() == TrackElemType::maze)
{
@@ -476,7 +476,8 @@ namespace OpenRCT2
// get the ride entrance's side relative to the TrackElement
Direction direction = (DirectionReverse(entranceExitCoords.direction) - tileElement->GetDirection()) & 3;
const auto& ted = GetTrackElementDescriptor(trackElement->GetTrackType());
auto connectionSides = ted.sequences[trackElement->GetSequenceIndex()].getEntranceConnectionSides();
auto connectionSides = ted.sequenceData.sequences[trackElement->GetSequenceIndex()]
.getEntranceConnectionSides();
if (connectionSides & (1 << direction))
{
// if that side of the TrackElement supports stations, the ride entrance is valid and faces away from
+1 -1
View File
@@ -7133,7 +7133,7 @@ namespace OpenRCT2::Ui::Windows
auto trackElement = tileElement->AsTrack();
auto trackType = trackElement->GetTrackType();
const auto& ted = GetTrackElementDescriptor(trackType);
if (ted.sequences[0].flags.has(SequenceFlag::trackOrigin))
if (ted.sequenceData.sequences[0].flags.has(SequenceFlag::trackOrigin))
{
auto stationIndex = trackElement->GetStationIndex();
return WindowRideOpenStation(*ride, stationIndex);
+10 -10
View File
@@ -2293,9 +2293,9 @@ namespace OpenRCT2::Ui::Windows
const auto& ted = GetTrackElementDescriptor(trackType);
trackDirection &= 3;
MapSelection::clearSelectedTiles();
for (uint8_t i = 0; i < ted.numSequences; i++)
for (uint8_t i = 0; i < ted.sequenceData.numSequences; i++)
{
CoordsXY offsets = { ted.sequences[i].clearance.x, ted.sequences[i].clearance.y };
CoordsXY offsets = { ted.sequenceData.sequences[i].clearance.x, ted.sequenceData.sequences[i].clearance.y };
CoordsXY currentTileCoords = tileCoords + offsets.Rotate(trackDirection);
MapSelection::addSelectedTile(currentTileCoords);
@@ -2455,7 +2455,7 @@ namespace OpenRCT2::Ui::Windows
}
const auto& ted = GetTrackElementDescriptor(tileElement->AsTrack()->GetTrackType());
newCoords->z = (tileElement->GetBaseZ()) - ted.sequences[0].clearance.z;
newCoords->z = (tileElement->GetBaseZ()) - ted.sequenceData.sequences[0].clearance.z;
_gotoStartPlacementMode = true;
}
@@ -2712,7 +2712,7 @@ namespace OpenRCT2::Ui::Windows
}
const auto& ted = GetTrackElementDescriptor(trackType);
const auto trackBlock = ted.sequences[ted.numSequences - 1].clearance;
const auto trackBlock = ted.sequenceData.sequences[ted.sequenceData.numSequences - 1].clearance;
CoordsXYZ mapCoords{ trackBlock.x, trackBlock.y, trackBlock.z };
if (trackBlock.flags & RCT_PREVIEW_TRACK_FLAG_1)
{
@@ -2781,9 +2781,9 @@ namespace OpenRCT2::Ui::Windows
auto clearanceHeight = (rideEntry != nullptr) ? rideEntry->Clearance
: currentRide->getRideTypeDescriptor().Heights.ClearanceHeight;
for (uint8_t i = 0; i < ted.numSequences; i++)
for (uint8_t i = 0; i < ted.sequenceData.numSequences; i++)
{
const auto& trackBlock = ted.sequences[i].clearance;
const auto& trackBlock = ted.sequenceData.sequences[i].clearance;
auto quarterTile = trackBlock.quarterTile.Rotate(trackDirection);
CoordsXY offsets = { trackBlock.x, trackBlock.y };
@@ -3431,9 +3431,9 @@ namespace OpenRCT2::Ui::Windows
// Loc6CC91B:
const auto& ted = GetTrackElementDescriptor(trackType);
int32_t bx = 0;
for (uint8_t i = 0; i < ted.numSequences; i++)
for (uint8_t i = 0; i < ted.sequenceData.numSequences; i++)
{
bx = std::min<int32_t>(bx, ted.sequences[i].clearance.z);
bx = std::min<int32_t>(bx, ted.sequenceData.sequences[i].clearance.z);
}
z -= bx;
@@ -3660,9 +3660,9 @@ namespace OpenRCT2::Ui::Windows
{
const auto& ted = GetTrackElementDescriptor(_currentTrackPieceType);
int32_t bx = 0;
for (uint8_t i = 0; i < ted.numSequences; i++)
for (uint8_t i = 0; i < ted.sequenceData.numSequences; i++)
{
bx = std::min<int32_t>(bx, ted.sequences[i].clearance.z);
bx = std::min<int32_t>(bx, ted.sequenceData.sequences[i].clearance.z);
}
z -= bx;
+5 -4
View File
@@ -636,9 +636,9 @@ namespace OpenRCT2::Ui::Windows
{
// Follow a single track piece shape
const auto& ted = GetTrackElementDescriptor(trackElement.type);
for (size_t sequenceIndex = 0; sequenceIndex < ted.numSequences; sequenceIndex++)
for (size_t sequenceIndex = 0; sequenceIndex < ted.sequenceData.numSequences; sequenceIndex++)
{
const auto& trackBlock = ted.sequences[sequenceIndex].clearance;
const auto& trackBlock = ted.sequenceData.sequences[sequenceIndex].clearance;
auto rotatedAndOffsetTrackBlock = curTrackStart
+ CoordsXY{ trackBlock.x, trackBlock.y }.Rotate(curTrackRotation);
@@ -659,8 +659,9 @@ namespace OpenRCT2::Ui::Windows
auto bits = trackBlock.quarterTile.Rotate(curTrackRotation & 3).GetBaseQuarterOccupied();
// Station track is a lighter colour
auto colour = ted.sequences[0].flags.has(SequenceFlag::trackOrigin) ? kPaletteIndexColourStation
: kPaletteIndexColourTrack;
auto colour = ted.sequenceData.sequences[0].flags.has(SequenceFlag::trackOrigin)
? kPaletteIndexColourStation
: kPaletteIndexColourTrack;
for (int32_t i = 0; i < 4; i++)
{
@@ -442,7 +442,7 @@ namespace OpenRCT2::GameActions
int32_t z;
if (sequence == 0)
{
if (ted.sequences[0].flags.has(SequenceFlag::disallowDoors))
if (ted.sequenceData.sequences[0].flags.has(SequenceFlag::disallowDoors))
{
return false;
}
@@ -455,7 +455,7 @@ namespace OpenRCT2::GameActions
if (direction == _edge)
{
z = ted.coordinates.zBegin;
z = trackElement->BaseHeight + ((z - ted.sequences[sequence].clearance.z) * 8);
z = trackElement->BaseHeight + ((z - ted.sequenceData.sequences[sequence].clearance.z) * 8);
if (z == z0)
{
return true;
@@ -465,7 +465,7 @@ namespace OpenRCT2::GameActions
}
}
bool isLastInSequence = (sequence + 1) == ted.numSequences;
bool isLastInSequence = (sequence + 1) == ted.sequenceData.numSequences;
if (!isLastInSequence)
{
return false;
@@ -489,7 +489,7 @@ namespace OpenRCT2::GameActions
}
z = ted.coordinates.zEnd;
z = trackElement->BaseHeight + ((z - ted.sequences[sequence].clearance.z) * kCoordsZStep);
z = trackElement->BaseHeight + ((z - ted.sequenceData.sequences[sequence].clearance.z) * kCoordsZStep);
return z == z0;
}
@@ -597,7 +597,7 @@ namespace OpenRCT2::GameActions
if (!GetRideTypeDescriptor(rideType).flags.has(RtdFlag::noWallsAroundTrack))
{
const auto& ted = GetTrackElementDescriptor(trackType);
if (ted.sequences[trackSequence].allowedWallEdges & (1 << direction))
if (ted.sequenceData.sequences[trackSequence].allowedWallEdges & (1 << direction))
{
return true;
}
+15 -15
View File
@@ -183,9 +183,9 @@ namespace OpenRCT2::GameActions
const auto& ted = GetTrackElementDescriptor(_trackType);
uint32_t numElements = 0;
// First check if any of the track pieces are outside the park
for (uint8_t i = 0; i < ted.numSequences; i++)
for (uint8_t i = 0; i < ted.sequenceData.numSequences; i++)
{
const auto& trackBlock = ted.sequences[i].clearance;
const auto& trackBlock = ted.sequenceData.sequences[i].clearance;
auto rotatedTrack = CoordsXYZ{ CoordsXY{ trackBlock.x, trackBlock.y }.Rotate(_origin.direction), 0 };
auto tileCoords = CoordsXYZ{ _origin.x, _origin.y, _origin.z } + rotatedTrack;
@@ -232,9 +232,9 @@ namespace OpenRCT2::GameActions
money64 costs = 0;
money64 supportCosts = 0;
for (int32_t blockIndex = 0; blockIndex < ted.numSequences; blockIndex++)
for (int32_t blockIndex = 0; blockIndex < ted.sequenceData.numSequences; blockIndex++)
{
const auto& trackBlock = ted.sequences[blockIndex].clearance;
const auto& trackBlock = ted.sequenceData.sequences[blockIndex].clearance;
auto rotatedTrack = CoordsXYZ{ CoordsXY{ trackBlock.x, trackBlock.y }.Rotate(_origin.direction), trackBlock.z };
auto mapLoc = CoordsXYZ{ _origin.x, _origin.y, _origin.z } + rotatedTrack;
auto quarterTile = trackBlock.quarterTile.Rotate(_origin.direction);
@@ -351,7 +351,7 @@ namespace OpenRCT2::GameActions
}
}
if (ted.sequences[0].flags.has(SequenceFlag::trackOrigin) && blockIndex == 0)
if (ted.sequenceData.sequences[0].flags.has(SequenceFlag::trackOrigin) && blockIndex == 0)
{
const auto addElementResult = TrackAddStationElement(
{ mapLoc, baseZ, _origin.direction }, _rideIndex, {}, _fromTrackDesign);
@@ -443,13 +443,13 @@ namespace OpenRCT2::GameActions
money64 costs = 0;
money64 supportCosts = 0;
const auto& block0 = ted.sequences[0].clearance;
const auto& block0 = ted.sequenceData.sequences[0].clearance;
auto clearanceHeight = rideEntry->Clearance;
CoordsXYZ originLocation = CoordsXYZ{ _origin.x, _origin.y, _origin.z }
+ CoordsXYZ{ CoordsXY{ block0.x, block0.y }.Rotate(_origin.direction), block0.z };
for (int32_t blockIndex = 0; blockIndex < ted.numSequences; blockIndex++)
for (int32_t blockIndex = 0; blockIndex < ted.sequenceData.numSequences; blockIndex++)
{
const auto& trackBlock = ted.sequences[blockIndex].clearance;
const auto& trackBlock = ted.sequenceData.sequences[blockIndex].clearance;
auto rotatedTrack = CoordsXYZ{ CoordsXY{ trackBlock.x, trackBlock.y }.Rotate(_origin.direction), trackBlock.z };
auto mapLoc = CoordsXYZ{ _origin.x, _origin.y, _origin.z } + rotatedTrack;
@@ -504,7 +504,7 @@ namespace OpenRCT2::GameActions
else
{
// Remove walls in the directions this track intersects
uint8_t intersectingDirections = ted.sequences[blockIndex].allowedWallEdges;
uint8_t intersectingDirections = ted.sequenceData.sequences[blockIndex].allowedWallEdges;
intersectingDirections ^= 0x0F;
intersectingDirections = rol4(intersectingDirections, _origin.direction);
for (int32_t i = 0; i < kNumOrthogonalDirections; i++)
@@ -552,7 +552,7 @@ namespace OpenRCT2::GameActions
{
if (!GetFlags().has(CommandFlag::noSpend))
{
isOrigin = ted.sequences[0].flags.has(SequenceFlag::trackOrigin);
isOrigin = ted.sequenceData.sequences[0].flags.has(SequenceFlag::trackOrigin);
}
}
@@ -614,9 +614,9 @@ namespace OpenRCT2::GameActions
}
trackElement->SetColourScheme(static_cast<RideColourScheme>(_colour));
if (ted.sequences[0].flags.has(SequenceFlag::connectsToPath))
if (ted.sequenceData.sequences[0].flags.has(SequenceFlag::connectsToPath))
{
uint32_t connectionSides = ted.sequences[0].getEntranceConnectionSides();
uint32_t connectionSides = ted.sequenceData.sequences[0].getEntranceConnectionSides();
if (connectionSides != 0)
{
if (!GetFlags().has(CommandFlag::ghost) && !gameState.cheats.disableClearanceChecks)
@@ -639,7 +639,7 @@ namespace OpenRCT2::GameActions
// If the placed tile is a station modify station properties.
// Don't do this if the tile is a ghost to prevent desyncs
// However, ghost tiles from track designs need to modify station data to display properly
if (ted.sequences[0].flags.has(SequenceFlag::trackOrigin)
if (ted.sequenceData.sequences[0].flags.has(SequenceFlag::trackOrigin)
&& (!GetFlags().has(CommandFlag::ghost) || _fromTrackDesign))
{
if (blockIndex == 0)
@@ -737,9 +737,9 @@ namespace OpenRCT2::GameActions
bool TrackPlaceAction::CheckMapCapacity(int16_t numTiles) const
{
const auto& ted = GetTrackElementDescriptor(_trackType);
for (uint8_t i = 0; i < ted.numSequences; i++)
for (uint8_t i = 0; i < ted.sequenceData.numSequences; i++)
{
const auto& trackBlock = ted.sequences[i].clearance;
const auto& trackBlock = ted.sequenceData.sequences[i].clearance;
auto rotatedTrack = CoordsXY{ trackBlock.x, trackBlock.y }.Rotate(_origin.direction);
auto tileCoords = CoordsXY{ _origin.x, _origin.y } + rotatedTrack;
@@ -142,12 +142,12 @@ namespace OpenRCT2::GameActions
}
const auto& ted = GetTrackElementDescriptor(trackType);
auto sequenceIndex = tileElement->AsTrack()->GetSequenceIndex();
if (sequenceIndex >= ted.numSequences)
if (sequenceIndex >= ted.sequenceData.numSequences)
{
LOG_ERROR("Track block %d not found for track type %d.", sequenceIndex, trackType);
return Result(Status::invalidParameters, STR_RIDE_CONSTRUCTION_CANT_REMOVE_THIS, STR_ERR_TRACK_BLOCK_NOT_FOUND);
}
const auto& currentTrackBlock = ted.sequences[sequenceIndex].clearance;
const auto& currentTrackBlock = ted.sequenceData.sequences[sequenceIndex].clearance;
auto startLoc = _origin;
startLoc.direction = tileElement->GetDirection();
@@ -163,9 +163,9 @@ namespace OpenRCT2::GameActions
money64 supportCosts = 0;
for (uint8_t i = 0; i < ted.numSequences; i++)
for (uint8_t i = 0; i < ted.sequenceData.numSequences; i++)
{
const auto& trackBlock = ted.sequences[i].clearance;
const auto& trackBlock = ted.sequenceData.sequences[i].clearance;
rotatedTrack = CoordsXYZ{ CoordsXY{ trackBlock.x, trackBlock.y }.Rotate(startLoc.direction), trackBlock.z };
auto mapLoc = CoordsXYZ{ startLoc.x, startLoc.y, startLoc.z } + rotatedTrack;
@@ -212,7 +212,8 @@ namespace OpenRCT2::GameActions
return Result(Status::unknown, STR_RIDE_CONSTRUCTION_CANT_REMOVE_THIS, STR_ERR_TRACK_ELEMENT_NOT_FOUND);
}
if (ted.sequences[0].flags.has(SequenceFlag::trackOrigin) && (tileElement->AsTrack()->GetSequenceIndex() == 0))
if (ted.sequenceData.sequences[0].flags.has(SequenceFlag::trackOrigin)
&& (tileElement->AsTrack()->GetSequenceIndex() == 0))
{
const auto removeElementResult = TrackRemoveStationElement({ mapLoc, _origin.direction }, rideIndex, {});
if (!removeElementResult.Successful)
@@ -314,7 +315,7 @@ namespace OpenRCT2::GameActions
}
const auto& ted = GetTrackElementDescriptor(trackType);
auto sequenceIndex = tileElement->AsTrack()->GetSequenceIndex();
if (sequenceIndex >= ted.numSequences)
if (sequenceIndex >= ted.sequenceData.numSequences)
{
LOG_ERROR("Track block %d not found for track type %d.", sequenceIndex, trackType);
return Result(Status::invalidParameters, STR_RIDE_CONSTRUCTION_CANT_REMOVE_THIS, STR_ERR_TRACK_BLOCK_NOT_FOUND);
@@ -323,7 +324,7 @@ namespace OpenRCT2::GameActions
auto startLoc = _origin;
startLoc.direction = tileElement->GetDirection();
const auto& currentTrackBlock = ted.sequences[sequenceIndex].clearance;
const auto& currentTrackBlock = ted.sequenceData.sequences[sequenceIndex].clearance;
auto rotatedTrackLoc = CoordsXYZ{ CoordsXY{ currentTrackBlock.x, currentTrackBlock.y }.Rotate(startLoc.direction),
currentTrackBlock.z };
startLoc.x -= rotatedTrackLoc.x;
@@ -335,9 +336,9 @@ namespace OpenRCT2::GameActions
money64 supportCosts = 0;
for (uint8_t i = 0; i < ted.numSequences; i++)
for (uint8_t i = 0; i < ted.sequenceData.numSequences; i++)
{
const auto& trackBlock = ted.sequences[i].clearance;
const auto& trackBlock = ted.sequenceData.sequences[i].clearance;
rotatedTrackLoc = CoordsXYZ{ CoordsXY{ trackBlock.x, trackBlock.y }.Rotate(startLoc.direction), trackBlock.z };
auto mapLoc = CoordsXYZ{ startLoc.x, startLoc.y, startLoc.z } + rotatedTrackLoc;
@@ -381,7 +382,8 @@ namespace OpenRCT2::GameActions
return Result(Status::unknown, STR_RIDE_CONSTRUCTION_CANT_REMOVE_THIS, STR_ERR_TRACK_ELEMENT_NOT_FOUND);
}
if (ted.sequences[0].flags.has(SequenceFlag::trackOrigin) && (tileElement->AsTrack()->GetSequenceIndex() == 0))
if (ted.sequenceData.sequences[0].flags.has(SequenceFlag::trackOrigin)
&& (tileElement->AsTrack()->GetSequenceIndex() == 0))
{
const auto removeElementResult = TrackRemoveStationElement({ mapLoc, _origin.direction }, rideIndex, {});
if (!removeElementResult.Successful)
@@ -407,7 +409,7 @@ namespace OpenRCT2::GameActions
// If the removed tile is a station modify station properties.
// Don't do this if the ride is simulating and the tile is a ghost to prevent desyncs.
if (ted.sequences[0].flags.has(SequenceFlag::trackOrigin)
if (ted.sequenceData.sequences[0].flags.has(SequenceFlag::trackOrigin)
&& (!GetFlags().has(CommandFlag::ghost) || (GetFlags().has(CommandFlag::trackDesign)))
&& (tileElement->AsTrack()->GetSequenceIndex() == 0))
{
@@ -661,7 +661,7 @@ bool DrawSupportForSequenceA(
const Direction direction, const int32_t height, const ImageId imageTemplate)
{
const auto& ted = TrackMetadata::GetTrackElementDescriptor(trackType);
const auto& sequenceDesc = ted.sequences[sequence];
const auto& sequenceDesc = ted.sequenceData.sequences[sequence];
const auto& desc = sequenceDesc.woodenSupports;
if (desc.subType == WoodenSupportSubType::null)
@@ -678,7 +678,7 @@ bool DrawSupportForSequenceB(
const Direction direction, const int32_t height, const ImageId imageTemplate)
{
const auto& ted = TrackMetadata::GetTrackElementDescriptor(trackType);
const auto& sequenceDesc = ted.sequences[sequence];
const auto& sequenceDesc = ted.sequenceData.sequences[sequence];
const auto& desc = sequenceDesc.woodenSupports;
if (desc.subType == WoodenSupportSubType::null)
@@ -18,7 +18,7 @@ bool DrawSupportForSequenceA(
const int32_t height, const ImageId imageTemplate)
{
const auto& ted = OpenRCT2::TrackMetadata::GetTrackElementDescriptor(trackType);
const auto& sequenceDesc = ted.sequences[sequence];
const auto& sequenceDesc = ted.sequenceData.sequences[sequence];
const auto& desc = sequenceDesc.woodenSupports;
if (desc.subType == WoodenSupportSubType::null)
@@ -36,7 +36,7 @@ bool DrawSupportForSequenceB(
const int32_t height, const ImageId imageTemplate)
{
const auto& ted = OpenRCT2::TrackMetadata::GetTrackElementDescriptor(trackType);
const auto& sequenceDesc = ted.sequences[sequence];
const auto& sequenceDesc = ted.sequenceData.sequences[sequence];
const auto& desc = sequenceDesc.woodenSupports;
if (desc.subType == WoodenSupportSubType::null)
+19 -19
View File
@@ -499,7 +499,7 @@ bool RideTryGetOriginElement(const Ride& ride, CoordsXYE* output)
bool specialTrackPiece
= (it.element->AsTrack()->GetTrackType() != TrackElemType::beginStation
&& it.element->AsTrack()->GetTrackType() != TrackElemType::middleStation
&& ted.sequences[0].flags.has(SequenceFlag::trackOrigin));
&& ted.sequenceData.sequences[0].flags.has(SequenceFlag::trackOrigin));
// Set result tile to this track piece if first found track or a ???
if (resultTileElement == nullptr || specialTrackPiece)
@@ -566,7 +566,7 @@ bool TrackBlockGetNextFromZero(
continue;
const auto& ted = GetTrackElementDescriptor(trackElement->GetTrackType());
if (ted.numSequences == 0)
if (ted.sequenceData.numSequences == 0)
continue;
const auto& nextTrackCoordinate = ted.coordinates;
@@ -576,7 +576,7 @@ bool TrackBlockGetNextFromZero(
if (nextRotation != direction_start)
continue;
int16_t nextZ = nextTrackCoordinate.zBegin - ted.sequences[0].clearance.z + tileElement->GetBaseZ();
int16_t nextZ = nextTrackCoordinate.zBegin - ted.sequenceData.sequences[0].clearance.z + tileElement->GetBaseZ();
if (nextZ != trackPos.z)
continue;
@@ -616,10 +616,10 @@ bool TrackBlockGetNext(CoordsXYE* input, CoordsXYE* output, int32_t* z, int32_t*
const auto& ted = GetTrackElementDescriptor(inputElement->GetTrackType());
auto sequenceIndex = inputElement->GetSequenceIndex();
if (sequenceIndex >= ted.numSequences)
if (sequenceIndex >= ted.sequenceData.numSequences)
return false;
const auto& trackBlock = ted.sequences[sequenceIndex].clearance;
const auto& trackBlock = ted.sequenceData.sequences[sequenceIndex].clearance;
const auto& trackCoordinate = ted.coordinates;
int32_t x = input->x;
@@ -683,14 +683,14 @@ bool TrackBlockGetPreviousFromZero(
continue;
const auto& ted = GetTrackElementDescriptor(trackElement->GetTrackType());
if (ted.numSequences == 0)
if (ted.sequenceData.numSequences == 0)
continue;
auto sequenceIndex = trackElement->GetSequenceIndex();
if ((sequenceIndex + 1) != ted.numSequences)
if ((sequenceIndex + 1) != ted.sequenceData.numSequences)
continue;
const auto& currentBlock = ted.sequences[sequenceIndex].clearance;
const auto& currentBlock = ted.sequenceData.sequences[sequenceIndex].clearance;
const auto& nextTrackCoordinate = ted.coordinates;
uint8_t nextRotation = tileElement->GetDirectionWithOffset(nextTrackCoordinate.rotationEnd)
@@ -719,7 +719,7 @@ bool TrackBlockGetPreviousFromZero(
outTrackBeginEnd->begin_z = tileElement->GetBaseZ();
const auto& firstBlock = ted.sequences[0].clearance;
const auto& firstBlock = ted.sequenceData.sequences[0].clearance;
outTrackBeginEnd->begin_z += firstBlock.z - currentBlock.z;
outTrackBeginEnd->begin_direction = nextRotation;
outTrackBeginEnd->end_direction = DirectionReverse(directionStart);
@@ -759,10 +759,10 @@ bool TrackBlockGetPrevious(const CoordsXYE& trackPos, TrackBeginEnd* outTrackBeg
return false;
auto sequenceIndex = trackElement->GetSequenceIndex();
if (sequenceIndex >= ted.numSequences)
if (sequenceIndex >= ted.sequenceData.numSequences)
return false;
const auto& trackBlock = ted.sequences[sequenceIndex].clearance;
const auto& trackBlock = ted.sequenceData.sequences[sequenceIndex].clearance;
auto trackCoordinate = ted.coordinates;
int32_t z = trackElement->GetBaseZ();
@@ -2393,7 +2393,7 @@ static void RideShopConnected(const Ride& ride)
return;
const auto& ted = GetTrackElementDescriptor(track_type);
uint8_t connectionSides = ted.sequences[0].getEntranceConnectionSides();
uint8_t connectionSides = ted.sequenceData.sequences[0].getEntranceConnectionSides();
uint8_t tile_direction = trackElement->GetDirection();
connectionSides = Numerics::rol4(connectionSides, tile_direction);
@@ -2932,7 +2932,7 @@ static int32_t RideCheckStationLength(const CoordsXYE& input, CoordsXYE* output)
do
{
const auto& ted = GetTrackElementDescriptor(output->element->AsTrack()->GetTrackType());
if (ted.sequences[0].flags.has(SequenceFlag::trackOrigin))
if (ted.sequenceData.sequences[0].flags.has(SequenceFlag::trackOrigin))
{
num_station_elements++;
last_good_station = *output;
@@ -2980,8 +2980,8 @@ static bool RideCheckStartAndEndIsStation(const CoordsXYE& input)
// Check back of the track
TrackGetBack(input, &trackBack);
auto trackType = trackBack.element->AsTrack()->GetTrackType();
const auto* ted = &GetTrackElementDescriptor(trackType);
if (!ted->sequences[0].flags.has(SequenceFlag::trackOrigin))
const auto& tedBack = GetTrackElementDescriptor(trackType);
if (tedBack.sequenceData.sequences[0].flags.has(SequenceFlag::trackOrigin))
{
return false;
}
@@ -2990,8 +2990,8 @@ static bool RideCheckStartAndEndIsStation(const CoordsXYE& input)
// Check front of the track
TrackGetFront(input, &trackFront);
trackType = trackFront.element->AsTrack()->GetTrackType();
ted = &GetTrackElementDescriptor(trackType);
if (!ted->sequences[0].flags.has(SequenceFlag::trackOrigin))
const auto& tedFront = GetTrackElementDescriptor(trackType);
if (tedFront.sequenceData.sequences[0].flags.has(SequenceFlag::trackOrigin))
{
return false;
}
@@ -4056,7 +4056,7 @@ TrackElement* Ride::getOriginElement(StationIndex stationIndex) const
auto* trackElement = tileElement->AsTrack();
const auto& ted = GetTrackElementDescriptor(trackElement->GetTrackType());
if (!ted.sequences[0].flags.has(SequenceFlag::trackOrigin))
if (!ted.sequenceData.sequences[0].flags.has(SequenceFlag::trackOrigin))
continue;
if (trackElement->GetRideIndex() == id)
@@ -5047,7 +5047,7 @@ static int32_t RideGetTrackLength(const Ride& ride)
trackType = tileElement->AsTrack()->GetTrackType();
const auto& ted = GetTrackElementDescriptor(trackType);
if (!ted.sequences[0].flags.has(SequenceFlag::trackOrigin))
if (!ted.sequenceData.sequences[0].flags.has(SequenceFlag::trackOrigin))
continue;
if (tileElement->GetBaseZ() != trackStart.z)
+11 -11
View File
@@ -404,10 +404,10 @@ std::optional<CoordsXYZ> GetTrackElementOriginAndApplyChanges(
// Now find all the elements that belong to this track piece
int32_t sequence = trackElement->GetSequenceIndex();
uint8_t mapDirection = trackElement->GetDirection();
if (sequence >= ted.numSequences)
if (sequence >= ted.sequenceData.numSequences)
return std::nullopt;
const auto& trackBlock = ted.sequences[sequence].clearance;
const auto& trackBlock = ted.sequenceData.sequences[sequence].clearance;
CoordsXY offsets = { trackBlock.x, trackBlock.y };
CoordsXY newCoords = location;
@@ -416,13 +416,13 @@ std::optional<CoordsXYZ> GetTrackElementOriginAndApplyChanges(
auto retCoordsXYZ = CoordsXYZ{ newCoords.x, newCoords.y, location.z - trackBlock.z };
int32_t start_z = retCoordsXYZ.z;
assert(ted.numSequences > 0);
const auto block0 = ted.sequences[0].clearance;
assert(ted.sequenceData.numSequences > 0);
const auto block0 = ted.sequenceData.sequences[0].clearance;
retCoordsXYZ.z += block0.z;
for (int32_t i = 0; i < ted.numSequences; i++)
for (int32_t i = 0; i < ted.sequenceData.numSequences; i++)
{
const auto& block = ted.sequences[i].clearance;
const auto& block = ted.sequenceData.sequences[i].clearance;
CoordsXY cur = { retCoordsXYZ };
offsets = { block.x, block.y };
cur += offsets.Rotate(mapDirection);
@@ -1226,7 +1226,7 @@ void Ride::validateStations()
const auto& ted = GetTrackElementDescriptor(tileElement->AsTrack()->GetTrackType());
// keep searching for a station piece (coaster station, tower ride base, shops, and flat ride base)
if (!ted.sequences[0].flags.has(SequenceFlag::trackOrigin))
if (!ted.sequenceData.sequences[0].flags.has(SequenceFlag::trackOrigin))
continue;
trackFound = true;
@@ -1258,9 +1258,9 @@ void Ride::validateStations()
}
// update all the blocks with StationIndex
const auto& ted = GetTrackElementDescriptor(tileElement->AsTrack()->GetTrackType());
for (uint8_t i = 0; i < ted.numSequences; i++)
for (uint8_t i = 0; i < ted.sequenceData.numSequences; i++)
{
const auto& block = ted.sequences[i].clearance;
const auto& block = ted.sequenceData.sequences[i].clearance;
CoordsXYZ blockLocation = location + CoordsXYZ{ CoordsXY{ block.x, block.y }.Rotate(direction), 0 };
bool trackFound = false;
@@ -1276,7 +1276,7 @@ void Ride::validateStations()
continue;
const auto& ted2 = GetTrackElementDescriptor(tileElement->AsTrack()->GetTrackType());
if (!ted2.sequences[0].flags.has(SequenceFlag::trackOrigin))
if (!ted2.sequenceData.sequences[0].flags.has(SequenceFlag::trackOrigin))
continue;
trackFound = true;
@@ -1383,7 +1383,7 @@ void Ride::validateStations()
// if the ride entrance is not on a valid side, remove it
const auto& ted = GetTrackElementDescriptor(trackType);
auto connectionSides = ted.sequences[trackSequence].getEntranceConnectionSides();
auto connectionSides = ted.sequenceData.sequences[trackSequence].getEntranceConnectionSides();
if (!(connectionSides & (1 << direction)))
{
continue;
+2 -2
View File
@@ -753,10 +753,10 @@ std::optional<CoordsXYZD> GetTrackSegmentOrigin(const CoordsXYE& posEl)
// Subtract the current sequence's offset
auto sequenceIndex = trackEl->GetSequenceIndex();
if (sequenceIndex >= ted.numSequences)
if (sequenceIndex >= ted.sequenceData.numSequences)
return {};
const auto& trackBlock = ted.sequences[sequenceIndex].clearance;
const auto& trackBlock = ted.sequenceData.sequences[sequenceIndex].clearance;
CoordsXY trackBlockOffset = { trackBlock.x, trackBlock.y };
coords += trackBlockOffset.Rotate(DirectionReverse(direction));
coords.z -= trackBlock.z;
File diff suppressed because it is too large. Load diff
+7 -6
View File
@@ -219,7 +219,8 @@ ResultWithMessage TrackDesign::CreateTrackDesignTrack(TrackDesignState& tds, con
// start.
TileElement* initialMap = trackElement.element;
CoordsXYZ startPos = { trackElement.x, trackElement.y, z + trackCoordinates->zBegin - ted.sequences[0].clearance.z };
CoordsXYZ startPos = { trackElement.x, trackElement.y,
z + trackCoordinates->zBegin - ted.sequenceData.sequences[0].clearance.z };
tds.origin = startPos;
do
@@ -1586,9 +1587,9 @@ static GameActions::Result TrackDesignPlaceRide(
switch (tds.placeOperation)
{
case TrackPlaceOperation::drawOutlines:
for (uint8_t i = 0; i < ted.numSequences; i++)
for (uint8_t i = 0; i < ted.sequenceData.numSequences; i++)
{
const auto& trackBlock = ted.sequences[i].clearance;
const auto& trackBlock = ted.sequenceData.sequences[i].clearance;
auto tile = CoordsXY{ newCoords } + CoordsXY{ trackBlock.x, trackBlock.y }.Rotate(rotation);
TrackDesignUpdatePreviewBounds(tds, { tile, newCoords.z });
TrackDesignAddSelectedTile(tile);
@@ -1597,7 +1598,7 @@ static GameActions::Result TrackDesignPlaceRide(
case TrackPlaceOperation::removeGhost:
{
const TrackCoordinates* trackCoordinates = &ted.coordinates;
int32_t tempZ = newCoords.z - trackCoordinates->zBegin + ted.sequences[0].clearance.z;
int32_t tempZ = newCoords.z - trackCoordinates->zBegin + ted.sequenceData.sequences[0].clearance.z;
auto trackRemoveAction = GameActions::TrackRemoveAction(
trackType, 0, { newCoords, tempZ, static_cast<Direction>(rotation & 3) });
trackRemoveAction.SetFlags(
@@ -1661,9 +1662,9 @@ static GameActions::Result TrackDesignPlaceRide(
case TrackPlaceOperation::getPlaceZ:
{
int32_t tempZ = newCoords.z - ted.coordinates.zBegin;
for (uint8_t i = 0; i < ted.numSequences; i++)
for (uint8_t i = 0; i < ted.sequenceData.numSequences; i++)
{
const auto& trackBlock = ted.sequences[i].clearance;
const auto& trackBlock = ted.sequenceData.sequences[i].clearance;
auto tile = CoordsXY{ newCoords } + CoordsXY{ trackBlock.x, trackBlock.y }.Rotate(rotation);
if (!MapIsLocationValid(tile))
{
+2 -1
View File
@@ -1980,7 +1980,8 @@ void PaintTrack(PaintSession& session, Direction direction, int32_t height, cons
session.InteractionType = ViewportInteractionItem::none;
const auto& ted = GetTrackElementDescriptor(trackType);
if ((trackType == TrackElemType::maze)
|| (trackSequence < ted.numSequences && ted.sequences[trackSequence].flags.has(SequenceFlag::hasHeightMarker)))
|| (trackSequence < ted.sequenceData.numSequences
&& ted.sequenceData.sequences[trackSequence].flags.has(SequenceFlag::hasHeightMarker)))
{
uint16_t ax = ride->getRideTypeDescriptor().Heights.VehicleZOffset;
// 0x1689 represents 0 height there are -127 to 128 heights above and below it
+1 -1
View File
@@ -603,7 +603,7 @@ void Vehicle::Loc6DCE02(const Ride& curRide)
auto trackType = GetTrackType();
const auto& ted = GetTrackElementDescriptor(trackType);
if (!ted.sequences[0].flags.has(SequenceFlag::trackOrigin))
if (!ted.sequenceData.sequences[0].flags.has(SequenceFlag::trackOrigin))
{
return;
}
+3 -2
View File
@@ -114,7 +114,7 @@ void Vehicle::UpdateSceneryDoor() const
{
auto trackType = GetTrackType();
const auto& ted = GetTrackElementDescriptor(trackType);
const auto& trackBlock = ted.sequences[ted.numSequences - 1].clearance;
const auto& trackBlock = ted.sequenceData.sequences[ted.sequenceData.numSequences - 1].clearance;
const TrackCoordinates* trackCoordinates = &ted.coordinates;
auto wallCoords = CoordsXYZ{ x, y, TrackLocation.z - trackBlock.z + trackCoordinates->zEnd }.ToTileStart();
int32_t direction = (GetTrackDirection() + trackCoordinates->rotationEnd) & 3;
@@ -212,7 +212,8 @@ void Vehicle::UpdateSceneryDoorBackwards() const
auto trackType = GetTrackType();
const auto& ted = GetTrackElementDescriptor(trackType);
const TrackCoordinates* trackCoordinates = &ted.coordinates;
auto wallCoords = CoordsXYZ{ TrackLocation, TrackLocation.z - ted.sequences[0].clearance.z + trackCoordinates->zBegin };
auto wallCoords = CoordsXYZ{ TrackLocation,
TrackLocation.z - ted.sequenceData.sequences[0].clearance.z + trackCoordinates->zBegin };
int32_t direction = (GetTrackDirection() + trackCoordinates->rotationBegin) & 3;
direction = DirectionReverse(direction);
+1 -1
View File
@@ -436,7 +436,7 @@ void Vehicle::Sub6DBF3E()
auto trackType = GetTrackType();
const auto& ted = GetTrackElementDescriptor(trackType);
if (!ted.sequences[0].flags.has(SequenceFlag::trackOrigin))
if (!ted.sequenceData.sequences[0].flags.has(SequenceFlag::trackOrigin))
{
return;
}
@@ -235,6 +235,12 @@ namespace OpenRCT2::TrackMetadata
int8_t previewZOffset;
};
struct SequenceTable
{
uint8_t numSequences{};
std::array<SequenceDescriptor, kMaxSequencesPerPiece> sequences;
};
struct TrackElementDescriptor
{
StringId description = kStringIdEmpty;
@@ -252,13 +258,12 @@ namespace OpenRCT2::TrackMetadata
TrackElemType mirrorElement;
TrackFlags flags;
uint8_t numSequences{};
std::array<SequenceDescriptor, kMaxSequencesPerPiece> sequences;
TrackDefinition definition;
SpinFunction spinFunction = SpinFunction::none;
TrackComputeFunction verticalFactor = EvaluatorConst<0>;
TrackComputeFunction lateralFactor = EvaluatorConst<0>;
SequenceTable sequenceData;
};
} // namespace OpenRCT2::TrackMetadata
@@ -568,7 +568,7 @@ namespace OpenRCT2::Scripting
const auto& trackType = el->AsTrack()->GetTrackType();
const auto& ted = GetTrackElementDescriptor(trackType);
const auto& seq0 = ted.sequences[0].clearance;
const auto& seq0 = ted.sequenceData.sequences[0].clearance;
const auto trackLoc = CoordsXYZ(origin->x + seq0.x, origin->y + seq0.y, origin->z + seq0.z);
vehicle->TrackLocation.x = trackLoc.x;
@@ -77,7 +77,7 @@ DukValue ScTrackIterator::previousPosition_get() const
auto ctx = scriptEngine.GetContext();
auto& ted = GetTrackElementDescriptor(_type);
const auto& seq0 = ted.sequences[0].clearance;
const auto& seq0 = ted.sequenceData.sequences[0].clearance;
auto pos = _position + CoordsXYZ(seq0.x, seq0.y, seq0.z);
auto el = MapGetTrackElementAtOfTypeSeq(pos, _type, 0);
@@ -97,7 +97,7 @@ DukValue ScTrackIterator::nextPosition_get() const
auto ctx = scriptEngine.GetContext();
auto& ted = GetTrackElementDescriptor(_type);
const auto& seq0 = ted.sequences[0].clearance;
const auto& seq0 = ted.sequenceData.sequences[0].clearance;
auto pos = _position + CoordsXYZ(seq0.x, seq0.y, seq0.z);
auto el = MapGetTrackElementAtOfTypeSeq(pos, _type, 0);
@@ -116,7 +116,7 @@ DukValue ScTrackIterator::nextPosition_get() const
bool ScTrackIterator::previous()
{
auto& ted = GetTrackElementDescriptor(_type);
const auto& seq0 = ted.sequences[0].clearance;
const auto& seq0 = ted.sequenceData.sequences[0].clearance;
auto pos = _position + CoordsXYZ(seq0.x, seq0.y, seq0.z);
auto el = MapGetTrackElementAtOfTypeSeq(pos, _type, 0);
@@ -142,7 +142,7 @@ bool ScTrackIterator::previous()
bool ScTrackIterator::next()
{
auto& ted = GetTrackElementDescriptor(_type);
const auto& seq0 = ted.sequences[0].clearance;
const auto& seq0 = ted.sequenceData.sequences[0].clearance;
auto pos = _position + CoordsXYZ(seq0.x, seq0.y, seq0.z);
auto el = MapGetTrackElementAtOfTypeSeq(pos, _type, 0);
@@ -158,9 +158,9 @@ DukValue ScTrackSegment::elements_get() const
duk_push_array(ctx);
duk_uarridx_t index = 0;
for (uint8_t i = 0; i < ted.numSequences; i++)
for (uint8_t i = 0; i < ted.sequenceData.numSequences; i++)
{
auto& block = ted.sequences[i].clearance;
auto& block = ted.sequenceData.sequences[i].clearance;
duk_push_object(ctx);
duk_push_number(ctx, block.x);
duk_put_prop_string(ctx, -2, "x");
+1 -1
View File
@@ -98,7 +98,7 @@ static bool landSlopeFitsUnderTrack(int32_t baseZ, uint8_t slope, const TrackEle
const TrackElemType trackElemType = trackElement.GetTrackType();
const auto& ted = TrackMetadata::GetTrackElementDescriptor(trackElemType);
const uint8_t sequenceIndex = trackElemType == TrackElemType::maze ? 0 : trackElement.GetSequenceIndex();
const auto& trackClearances = ted.sequences[sequenceIndex].clearance;
const auto& trackClearances = ted.sequenceData.sequences[sequenceIndex].clearance;
const auto trackQuarters = trackClearances.quarterTile.Rotate(trackElement.GetDirection());
const auto trackQuarterHeights = trackQuarters.GetQuarterHeights(trackElement.GetBaseZ());
const uint8_t trackOccupiedQuarters = trackQuarters.GetBaseQuarterOccupied();
+6 -6
View File
@@ -597,12 +597,12 @@ static void Loc6A6D7E(
const auto trackType = tileElement->AsTrack()->GetTrackType();
const uint8_t trackSequence = tileElement->AsTrack()->GetSequenceIndex();
const auto& ted = GetTrackElementDescriptor(trackType);
if (!ted.sequences[trackSequence].flags.has(SequenceFlag::connectsToPath))
if (!ted.sequenceData.sequences[trackSequence].flags.has(SequenceFlag::connectsToPath))
{
return;
}
uint16_t dx = DirectionReverse((direction - tileElement->GetDirection()) & kTileElementDirectionMask);
auto connectionSides = ted.sequences[trackSequence].getEntranceConnectionSides();
auto connectionSides = ted.sequenceData.sequences[trackSequence].getEntranceConnectionSides();
if (!(connectionSides & (1 << dx)))
{
return;
@@ -683,12 +683,12 @@ static void Loc6A6C85(
const auto trackType = tileElementPos.element->AsTrack()->GetTrackType();
const uint8_t trackSequence = tileElementPos.element->AsTrack()->GetSequenceIndex();
const auto& ted = GetTrackElementDescriptor(trackType);
if (!ted.sequences[trackSequence].flags.has(SequenceFlag::connectsToPath))
if (!ted.sequenceData.sequences[trackSequence].flags.has(SequenceFlag::connectsToPath))
{
return;
}
uint16_t dx = (direction - tileElementPos.element->GetDirection()) & kTileElementDirectionMask;
auto connectionSides = ted.sequences[trackSequence].getEntranceConnectionSides();
auto connectionSides = ted.sequenceData.sequences[trackSequence].getEntranceConnectionSides();
if (!(connectionSides & (1 << dx)))
{
return;
@@ -1692,10 +1692,10 @@ bool TileElementWantsPathConnectionTowards(const TileCoordsXYZD& coords, const T
const auto trackType = tileElement->AsTrack()->GetTrackType();
const uint8_t trackSequence = tileElement->AsTrack()->GetSequenceIndex();
const auto& ted = GetTrackElementDescriptor(trackType);
if (ted.sequences[trackSequence].flags.has(SequenceFlag::connectsToPath))
if (ted.sequenceData.sequences[trackSequence].flags.has(SequenceFlag::connectsToPath))
{
uint16_t dx = ((coords.direction - tileElement->GetDirection()) & kTileElementDirectionMask);
auto connectionSides = ted.sequences[trackSequence].getEntranceConnectionSides();
auto connectionSides = ted.sequenceData.sequences[trackSequence].getEntranceConnectionSides();
if (connectionSides & (1 << dx))
{
// Track element has the flags required for the given direction
+8 -8
View File
@@ -731,11 +731,11 @@ namespace OpenRCT2::TileInspector
const auto& ted = GetTrackElementDescriptor(type);
auto sequenceIndex = trackElement->AsTrack()->GetSequenceIndex();
if (sequenceIndex >= ted.numSequences)
if (sequenceIndex >= ted.sequenceData.numSequences)
return GameActions::Result(
GameActions::Status::invalidParameters, STR_ERR_INVALID_PARAMETER, STR_ERR_TRACK_BLOCK_NOT_FOUND);
const auto& trackBlock = ted.sequences[sequenceIndex].clearance;
const auto& trackBlock = ted.sequenceData.sequences[sequenceIndex].clearance;
uint8_t originDirection = trackElement->GetDirection();
CoordsXY offsets = { trackBlock.x, trackBlock.y };
CoordsXY coords = { originX, originY };
@@ -745,9 +745,9 @@ namespace OpenRCT2::TileInspector
originY = static_cast<int16_t>(coords.y);
originZ -= trackBlock.z;
for (uint8_t i = 0; i < ted.numSequences; i++)
for (uint8_t i = 0; i < ted.sequenceData.numSequences; i++)
{
const auto& trackBlock2 = ted.sequences[i].clearance;
const auto& trackBlock2 = ted.sequenceData.sequences[i].clearance;
CoordsXYZD elem = { originX, originY, originZ + trackBlock2.z, rotation };
offsets.x = trackBlock2.x;
offsets.y = trackBlock2.y;
@@ -815,11 +815,11 @@ namespace OpenRCT2::TileInspector
const auto& ted = GetTrackElementDescriptor(type);
auto sequenceIndex = trackElement->AsTrack()->GetSequenceIndex();
if (sequenceIndex >= ted.numSequences)
if (sequenceIndex >= ted.sequenceData.numSequences)
return GameActions::Result(
GameActions::Status::invalidParameters, STR_ERR_INVALID_PARAMETER, STR_ERR_TRACK_BLOCK_NOT_FOUND);
const auto& trackBlock = ted.sequences[sequenceIndex].clearance;
const auto& trackBlock = ted.sequenceData.sequences[sequenceIndex].clearance;
uint8_t originDirection = trackElement->GetDirection();
CoordsXY offsets = { trackBlock.x, trackBlock.y };
CoordsXY coords = { originX, originY };
@@ -829,9 +829,9 @@ namespace OpenRCT2::TileInspector
originY = static_cast<int16_t>(coords.y);
originZ -= trackBlock.z;
for (uint8_t i = 0; i < ted.numSequences; i++)
for (uint8_t i = 0; i < ted.sequenceData.numSequences; i++)
{
const auto& trackBlock2 = ted.sequences[i].clearance;
const auto& trackBlock2 = ted.sequenceData.sequences[i].clearance;
CoordsXYZD elem = { originX, originY, originZ + trackBlock2.z, rotation };
offsets.x = trackBlock2.x;
offsets.y = trackBlock2.y;