0x004A40C5
| 4607 | |
| 4608 | // 0x004A40C5 |
| 4609 | static std::optional<GameCommands::VehiclePlacementArgs> getTrackAtCursor(const int16_t x, const int16_t y) |
| 4610 | { |
| 4611 | auto [interaction, viewport] = ViewportInteraction::getMapCoordinatesFromPos(x, y, ~ViewportInteraction::InteractionItemFlags::track); |
| 4612 | if (interaction.type != ViewportInteraction::InteractionItem::track) |
| 4613 | { |
| 4614 | return {}; |
| 4615 | } |
| 4616 | |
| 4617 | // Get the best progress along the track relative to the cursor |
| 4618 | auto* trackElement = static_cast<World::TrackElement*>(interaction.object); |
| 4619 | World::Pos3 loc(interaction.pos.x, interaction.pos.y, trackElement->baseHeight()); |
| 4620 | auto progress = getTrackProgressAtCursor({ x, y }, *viewport, *trackElement, loc); |
| 4621 | |
| 4622 | // Get the coordinates of the first tile of the possibly multi-tile road |
| 4623 | const auto& trackDataArr = World::TrackData::getTrackPiece(trackElement->trackId()); |
| 4624 | const auto& trackData = trackDataArr[trackElement->sequenceIndex()]; |
| 4625 | auto trackOffset2 = Math::Vector::rotate(World::Pos2(trackData.x, trackData.y), trackElement->rotation()); |
| 4626 | auto trackOffset = World::Pos3(trackOffset2.x, trackOffset2.y, trackData.z); |
| 4627 | auto trackFirstTile = loc - trackOffset; |
| 4628 | |
| 4629 | GameCommands::VehiclePlacementArgs placementArgs; |
| 4630 | placementArgs.pos = trackFirstTile; |
| 4631 | placementArgs.trackProgress = progress; |
| 4632 | placementArgs.trackAndDirection = trackElement->rotation() | (trackElement->trackId() << 3); |
| 4633 | return { placementArgs }; |
| 4634 | } |
| 4635 | |
| 4636 | // 0x004B6444 |
| 4637 | static std::optional<GameCommands::VehiclePlacementArgs> getVehicleRailPlacementArgsFromCursor(const Vehicles::VehicleHead& head, const int16_t x, const int16_t y) |
no test coverage detected