summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbjarni <bjarni@openttd.org>2004-12-09 21:46:56 +0000
committerbjarni <bjarni@openttd.org>2004-12-09 21:46:56 +0000
commit02bf3ed5c07451ae860bf4a197fca00908eb4293 (patch)
treedcab8de4962e2d4d20e640fa781a69cd6480a973
parent93a4dbda4b10d8b26c575e4b16d4505ea881dae5 (diff)
downloadopenttd-02bf3ed5c07451ae860bf4a197fca00908eb4293.tar.xz
(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--)
-rw-r--r--aircraft_cmd.c5
-rw-r--r--roadveh_cmd.c7
-rw-r--r--ship_cmd.c6
-rw-r--r--train_cmd.c6
-rw-r--r--vehicle.c6
-rw-r--r--vehicle.h1
6 files changed, 19 insertions, 12 deletions
diff --git a/aircraft_cmd.c b/aircraft_cmd.c
index 26ebc4211..992900366 100644
--- a/aircraft_cmd.c
+++ b/aircraft_cmd.c
@@ -652,9 +652,7 @@ static void ServiceAircraft(Vehicle *v)
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 @@ static void AircraftLeaveHangar(Vehicle *v)
}
}
+ VehicleServiceInDepot(v);
SetAircraftPosition(v, v->x_pos, v->y_pos, v->z_pos);
InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
}
diff --git a/roadveh_cmd.c b/roadveh_cmd.c
index 6b39a5a11..f9acd3c44 100644
--- a/roadveh_cmd.c
+++ b/roadveh_cmd.c
@@ -1119,6 +1119,8 @@ static void RoadVehEventHandler(Vehicle *v)
if (RoadVehFindCloseTo(v,x,y,v->direction))
return;
+ VehicleServiceInDepot(v);
+
StartRoadVehSound(v);
BeginVehicleMove(v);
@@ -1377,13 +1379,12 @@ void RoadVehEnterDepot(Vehicle *v)
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) {
diff --git a/ship_cmd.c b/ship_cmd.c
index 7894eed6b..578fce38a 100644
--- a/ship_cmd.c
+++ b/ship_cmd.c
@@ -352,6 +352,7 @@ static void CheckShipLeaveDepot(Vehicle *v)
RecalcShipStuff(v);
PlayShipSound(v);
+ VehicleServiceInDepot(v);
}
static bool ShipAccelerate(Vehicle *v)
@@ -394,9 +395,8 @@ static void ShipEnterDepot(Vehicle *v)
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));
diff --git a/train_cmd.c b/train_cmd.c
index 249cd1ab4..1b79001fc 100644
--- a/train_cmd.c
+++ b/train_cmd.c
@@ -1288,6 +1288,7 @@ static bool CheckTrainStayInDepot(Vehicle *v)
return true;
}
+ VehicleServiceInDepot(v);
TrainPlayLeaveStationSound(v);
v->u.rail.track = 1;
@@ -2554,9 +2555,8 @@ void TrainEnterDepot(Vehicle *v, uint tile)
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;
diff --git a/vehicle.c b/vehicle.c
index ceb164407..6f923778c 100644
--- a/vehicle.c
+++ b/vehicle.c
@@ -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)
{
diff --git a/vehicle.h b/vehicle.h
index b1d474d6b..557536441 100644
--- a/vehicle.h
+++ b/vehicle.h
@@ -300,6 +300,7 @@ typedef struct {
char name[32];
} BackuppedOrders;
+void VehicleServiceInDepot(Vehicle *v);
void BackupVehicleOrders(Vehicle *v, BackuppedOrders *order);
void RestoreVehicleOrders(Vehicle *v, BackuppedOrders *order);
Vehicle *AllocateVehicle();