mirror of https://github.com/OpenTTD/OpenTTD
(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--)
parent
93a4dbda4b
commit
02bf3ed5c0
|
@ -652,9 +652,7 @@ static void ServiceAircraft(Vehicle *v)
|
||||||
SetAircraftPosition(v, v->x_pos, v->y_pos, v->z_pos);
|
SetAircraftPosition(v, v->x_pos, v->y_pos, v->z_pos);
|
||||||
InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
|
InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
|
||||||
|
|
||||||
v->date_of_last_service = _date;
|
VehicleServiceInDepot(v);
|
||||||
v->breakdowns_since_last_service = 0;
|
|
||||||
v->reliability = _engines[v->engine_type].reliability;
|
|
||||||
InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
|
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);
|
SetAircraftPosition(v, v->x_pos, v->y_pos, v->z_pos);
|
||||||
InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
|
InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1119,6 +1119,8 @@ static void RoadVehEventHandler(Vehicle *v)
|
||||||
if (RoadVehFindCloseTo(v,x,y,v->direction))
|
if (RoadVehFindCloseTo(v,x,y,v->direction))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
VehicleServiceInDepot(v);
|
||||||
|
|
||||||
StartRoadVehSound(v);
|
StartRoadVehSound(v);
|
||||||
|
|
||||||
BeginVehicleMove(v);
|
BeginVehicleMove(v);
|
||||||
|
@ -1377,13 +1379,12 @@ void RoadVehEnterDepot(Vehicle *v)
|
||||||
v->u.road.state = 254;
|
v->u.road.state = 254;
|
||||||
v->vehstatus |= VS_HIDDEN;
|
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);
|
InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
|
||||||
|
|
||||||
MaybeRenewVehicle(v, EstimateRoadVehCost(v->engine_type));
|
MaybeRenewVehicle(v, EstimateRoadVehCost(v->engine_type));
|
||||||
|
|
||||||
|
VehicleServiceInDepot(v);
|
||||||
|
|
||||||
TriggerVehicle(v, VEHICLE_TRIGGER_DEPOT);
|
TriggerVehicle(v, VEHICLE_TRIGGER_DEPOT);
|
||||||
|
|
||||||
if (v->current_order.type == OT_GOTO_DEPOT) {
|
if (v->current_order.type == OT_GOTO_DEPOT) {
|
||||||
|
|
|
@ -352,6 +352,7 @@ static void CheckShipLeaveDepot(Vehicle *v)
|
||||||
RecalcShipStuff(v);
|
RecalcShipStuff(v);
|
||||||
|
|
||||||
PlayShipSound(v);
|
PlayShipSound(v);
|
||||||
|
VehicleServiceInDepot(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool ShipAccelerate(Vehicle *v)
|
static bool ShipAccelerate(Vehicle *v)
|
||||||
|
@ -394,9 +395,8 @@ static void ShipEnterDepot(Vehicle *v)
|
||||||
v->cur_speed = 0;
|
v->cur_speed = 0;
|
||||||
RecalcShipStuff(v);
|
RecalcShipStuff(v);
|
||||||
|
|
||||||
v->date_of_last_service = _date;
|
VehicleServiceInDepot(v);
|
||||||
v->breakdowns_since_last_service = 0;
|
|
||||||
v->reliability = _engines[v->engine_type].reliability;
|
|
||||||
InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
|
InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
|
||||||
|
|
||||||
MaybeRenewVehicle(v, EstimateShipCost(v->engine_type));
|
MaybeRenewVehicle(v, EstimateShipCost(v->engine_type));
|
||||||
|
|
|
@ -1288,6 +1288,7 @@ static bool CheckTrainStayInDepot(Vehicle *v)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VehicleServiceInDepot(v);
|
||||||
TrainPlayLeaveStationSound(v);
|
TrainPlayLeaveStationSound(v);
|
||||||
|
|
||||||
v->u.rail.track = 1;
|
v->u.rail.track = 1;
|
||||||
|
@ -2554,9 +2555,8 @@ void TrainEnterDepot(Vehicle *v, uint tile)
|
||||||
if (v->subtype != 0)
|
if (v->subtype != 0)
|
||||||
v = GetFirstVehicleInChain(v);
|
v = GetFirstVehicleInChain(v);
|
||||||
|
|
||||||
v->date_of_last_service = _date;
|
VehicleServiceInDepot(v);
|
||||||
v->breakdowns_since_last_service = 0;
|
|
||||||
v->reliability = _engines[v->engine_type].reliability;
|
|
||||||
InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
|
InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
|
||||||
|
|
||||||
v->load_unload_time_rem = 0;
|
v->load_unload_time_rem = 0;
|
||||||
|
|
|
@ -15,6 +15,12 @@
|
||||||
#define INVALID_COORD (-0x8000)
|
#define INVALID_COORD (-0x8000)
|
||||||
#define GEN_HASH(x,y) (((x & 0x1F80)>>7) + ((y & 0xFC0)))
|
#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)
|
Order UnpackOldOrder(uint16 packed)
|
||||||
{
|
{
|
||||||
|
|
|
@ -300,6 +300,7 @@ typedef struct {
|
||||||
char name[32];
|
char name[32];
|
||||||
} BackuppedOrders;
|
} BackuppedOrders;
|
||||||
|
|
||||||
|
void VehicleServiceInDepot(Vehicle *v);
|
||||||
void BackupVehicleOrders(Vehicle *v, BackuppedOrders *order);
|
void BackupVehicleOrders(Vehicle *v, BackuppedOrders *order);
|
||||||
void RestoreVehicleOrders(Vehicle *v, BackuppedOrders *order);
|
void RestoreVehicleOrders(Vehicle *v, BackuppedOrders *order);
|
||||||
Vehicle *AllocateVehicle();
|
Vehicle *AllocateVehicle();
|
||||||
|
|
Loading…
Reference in New Issue