diff options
author | frosch <frosch@openttd.org> | 2008-04-08 15:48:32 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2008-04-08 15:48:32 +0000 |
commit | 96700d560560215ec24d283d774f7dbaa11c384c (patch) | |
tree | aa0aa02603f911329fcc1e70972dd58ae153c69a /src/vehicle.cpp | |
parent | 71a2dd21fd7cb180022ce10793bbbf144d499bdd (diff) | |
download | openttd-96700d560560215ec24d283d774f7dbaa11c384c.tar.xz |
(svn r12629) -Codechange: Split VehicleNeedsService() into Vehicle::NeedsServicing() and Vehicle::NeedsAutomaticServicing().
-Fix (r11052): Disable servicing by service-interval if a vehicle has depot orders.
Diffstat (limited to 'src/vehicle.cpp')
-rw-r--r-- | src/vehicle.cpp | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/src/vehicle.cpp b/src/vehicle.cpp index c8c963b7c..60f212b2d 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -118,22 +118,27 @@ void VehicleServiceInDepot(Vehicle *v) InvalidateWindow(WC_VEHICLE_DETAILS, v->index); // ensure that last service date and reliability are updated } -bool VehicleNeedsService(const Vehicle *v) +bool Vehicle::NeedsServicing() const { - if (v->vehstatus & (VS_STOPPED | VS_CRASHED)) return false; - if (!v->current_order.IsType(OT_GOTO_DEPOT) || !(v->current_order.GetDepotOrderType() & ODTFB_PART_OF_ORDERS)) { // Don't interfere with a depot visit by the order list - if (_patches.gotodepot && VehicleHasDepotOrders(v)) return false; - if (v->current_order.IsType(OT_LOADING)) return false; - if (v->current_order.IsType(OT_GOTO_DEPOT) && v->current_order.GetDepotActionType() & ODATFB_HALT) return false; - } + if (this->vehstatus & (VS_STOPPED | VS_CRASHED)) return false; if (_patches.no_servicing_if_no_breakdowns && _opt.diff.vehicle_breakdowns == 0) { - return EngineHasReplacementForPlayer(GetPlayer(v->owner), v->engine_type, v->group_id); /* Vehicles set for autoreplacing needs to go to a depot even if breakdowns are turned off */ + /* Vehicles set for autoreplacing needs to go to a depot even if breakdowns are turned off. + * Note: If servicing is enabled, we postpone replacement till next service. */ + return EngineHasReplacementForPlayer(GetPlayer(this->owner), this->engine_type, this->group_id); } return _patches.servint_ispercent ? - (v->reliability < GetEngine(v->engine_type)->reliability * (100 - v->service_interval) / 100) : - (v->date_of_last_service + v->service_interval < _date); + (this->reliability < GetEngine(this->engine_type)->reliability * (100 - this->service_interval) / 100) : + (this->date_of_last_service + this->service_interval < _date); +} + +bool Vehicle::NeedsAutomaticServicing() const +{ + if (_patches.gotodepot && VehicleHasDepotOrders(this)) return false; + if (this->current_order.IsType(OT_LOADING)) return false; + if (this->current_order.IsType(OT_GOTO_DEPOT) && this->current_order.GetDepotActionType() & ODATFB_HALT) return false; + return NeedsServicing(); } StringID VehicleInTheWayErrMsg(const Vehicle* v) |