--- a/aircraft_cmd.c Sat Dec 11 09:51:55 2004 +0000
+++ b/aircraft_cmd.c Sat Dec 11 10:17:10 2004 +0000
@@ -461,7 +461,7 @@
if (_patches.servint_aircraft == 0)
return;
- if (SERVICE_INTERVAL)
+ if (!VehicleNeedsService(v))
return;
if (v->vehstatus & VS_STOPPED)
@@ -997,7 +997,7 @@
if (v->current_order.type == OT_GOTO_DEPOT &&
(v->current_order.flags & (OF_UNLOAD | OF_FULL_LOAD)) == (OF_UNLOAD | OF_FULL_LOAD) &&
- SERVICE_INTERVAL) {
+ !VehicleNeedsService(v)) {
v->cur_order_index++;
}
--- a/roadveh_cmd.c Sat Dec 11 09:51:55 2004 +0000
+++ b/roadveh_cmd.c Sat Dec 11 10:17:10 2004 +0000
@@ -569,7 +569,7 @@
if (v->current_order.type == OT_GOTO_DEPOT &&
(v->current_order.flags & (OF_UNLOAD | OF_FULL_LOAD)) == (OF_UNLOAD | OF_FULL_LOAD) &&
- SERVICE_INTERVAL ) {
+ !VehicleNeedsService(v)) {
v->cur_order_index++;
}
@@ -1433,7 +1433,7 @@
if (_patches.servint_roadveh == 0)
return;
- if (SERVICE_INTERVAL)
+ if (!VehicleNeedsService(v))
return;
if (v->vehstatus & VS_STOPPED)
--- a/ship_cmd.c Sat Dec 11 09:51:55 2004 +0000
+++ b/ship_cmd.c Sat Dec 11 10:17:10 2004 +0000
@@ -89,7 +89,7 @@
if (_patches.servint_ships == 0)
return;
- if (SERVICE_INTERVAL)
+ if (!VehicleNeedsService(v))
return;
if (v->vehstatus & VS_STOPPED)
@@ -214,7 +214,7 @@
if (v->current_order.type == OT_GOTO_DEPOT &&
(v->current_order.flags & (OF_UNLOAD | OF_FULL_LOAD)) == (OF_UNLOAD | OF_FULL_LOAD) &&
- SERVICE_INTERVAL) {
+ !VehicleNeedsService(v)) {
v->cur_order_index++;
}
--- a/train_cmd.c Sat Dec 11 09:51:55 2004 +0000
+++ b/train_cmd.c Sat Dec 11 10:17:10 2004 +0000
@@ -1589,7 +1589,7 @@
if (v->current_order.type == OT_GOTO_DEPOT &&
(v->current_order.flags & (OF_UNLOAD | OF_FULL_LOAD)) == (OF_UNLOAD | OF_FULL_LOAD) &&
- SERVICE_INTERVAL) {
+ !VehicleNeedsService(v)) {
v->cur_order_index++;
}
@@ -2597,7 +2597,7 @@
if (_patches.servint_trains == 0)
return;
- if (SERVICE_INTERVAL)
+ if (!VehicleNeedsService(v))
return;
if (v->vehstatus & VS_STOPPED)
--- a/vehicle.c Sat Dec 11 09:51:55 2004 +0000
+++ b/vehicle.c Sat Dec 11 10:17:10 2004 +0000
@@ -22,6 +22,13 @@
v->reliability = _engines[v->engine_type].reliability;
}
+bool VehicleNeedsService(const Vehicle *v)
+{
+ return _patches.servint_ispercent ?
+ (v->reliability < _engines[v->engine_type].reliability * (100 - v->service_interval) / 100) :
+ (v->date_of_last_service + v->service_interval < _date);
+}
+
Order UnpackOldOrder(uint16 packed)
{
Order order;
--- a/vehicle.h Sat Dec 11 09:51:55 2004 +0000
+++ b/vehicle.h Sat Dec 11 10:17:10 2004 +0000
@@ -390,6 +390,8 @@
int ScheduleHasDepotOrders(const Order *schedule);
int CheckOrders(Vehicle *v);
+bool VehicleNeedsService(const Vehicle *v);
+
typedef struct GetNewVehiclePosResult {
int x,y;
uint old_tile;
@@ -449,7 +451,6 @@
#define INVALID_VEHICLE 0xffff
-#define SERVICE_INTERVAL (_patches.servint_ispercent ? (v->reliability > _engines[v->engine_type].reliability * (100 - v->service_interval) / 100) : (v->date_of_last_service + v->service_interval > _date))
#define MIN_SERVINT_PERCENT 5
#define MAX_SERVINT_PERCENT 90
#define MIN_SERVINT_DAYS 30