* Get the order command a vehicle can do in a given tile. * @param v Vehicle involved. * @param tile Tile being queried. * @return The order associated to vehicle v in given tile (or empty order if vehicle can do nothing in the tile). */
| 365 | * @return The order associated to vehicle v in given tile (or empty order if vehicle can do nothing in the tile). |
| 366 | */ |
| 367 | static Order GetOrderCmdFromTile(const Vehicle *v, TileIndex tile) |
| 368 | { |
| 369 | Order order{}; |
| 370 | |
| 371 | /* check depot first */ |
| 372 | if (IsDepotTypeTile(tile, (TransportType)(uint)v->type) && IsTileOwner(tile, _local_company)) { |
| 373 | order.MakeGoToDepot(GetDepotDestinationIndex(tile), |
| 374 | OrderDepotTypeFlag::PartOfOrders, |
| 375 | (_settings_client.gui.new_nonstop && v->IsGroundVehicle()) ? OrderNonStopFlag::NoIntermediate : OrderNonStopFlags{}); |
| 376 | |
| 377 | if (_ctrl_pressed) { |
| 378 | /* Now we are allowed to set the action type. */ |
| 379 | order.SetDepotActionType(OrderDepotActionFlag::Unbunch); |
| 380 | } |
| 381 | |
| 382 | return order; |
| 383 | } |
| 384 | |
| 385 | /* check rail waypoint */ |
| 386 | if (IsRailWaypointTile(tile) && |
| 387 | v->type == VEH_TRAIN && |
| 388 | IsTileOwner(tile, _local_company)) { |
| 389 | order.MakeGoToWaypoint(GetStationIndex(tile)); |
| 390 | if (_settings_client.gui.new_nonstop != _ctrl_pressed) order.SetNonStopType({OrderNonStopFlag::NoIntermediate, OrderNonStopFlag::NoDestination}); |
| 391 | return order; |
| 392 | } |
| 393 | |
| 394 | /* check road waypoint */ |
| 395 | if (IsRoadWaypointTile(tile) && |
| 396 | v->type == VEH_ROAD && |
| 397 | IsTileOwner(tile, _local_company)) { |
| 398 | order.MakeGoToWaypoint(GetStationIndex(tile)); |
| 399 | if (_settings_client.gui.new_nonstop != _ctrl_pressed) order.SetNonStopType({OrderNonStopFlag::NoIntermediate, OrderNonStopFlag::NoDestination}); |
| 400 | return order; |
| 401 | } |
| 402 | |
| 403 | /* check buoy (no ownership) */ |
| 404 | if (IsBuoyTile(tile) && v->type == VEH_SHIP) { |
| 405 | order.MakeGoToWaypoint(GetStationIndex(tile)); |
| 406 | return order; |
| 407 | } |
| 408 | |
| 409 | /* check for station or industry with neutral station */ |
| 410 | if (IsTileType(tile, MP_STATION) || IsTileType(tile, MP_INDUSTRY)) { |
| 411 | const Station *st = nullptr; |
| 412 | |
| 413 | if (IsTileType(tile, MP_STATION)) { |
| 414 | st = Station::GetByTile(tile); |
| 415 | } else { |
| 416 | const Industry *in = Industry::GetByTile(tile); |
| 417 | st = in->neutral_station; |
| 418 | } |
| 419 | if (st != nullptr && (st->owner == _local_company || st->owner == OWNER_NONE)) { |
| 420 | StationFacilities facil; |
| 421 | switch (v->type) { |
| 422 | case VEH_SHIP: facil = StationFacility::Dock; break; |
| 423 | case VEH_TRAIN: facil = StationFacility::Train; break; |
| 424 | case VEH_AIRCRAFT: facil = StationFacility::Airport; break; |
no test coverage detected