Merge pull request #22453 from Gymnasiast/refactor/track-data-in-namespace

Refactor TrackData.h
This commit is contained in:
Michael Steenbeek authored and GitHub committed 2024-08-04 21:46:43 +02:00
commit ceb04733ee
22 files changed
+8309 -8283

No files matched your search

+8 -8
View File
@@ -62,20 +62,20 @@ namespace OpenRCT2
for (track_type_t trackType : DropdownOrder)
{
const auto& ted = GetTrackElementDescriptor(trackType);
if (!IsTrackEnabled(ted.Definition.Type))
if (!IsTrackEnabled(ted.definition.Type))
continue;
bool entryIsDisabled;
// If the current build orientation (slope, bank, diagonal) matches the track element's, show the piece as enabled
if (state == RideConstructionState::Back)
{
entryIsDisabled = ted.Definition.PitchEnd != buildSlope || ted.Definition.RollEnd != buildBank
|| TrackPieceDirectionIsDiagonal(ted.Coordinates.rotation_end) != buildDirectionIsDiagonal;
entryIsDisabled = ted.definition.PitchEnd != buildSlope || ted.definition.RollEnd != buildBank
|| TrackPieceDirectionIsDiagonal(ted.coordinates.rotation_end) != buildDirectionIsDiagonal;
}
else
{
entryIsDisabled = ted.Definition.PitchStart != buildSlope || ted.Definition.RollStart != buildBank
|| TrackPieceDirectionIsDiagonal(ted.Coordinates.rotation_begin) != buildDirectionIsDiagonal;
entryIsDisabled = ted.definition.PitchStart != buildSlope || ted.definition.RollStart != buildBank
|| TrackPieceDirectionIsDiagonal(ted.coordinates.rotation_begin) != buildDirectionIsDiagonal;
}
// Additional tower bases can only be built if the ride allows for it (elevator)
@@ -85,7 +85,7 @@ namespace OpenRCT2
// Check if a previous element exists, to collate entries if possible
if (!list.Elements.empty()
&& GetTrackElementDescriptor(list.Elements.back().TrackType).Description == ted.Description)
&& GetTrackElementDescriptor(list.Elements.back().TrackType).description == ted.description)
{
// If the current element is disabled, do not add current element.
if (entryIsDisabled)
@@ -125,7 +125,7 @@ namespace OpenRCT2
if (trackElement->GetRideIndex() == gRideEntranceExitPlaceRideIndex)
{
const auto& ted = GetTrackElementDescriptor(trackElement->GetTrackType());
if (std::get<0>(ted.SequenceProperties) & TRACK_SEQUENCE_FLAG_ORIGIN)
if (std::get<0>(ted.sequenceProperties) & TRACK_SEQUENCE_FLAG_ORIGIN)
{
if (trackElement->GetTrackType() == TrackElemType::Maze)
{
@@ -220,7 +220,7 @@ 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());
if (ted.SequenceProperties[trackElement->GetSequenceIndex()] & (1 << direction))
if (ted.sequenceProperties[trackElement->GetSequenceIndex()] & (1 << direction))
{
// if that side of the TrackElement supports stations, the ride entrance is valid and faces away from
// the station
+1 -1
View File
@@ -960,7 +960,7 @@ static Widget window_new_ride_widgets[] = {
int32_t startPieceId = GetRideTypeDescriptor(item.Type).StartTrackPiece;
money64 price = GetRideTypeDescriptor(item.Type).BuildCosts.TrackPrice;
const auto& ted = GetTrackElementDescriptor(startPieceId);
price *= ted.PriceModifier;
price *= ted.priceModifier;
price = (price >> 16) * GetRideTypeDescriptor(item.Type).BuildCosts.PriceEstimateMultiplier;
//
+1 -1
View File
@@ -6977,7 +6977,7 @@ static_assert(std::size(RatingNames) == 6);
auto trackElement = tileElement->AsTrack();
auto trackType = trackElement->GetTrackType();
const auto& ted = GetTrackElementDescriptor(trackType);
if (ted.SequenceProperties[0] & TRACK_SEQUENCE_FLAG_ORIGIN)
if (ted.sequenceProperties[0] & TRACK_SEQUENCE_FLAG_ORIGIN)
{
auto stationIndex = trackElement->GetStationIndex();
return WindowRideOpenStation(*ride, stationIndex);
+9 -9
View File
@@ -1514,7 +1514,7 @@ static Widget _rideConstructionWidgets[] = {
{
const auto& rtd = currentRide->GetRideTypeDescriptor();
const auto& ted = GetTrackElementDescriptor(_currentTrackCurve & ~RideConstructionSpecialPieceSelected);
stringId = ted.Description;
stringId = ted.description;
if (stringId == STR_RAPIDS && rtd.Category != RIDE_CATEGORY_WATER)
{
stringId = STR_LOG_BUMPS;
@@ -2209,7 +2209,7 @@ static Widget _rideConstructionWidgets[] = {
const PreviewTrack* trackBlock;
const auto& ted = GetTrackElementDescriptor(trackType);
trackBlock = ted.Block;
trackBlock = ted.block;
trackDirection &= 3;
gMapSelectionTiles.clear();
while (trackBlock->index != 255)
@@ -2372,7 +2372,7 @@ static Widget _rideConstructionWidgets[] = {
}
const auto& ted = GetTrackElementDescriptor(tileElement->AsTrack()->GetTrackType());
const PreviewTrack* trackBlock = ted.Block;
const PreviewTrack* trackBlock = ted.block;
newCoords->z = (tileElement->GetBaseZ()) - trackBlock->z;
_gotoStartPlacementMode = true;
}
@@ -2515,7 +2515,7 @@ static Widget _rideConstructionWidgets[] = {
track_type_t trackPiece = _specialElementDropdownState.Elements[i].TrackType;
const auto& ted = GetTrackElementDescriptor(trackPiece);
StringId trackPieceStringId = ted.Description;
StringId trackPieceStringId = ted.description;
if (trackPieceStringId == STR_RAPIDS)
{
auto currentRide = GetRide(_currentRideIndex);
@@ -2605,7 +2605,7 @@ static Widget _rideConstructionWidgets[] = {
}
const auto& ted = GetTrackElementDescriptor(trackType);
const auto* trackBlock = ted.Block;
const auto* trackBlock = ted.block;
while ((trackBlock + 1)->index != 0xFF)
trackBlock++;
@@ -2622,7 +2622,7 @@ static Widget _rideConstructionWidgets[] = {
mapCoords.y = 4112 + (rotatedMapCoords.y / 2);
mapCoords.z = 1024 + mapCoords.z;
auto previewZOffset = ted.Definition.PreviewZOffset;
auto previewZOffset = ted.definition.PreviewZOffset;
mapCoords.z -= previewZOffset;
const ScreenCoordsXY rotatedScreenCoords = Translate3DTo2DWithZ(GetCurrentRotation(), mapCoords);
@@ -2668,7 +2668,7 @@ static Widget _rideConstructionWidgets[] = {
tempTrackTileElement.AsTrack()->SetRideIndex(rideIndex);
const auto& ted = GetTrackElementDescriptor(trackType);
const auto* trackBlock = ted.Block;
const auto* trackBlock = ted.block;
const auto* rideEntry = currentRide->GetRideEntry();
auto clearanceHeight = (rideEntry != nullptr) ? rideEntry->Clearance
: currentRide->GetRideTypeDescriptor().Heights.ClearanceHeight;
@@ -3310,7 +3310,7 @@ static Widget _rideConstructionWidgets[] = {
}
// Loc6CC91B:
const auto& ted = GetTrackElementDescriptor(trackType);
trackBlock = ted.Block;
trackBlock = ted.block;
int32_t bx = 0;
do
{
@@ -3546,7 +3546,7 @@ static Widget _rideConstructionWidgets[] = {
if (_trackPlaceZ == 0)
{
const auto& ted = GetTrackElementDescriptor(_currentTrackPieceType);
const PreviewTrack* trackBlock = ted.Block;
const PreviewTrack* trackBlock = ted.block;
int32_t bx = 0;
do
{
+3 -3
View File
@@ -478,7 +478,7 @@ static Widget _trackPlaceWidgets[] = {
{
// Follow a single track piece shape
const auto& ted = GetTrackElementDescriptor(trackElement.type);
const PreviewTrack* trackBlock = ted.Block;
const PreviewTrack* trackBlock = ted.block;
while (trackBlock->index != 255)
{
auto rotatedAndOffsetTrackBlock = curTrackStart
@@ -501,7 +501,7 @@ static Widget _trackPlaceWidgets[] = {
auto bits = trackBlock->var_08.Rotate(curTrackRotation & 3).GetBaseQuarterOccupied();
// Station track is a lighter colour
uint8_t colour = (ted.SequenceProperties[0] & TRACK_SEQUENCE_FLAG_ORIGIN)
uint8_t colour = (ted.sequenceProperties[0] & TRACK_SEQUENCE_FLAG_ORIGIN)
? _PaletteIndexColourStation
: _PaletteIndexColourTrack;
@@ -524,7 +524,7 @@ static Widget _trackPlaceWidgets[] = {
// Change rotation and next position based on track curvature
curTrackRotation &= 3;
const TrackCoordinates* track_coordinate = &ted.Coordinates;
const TrackCoordinates* track_coordinate = &ted.coordinates;
curTrackStart += CoordsXY{ track_coordinate->x, track_coordinate->y }.Rotate(curTrackRotation);
curTrackRotation += track_coordinate->rotation_end - track_coordinate->rotation_begin;
+16 -16
View File
@@ -165,7 +165,7 @@ GameActions::Result TrackPlaceAction::Query() const
&& !GetGameState().Cheats.EnableChainLiftOnAllTrack)
{
const auto& ted = GetTrackElementDescriptor(_trackType);
if (ted.Flags & TRACK_ELEM_FLAG_IS_STEEP_UP)
if (ted.flags & TRACK_ELEM_FLAG_IS_STEEP_UP)
{
return GameActions::Result(
GameActions::Status::Disallowed, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE,
@@ -175,7 +175,7 @@ GameActions::Result TrackPlaceAction::Query() const
}
const auto& ted = GetTrackElementDescriptor(_trackType);
const PreviewTrack* trackBlock = ted.Block;
const PreviewTrack* trackBlock = ted.block;
uint32_t numElements = 0;
// First check if any of the track pieces are outside the park
for (; trackBlock->index != 0xFF; trackBlock++)
@@ -206,7 +206,7 @@ GameActions::Result TrackPlaceAction::Query() const
if (!GetGameState().Cheats.AllowTrackPlaceInvalidHeights)
{
if (ted.Flags & TRACK_ELEM_FLAG_STARTS_AT_HALF_HEIGHT)
if (ted.flags & TRACK_ELEM_FLAG_STARTS_AT_HALF_HEIGHT)
{
if ((_origin.z & 0x0F) != 8)
{
@@ -225,7 +225,7 @@ GameActions::Result TrackPlaceAction::Query() const
}
// If that is not the case, then perform the remaining checks
trackBlock = ted.Block;
trackBlock = ted.block;
auto clearanceHeight = rideEntry->Clearance;
money64 costs = 0;
@@ -277,7 +277,7 @@ GameActions::Result TrackPlaceAction::Query() const
const auto clearanceData = canBuild.GetData<ConstructClearResult>();
uint8_t mapGroundFlags = clearanceData.GroundFlags & (ELEMENT_IS_ABOVE_GROUND | ELEMENT_IS_UNDERGROUND);
if (!(ted.Flags & TRACK_ELEM_FLAG_CAN_BE_PARTLY_UNDERGROUND))
if (!(ted.flags & TRACK_ELEM_FLAG_CAN_BE_PARTLY_UNDERGROUND))
{
if (resultData.GroundFlags != 0 && (resultData.GroundFlags & mapGroundFlags) == 0)
{
@@ -288,7 +288,7 @@ GameActions::Result TrackPlaceAction::Query() const
}
resultData.GroundFlags = mapGroundFlags;
if (ted.Flags & TRACK_ELEM_FLAG_ONLY_ABOVE_GROUND)
if (ted.flags & TRACK_ELEM_FLAG_ONLY_ABOVE_GROUND)
{
if (resultData.GroundFlags & ELEMENT_IS_UNDERGROUND)
{
@@ -298,7 +298,7 @@ GameActions::Result TrackPlaceAction::Query() const
}
}
if (ted.Flags & TRACK_ELEM_FLAG_ONLY_UNDERWATER)
if (ted.flags & TRACK_ELEM_FLAG_ONLY_UNDERWATER)
{ // No element has this flag
if (clearanceData.GroundFlags & ELEMENT_IS_UNDERWATER)
{
@@ -353,7 +353,7 @@ GameActions::Result TrackPlaceAction::Query() const
}
}
int32_t entranceDirections = std::get<0>(ted.SequenceProperties);
int32_t entranceDirections = std::get<0>(ted.sequenceProperties);
if ((entranceDirections & TRACK_SEQUENCE_FLAG_ORIGIN) && trackBlock->index == 0)
{
const auto addElementResult = TrackAddStationElement(
@@ -411,7 +411,7 @@ GameActions::Result TrackPlaceAction::Query() const
}
money64 price = ride->GetRideTypeDescriptor().BuildCosts.TrackPrice;
price *= ted.PriceModifier;
price *= ted.priceModifier;
price >>= 16;
res.Cost = costs + supportCosts + price;
@@ -449,11 +449,11 @@ GameActions::Result TrackPlaceAction::Execute() const
uint32_t rideTypeFlags = ride->GetRideTypeDescriptor().Flags;
const auto& ted = GetTrackElementDescriptor(_trackType);
const auto& wallEdges = ted.SequenceElementAllowedWallEdges;
const auto& wallEdges = ted.sequenceElementAllowedWallEdges;
money64 costs = 0;
money64 supportCosts = 0;
const PreviewTrack* trackBlock = ted.Block;
const PreviewTrack* trackBlock = ted.block;
auto clearanceHeight = rideEntry->Clearance;
CoordsXYZ originLocation = CoordsXYZ{ _origin.x, _origin.y, _origin.z }
+ CoordsXYZ{ CoordsXY{ trackBlock->x, trackBlock->y }.Rotate(_origin.direction), trackBlock->z };
@@ -526,7 +526,7 @@ GameActions::Result TrackPlaceAction::Execute() const
const auto clearanceData = canBuild.GetData<ConstructClearResult>();
uint8_t mapGroundFlags = clearanceData.GroundFlags & (ELEMENT_IS_ABOVE_GROUND | ELEMENT_IS_UNDERGROUND);
if (!(ted.Flags & TRACK_ELEM_FLAG_CAN_BE_PARTLY_UNDERGROUND))
if (!(ted.flags & TRACK_ELEM_FLAG_CAN_BE_PARTLY_UNDERGROUND))
{
if (resultData.GroundFlags != 0 && (resultData.GroundFlags & mapGroundFlags) == 0)
{
@@ -560,7 +560,7 @@ GameActions::Result TrackPlaceAction::Execute() const
{
if (!(GetFlags() & GAME_COMMAND_FLAG_NO_SPEND))
{
entranceDirections = std::get<0>(ted.SequenceProperties);
entranceDirections = std::get<0>(ted.sequenceProperties);
}
}
@@ -627,7 +627,7 @@ GameActions::Result TrackPlaceAction::Execute() const
}
trackElement->SetColourScheme(static_cast<RideColourScheme>(_colour));
entranceDirections = std::get<0>(ted.SequenceProperties);
entranceDirections = std::get<0>(ted.sequenceProperties);
if (entranceDirections & TRACK_SEQUENCE_FLAG_CONNECTS_TO_PATH)
{
uint32_t availableDirections = entranceDirections & 0x0F;
@@ -734,7 +734,7 @@ GameActions::Result TrackPlaceAction::Execute() const
}
money64 price = ride->GetRideTypeDescriptor().BuildCosts.TrackPrice;
price *= ted.PriceModifier;
price *= ted.priceModifier;
price >>= 16;
res.Cost = costs + supportCosts + price;
@@ -746,7 +746,7 @@ GameActions::Result TrackPlaceAction::Execute() const
bool TrackPlaceAction::CheckMapCapacity(int16_t numTiles) const
{
const auto& ted = GetTrackElementDescriptor(_trackType);
for (const PreviewTrack* trackBlock = ted.Block; trackBlock->index != 0xFF; trackBlock++)
for (const PreviewTrack* trackBlock = ted.block; trackBlock->index != 0xFF; trackBlock++)
{
auto rotatedTrack = CoordsXY{ trackBlock->x, trackBlock->y }.Rotate(_origin.direction);
+6 -6
View File
@@ -162,7 +162,7 @@ GameActions::Result TrackRemoveAction::Query() const
money64 supportCosts = 0;
trackBlock = ted.Block;
trackBlock = ted.block;
for (; trackBlock->index != 255; trackBlock++)
{
rotatedTrack = CoordsXYZ{ CoordsXY{ trackBlock->x, trackBlock->y }.Rotate(startLoc.direction), trackBlock->z };
@@ -213,7 +213,7 @@ GameActions::Result TrackRemoveAction::Query() const
GameActions::Status::Unknown, STR_RIDE_CONSTRUCTION_CANT_REMOVE_THIS, STR_ERR_TRACK_ELEMENT_NOT_FOUND);
}
int32_t entranceDirections = std::get<0>(ted.SequenceProperties);
int32_t entranceDirections = std::get<0>(ted.sequenceProperties);
if (entranceDirections & TRACK_SEQUENCE_FLAG_ORIGIN && (tileElement->AsTrack()->GetSequenceIndex() == 0))
{
const auto removeElementResult = TrackRemoveStationElement({ mapLoc, _origin.direction }, rideIndex, 0);
@@ -242,7 +242,7 @@ GameActions::Result TrackRemoveAction::Query() const
}
money64 price = ride->GetRideTypeDescriptor().BuildCosts.TrackPrice;
price *= ted.PriceModifier;
price *= ted.priceModifier;
price >>= 16;
price = supportCosts + price;
if (ride->lifecycle_flags & RIDE_LIFECYCLE_EVER_BEEN_OPENED)
@@ -341,7 +341,7 @@ GameActions::Result TrackRemoveAction::Execute() const
money64 supportCosts = 0;
trackBlock = ted.Block;
trackBlock = ted.block;
for (; trackBlock->index != 255; trackBlock++)
{
rotatedTrackLoc = CoordsXYZ{ CoordsXY{ trackBlock->x, trackBlock->y }.Rotate(startLoc.direction), trackBlock->z };
@@ -387,7 +387,7 @@ GameActions::Result TrackRemoveAction::Execute() const
GameActions::Status::Unknown, STR_RIDE_CONSTRUCTION_CANT_REMOVE_THIS, STR_ERR_TRACK_ELEMENT_NOT_FOUND);
}
int32_t entranceDirections = std::get<0>(ted.SequenceProperties);
int32_t entranceDirections = std::get<0>(ted.sequenceProperties);
if (entranceDirections & TRACK_SEQUENCE_FLAG_ORIGIN && (tileElement->AsTrack()->GetSequenceIndex() == 0))
{
const auto removeElementResult = TrackRemoveStationElement({ mapLoc, _origin.direction }, rideIndex, 0);
@@ -493,7 +493,7 @@ GameActions::Result TrackRemoveAction::Execute() const
}
money64 price = ride->GetRideTypeDescriptor().BuildCosts.TrackPrice;
price *= ted.PriceModifier;
price *= ted.priceModifier;
price >>= 16;
price = supportCosts + price;
if (ride->lifecycle_flags & RIDE_LIFECYCLE_EVER_BEEN_OPENED)
+10 -10
View File
@@ -448,20 +448,20 @@ bool WallPlaceAction::WallCheckObstructionWithTrack(
int32_t z;
if (sequence == 0)
{
if (std::get<0>(ted.SequenceProperties) & TRACK_SEQUENCE_FLAG_DISALLOW_DOORS)
if (std::get<0>(ted.sequenceProperties) & TRACK_SEQUENCE_FLAG_DISALLOW_DOORS)
{
return false;
}
if (ted.Definition.RollStart == TrackRoll::None)
if (ted.definition.RollStart == TrackRoll::None)
{
if (!(ted.Coordinates.rotation_begin & 4))
if (!(ted.coordinates.rotation_begin & 4))
{
direction = DirectionReverse(trackElement->GetDirection());
if (direction == _edge)
{
const PreviewTrack* trackBlock = ted.GetBlockForSequence(sequence);
z = ted.Coordinates.z_begin;
z = ted.coordinates.z_begin;
z = trackElement->BaseHeight + ((z - trackBlock->z) * 8);
if (z == z0)
{
@@ -472,31 +472,31 @@ bool WallPlaceAction::WallCheckObstructionWithTrack(
}
}
const PreviewTrack* trackBlock = &ted.Block[sequence + 1];
const PreviewTrack* trackBlock = &ted.block[sequence + 1];
if (trackBlock->index != 0xFF)
{
return false;
}
if (ted.Definition.RollEnd != TrackRoll::None)
if (ted.definition.RollEnd != TrackRoll::None)
{
return false;
}
direction = ted.Coordinates.rotation_end;
direction = ted.coordinates.rotation_end;
if (direction & 4)
{
return false;
}
direction = (trackElement->GetDirection() + ted.Coordinates.rotation_end) & kTileElementDirectionMask;
direction = (trackElement->GetDirection() + ted.coordinates.rotation_end) & kTileElementDirectionMask;
if (direction != _edge)
{
return false;
}
trackBlock = ted.GetBlockForSequence(sequence);
z = ted.Coordinates.z_end;
z = ted.coordinates.z_end;
z = trackElement->BaseHeight + ((z - trackBlock->z) * 8);
return z == z0;
}
@@ -605,7 +605,7 @@ bool WallPlaceAction::TrackIsAllowedWallEdges(
if (!GetRideTypeDescriptor(rideType).HasFlag(RIDE_TYPE_FLAG_TRACK_NO_WALLS))
{
const auto& ted = GetTrackElementDescriptor(trackType);
if (ted.SequenceElementAllowedWallEdges[trackSequence] & (1 << direction))
if (ted.sequenceElementAllowedWallEdges[trackSequence] & (1 << direction))
{
return true;
}
+1 -1
View File
@@ -22,7 +22,7 @@ namespace OpenRCT2
money64 MazeCalculateCost(money64 constructionCost, const Ride& ride, const CoordsXYZ& loc)
{
const auto& ted = GetTrackElementDescriptor(TrackElemType::Maze);
money64 price = (ride.GetRideTypeDescriptor().BuildCosts.TrackPrice * ted.PriceModifier) >> 16;
money64 price = (ride.GetRideTypeDescriptor().BuildCosts.TrackPrice * ted.priceModifier) >> 16;
auto surfaceElement = MapGetSurfaceElementAt(loc);
auto heightDifference = (loc.z - surfaceElement->GetBaseZ()) / kCoordsZPerTinyZ;
+18 -18
View File
@@ -496,7 +496,7 @@ bool RideTryGetOriginElement(const Ride& ride, CoordsXYE* output)
bool specialTrackPiece
= (it.element->AsTrack()->GetTrackType() != TrackElemType::BeginStation
&& it.element->AsTrack()->GetTrackType() != TrackElemType::MiddleStation
&& (std::get<0>(ted.SequenceProperties) & TRACK_SEQUENCE_FLAG_ORIGIN));
&& (std::get<0>(ted.sequenceProperties) & TRACK_SEQUENCE_FLAG_ORIGIN));
// Set result tile to this track piece if first found track or a ???
if (resultTileElement == nullptr || specialTrackPiece)
@@ -563,11 +563,11 @@ bool TrackBlockGetNextFromZero(
continue;
const auto& ted = GetTrackElementDescriptor(trackElement->GetTrackType());
const auto* nextTrackBlock = ted.Block;
const auto* nextTrackBlock = ted.block;
if (nextTrackBlock == nullptr)
continue;
const auto& nextTrackCoordinate = ted.Coordinates;
const auto& nextTrackCoordinate = ted.coordinates;
uint8_t nextRotation = tileElement->GetDirectionWithOffset(nextTrackCoordinate.rotation_begin)
| (nextTrackCoordinate.rotation_begin & TRACK_BLOCK_2);
@@ -617,7 +617,7 @@ bool TrackBlockGetNext(CoordsXYE* input, CoordsXYE* output, int32_t* z, int32_t*
if (trackBlock == nullptr)
return false;
const auto& trackCoordinate = ted.Coordinates;
const auto& trackCoordinate = ted.coordinates;
int32_t x = input->x;
int32_t y = input->y;
@@ -680,7 +680,7 @@ bool TrackBlockGetPreviousFromZero(
continue;
const auto* ted = &GetTrackElementDescriptor(trackElement->GetTrackType());
const auto& nextTrackCoordinate = ted->Coordinates;
const auto& nextTrackCoordinate = ted->coordinates;
const auto* nextTrackBlock = ted->GetBlockForSequence(trackElement->GetSequenceIndex());
if (nextTrackBlock == nullptr)
@@ -715,7 +715,7 @@ bool TrackBlockGetPreviousFromZero(
outTrackBeginEnd->begin_z = tileElement->GetBaseZ();
ted = &GetTrackElementDescriptor(trackElement->GetTrackType());
const auto* nextTrackBlock2 = ted->Block;
const auto* nextTrackBlock2 = ted->block;
if (nextTrackBlock2 == nullptr)
continue;
@@ -761,7 +761,7 @@ bool TrackBlockGetPrevious(const CoordsXYE& trackPos, TrackBeginEnd* outTrackBeg
if (trackBlock == nullptr)
return false;
auto trackCoordinate = ted.Coordinates;
auto trackCoordinate = ted.coordinates;
int32_t z = trackElement->GetBaseZ();
@@ -2385,7 +2385,7 @@ static void RideShopConnected(const Ride& ride)
return;
const auto& ted = GetTrackElementDescriptor(track_type);
uint8_t entrance_directions = std::get<0>(ted.SequenceProperties) & 0xF;
uint8_t entrance_directions = std::get<0>(ted.sequenceProperties) & 0xF;
uint8_t tile_direction = trackElement->GetDirection();
entrance_directions = Numerics::rol4(entrance_directions, tile_direction);
@@ -2809,7 +2809,7 @@ static bool RideCheckTrackContainsInversions(const CoordsXYE& input, CoordsXYE*
{
auto trackType = it.current.element->AsTrack()->GetTrackType();
const auto& ted = GetTrackElementDescriptor(trackType);
if (ted.Flags & TRACK_ELEM_FLAG_INVERSION_TO_NORMAL)
if (ted.flags & TRACK_ELEM_FLAG_INVERSION_TO_NORMAL)
{
*output = it.current;
return true;
@@ -2869,7 +2869,7 @@ static bool RideCheckTrackContainsBanked(const CoordsXYE& input, CoordsXYE* outp
{
auto trackType = it.current.element->AsTrack()->GetTrackType();
const auto& ted = GetTrackElementDescriptor(trackType);
if (ted.Flags & TRACK_ELEM_FLAG_BANKED)
if (ted.flags & TRACK_ELEM_FLAG_BANKED)
{
*output = it.current;
return true;
@@ -2919,7 +2919,7 @@ static int32_t RideCheckStationLength(const CoordsXYE& input, CoordsXYE* output)
do
{
const auto& ted = GetTrackElementDescriptor(output->element->AsTrack()->GetTrackType());
if (std::get<0>(ted.SequenceProperties) & TRACK_SEQUENCE_FLAG_ORIGIN)
if (std::get<0>(ted.sequenceProperties) & TRACK_SEQUENCE_FLAG_ORIGIN)
{
num_station_elements++;
last_good_station = *output;
@@ -2967,7 +2967,7 @@ static bool RideCheckStartAndEndIsStation(const CoordsXYE& input)
TrackGetBack(input, &trackBack);
auto trackType = trackBack.element->AsTrack()->GetTrackType();
const auto* ted = &GetTrackElementDescriptor(trackType);
if (!(std::get<0>(ted->SequenceProperties) & TRACK_SEQUENCE_FLAG_ORIGIN))
if (!(std::get<0>(ted->sequenceProperties) & TRACK_SEQUENCE_FLAG_ORIGIN))
{
return false;
}
@@ -2977,7 +2977,7 @@ static bool RideCheckStartAndEndIsStation(const CoordsXYE& input)
TrackGetFront(input, &trackFront);
trackType = trackFront.element->AsTrack()->GetTrackType();
ted = &GetTrackElementDescriptor(trackType);
if (!(std::get<0>(ted->SequenceProperties) & TRACK_SEQUENCE_FLAG_ORIGIN))
if (!(std::get<0>(ted->sequenceProperties) & TRACK_SEQUENCE_FLAG_ORIGIN))
{
return false;
}
@@ -3015,7 +3015,7 @@ static void RideSetBoatHireReturnPoint(Ride& ride, const CoordsXYE& startElement
trackType = returnPos.element->AsTrack()->GetTrackType();
const auto& ted = GetTrackElementDescriptor(trackType);
int32_t elementReturnDirection = ted.Coordinates.rotation_begin;
int32_t elementReturnDirection = ted.coordinates.rotation_begin;
ride.boat_hire_return_direction = returnPos.element->GetDirectionWithOffset(elementReturnDirection);
ride.boat_hire_return_position = TileCoordsXY{ returnPos };
}
@@ -3783,7 +3783,7 @@ static ResultWithMessage RideInitialiseCableLiftTrack(const Ride& ride, bool isA
continue;
const auto& ted = GetTrackElementDescriptor(tileElement->AsTrack()->GetTrackType());
if (!(std::get<0>(ted.SequenceProperties) & TRACK_SEQUENCE_FLAG_ORIGIN))
if (!(std::get<0>(ted.sequenceProperties) & TRACK_SEQUENCE_FLAG_ORIGIN))
{
continue;
}
@@ -4021,7 +4021,7 @@ TrackElement* Ride::GetOriginElement(StationIndex stationIndex) const
auto* trackElement = tileElement->AsTrack();
const auto& ted = GetTrackElementDescriptor(trackElement->GetTrackType());
if (!(std::get<0>(ted.SequenceProperties) & TRACK_SEQUENCE_FLAG_ORIGIN))
if (!(std::get<0>(ted.sequenceProperties) & TRACK_SEQUENCE_FLAG_ORIGIN))
continue;
if (trackElement->GetRideIndex() == id)
@@ -4990,7 +4990,7 @@ static int32_t RideGetTrackLength(const Ride& ride)
trackType = tileElement->AsTrack()->GetTrackType();
const auto& ted = GetTrackElementDescriptor(trackType);
if (!(std::get<0>(ted.SequenceProperties) & TRACK_SEQUENCE_FLAG_ORIGIN))
if (!(std::get<0>(ted.sequenceProperties) & TRACK_SEQUENCE_FLAG_ORIGIN))
continue;
if (tileElement->GetBaseZ() != trackStart.z)
@@ -5025,7 +5025,7 @@ static int32_t RideGetTrackLength(const Ride& ride)
{
trackType = it.current.element->AsTrack()->GetTrackType();
const auto& ted = GetTrackElementDescriptor(trackType);
result += ted.PieceLength;
result += ted.pieceLength;
moveSlowIt = !moveSlowIt;
if (moveSlowIt)
+14 -14
View File
@@ -408,17 +408,17 @@ std::optional<CoordsXYZ> GetTrackElementOriginAndApplyChanges(
assert(block0 != nullptr);
retCoordsXYZ.z += block0->z;
for (int32_t i = 0; ted.Block[i].index != 0xFF; ++i)
for (int32_t i = 0; ted.block[i].index != 0xFF; ++i)
{
CoordsXY cur = { retCoordsXYZ };
offsets = { ted.Block[i].x, ted.Block[i].y };
offsets = { ted.block[i].x, ted.block[i].y };
cur += offsets.Rotate(mapDirection);
int32_t cur_z = start_z + ted.Block[i].z;
int32_t cur_z = start_z + ted.block[i].z;
MapInvalidateTileFull(cur);
trackElement = MapGetTrackElementAtOfTypeSeq(
{ cur, cur_z, static_cast<Direction>(location.direction) }, type, ted.Block[i].index);
{ cur, cur_z, static_cast<Direction>(location.direction) }, type, ted.block[i].index);
if (trackElement == nullptr)
{
return std::nullopt;
@@ -679,9 +679,9 @@ void RideConstructionSetDefaultNextPiece()
}
ted = &GetTrackElementDescriptor(trackType);
curve = ted->CurveChain.next;
auto bank = ted->Definition.RollEnd;
auto slope = ted->Definition.PitchEnd;
curve = ted->curveChain.next;
auto bank = ted->definition.RollEnd;
auto slope = ted->definition.PitchEnd;
// Set track curve
_currentTrackCurve = curve;
@@ -728,9 +728,9 @@ void RideConstructionSetDefaultNextPiece()
}
ted = &GetTrackElementDescriptor(trackType);
curve = ted->CurveChain.previous;
auto bank = ted->Definition.RollStart;
auto slope = ted->Definition.PitchStart;
curve = ted->curveChain.previous;
auto bank = ted->definition.RollStart;
auto slope = ted->definition.PitchStart;
// Set track curve
_currentTrackCurve = curve;
@@ -1253,7 +1253,7 @@ void Ride::ValidateStations()
ted = &GetTrackElementDescriptor(tileElement->AsTrack()->GetTrackType());
// keep searching for a station piece (coaster station, tower ride base, shops, and flat ride base)
if (!(std::get<0>(ted->SequenceProperties) & TRACK_SEQUENCE_FLAG_ORIGIN))
if (!(std::get<0>(ted->sequenceProperties) & TRACK_SEQUENCE_FLAG_ORIGIN))
continue;
trackFound = true;
@@ -1285,7 +1285,7 @@ void Ride::ValidateStations()
}
// update all the blocks with StationIndex
ted = &GetTrackElementDescriptor(tileElement->AsTrack()->GetTrackType());
const PreviewTrack* trackBlock = ted->Block;
const PreviewTrack* trackBlock = ted->block;
while ((++trackBlock)->index != 0xFF)
{
CoordsXYZ blockLocation = location + CoordsXYZ{ CoordsXY{ trackBlock->x, trackBlock->y }.Rotate(direction), 0 };
@@ -1303,7 +1303,7 @@ void Ride::ValidateStations()
continue;
ted = &GetTrackElementDescriptor(tileElement->AsTrack()->GetTrackType());
if (!(std::get<0>(ted->SequenceProperties) & TRACK_SEQUENCE_FLAG_ORIGIN))
if (!(std::get<0>(ted->sequenceProperties) & TRACK_SEQUENCE_FLAG_ORIGIN))
continue;
trackFound = true;
@@ -1410,7 +1410,7 @@ void Ride::ValidateStations()
// if the ride entrance is not on a valid side, remove it
ted = &GetTrackElementDescriptor(trackType);
if (!(ted->SequenceProperties[trackSequence] & (1 << direction)))
if (!(ted->sequenceProperties[trackSequence] & (1 << direction)))
{
continue;
}
+7 -7
View File
@@ -44,13 +44,13 @@ using namespace OpenRCT2::TrackMetaData;
PitchAndRoll TrackPitchAndRollStart(track_type_t trackType)
{
const auto& ted = GetTrackElementDescriptor(trackType);
return { ted.Definition.PitchStart, ted.Definition.RollStart };
return { ted.definition.PitchStart, ted.definition.RollStart };
}
PitchAndRoll TrackPitchAndRollEnd(track_type_t trackType)
{
const auto& ted = GetTrackElementDescriptor(trackType);
return { ted.Definition.PitchEnd, ted.Definition.RollEnd };
return { ted.definition.PitchEnd, ted.definition.RollEnd };
}
/**
@@ -60,14 +60,14 @@ int32_t TrackIsConnectedByShape(TileElement* a, TileElement* b)
{
auto trackType = a->AsTrack()->GetTrackType();
const auto* ted = &GetTrackElementDescriptor(trackType);
auto aBank = ted->Definition.RollEnd;
auto aAngle = ted->Definition.PitchEnd;
auto aBank = ted->definition.RollEnd;
auto aAngle = ted->definition.PitchEnd;
aBank = TrackGetActualBank(a, aBank);
trackType = b->AsTrack()->GetTrackType();
ted = &GetTrackElementDescriptor(trackType);
auto bBank = ted->Definition.RollStart;
auto bAngle = ted->Definition.PitchStart;
auto bBank = ted->definition.RollStart;
auto bAngle = ted->definition.PitchStart;
bBank = TrackGetActualBank(b, bBank);
return aBank == bBank && aAngle == bAngle;
@@ -601,7 +601,7 @@ TrackRoll TrackGetActualBank3(bool useInvertedSprites, TileElement* tileElement)
{
auto trackType = tileElement->AsTrack()->GetTrackType();
const auto& ted = GetTrackElementDescriptor(trackType);
auto bankStart = ted.Definition.RollStart;
auto bankStart = ted.definition.RollStart;
auto ride = GetRide(tileElement->AsTrack()->GetRideIndex());
if (ride == nullptr)
return bankStart;
File diff suppressed because it is too large. Load diff
+95 -98
View File
@@ -11,105 +11,102 @@
#include "Track.h"
constexpr uint8_t MaxSequencesPerPiece = 16;
// 0x009968BB, 0x009968BC, 0x009968BD, 0x009968BF, 0x009968C1, 0x009968C3
struct TrackCurveChain
namespace OpenRCT2::TrackMetaData
{
int32_t next;
int32_t previous;
};
constexpr uint8_t kMaxSequencesPerPiece = 16;
struct TrackDescriptor
{
bool starts_diagonal;
TrackPitch slope_start;
TrackRoll RollStart;
TrackCurve track_curve;
TrackPitch slope_end;
TrackRoll RollEnd;
track_type_t track_element;
};
// 0x009968BB, 0x009968BC, 0x009968BD, 0x009968BF, 0x009968C1, 0x009968C3
enum
{
NO_SPIN,
L8_SPIN,
R8_SPIN,
LR_SPIN,
RL_SPIN,
L7_SPIN,
R7_SPIN,
L5_SPIN,
R5_SPIN,
RC_SPIN, // Rotation Control Spin
SP_SPIN, // Special rapids Spin
L9_SPIN,
R9_SPIN
};
extern const TrackDescriptor gTrackDescriptors[186];
struct DodgemsTrackSize
{
uint8_t left;
uint8_t top;
uint8_t right;
uint8_t bottom;
};
constexpr DodgemsTrackSize GetDodgemsTrackSize(track_type_t type)
{
if (type == OpenRCT2::TrackElemType::FlatTrack2x2)
return { 4, 4, 59, 59 };
if (type == OpenRCT2::TrackElemType::FlatTrack4x4)
return { 4, 4, 123, 123 };
if (type == OpenRCT2::TrackElemType::FlatTrack2x4)
return { 4, 4, 59, 123 };
return { 0, 0, 0, 0 };
}
using TrackComputeFunction = int32_t (*)(const int16_t);
struct TrackElementDescriptor
{
StringId Description;
TrackCoordinates Coordinates;
PreviewTrack* Block;
uint8_t PieceLength;
TrackCurveChain CurveChain;
track_type_t AlternativeType;
// Price Modifier should be used as in the following calculation:
// (RideTrackPrice * TED::PriceModifier) / 65536
uint32_t PriceModifier;
track_type_t MirrorElement;
uint32_t HeightMarkerPositions;
uint32_t Flags;
std::array<uint8_t, MaxSequencesPerPiece> SequenceElementAllowedWallEdges;
std::array<uint8_t, MaxSequencesPerPiece> SequenceProperties;
TrackDefinition Definition;
uint8_t SpinFunction;
TrackComputeFunction VerticalFactor;
TrackComputeFunction LateralFactor;
/**
* Retrieves the block for the given sequence. This method safely handles
* out-of-bounds sequence indices.
*
* @param sequenceIndex
* @return The track block, or nullptr if it doesn’t exist.
*/
const PreviewTrack* GetBlockForSequence(uint8_t sequenceIndex) const;
};
namespace OpenRCT2
{
namespace TrackMetaData
struct TrackCurveChain
{
const TrackElementDescriptor& GetTrackElementDescriptor(const uint32_t type);
} // namespace TrackMetaData
} // namespace OpenRCT2
int32_t next;
int32_t previous;
};
struct TrackDescriptor
{
bool startsDiagonally;
TrackPitch slopeStart;
TrackRoll rollStart;
TrackCurve trackCurve;
TrackPitch slopeEnd;
TrackRoll rollEnd;
track_type_t trackElement;
};
enum class SpinFunction : uint8_t
{
None,
L8,
R8,
LR,
RL,
L7,
R7,
L5,
R5,
RC, // Rotation Control Spin
SP, // Special rapids Spin
L9,
R9
};
extern const TrackDescriptor gTrackDescriptors[186];
struct DodgemsTrackSize
{
uint8_t left;
uint8_t top;
uint8_t right;
uint8_t bottom;
};
constexpr DodgemsTrackSize GetDodgemsTrackSize(track_type_t type)
{
if (type == OpenRCT2::TrackElemType::FlatTrack2x2)
return { 4, 4, 59, 59 };
if (type == OpenRCT2::TrackElemType::FlatTrack4x4)
return { 4, 4, 123, 123 };
if (type == OpenRCT2::TrackElemType::FlatTrack2x4)
return { 4, 4, 59, 123 };
return { 0, 0, 0, 0 };
}
using TrackComputeFunction = int32_t (*)(const int16_t);
struct TrackElementDescriptor
{
StringId description;
TrackCoordinates coordinates;
PreviewTrack* block;
uint8_t pieceLength;
TrackCurveChain curveChain;
track_type_t alternativeType;
// Price Modifier should be used as in the following calculation:
// (RideTrackPrice * TED::PriceModifier) / 65536
uint32_t priceModifier;
track_type_t mirrorElement;
uint32_t heightMarkerPositions;
uint32_t flags;
std::array<uint8_t, kMaxSequencesPerPiece> sequenceElementAllowedWallEdges;
std::array<uint8_t, kMaxSequencesPerPiece> sequenceProperties;
TrackDefinition definition;
SpinFunction spinFunction;
TrackComputeFunction verticalFactor;
TrackComputeFunction lateralFactor;
/**
* Retrieves the block for the given sequence. This method safely handles
* out-of-bounds sequence indices.
*
* @param sequenceIndex
* @return The track block, or nullptr if it doesn’t exist.
*/
const PreviewTrack* GetBlockForSequence(uint8_t sequenceIndex) const;
};
const TrackElementDescriptor& GetTrackElementDescriptor(const uint32_t type);
} // namespace OpenRCT2::TrackMetaData
+10 -10
View File
@@ -203,8 +203,8 @@ ResultWithMessage TrackDesign::CreateTrackDesignTrack(TrackDesignState& tds, con
z = newCoords->z;
const auto& ted = GetTrackElementDescriptor(trackElement.element->AsTrack()->GetTrackType());
const TrackCoordinates* trackCoordinates = &ted.Coordinates;
const auto* trackBlock = ted.Block;
const TrackCoordinates* trackCoordinates = &ted.coordinates;
const auto* trackBlock = ted.block;
// Used in the following loop to know when we have
// completed all of the elements and are back at the
// start.
@@ -866,7 +866,7 @@ static void TrackDesignMirrorRide(TrackDesign& td)
for (auto& track : td.trackElements)
{
const auto& ted = GetTrackElementDescriptor(track.type);
track.type = ted.MirrorElement;
track.type = ted.mirrorElement;
}
}
@@ -1565,7 +1565,7 @@ static GameActions::Result TrackDesignPlaceRide(
switch (tds.placeOperation)
{
case TrackPlaceOperation::drawOutlines:
for (const PreviewTrack* trackBlock = ted.Block; trackBlock->index != 0xFF; trackBlock++)
for (const PreviewTrack* trackBlock = ted.block; trackBlock->index != 0xFF; trackBlock++)
{
auto tile = CoordsXY{ newCoords } + CoordsXY{ trackBlock->x, trackBlock->y }.Rotate(rotation);
TrackDesignUpdatePreviewBounds(tds, { tile, newCoords.z });
@@ -1574,8 +1574,8 @@ static GameActions::Result TrackDesignPlaceRide(
break;
case TrackPlaceOperation::removeGhost:
{
const TrackCoordinates* trackCoordinates = &ted.Coordinates;
const PreviewTrack* trackBlock = ted.Block;
const TrackCoordinates* trackCoordinates = &ted.coordinates;
const PreviewTrack* trackBlock = ted.block;
int32_t tempZ = newCoords.z - trackCoordinates->z_begin + trackBlock->z;
auto trackRemoveAction = TrackRemoveAction(
trackType, 0, { newCoords, tempZ, static_cast<Direction>(rotation & 3) });
@@ -1590,7 +1590,7 @@ static GameActions::Result TrackDesignPlaceRide(
case TrackPlaceOperation::placeGhost:
case TrackPlaceOperation::placeTrackPreview:
{
const TrackCoordinates* trackCoordinates = &ted.Coordinates;
const TrackCoordinates* trackCoordinates = &ted.coordinates;
// di
int16_t tempZ = newCoords.z - trackCoordinates->z_begin;
@@ -1643,8 +1643,8 @@ static GameActions::Result TrackDesignPlaceRide(
}
case TrackPlaceOperation::getPlaceZ:
{
int32_t tempZ = newCoords.z - ted.Coordinates.z_begin;
for (const PreviewTrack* trackBlock = ted.Block; trackBlock->index != 0xFF; trackBlock++)
int32_t tempZ = newCoords.z - ted.coordinates.z_begin;
for (const PreviewTrack* trackBlock = ted.block; trackBlock->index != 0xFF; trackBlock++)
{
auto tile = CoordsXY{ newCoords } + CoordsXY{ trackBlock->x, trackBlock->y }.Rotate(rotation);
if (!MapIsLocationValid(tile))
@@ -1685,7 +1685,7 @@ static GameActions::Result TrackDesignPlaceRide(
}
}
const TrackCoordinates& track_coordinates = ted.Coordinates;
const TrackCoordinates& track_coordinates = ted.coordinates;
auto offsetAndRotatedTrack = CoordsXY{ newCoords }
+ CoordsXY{ track_coordinates.x, track_coordinates.y }.Rotate(rotation);
+1 -1
View File
@@ -1975,7 +1975,7 @@ void PaintTrack(PaintSession& session, Direction direction, int32_t height, cons
{
session.InteractionType = ViewportInteractionItem::None;
const auto& ted = GetTrackElementDescriptor(trackType);
if (ted.HeightMarkerPositions & (1 << trackSequence))
if (ted.heightMarkerPositions & (1 << trackSequence))
{
uint16_t ax = ride->GetRideTypeDescriptor().Heights.VehicleZOffset;
// 0x1689 represents 0 height there are -127 to 128 heights above and below it
+33 -31
View File
@@ -781,7 +781,7 @@ bool Vehicle::OpenRestraints()
void RideUpdateMeasurementsSpecialElements_Default(Ride& ride, const track_type_t trackType)
{
const auto& ted = GetTrackElementDescriptor(trackType);
uint16_t trackFlags = ted.Flags;
uint16_t trackFlags = ted.flags;
if (trackFlags & TRACK_ELEM_FLAG_NORMAL_TO_INVERSION)
{
if (ride.inversions < OpenRCT2::Limits::kMaxInversions)
@@ -792,7 +792,7 @@ void RideUpdateMeasurementsSpecialElements_Default(Ride& ride, const track_type_
void RideUpdateMeasurementsSpecialElements_MiniGolf(Ride& ride, const track_type_t trackType)
{
const auto& ted = GetTrackElementDescriptor(trackType);
uint16_t trackFlags = ted.Flags;
uint16_t trackFlags = ted.flags;
if (trackFlags & TRACK_ELEM_FLAG_IS_GOLF_HOLE)
{
if (ride.holes < OpenRCT2::Limits::kMaxGolfHoles)
@@ -938,7 +938,7 @@ void Vehicle::UpdateMeasurements()
}
const auto& ted = GetTrackElementDescriptor(trackElemType);
uint16_t trackFlags = ted.Flags;
uint16_t trackFlags = ted.flags;
uint32_t testingFlags = curRide->testing_flags;
if (testingFlags & RIDE_TESTING_TURN_LEFT && trackFlags & TRACK_ELEM_FLAG_TURN_LEFT)
{
@@ -5030,8 +5030,8 @@ GForces Vehicle::GetGForces() const
gForceVert = ((static_cast<int64_t>(gForceVert)) * Unk9A39C4[bank_rotation]) >> 32;
const auto& ted = GetTrackElementDescriptor(GetTrackType());
const int32_t vertFactor = ted.VerticalFactor(track_progress);
const int32_t lateralFactor = ted.LateralFactor(track_progress);
const int32_t vertFactor = ted.verticalFactor(track_progress);
const int32_t lateralFactor = ted.lateralFactor(track_progress);
int32_t gForceLateral = 0;
@@ -5903,9 +5903,9 @@ void Vehicle::UpdateSpinningCar()
// The bigger the number the less change in spin.
const auto& ted = GetTrackElementDescriptor(trackType);
switch (ted.SpinFunction)
switch (ted.spinFunction)
{
case RC_SPIN:
case SpinFunction::RC:
// On a rotation control track element
spinningInertia += 6;
spinSpeed = dword_F64E08 >> spinningInertia;
@@ -5919,69 +5919,71 @@ void Vehicle::UpdateSpinningCar()
spin_speed += spinSpeed;
}
break;
case R5_SPIN:
case SpinFunction::R5:
// It looks like in the original there was going to be special code for whirlpool
// this has been removed and just uses R5_SPIN
// this has been removed and just uses R5
spinningInertia += 5;
spin_speed -= dword_F64E08 >> spinningInertia;
break;
case L5_SPIN:
case SpinFunction::L5:
spinningInertia += 5;
spin_speed += dword_F64E08 >> spinningInertia;
break;
case R7_SPIN:
case SpinFunction::R7:
spinningInertia += 7;
spin_speed -= dword_F64E08 >> spinningInertia;
break;
case L7_SPIN:
case SpinFunction::L7:
spinningInertia += 7;
spin_speed += dword_F64E08 >> spinningInertia;
break;
case RL_SPIN:
case SpinFunction::RL:
// Right Left Curve Track Piece
if (track_progress < 48)
{
// R8_SPIN
// R8
spinningInertia += 8;
spin_speed -= dword_F64E08 >> spinningInertia;
break;
}
[[fallthrough]];
case L9_SPIN:
case SpinFunction::L9:
spinningInertia += 9;
spin_speed += dword_F64E08 >> spinningInertia;
break;
case L8_SPIN:
case SpinFunction::L8:
spinningInertia += 8;
spin_speed += dword_F64E08 >> spinningInertia;
break;
case SP_SPIN:
case SpinFunction::SP:
// On rapids spin after fully on them
if (track_progress > 22)
{
// L5_SPIN
// L5
spinningInertia += 5;
spin_speed += dword_F64E08 >> spinningInertia;
}
break;
case LR_SPIN:
case SpinFunction::LR:
// Left Right Curve Track Piece
if (track_progress < 48)
{
// L8_SPIN
// L8
spinningInertia += 8;
spin_speed += dword_F64E08 >> spinningInertia;
break;
}
[[fallthrough]];
case R9_SPIN:
case SpinFunction::R9:
spinningInertia += 9;
spin_speed -= dword_F64E08 >> spinningInertia;
break;
case R8_SPIN:
case SpinFunction::R8:
spinningInertia += 8;
spin_speed -= dword_F64E08 >> spinningInertia;
break;
case SpinFunction::None:
break;
}
spinSpeed = std::clamp(spin_speed, VEHICLE_MIN_SPIN_SPEED, VEHICLE_MAX_SPIN_SPEED);
@@ -6298,12 +6300,12 @@ void Vehicle::UpdateSceneryDoor() const
{
auto trackType = GetTrackType();
const auto& ted = GetTrackElementDescriptor(trackType);
const PreviewTrack* trackBlock = ted.Block;
const PreviewTrack* trackBlock = ted.block;
while ((trackBlock + 1)->index != 255)
{
trackBlock++;
}
const TrackCoordinates* trackCoordinates = &ted.Coordinates;
const TrackCoordinates* trackCoordinates = &ted.coordinates;
auto wallCoords = CoordsXYZ{ x, y, TrackLocation.z - trackBlock->z + trackCoordinates->z_end }.ToTileStart();
int32_t direction = (GetTrackDirection() + trackCoordinates->rotation_end) & 3;
@@ -6356,7 +6358,7 @@ static PitchAndRoll PitchAndRollStart(bool useInvertedSprites, TileElement* tile
{
auto trackType = tileElement->AsTrack()->GetTrackType();
const auto& ted = GetTrackElementDescriptor(trackType);
return PitchAndRoll{ ted.Definition.PitchStart, TrackGetActualBank3(useInvertedSprites, tileElement) };
return PitchAndRoll{ ted.definition.PitchStart, TrackGetActualBank3(useInvertedSprites, tileElement) };
}
void Vehicle::UpdateGoKartAttemptSwitchLanes()
@@ -6396,8 +6398,8 @@ void Vehicle::UpdateSceneryDoorBackwards() const
{
auto trackType = GetTrackType();
const auto& ted = GetTrackElementDescriptor(trackType);
const PreviewTrack* trackBlock = ted.Block;
const TrackCoordinates* trackCoordinates = &ted.Coordinates;
const PreviewTrack* trackBlock = ted.block;
const TrackCoordinates* trackCoordinates = &ted.coordinates;
auto wallCoords = CoordsXYZ{ TrackLocation, TrackLocation.z - trackBlock->z + trackCoordinates->z_begin };
int32_t direction = (GetTrackDirection() + trackCoordinates->rotation_begin) & 3;
direction = DirectionReverse(direction);
@@ -6744,7 +6746,7 @@ void Vehicle::Sub6DBF3E()
auto trackType = GetTrackType();
const auto& ted = GetTrackElementDescriptor(trackType);
if (!(std::get<0>(ted.SequenceProperties) & TRACK_SEQUENCE_FLAG_ORIGIN))
if (!(std::get<0>(ted.sequenceProperties) & TRACK_SEQUENCE_FLAG_ORIGIN))
{
return;
}
@@ -7301,7 +7303,7 @@ static PitchAndRoll PitchAndRollEnd(const Ride& curRide, bool useInvertedSprites
{
bool isInverted = useInvertedSprites ^ tileElement->AsTrack()->IsInverted();
const auto& ted = GetTrackElementDescriptor(trackType);
return { ted.Definition.PitchEnd, TrackGetActualBank2(curRide.type, isInverted, ted.Definition.RollEnd) };
return { ted.definition.PitchEnd, TrackGetActualBank2(curRide.type, isInverted, ted.definition.RollEnd) };
}
/**
@@ -7419,7 +7421,7 @@ bool Vehicle::UpdateTrackMotionBackwardsGetNewTrack(uint16_t trackType, const Ri
{
trackType = tileElement->AsTrack()->GetTrackType();
const auto& ted = GetTrackElementDescriptor(trackType);
if (!(ted.Flags & TRACK_ELEM_FLAG_DOWN))
if (!(ted.flags & TRACK_ELEM_FLAG_DOWN))
{
_vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_9;
}
@@ -8201,7 +8203,7 @@ void Vehicle::Loc6DCE02(const Ride& curRide)
auto trackType = GetTrackType();
const auto& ted = GetTrackElementDescriptor(trackType);
if (!(std::get<0>(ted.SequenceProperties) & TRACK_SEQUENCE_FLAG_ORIGIN))
if (!(std::get<0>(ted.sequenceProperties) & TRACK_SEQUENCE_FLAG_ORIGIN))
{
return;
}
@@ -74,7 +74,7 @@ DukValue ScTrackIterator::previousPosition_get() const
auto ctx = scriptEngine.GetContext();
auto& ted = GetTrackElementDescriptor(_type);
auto& seq0 = ted.Block;
auto& seq0 = ted.block;
auto pos = _position + CoordsXYZ(seq0->x, seq0->y, seq0->z);
auto el = MapGetTrackElementAtOfTypeSeq(pos, _type, 0);
@@ -94,7 +94,7 @@ DukValue ScTrackIterator::nextPosition_get() const
auto ctx = scriptEngine.GetContext();
auto& ted = GetTrackElementDescriptor(_type);
auto& seq0 = ted.Block;
auto& seq0 = ted.block;
auto pos = _position + CoordsXYZ(seq0->x, seq0->y, seq0->z);
auto el = MapGetTrackElementAtOfTypeSeq(pos, _type, 0);
@@ -113,7 +113,7 @@ DukValue ScTrackIterator::nextPosition_get() const
bool ScTrackIterator::previous()
{
auto& ted = GetTrackElementDescriptor(_type);
auto& seq0 = ted.Block;
auto& seq0 = ted.block;
auto pos = _position + CoordsXYZ(seq0->x, seq0->y, seq0->z);
auto el = MapGetTrackElementAtOfTypeSeq(pos, _type, 0);
@@ -139,7 +139,7 @@ bool ScTrackIterator::previous()
bool ScTrackIterator::next()
{
auto& ted = GetTrackElementDescriptor(_type);
auto& seq0 = ted.Block;
auto& seq0 = ted.block;
auto pos = _position + CoordsXYZ(seq0->x, seq0->y, seq0->z);
auto el = MapGetTrackElementAtOfTypeSeq(pos, _type, 0);
@@ -78,73 +78,73 @@ int32_t ScTrackSegment::type_get() const
std::string ScTrackSegment::description_get() const
{
const auto& ted = GetTrackElementDescriptor(_type);
return LanguageGetString(ted.Description);
return LanguageGetString(ted.description);
}
int32_t ScTrackSegment::beginZ_get() const
{
const auto& ted = GetTrackElementDescriptor(_type);
return ted.Coordinates.z_begin;
return ted.coordinates.z_begin;
}
int32_t ScTrackSegment::beginDirection_get() const
{
const auto& ted = GetTrackElementDescriptor(_type);
return ted.Coordinates.rotation_begin;
return ted.coordinates.rotation_begin;
}
int32_t ScTrackSegment::beginSlope_get() const
{
const auto& ted = GetTrackElementDescriptor(_type);
return EnumValue(ted.Definition.PitchStart);
return EnumValue(ted.definition.PitchStart);
}
int32_t ScTrackSegment::beginBank_get() const
{
const auto& ted = GetTrackElementDescriptor(_type);
return EnumValue(ted.Definition.RollStart);
return EnumValue(ted.definition.RollStart);
}
int32_t ScTrackSegment::endX_get() const
{
const auto& ted = GetTrackElementDescriptor(_type);
return ted.Coordinates.x;
return ted.coordinates.x;
}
int32_t ScTrackSegment::endY_get() const
{
const auto& ted = GetTrackElementDescriptor(_type);
return ted.Coordinates.y;
return ted.coordinates.y;
}
int32_t ScTrackSegment::endZ_get() const
{
const auto& ted = GetTrackElementDescriptor(_type);
return ted.Coordinates.z_end;
return ted.coordinates.z_end;
}
int32_t ScTrackSegment::endDirection_get() const
{
const auto& ted = GetTrackElementDescriptor(_type);
return ted.Coordinates.rotation_end;
return ted.coordinates.rotation_end;
}
int32_t ScTrackSegment::endSlope_get() const
{
const auto& ted = GetTrackElementDescriptor(_type);
return EnumValue(ted.Definition.PitchEnd);
return EnumValue(ted.definition.PitchEnd);
}
int32_t ScTrackSegment::endBank_get() const
{
const auto& ted = GetTrackElementDescriptor(_type);
return EnumValue(ted.Definition.RollEnd);
return EnumValue(ted.definition.RollEnd);
}
int32_t ScTrackSegment::length_get() const
{
const auto& ted = GetTrackElementDescriptor(_type);
return ted.PieceLength;
return ted.pieceLength;
}
DukValue ScTrackSegment::elements_get() const
@@ -157,7 +157,7 @@ DukValue ScTrackSegment::elements_get() const
duk_push_array(ctx);
duk_uarridx_t index = 0;
for (auto* block = ted.Block; block->index != 0xFF; block++)
for (auto* block = ted.block; block->index != 0xFF; block++)
{
duk_push_object(ctx);
duk_push_number(ctx, block->x);
@@ -199,7 +199,7 @@ DukValue ScTrackSegment::nextCurveElement_get() const
const auto ctx = GetContext()->GetScriptEngine().GetContext();
const auto& ted = GetTrackElementDescriptor(_type);
int32_t curve = ted.CurveChain.next;
int32_t curve = ted.curveChain.next;
if (curve & RideConstructionSpecialPieceSelected)
return ToDuk<int32_t>(ctx, curve & (~RideConstructionSpecialPieceSelected));
switch (curve)
@@ -218,7 +218,7 @@ DukValue ScTrackSegment::previousCurveElement_get() const
const auto ctx = GetContext()->GetScriptEngine().GetContext();
const auto& ted = GetTrackElementDescriptor(_type);
int32_t curve = ted.CurveChain.previous;
int32_t curve = ted.curveChain.previous;
if (curve & RideConstructionSpecialPieceSelected)
return ToDuk<int32_t>(ctx, curve & (~RideConstructionSpecialPieceSelected));
switch (curve)
@@ -236,47 +236,47 @@ DukValue ScTrackSegment::getMirrorElement() const
{
const auto ctx = GetContext()->GetScriptEngine().GetContext();
const auto& ted = GetTrackElementDescriptor(_type);
if (ted.MirrorElement == TrackElemType::None)
if (ted.mirrorElement == TrackElemType::None)
return ToDuk(ctx, nullptr);
return ToDuk<int32_t>(ctx, ted.MirrorElement);
return ToDuk<int32_t>(ctx, ted.mirrorElement);
}
DukValue ScTrackSegment::getAlternativeElement() const
{
const auto ctx = GetContext()->GetScriptEngine().GetContext();
const auto& ted = GetTrackElementDescriptor(_type);
if (ted.AlternativeType == TrackElemType::None)
if (ted.alternativeType == TrackElemType::None)
return ToDuk(ctx, nullptr);
return ToDuk<int32_t>(ctx, ted.AlternativeType);
return ToDuk<int32_t>(ctx, ted.alternativeType);
}
int32_t ScTrackSegment::getPriceModifier() const
{
const auto& ted = GetTrackElementDescriptor(_type);
return ted.PriceModifier;
return ted.priceModifier;
}
template<uint16_t flag> bool ScTrackSegment::getTrackFlag() const
{
const auto& ted = GetTrackElementDescriptor(_type);
return ted.Flags & flag;
return ted.flags & flag;
}
int32_t ScTrackSegment::getTrackGroup() const
{
const auto& ted = GetTrackElementDescriptor(_type);
return ted.Definition.Type;
return ted.definition.Type;
}
std::string ScTrackSegment::getTrackCurvature() const
{
const auto& ted = GetTrackElementDescriptor(_type);
if (ted.Flags & TRACK_ELEM_FLAG_TURN_LEFT)
if (ted.flags & TRACK_ELEM_FLAG_TURN_LEFT)
return "left";
if (ted.Flags & TRACK_ELEM_FLAG_TURN_RIGHT)
if (ted.flags & TRACK_ELEM_FLAG_TURN_RIGHT)
return "right";
return "straight";
}
@@ -284,9 +284,9 @@ std::string ScTrackSegment::getTrackCurvature() const
std::string ScTrackSegment::getTrackPitchDirection() const
{
const auto& ted = GetTrackElementDescriptor(_type);
if (ted.Flags & TRACK_ELEM_FLAG_UP)
if (ted.flags & TRACK_ELEM_FLAG_UP)
return "up";
if (ted.Flags & TRACK_ELEM_FLAG_DOWN)
if (ted.flags & TRACK_ELEM_FLAG_DOWN)
return "down";
return "flat";
}
+12 -12
View File
@@ -80,7 +80,7 @@ money64 PlaceProvisionalTrackPiece(
int16_t z_begin{};
const auto& ted = GetTrackElementDescriptor(trackType);
const TrackCoordinates& coords = ted.Coordinates;
const TrackCoordinates& coords = ted.coordinates;
if (ride->GetRideTypeDescriptor().HasFlag(RIDE_TYPE_FLAG_HAS_TRACK))
{
z_begin = coords.z_begin;
@@ -138,20 +138,20 @@ static std::tuple<bool, track_type_t> window_ride_construction_update_state_get_
{
const TrackDescriptor* trackDescriptor = &gTrackDescriptors[i];
if (EnumValue(trackDescriptor->track_curve) != curve)
if (EnumValue(trackDescriptor->trackCurve) != curve)
continue;
if (trackDescriptor->starts_diagonal != startsDiagonal)
if (trackDescriptor->startsDiagonally != startsDiagonal)
continue;
if (trackDescriptor->slope_start != startSlope)
if (trackDescriptor->slopeStart != startSlope)
continue;
if (trackDescriptor->slope_end != endSlope)
if (trackDescriptor->slopeEnd != endSlope)
continue;
if (trackDescriptor->RollStart != startBank)
if (trackDescriptor->rollStart != startBank)
continue;
if (trackDescriptor->RollEnd != endBank)
if (trackDescriptor->rollEnd != endBank)
continue;
return std::make_tuple(true, trackDescriptor->track_element);
return std::make_tuple(true, trackDescriptor->trackElement);
}
return std::make_tuple(false, 0);
@@ -281,7 +281,7 @@ bool WindowRideConstructionUpdateState(
{
auto availablePieces = trackDrawerDecriptor.Covered.EnabledTrackPieces;
const auto& ted = GetTrackElementDescriptor(trackType);
auto alternativeType = ted.AlternativeType;
auto alternativeType = ted.alternativeType;
// this method limits the track element types that can be used
if (alternativeType != TrackElemType::None && (availablePieces.get(trackType)))
{
@@ -292,7 +292,7 @@ bool WindowRideConstructionUpdateState(
}
const auto& ted = GetTrackElementDescriptor(trackType);
const TrackCoordinates& trackCoordinates = ted.Coordinates;
const TrackCoordinates& trackCoordinates = ted.coordinates;
x = _currentTrackBegin.x;
y = _currentTrackBegin.y;
@@ -325,13 +325,13 @@ bool WindowRideConstructionUpdateState(
bool turnOffLiftHill = false;
if (!IsTrackEnabled(TRACK_LIFT_HILL_CURVE))
{
if (ted.Flags & TRACK_ELEM_FLAG_CURVE_ALLOWS_LIFT)
if (ted.flags & TRACK_ELEM_FLAG_CURVE_ALLOWS_LIFT)
{
turnOffLiftHill = true;
}
}
if (!(ted.Flags & TRACK_ELEM_FLAG_ALLOW_LIFT_HILL))
if (!(ted.flags & TRACK_ELEM_FLAG_ALLOW_LIFT_HILL))
{
turnOffLiftHill = true;
}
+6 -6
View File
@@ -727,13 +727,13 @@ static void Loc6A6D7E(
const auto trackType = tileElement->AsTrack()->GetTrackType();
const uint8_t trackSequence = tileElement->AsTrack()->GetSequenceIndex();
const auto& ted = GetTrackElementDescriptor(trackType);
if (!(ted.SequenceProperties[trackSequence] & TRACK_SEQUENCE_FLAG_CONNECTS_TO_PATH))
if (!(ted.sequenceProperties[trackSequence] & TRACK_SEQUENCE_FLAG_CONNECTS_TO_PATH))
{
return;
}
uint16_t dx = DirectionReverse((direction - tileElement->GetDirection()) & kTileElementDirectionMask);
if (!(ted.SequenceProperties[trackSequence] & (1 << dx)))
if (!(ted.sequenceProperties[trackSequence] & (1 << dx)))
{
return;
}
@@ -813,12 +813,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.SequenceProperties[trackSequence] & TRACK_SEQUENCE_FLAG_CONNECTS_TO_PATH))
if (!(ted.sequenceProperties[trackSequence] & TRACK_SEQUENCE_FLAG_CONNECTS_TO_PATH))
{
return;
}
uint16_t dx = (direction - tileElementPos.element->GetDirection()) & kTileElementDirectionMask;
if (!(ted.SequenceProperties[trackSequence] & (1 << dx)))
if (!(ted.sequenceProperties[trackSequence] & (1 << dx)))
{
return;
}
@@ -2057,10 +2057,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.SequenceProperties[trackSequence] & TRACK_SEQUENCE_FLAG_CONNECTS_TO_PATH)
if (ted.sequenceProperties[trackSequence] & TRACK_SEQUENCE_FLAG_CONNECTS_TO_PATH)
{
uint16_t dx = ((coords.direction - tileElement->GetDirection()) & kTileElementDirectionMask);
if (ted.SequenceProperties[trackSequence] & (1 << dx))
if (ted.sequenceProperties[trackSequence] & (1 << dx))
{
// Track element has the flags required for the given direction
return true;
+2 -2
View File
@@ -739,7 +739,7 @@ namespace OpenRCT2::TileInspector
originY = static_cast<int16_t>(coords.y);
originZ -= trackBlock->z;
trackBlock = ted.Block;
trackBlock = ted.block;
for (; trackBlock->index != 255; trackBlock++)
{
CoordsXYZD elem = { originX, originY, originZ + trackBlock->z, rotation };
@@ -820,7 +820,7 @@ namespace OpenRCT2::TileInspector
originY = static_cast<int16_t>(coords.y);
originZ -= trackBlock->z;
trackBlock = ted.Block;
trackBlock = ted.block;
for (; trackBlock->index != 255; trackBlock++)
{
CoordsXYZD elem = { originX, originY, originZ + trackBlock->z, rotation };