| 1559 | } |
| 1560 | |
| 1561 | static GameActions::Result TrackDesignPlaceRide( |
| 1562 | TrackDesignState& tds, const TrackDesign& td, const CoordsXYZ& origin, Ride& ride) |
| 1563 | { |
| 1564 | tds.origin = origin; |
| 1565 | if (tds.placeOperation == TrackPlaceOperation::drawOutlines) |
| 1566 | { |
| 1567 | MapSelection::clearSelectedTiles(); |
| 1568 | gMapSelectArrowPosition = CoordsXYZ{ origin, TileElementHeight(origin) }; |
| 1569 | gMapSelectArrowDirection = _currentTrackPieceDirection; |
| 1570 | } |
| 1571 | |
| 1572 | tds.placeZ = 0; |
| 1573 | money64 totalCost = 0; |
| 1574 | uint8_t rotation = _currentTrackPieceDirection; |
| 1575 | |
| 1576 | auto& gameState = getGameState(); |
| 1577 | |
| 1578 | // Track elements |
| 1579 | auto newCoords = origin; |
| 1580 | for (const auto& track : td.trackElements) |
| 1581 | { |
| 1582 | auto trackType = track.type; |
| 1583 | const auto& ted = GetTrackElementDescriptor(trackType); |
| 1584 | |
| 1585 | TrackDesignUpdatePreviewBounds(tds, newCoords); |
| 1586 | |
| 1587 | switch (tds.placeOperation) |
| 1588 | { |
| 1589 | case TrackPlaceOperation::drawOutlines: |
| 1590 | for (uint8_t i = 0; i < ted.sequenceData.numSequences; i++) |
| 1591 | { |
| 1592 | const auto& trackBlock = ted.sequenceData.sequences[i].clearance; |
| 1593 | auto tile = CoordsXY{ newCoords } + CoordsXY{ trackBlock.x, trackBlock.y }.Rotate(rotation); |
| 1594 | TrackDesignUpdatePreviewBounds(tds, { tile, newCoords.z }); |
| 1595 | TrackDesignAddSelectedTile(tile); |
| 1596 | } |
| 1597 | break; |
| 1598 | case TrackPlaceOperation::removeGhost: |
| 1599 | { |
| 1600 | const TrackCoordinates* trackCoordinates = &ted.coordinates; |
| 1601 | int32_t tempZ = newCoords.z - trackCoordinates->zBegin + ted.sequenceData.sequences[0].clearance.z; |
| 1602 | auto trackRemoveAction = GameActions::TrackRemoveAction( |
| 1603 | trackType, 0, { newCoords, tempZ, static_cast<Direction>(rotation & 3) }); |
| 1604 | trackRemoveAction.SetFlags( |
| 1605 | { CommandFlag::allowDuringPaused, CommandFlag::noSpend, CommandFlag::ghost, CommandFlag::trackDesign }); |
| 1606 | GameActions::ExecuteNested(&trackRemoveAction, gameState); |
| 1607 | break; |
| 1608 | } |
| 1609 | case TrackPlaceOperation::placeQuery: |
| 1610 | case TrackPlaceOperation::place: |
| 1611 | case TrackPlaceOperation::placeGhost: |
| 1612 | case TrackPlaceOperation::placeTrackPreview: |
| 1613 | { |
| 1614 | const TrackCoordinates* trackCoordinates = &ted.coordinates; |
| 1615 | |
| 1616 | // di |
| 1617 | int16_t tempZ = newCoords.z - trackCoordinates->zBegin; |
| 1618 |
no test coverage detected