diff options
author | tron <tron@openttd.org> | 2004-12-11 10:17:10 +0000 |
---|---|---|
committer | tron <tron@openttd.org> | 2004-12-11 10:17:10 +0000 |
commit | 03910ce7e9010d7457e1088f22d78267554bd0cc (patch) | |
tree | d480e20495e9f20ac7e66ff407aa48a08fcb4321 | |
parent | 2dd36c201275570fcfcfa68fca2fb8b9e06fa9be (diff) | |
download | openttd-03910ce7e9010d7457e1088f22d78267554bd0cc.tar.xz |
(svn r1015) MFM r789
Replaced the slightly misleading SERVICE_INTERVAL by a function VehicleNeedsService()
-rw-r--r-- | aircraft_cmd.c | 4 | ||||
-rw-r--r-- | roadveh_cmd.c | 4 | ||||
-rw-r--r-- | ship_cmd.c | 4 | ||||
-rw-r--r-- | train_cmd.c | 4 | ||||
-rw-r--r-- | vehicle.c | 7 | ||||
-rw-r--r-- | vehicle.h | 3 |
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) @@ -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; @@ -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 |