(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.

This commit is contained in:
frosch
2012-07-07 15:39:46 +00:00
parent 8d004f3c63
commit 08a8c3a773
14 changed files with 55 additions and 63 deletions

View File

@@ -416,11 +416,23 @@ 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