summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortron <tron@openttd.org>2004-12-11 10:17:10 +0000
committertron <tron@openttd.org>2004-12-11 10:17:10 +0000
commit03910ce7e9010d7457e1088f22d78267554bd0cc (patch)
treed480e20495e9f20ac7e66ff407aa48a08fcb4321
parent2dd36c201275570fcfcfa68fca2fb8b9e06fa9be (diff)
downloadopenttd-03910ce7e9010d7457e1088f22d78267554bd0cc.tar.xz
(svn r1015) MFM r789
Replaced the slightly misleading SERVICE_INTERVAL by a function VehicleNeedsService()
-rw-r--r--aircraft_cmd.c4
-rw-r--r--roadveh_cmd.c4
-rw-r--r--ship_cmd.c4
-rw-r--r--train_cmd.c4
-rw-r--r--vehicle.c7
-rw-r--r--vehicle.h3
6 files changed, 17 insertions, 9 deletions
diff --git a/aircraft_cmd.c b/aircraft_cmd.c
index 74a823251..a851343fe 100644
--- a/aircraft_cmd.c
+++ b/aircraft_cmd.c
@@ -461,7 +461,7 @@ static void CheckIfAircraftNeedsService(Vehicle *v)
if (_patches.servint_aircraft == 0)
return;
- if (SERVICE_INTERVAL)
+ if (!VehicleNeedsService(v))
return;
if (v->vehstatus & VS_STOPPED)
@@ -997,7 +997,7 @@ static void ProcessAircraftOrder(Vehicle *v)
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++;
}
diff --git a/roadveh_cmd.c b/roadveh_cmd.c
index 7df7b7f44..a36604713 100644
--- a/roadveh_cmd.c
+++ b/roadveh_cmd.c
@@ -569,7 +569,7 @@ static void ProcessRoadVehOrder(Vehicle *v)
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 @@ static void CheckIfRoadVehNeedsService(Vehicle *v)
if (_patches.servint_roadveh == 0)
return;
- if (SERVICE_INTERVAL)
+ if (!VehicleNeedsService(v))
return;
if (v->vehstatus & VS_STOPPED)
diff --git a/ship_cmd.c b/ship_cmd.c
index 2c91fda3c..8f2dfb89a 100644
--- a/ship_cmd.c
+++ b/ship_cmd.c
@@ -89,7 +89,7 @@ static void CheckIfShipNeedsService(Vehicle *v)
if (_patches.servint_ships == 0)
return;
- if (SERVICE_INTERVAL)
+ if (!VehicleNeedsService(v))
return;
if (v->vehstatus & VS_STOPPED)
@@ -214,7 +214,7 @@ static void ProcessShipOrder(Vehicle *v)
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++;
}
diff --git a/train_cmd.c b/train_cmd.c
index 256ccb6d5..50df00a59 100644
--- a/train_cmd.c
+++ b/train_cmd.c
@@ -1589,7 +1589,7 @@ static bool ProcessTrainOrder(Vehicle *v)
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 @@ static void CheckIfTrainNeedsService(Vehicle *v)
if (_patches.servint_trains == 0)
return;
- if (SERVICE_INTERVAL)
+ if (!VehicleNeedsService(v))
return;
if (v->vehstatus & VS_STOPPED)
diff --git a/vehicle.c b/vehicle.c
index 145d22561..55bb3a186 100644
--- a/vehicle.c
+++ b/vehicle.c
@@ -22,6 +22,13 @@ void VehicleServiceInDepot(Vehicle *v)
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;
diff --git a/vehicle.h b/vehicle.h
index 557536441..fdc91c92f 100644
--- a/vehicle.h
+++ b/vehicle.h
@@ -390,6 +390,8 @@ int CheckStoppedInDepot(Vehicle *v);
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 @@ VARDEF BackuppedOrders _backup_orders_data[1];
#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