Loading

Bus stop at station

  1. /**
  2.  * Check whether the given vehicle should stop at the given station
  3.  * based on this order and the non-stop settings.
  4.  * @param v       the vehicle that might be stopping.
  5.  * @param station the station to stop at.
  6.  * @return true if the vehicle should stop.
  7.  */
  8. bool Order::ShouldStopAtStation(const Vehicle *v, StationID stationId) const
  9. {
  10.     bool is_dest_station = this->IsType(OT_GOTO_STATION) && this->dest == stationId;
  11.  
  12.     /* Check if the vehicle is a road vehicle, it is carrying CT_PASSENGERS,
  13.      * it is going to a depot or waypoint and if the station is not the station the
  14.      * vehicle served exactly that station last. */
  15.     //TODO: Add vehicle cargo check.
  16.     if (v->type == VEH_ROAD && v->cargo_type == CT_PASSENGERS
  17.         && !this->IsType(OT_GOTO_DEPOT) && !this->IsType(OT_GOTO_WAYPOINT)
  18.         && v->last_station_visited != stationId) {
  19.         Station* station = Station::Get(stationId);
  20.         if (station->goods[CT_PASSENGERS].HasVehicleEverTriedLoading() == false) return true;
  21.         if ((station->goods[CT_PASSENGERS].cargo.AvailableCount() & v->cargo.StoredCount()) == 0 || !station->goods[CT_PASSENGERS].GES_ACCEPTANCE) {
  22.             CmdSkipToOrder(v->tile, DC_EXEC, v->index, 1, "");
  23.             return false;
  24.         }
  25.         return true;
  26.     }
  27.  
  28.     return (!this->IsType(OT_GOTO_DEPOT) || (this->GetDepotOrderType() & ODTFB_PART_OF_ORDERS) != 0) &&
  29.             v->last_station_visited != stationId && // Do stop only when we've not just been there
  30.             /* Finally do stop when there is no non-stop flag set for this type of station. */
  31.             !(this->GetNonStopType() & (is_dest_station ? ONSF_NO_STOP_AT_DESTINATION_STATION : ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS));
  32. }

Comments