3474 if (++v->u.rail.crash_anim_pos >= 4400) |
3474 if (++v->u.rail.crash_anim_pos >= 4400) |
3475 DeleteVehicle(v); |
3475 DeleteVehicle(v); |
3476 } |
3476 } |
3477 } |
3477 } |
3478 |
3478 |
3479 |
|
3480 void TrainEnterDepot(Vehicle *v, TileIndex tile) |
|
3481 { |
|
3482 UpdateSignalsOnSegment(tile, GetRailDepotDirection(tile)); |
|
3483 |
|
3484 if (!IsFrontEngine(v)) v = GetFirstVehicleInChain(v); |
|
3485 |
|
3486 VehicleServiceInDepot(v); |
|
3487 |
|
3488 InvalidateWindow(WC_VEHICLE_DETAILS, v->index); |
|
3489 |
|
3490 v->load_unload_time_rem = 0; |
|
3491 v->cur_speed = 0; |
|
3492 |
|
3493 TriggerVehicle(v, VEHICLE_TRIGGER_DEPOT); |
|
3494 |
|
3495 if (v->current_order.type == OT_GOTO_DEPOT) { |
|
3496 Order t; |
|
3497 int32 cost; |
|
3498 |
|
3499 InvalidateWindow(WC_VEHICLE_VIEW, v->index); |
|
3500 |
|
3501 t = v->current_order; |
|
3502 v->current_order.type = OT_DUMMY; |
|
3503 v->current_order.flags = 0; |
|
3504 |
|
3505 _current_player = v->owner; |
|
3506 cost = DoCommand(v->tile, v->index, t.refit_cargo | t.refit_subtype << 8, DC_EXEC, CMD_REFIT_RAIL_VEHICLE); |
|
3507 if (!CmdFailed(cost) && v->owner == _local_player && cost != 0) ShowCostOrIncomeAnimation(v->x_pos, v->y_pos, v->z_pos, cost); |
|
3508 |
|
3509 if (HASBIT(t.flags, OFB_PART_OF_ORDERS)) { // Part of the orderlist? |
|
3510 v->u.rail.days_since_order_progr = 0; |
|
3511 v->cur_order_index++; |
|
3512 } else if (HASBIT(t.flags, OFB_HALT_IN_DEPOT)) { // User initiated? |
|
3513 v->vehstatus |= VS_STOPPED; |
|
3514 if (v->owner == _local_player) { |
|
3515 SetDParam(0, v->unitnumber); |
|
3516 AddNewsItem( |
|
3517 STR_8814_TRAIN_IS_WAITING_IN_DEPOT, |
|
3518 NEWS_FLAGS(NM_SMALL, NF_VIEWPORT|NF_VEHICLE, NT_ADVICE, 0), |
|
3519 v->index, |
|
3520 0 |
|
3521 ); |
|
3522 } |
|
3523 } |
|
3524 } |
|
3525 InvalidateWindowClasses(WC_TRAINS_LIST); |
|
3526 } |
|
3527 |
|
3528 #define MAX_ACCEPTABLE_DEPOT_DIST 16 |
3479 #define MAX_ACCEPTABLE_DEPOT_DIST 16 |
3529 |
3480 |
3530 static void CheckIfTrainNeedsService(Vehicle *v) |
3481 static void CheckIfTrainNeedsService(Vehicle *v) |
3531 { |
3482 { |
3532 const Depot* depot; |
3483 const Depot* depot; |