diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -2112,6 +2112,9 @@ CommandCost CmdReverseTrainDirection(DoC HideFillingPercent(&v->fill_percent_te_id); ReverseTrainDirection(v); } + + /* Unbunching data is no longer valid. */ + v->ResetDepotUnbunching(); } } return CommandCost(); @@ -2142,6 +2145,9 @@ CommandCost CmdForceTrainProceed(DoComma * next signal we encounter. */ t->force_proceed = t->force_proceed == TFP_SIGNAL ? TFP_NONE : HasBit(t->flags, VRF_TRAIN_STUCK) || t->IsChainInDepot() ? TFP_STUCK : TFP_SIGNAL; SetWindowDirty(WC_VEHICLE_VIEW, t->index); + + /* Unbunching data is no longer valid. */ + t->ResetDepotUnbunching(); } return CommandCost(); @@ -2275,6 +2281,9 @@ static bool CheckTrainStayInDepot(Train return true; } + /* Check if we should wait here for unbunching. */ + if (v->IsWaitingForUnbunching()) return true; + SigSegState seg_state; if (v->force_proceed == TFP_NONE) { @@ -2315,8 +2324,9 @@ static bool CheckTrainStayInDepot(Train if (_settings_client.gui.show_track_reservation) MarkTileDirtyByTile(v->tile); VehicleServiceInDepot(v); + v->LeaveUnbunchingDepot(); + v->PlayLeaveStationSound(); SetWindowClassesDirty(WC_TRAINS_LIST); - v->PlayLeaveStationSound(); v->track = TRACK_BIT_X; if (v->direction & 2) v->track = TRACK_BIT_Y;