From aa29ee6eda861ceac08d226a6d7e1de5dae74749 Mon Sep 17 00:00:00 2001 From: hackykid Date: Fri, 22 Jul 2005 08:40:19 +0000 Subject: [PATCH] (svn r2674) - CodeChange: [pbs] Generalise the PSBISPbsDepot function so it can check if an arbitrary junction is a pbs junction. Preparations for making pbs more safe. --- npf.c | 2 +- pbs.c | 6 +++--- pbs.h | 11 ++++++----- train_cmd.c | 4 ++-- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/npf.c b/npf.c index 6bbaefcf2c..66d370136b 100644 --- a/npf.c +++ b/npf.c @@ -525,7 +525,7 @@ static int32 NPFRailPathCost(AyStar* as, AyStarNode* current, OpenListNode* pare if (NPFGetFlag(current, NPF_FLAG_PBS_BLOCKED)) { cost += 1000; } - if (PBSIsPbsDepot(tile)) { + if (PBSIsPbsSegment(tile, ReverseTrackdir(trackdir))) { NPFSetFlag(current, NPF_FLAG_PBS_EXIT, true); NPFSetFlag(current, NPF_FLAG_SEEN_SIGNAL, true); } diff --git a/pbs.c b/pbs.c index 4cfa2d9f5c..c612ae41c8 100644 --- a/pbs.c +++ b/pbs.c @@ -269,11 +269,11 @@ static bool SetSignalsEnumProcPBS(uint tile, SetSignalsDataPbs *ssd, int trackdi return false; } -bool PBSIsPbsDepot(uint tile) +bool PBSIsPbsSegment(uint tile, Trackdir trackdir) { SetSignalsDataPbs ssd; - bool result = false; - DiagDirection direction = GetDepotDirection(tile,TRANSPORT_RAIL); + bool result = PBSIsPbsSignal(tile, trackdir); + DiagDirection direction = TrackdirToExitdir(trackdir);//GetDepotDirection(tile,TRANSPORT_RAIL); int i; ssd.cur = 0; diff --git a/pbs.h b/pbs.h index 2cac9498e9..9b9aea1609 100644 --- a/pbs.h +++ b/pbs.h @@ -72,12 +72,13 @@ bool PBSIsPbsSignal(TileIndex tile, Trackdir trackdir); * @return True when there are pbs signals on that tile */ -bool PBSIsPbsDepot(uint tile); +bool PBSIsPbsSegment(uint tile, Trackdir trackdir); /**< - * Checks if a depot is inside a pbs block. - * Tis means that the block it is in needs to have at least 1 signal, and that all signals in it need to be pbs signals. - * @param tile The depot tile to check - * @return True when the depot is inside a pbs block. + * Checks if a signal/depot leads to a pbs block. + * This means that the block needs to have at least 1 signal, and that all signals in it need to be pbs signals. + * @param tile The tile to check + * @param trackdir The direction in which to check + * @return True when the depot is inside a pbs block */ #endif diff --git a/train_cmd.c b/train_cmd.c index 471d15e595..f7ec9579f5 100644 --- a/train_cmd.c +++ b/train_cmd.c @@ -1801,6 +1801,7 @@ static bool CheckTrainStayInDepot(Vehicle *v) return false; if (v->u.rail.force_proceed == 0) { + byte trackdir = GetVehicleTrackdir(v); if (++v->load_unload_time_rem < 37) { InvalidateWindowClasses(WC_TRAINS_LIST); return true; @@ -1808,8 +1809,7 @@ static bool CheckTrainStayInDepot(Vehicle *v) v->load_unload_time_rem = 0; - if (PBSIsPbsDepot(v->tile)) { - byte trackdir = GetVehicleTrackdir(v); + if (PBSIsPbsSegment(v->tile, trackdir)) { NPFFindStationOrTileData fstd; NPFFoundTargetData ftd;