0x00428379
| 3685 | |
| 3686 | // 0x00428379 |
| 3687 | static std::optional<WaterPathingResult> getDockTargetFromStation(StationId stationId) |
| 3688 | { |
| 3689 | auto* station = StationManager::get(stationId); |
| 3690 | for (auto i = 0U; i < station->stationTileSize; ++i) |
| 3691 | { |
| 3692 | // Remember z needs floored |
| 3693 | const auto& pos = station->stationTiles[i]; |
| 3694 | |
| 3695 | StationElement* elStation = [&pos]() -> World::StationElement* { |
| 3696 | auto tile = TileManager::get(pos); |
| 3697 | for (auto& el : tile) |
| 3698 | { |
| 3699 | auto* elStation = el.as<StationElement>(); |
| 3700 | if (elStation == nullptr) |
| 3701 | { |
| 3702 | continue; |
| 3703 | } |
| 3704 | if (elStation->isGhost() || elStation->isAiAllocated()) |
| 3705 | { |
| 3706 | continue; |
| 3707 | } |
| 3708 | if (elStation->baseZ() != pos.z / World::kSmallZStep) |
| 3709 | { |
| 3710 | continue; |
| 3711 | } |
| 3712 | return elStation; |
| 3713 | } |
| 3714 | return nullptr; |
| 3715 | }(); |
| 3716 | if (elStation == nullptr) |
| 3717 | { |
| 3718 | continue; |
| 3719 | } |
| 3720 | if (elStation->stationType() != StationType::docks) |
| 3721 | { |
| 3722 | continue; |
| 3723 | } |
| 3724 | if (elStation->isFlag6()) |
| 3725 | { |
| 3726 | continue; |
| 3727 | } |
| 3728 | |
| 3729 | const auto* dockObj = ObjectManager::get<DockObject>(elStation->objectId()); |
| 3730 | const auto boatPos = Math::Vector::rotate(dockObj->boatPosition, elStation->rotation()) + pos; |
| 3731 | auto dockTarget = WaterPathingResult( |
| 3732 | boatPos + World::Pos2{ 32, 32 }, |
| 3733 | stationId, |
| 3734 | World::Pos3{ pos.x, pos.y, Numerics::floor2(pos.z, 4) }); |
| 3735 | return dockTarget; |
| 3736 | } |
| 3737 | return std::nullopt; |
| 3738 | } |
| 3739 | |
| 3740 | struct PathFindingResult |
| 3741 | { |
no test coverage detected