mirror of https://github.com/OpenTTD/OpenTTD
(svn r24380) -Fix [FS#5188]: RoadVehicle::IsInDepot did not check all articulated parts.
parent
3d3ab26ee6
commit
c1dd0107c7
|
@ -112,7 +112,7 @@ struct RoadVehicle FINAL : public GroundVehicle<RoadVehicle, VEH_ROAD> {
|
||||||
int GetDisplayMaxSpeed() const { return this->vcache.cached_max_speed / 2; }
|
int GetDisplayMaxSpeed() const { return this->vcache.cached_max_speed / 2; }
|
||||||
Money GetRunningCost() const;
|
Money GetRunningCost() const;
|
||||||
int GetDisplayImageWidth(Point *offset = NULL) const;
|
int GetDisplayImageWidth(Point *offset = NULL) const;
|
||||||
bool IsInDepot() const { return this->state == RVSB_IN_DEPOT; }
|
bool IsInDepot() const;
|
||||||
bool IsStoppedInDepot() const;
|
bool IsStoppedInDepot() const;
|
||||||
bool Tick();
|
bool Tick();
|
||||||
void OnNewDay();
|
void OnNewDay();
|
||||||
|
|
|
@ -308,11 +308,16 @@ CommandCost CmdBuildRoadVehicle(TileIndex tile, DoCommandFlag flags, const Engin
|
||||||
|
|
||||||
bool RoadVehicle::IsStoppedInDepot() const
|
bool RoadVehicle::IsStoppedInDepot() const
|
||||||
{
|
{
|
||||||
TileIndex tile = this->tile;
|
|
||||||
|
|
||||||
if (!IsRoadDepotTile(tile)) return false;
|
|
||||||
if (this->IsFrontEngine() && !(this->vehstatus & VS_STOPPED)) return false;
|
if (this->IsFrontEngine() && !(this->vehstatus & VS_STOPPED)) return false;
|
||||||
|
|
||||||
|
return this->IsInDepot();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool RoadVehicle::IsInDepot() const
|
||||||
|
{
|
||||||
|
TileIndex tile = this->tile;
|
||||||
|
if (!IsRoadDepotTile(tile)) return false;
|
||||||
|
|
||||||
for (const RoadVehicle *v = this; v != NULL; v = v->Next()) {
|
for (const RoadVehicle *v = this; v != NULL; v = v->Next()) {
|
||||||
if (v->state != RVSB_IN_DEPOT || v->tile != tile) return false;
|
if (v->state != RVSB_IN_DEPOT || v->tile != tile) return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue