(svn r998) now vehicles are serviced both when entering and when leaving depots to prevent that vehicles might need service when leaving after a long stay (ln--)
--- a/aircraft_cmd.c Thu Dec 09 18:18:21 2004 +0000
+++ b/aircraft_cmd.c Thu Dec 09 21:46:56 2004 +0000
@@ -652,9 +652,7 @@
SetAircraftPosition(v, v->x_pos, v->y_pos, v->z_pos);
InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
- v->date_of_last_service = _date;
- v->breakdowns_since_last_service = 0;
- v->reliability = _engines[v->engine_type].reliability;
+ VehicleServiceInDepot(v);
InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
}
@@ -1234,6 +1232,7 @@
}
}
+ VehicleServiceInDepot(v);
SetAircraftPosition(v, v->x_pos, v->y_pos, v->z_pos);
InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
}
--- a/roadveh_cmd.c Thu Dec 09 18:18:21 2004 +0000
+++ b/roadveh_cmd.c Thu Dec 09 21:46:56 2004 +0000
@@ -1119,6 +1119,8 @@
if (RoadVehFindCloseTo(v,x,y,v->direction))
return;
+ VehicleServiceInDepot(v);
+
StartRoadVehSound(v);
BeginVehicleMove(v);
@@ -1377,13 +1379,12 @@
v->u.road.state = 254;
v->vehstatus |= VS_HIDDEN;
- v->date_of_last_service = _date;
- v->breakdowns_since_last_service = 0;
- v->reliability = _engines[v->engine_type].reliability;
InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
MaybeRenewVehicle(v, EstimateRoadVehCost(v->engine_type));
+ VehicleServiceInDepot(v);
+
TriggerVehicle(v, VEHICLE_TRIGGER_DEPOT);
if (v->current_order.type == OT_GOTO_DEPOT) {
--- a/ship_cmd.c Thu Dec 09 18:18:21 2004 +0000
+++ b/ship_cmd.c Thu Dec 09 21:46:56 2004 +0000
@@ -352,6 +352,7 @@
RecalcShipStuff(v);
PlayShipSound(v);
+ VehicleServiceInDepot(v);
}
static bool ShipAccelerate(Vehicle *v)
@@ -394,9 +395,8 @@
v->cur_speed = 0;
RecalcShipStuff(v);
- v->date_of_last_service = _date;
- v->breakdowns_since_last_service = 0;
- v->reliability = _engines[v->engine_type].reliability;
+ VehicleServiceInDepot(v);
+
InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
MaybeRenewVehicle(v, EstimateShipCost(v->engine_type));
--- a/train_cmd.c Thu Dec 09 18:18:21 2004 +0000
+++ b/train_cmd.c Thu Dec 09 21:46:56 2004 +0000
@@ -1288,6 +1288,7 @@
return true;
}
+ VehicleServiceInDepot(v);
TrainPlayLeaveStationSound(v);
v->u.rail.track = 1;
@@ -2554,9 +2555,8 @@
if (v->subtype != 0)
v = GetFirstVehicleInChain(v);
- v->date_of_last_service = _date;
- v->breakdowns_since_last_service = 0;
- v->reliability = _engines[v->engine_type].reliability;
+ VehicleServiceInDepot(v);
+
InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
v->load_unload_time_rem = 0;
--- a/vehicle.c Thu Dec 09 18:18:21 2004 +0000
+++ b/vehicle.c Thu Dec 09 21:46:56 2004 +0000
@@ -15,6 +15,12 @@
#define INVALID_COORD (-0x8000)
#define GEN_HASH(x,y) (((x & 0x1F80)>>7) + ((y & 0xFC0)))
+void VehicleServiceInDepot(Vehicle *v)
+{
+ v->date_of_last_service = _date;
+ v->breakdowns_since_last_service = 0;
+ v->reliability = _engines[v->engine_type].reliability;
+}
Order UnpackOldOrder(uint16 packed)
{
--- a/vehicle.h Thu Dec 09 18:18:21 2004 +0000
+++ b/vehicle.h Thu Dec 09 21:46:56 2004 +0000
@@ -300,6 +300,7 @@
char name[32];
} BackuppedOrders;
+void VehicleServiceInDepot(Vehicle *v);
void BackupVehicleOrders(Vehicle *v, BackuppedOrders *order);
void RestoreVehicleOrders(Vehicle *v, BackuppedOrders *order);
Vehicle *AllocateVehicle();