1
0
Fork 0

Add: Add a ShouldStopAtDepot function.

pull/8480/head
Juanjo 2014-01-12 12:15:54 +01:00 committed by J0anJosep
parent 421a533fbb
commit 2b259442f1
3 changed files with 13 additions and 1 deletions

View File

@ -225,6 +225,7 @@ public:
inline void SetMaxSpeed(uint16_t speed) { this->max_speed = speed; } inline void SetMaxSpeed(uint16_t speed) { this->max_speed = speed; }
bool ShouldStopAtStation(const Vehicle *v, StationID station) const; bool ShouldStopAtStation(const Vehicle *v, StationID station) const;
bool ShouldStopAtDepot(DepotID depot) const;
bool CanLoadOrUnload() const; bool CanLoadOrUnload() const;
bool CanLeaveWithCargo(bool has_cargo) const; bool CanLeaveWithCargo(bool has_cargo) const;

View File

@ -2215,6 +2215,17 @@ bool Order::ShouldStopAtStation(const Vehicle *v, StationID station) const
!(this->GetNonStopType() & (is_dest_station ? ONSF_NO_STOP_AT_DESTINATION_STATION : ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS)); !(this->GetNonStopType() & (is_dest_station ? ONSF_NO_STOP_AT_DESTINATION_STATION : ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS));
} }
/**
* Check whether the given vehicle should stop at the given depot.
* @param v the vehicle that might be stopping.
* @param depot the depot to stop at.
* @return true if the vehicle should stop.
*/
bool Order::ShouldStopAtDepot(DepotID depot) const
{
return this->IsType(OT_GOTO_DEPOT) && this->dest == depot;
}
bool Order::CanLoadOrUnload() const bool Order::CanLoadOrUnload() const
{ {
return (this->IsType(OT_GOTO_STATION) || this->IsType(OT_IMPLICIT)) && return (this->IsType(OT_GOTO_STATION) || this->IsType(OT_IMPLICIT)) &&

View File

@ -2365,7 +2365,7 @@ static void CheckNextTrainTile(Train *v)
switch (v->current_order.GetType()) { switch (v->current_order.GetType()) {
/* Exit if we reached our destination depot. */ /* Exit if we reached our destination depot. */
case OT_GOTO_DEPOT: case OT_GOTO_DEPOT:
if (v->tile == v->dest_tile) return; if (IsRailDepotTile(v->tile) && v->current_order.ShouldStopAtDepot(GetDepotIndex(v->tile))) return;
break; break;
case OT_GOTO_WAYPOINT: case OT_GOTO_WAYPOINT: