From e78a235293be7938040ff33d932d44fa265ca83b Mon Sep 17 00:00:00 2001 From: rubidium Date: Sat, 2 Aug 2008 22:55:52 +0000 Subject: (svn r13960) -Codechange [YAPP]: Reserve a path when exiting a depot into a PBS block. (michi_cc) --- src/train_cmd.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'src/train_cmd.cpp') diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index 9e736e3cc..3ba1045d5 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -2379,7 +2379,10 @@ static bool CheckTrainStayInDepot(Vehicle *v) return true; } + SigSegState seg_state; + if (v->u.rail.force_proceed == 0) { + /* force proceed was not pressed */ if (++v->load_unload_time_rem < 37) { InvalidateWindowClasses(WC_TRAINS_LIST); return true; @@ -2387,12 +2390,27 @@ static bool CheckTrainStayInDepot(Vehicle *v) v->load_unload_time_rem = 0; - if (UpdateSignalsOnSegment(v->tile, INVALID_DIAGDIR, v->owner) == SIGSEG_FULL) { + seg_state = _settings_game.pf.reserve_paths ? SIGSEG_PBS : UpdateSignalsOnSegment(v->tile, INVALID_DIAGDIR, v->owner); + if (seg_state == SIGSEG_FULL || GetDepotWaypointReservation(v->tile)) { + /* Full and no PBS signal in block or depot reserved, can't exit. */ InvalidateWindowClasses(WC_TRAINS_LIST); return true; } + } else { + seg_state = _settings_game.pf.reserve_paths ? SIGSEG_PBS : UpdateSignalsOnSegment(v->tile, INVALID_DIAGDIR, v->owner); + } + + /* Only leave when we can reserve a path to our destination. */ + if (seg_state == SIGSEG_PBS && !TryPathReserve(v) && v->u.rail.force_proceed == 0) { + /* No path and no force proceed. */ + InvalidateWindowClasses(WC_TRAINS_LIST); + MarkTrainAsStuck(v); + return true; } + SetDepotWaypointReservation(v->tile, true); + if (_settings_client.gui.show_track_reservation) MarkTileDirtyByTile(v->tile); + VehicleServiceInDepot(v); InvalidateWindowClasses(WC_TRAINS_LIST); v->PlayLeaveStationSound(); -- cgit v1.2.3-54-g00ecf