MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / GetLocation

Method GetLocation

src/order_cmd.cpp:562–578  ·  view source on GitHub ↗

* Returns a tile somewhat representing the order destination (not suitable for pathfinding). * @param v The vehicle to get the location for. * @param airport Get the airport tile and not the station location for aircraft. * @return destination of order, or INVALID_TILE if none. */

Source from the content-addressed store, hash-verified

560 * @return destination of order, or INVALID_TILE if none.
561 */
562TileIndex Order::GetLocation(const Vehicle *v, bool airport) const
563{
564 switch (this->GetType()) {
565 case OT_GOTO_WAYPOINT:
566 case OT_GOTO_STATION:
567 case OT_IMPLICIT:
568 if (airport && v->type == VEH_AIRCRAFT) return Station::Get(this->GetDestination().ToStationID())->airport.tile;
569 return BaseStation::Get(this->GetDestination().ToStationID())->xy;
570
571 case OT_GOTO_DEPOT:
572 if (this->GetDestination() == DepotID::Invalid()) return INVALID_TILE;
573 return (v->type == VEH_AIRCRAFT) ? Station::Get(this->GetDestination().ToStationID())->xy : Depot::Get(this->GetDestination().ToDepotID())->xy;
574
575 default:
576 return INVALID_TILE;
577 }
578}
579
580/**
581 * Get the distance between two orders of a vehicle. Conditional orders are resolved

Callers 4

GetOrderDistanceFunction · 0.45
OnClickMethod · 0.45
OnPaintMethod · 0.45
OnClickMethod · 0.45

Calls 5

GetTypeMethod · 0.95
GetDestinationMethod · 0.95
InvalidFunction · 0.85
ToDepotIDMethod · 0.80
ToStationIDMethod · 0.45

Tested by

no test coverage detected