| 187 | } |
| 188 | |
| 189 | ResultWithMessage TrackDesign::CreateTrackDesignTrack(TrackDesignState& tds, const Ride& ride) |
| 190 | { |
| 191 | CoordsXYE trackElement; |
| 192 | if (!RideTryGetOriginElement(ride, &trackElement)) |
| 193 | { |
| 194 | return { false, STR_TRACK_TOO_LARGE_OR_TOO_MUCH_SCENERY }; |
| 195 | } |
| 196 | |
| 197 | RideGetStartOfTrack(&trackElement); |
| 198 | |
| 199 | int32_t z = trackElement.element->getBaseZ(); |
| 200 | auto trackType = trackElement.element->asTrack()->GetTrackType(); |
| 201 | uint8_t direction = trackElement.element->getDirection(); |
| 202 | _saveDirection = direction; |
| 203 | auto newCoords = GetTrackElementOriginAndApplyChanges( |
| 204 | { trackElement, z, direction }, trackType, 0, &trackElement.element, {}); |
| 205 | |
| 206 | if (!newCoords.has_value()) |
| 207 | { |
| 208 | return { false, STR_TRACK_TOO_LARGE_OR_TOO_MUCH_SCENERY }; |
| 209 | } |
| 210 | trackElement.x = newCoords->x; |
| 211 | trackElement.y = newCoords->y; |
| 212 | z = newCoords->z; |
| 213 | |
| 214 | const auto& ted = GetTrackElementDescriptor(trackElement.element->asTrack()->GetTrackType()); |
| 215 | const TrackCoordinates* trackCoordinates = &ted.coordinates; |
| 216 | // Used in the following loop to know when we have |
| 217 | // completed all of the elements and are back at the |
| 218 | // start. |
| 219 | TileElement* initialMap = trackElement.element; |
| 220 | |
| 221 | CoordsXYZ startPos = { trackElement.x, trackElement.y, |
| 222 | z + trackCoordinates->zBegin - ted.sequenceData.sequences[0].clearance.z }; |
| 223 | tds.origin = startPos; |
| 224 | |
| 225 | do |
| 226 | { |
| 227 | const auto& element = trackElement.element->asTrack(); |
| 228 | |
| 229 | if (element->GetTrackType() > TrackElemType::highestAlias) |
| 230 | { |
| 231 | version = RCT12::TD46Version::td7; |
| 232 | } |
| 233 | |
| 234 | TrackDesignTrackElement track{}; |
| 235 | track.type = element->GetTrackType(); |
| 236 | track.colourScheme = element->GetColourScheme(); |
| 237 | track.stationIndex = element->GetStationIndex(); |
| 238 | track.brakeBoosterSpeed = element->GetBrakeBoosterSpeed(); |
| 239 | track.seatRotation = element->GetSeatRotation(); |
| 240 | |
| 241 | if (track.type == TrackElemType::blockBrakes && element->GetBrakeBoosterSpeed() != kRCT2DefaultBlockBrakeSpeed) |
| 242 | { |
| 243 | version = RCT12::TD46Version::td7; |
| 244 | } |
| 245 | |
| 246 | if (element->HasChain()) |
nothing calls this directly
no test coverage detected