|
@@ -1400,27 +1400,25 @@ void VehicleEnterDepot(Vehicle *v)
|
|
|
v->MarkDirty();
|
|
|
|
|
|
if (v->current_order.IsType(OT_GOTO_DEPOT)) {
|
|
|
SetWindowDirty(WC_VEHICLE_VIEW, v->index);
|
|
|
|
|
|
const Order *real_order = v->GetOrder(v->cur_real_order_index);
|
|
|
Order t = v->current_order;
|
|
|
v->current_order.MakeDummy();
|
|
|
|
|
|
/* Test whether we are heading for this depot. If not, do nothing.
|
|
|
* Note: The target depot for nearest-/manual-depot-orders is only updated on junctions, but we want to accept every depot. */
|
|
|
if ((t.GetDepotOrderType() & ODTFB_PART_OF_ORDERS) &&
|
|
|
if ((v->current_order.GetDepotOrderType() & ODTFB_PART_OF_ORDERS) &&
|
|
|
real_order != NULL && !(real_order->GetDepotActionType() & ODATFB_NEAREST_DEPOT) &&
|
|
|
(v->type == VEH_AIRCRAFT ? t.GetDestination() != GetStationIndex(v->tile) : v->dest_tile != v->tile)) {
|
|
|
(v->type == VEH_AIRCRAFT ? v->current_order.GetDestination() != GetStationIndex(v->tile) : v->dest_tile != v->tile)) {
|
|
|
/* We are heading for another depot, keep driving. */
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if (t.IsRefit()) {
|
|
|
if (v->current_order.IsRefit()) {
|
|
|
Backup<CompanyByte> cur_company(_current_company, v->owner, FILE_LINE);
|
|
|
CommandCost cost = DoCommand(v->tile, v->index, t.GetRefitCargo() | 0xFF << 8, DC_EXEC, GetCmdRefitVeh(v));
|
|
|
CommandCost cost = DoCommand(v->tile, v->index, v->current_order.GetRefitCargo() | 0xFF << 8, DC_EXEC, GetCmdRefitVeh(v));
|
|
|
cur_company.Restore();
|
|
|
|
|
|
if (cost.Failed()) {
|
|
|
_vehicles_to_autoreplace[v] = false;
|
|
|
if (v->owner == _local_company) {
|
|
|
/* Notify the user that we stopped the vehicle */
|
|
@@ -1432,31 +1430,32 @@ void VehicleEnterDepot(Vehicle *v)
|
|
|
if (v->owner == _local_company) {
|
|
|
ShowCostOrIncomeAnimation(v->x_pos, v->y_pos, v->z_pos, cost.GetCost());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (t.GetDepotOrderType() & ODTFB_PART_OF_ORDERS) {
|
|
|
if (v->current_order.GetDepotOrderType() & ODTFB_PART_OF_ORDERS) {
|
|
|
/* Part of orders */
|
|
|
v->DeleteUnreachedImplicitOrders();
|
|
|
UpdateVehicleTimetable(v, true);
|
|
|
v->IncrementImplicitOrderIndex();
|
|
|
}
|
|
|
if (t.GetDepotActionType() & ODATFB_HALT) {
|
|
|
if (v->current_order.GetDepotActionType() & ODATFB_HALT) {
|
|
|
/* Vehicles are always stopped on entering depots. Do not restart this one. */
|
|
|
_vehicles_to_autoreplace[v] = false;
|
|
|
/* Invalidate last_loading_station. As the link from the station
|
|
|
* before the stop to the station after the stop can't be predicted
|
|
|
* we shouldn't construct it when the vehicle visits the next stop. */
|
|
|
v->last_loading_station = INVALID_STATION;
|
|
|
if (v->owner == _local_company) {
|
|
|
SetDParam(0, v->index);
|
|
|
AddVehicleAdviceNewsItem(STR_NEWS_TRAIN_IS_WAITING + v->type, v->index);
|
|
|
}
|
|
|
AI::NewEvent(v->owner, new ScriptEventVehicleWaitingInDepot(v->index));
|
|
|
}
|
|
|
v->current_order.MakeDummy();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* Update the position of the vehicle. This will update the hash that tells
|