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

Function HasStationInUse

src/station_cmd.cpp:2859–2873  ·  view source on GitHub ↗

* Tests whether the company's vehicles have this station in orders * @param station station ID * @param include_company If true only check vehicles of \a company, if false only check vehicles of other companies * @param company company ID */

Source from the content-addressed store, hash-verified

2857 * @param company company ID
2858 */
2859bool HasStationInUse(StationID station, bool include_company, CompanyID company)
2860{
2861 for (const OrderList *orderlist : OrderList::Iterate()) {
2862 const Vehicle *v = orderlist->GetFirstSharedVehicle();
2863 assert(v != nullptr);
2864 if ((v->owner == company) != include_company) continue;
2865
2866 for (const Order &order : orderlist->GetOrders()) {
2867 if (order.GetDestination() == station && (order.IsType(OT_GOTO_STATION) || order.IsType(OT_GOTO_WAYPOINT))) {
2868 return true;
2869 }
2870 }
2871 }
2872 return false;
2873}
2874
2875static const TileIndexDiffC _dock_tileoffs_chkaround[] = {
2876 {-1, 0},

Callers 2

RemoveBuoyFunction · 0.85
BuildStationsListMethod · 0.85

Calls 4

GetFirstSharedVehicleMethod · 0.80
GetOrdersMethod · 0.80
GetDestinationMethod · 0.80
IsTypeMethod · 0.80

Tested by

no test coverage detected