* * rct2: 0x006CB3AA */
| 4737 | * rct2: 0x006CB3AA |
| 4738 | */ |
| 4739 | static int32_t RideGetTrackLength(const Ride& ride) |
| 4740 | { |
| 4741 | TileElement* tileElement = nullptr; |
| 4742 | TrackElemType trackType; |
| 4743 | CoordsXYZ trackStart; |
| 4744 | bool foundTrack = false; |
| 4745 | |
| 4746 | for (const auto& station : ride.getStations()) |
| 4747 | { |
| 4748 | trackStart = station.GetStart(); |
| 4749 | if (trackStart.IsNull()) |
| 4750 | continue; |
| 4751 | |
| 4752 | tileElement = MapGetFirstElementAt(trackStart); |
| 4753 | if (tileElement == nullptr) |
| 4754 | continue; |
| 4755 | do |
| 4756 | { |
| 4757 | if (tileElement->getType() != TileElementType::Track) |
| 4758 | continue; |
| 4759 | |
| 4760 | trackType = tileElement->asTrack()->GetTrackType(); |
| 4761 | const auto& ted = GetTrackElementDescriptor(trackType); |
| 4762 | if (!ted.sequenceData.sequences[0].flags.has(SequenceFlag::trackOrigin)) |
| 4763 | continue; |
| 4764 | |
| 4765 | if (tileElement->getBaseZ() != trackStart.z) |
| 4766 | continue; |
| 4767 | |
| 4768 | foundTrack = true; |
| 4769 | } while (!foundTrack && !(tileElement++)->isLastForTile()); |
| 4770 | |
| 4771 | if (foundTrack) |
| 4772 | break; |
| 4773 | } |
| 4774 | |
| 4775 | if (!foundTrack) |
| 4776 | return 0; |
| 4777 | |
| 4778 | RideId rideIndex = tileElement->asTrack()->GetRideIndex(); |
| 4779 | |
| 4780 | auto* windowMgr = Ui::GetWindowManager(); |
| 4781 | WindowBase* w = windowMgr->FindByClass(WindowClass::rideConstruction); |
| 4782 | if (w != nullptr && _rideConstructionState != RideConstructionState::State0 && _currentRideIndex == rideIndex) |
| 4783 | { |
| 4784 | RideConstructionInvalidateCurrentTrack(); |
| 4785 | } |
| 4786 | |
| 4787 | bool moveSlowIt = true; |
| 4788 | int32_t result = 0; |
| 4789 | |
| 4790 | TrackCircuitIterator it; |
| 4791 | trackCircuitIteratorBegin(&it, { trackStart.x, trackStart.y, tileElement }); |
| 4792 | |
| 4793 | TrackCircuitIterator slowIt = it; |
| 4794 | while (trackCircuitIteratorNext(&it)) |
| 4795 | { |
| 4796 | trackType = it.current.element->asTrack()->GetTrackType(); |
no test coverage detected