diff options
author | frosch <frosch@openttd.org> | 2012-07-07 15:39:46 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2012-07-07 15:39:46 +0000 |
commit | 08a8c3a773e9c730bd92a39e1e07403a172e866a (patch) | |
tree | 5fea4034f5d65bf6be9c28458ce05369d702a78d /src/vehicle_base.h | |
parent | 8d004f3c63fbff4f3524f770483db90408a98c50 (diff) | |
download | openttd-08a8c3a773e9c730bd92a39e1e07403a172e866a.tar.xz |
(svn r24384) -Fix [FS#5188-ish]: Make IsInDepot() functions behave consistent across vehicle types and add IsChainInDepot instead, if that is what shall be checked.
Diffstat (limited to 'src/vehicle_base.h')
-rw-r--r-- | src/vehicle_base.h | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/vehicle_base.h b/src/vehicle_base.h index 7b2f371fa..fa06519e0 100644 --- a/src/vehicle_base.h +++ b/src/vehicle_base.h @@ -417,10 +417,22 @@ public: virtual bool IsInDepot() const { return false; } /** + * Check whether the whole vehicle chain is in the depot. + * @return true if and only if the whole chain is in the depot. + */ + virtual bool IsChainInDepot() const { return this->IsInDepot(); } + + /** * Check whether the vehicle is in the depot *and* stopped. * @return true if and only if the vehicle is in the depot and stopped. */ - virtual bool IsStoppedInDepot() const { return this->IsInDepot() && (this->vehstatus & VS_STOPPED) != 0; } + bool IsStoppedInDepot() const + { + assert(this == this->First()); + /* Free wagons have no VS_STOPPED state */ + if (this->IsPrimaryVehicle() && !(this->vehstatus & VS_STOPPED)) return false; + return this->IsChainInDepot(); + } /** * Calls the tick handler of the vehicle |