mirror of https://github.com/OpenTTD/OpenTTD
Add: Add a ShouldStopAtDepot function.
parent
421a533fbb
commit
2b259442f1
|
@ -225,6 +225,7 @@ public:
|
|||
inline void SetMaxSpeed(uint16_t speed) { this->max_speed = speed; }
|
||||
|
||||
bool ShouldStopAtStation(const Vehicle *v, StationID station) const;
|
||||
bool ShouldStopAtDepot(DepotID depot) const;
|
||||
bool CanLoadOrUnload() const;
|
||||
bool CanLeaveWithCargo(bool has_cargo) const;
|
||||
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
{
|
||||
return (this->IsType(OT_GOTO_STATION) || this->IsType(OT_IMPLICIT)) &&
|
||||
|
|
|
@ -2365,7 +2365,7 @@ static void CheckNextTrainTile(Train *v)
|
|||
switch (v->current_order.GetType()) {
|
||||
/* Exit if we reached our destination 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;
|
||||
|
||||
case OT_GOTO_WAYPOINT:
|
||||
|
|
Loading…
Reference in New Issue