(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.

pull/155/head
hackykid 19 years ago
parent 54cbd01825
commit aed6f08640

@ -525,7 +525,7 @@ static int32 NPFRailPathCost(AyStar* as, AyStarNode* current, OpenListNode* pare
if (NPFGetFlag(current, NPF_FLAG_PBS_BLOCKED)) { if (NPFGetFlag(current, NPF_FLAG_PBS_BLOCKED)) {
cost += 1000; cost += 1000;
} }
if (PBSIsPbsDepot(tile)) { if (PBSIsPbsSegment(tile, ReverseTrackdir(trackdir))) {
NPFSetFlag(current, NPF_FLAG_PBS_EXIT, true); NPFSetFlag(current, NPF_FLAG_PBS_EXIT, true);
NPFSetFlag(current, NPF_FLAG_SEEN_SIGNAL, true); NPFSetFlag(current, NPF_FLAG_SEEN_SIGNAL, true);
} }

@ -269,11 +269,11 @@ static bool SetSignalsEnumProcPBS(uint tile, SetSignalsDataPbs *ssd, int trackdi
return false; return false;
} }
bool PBSIsPbsDepot(uint tile) bool PBSIsPbsSegment(uint tile, Trackdir trackdir)
{ {
SetSignalsDataPbs ssd; SetSignalsDataPbs ssd;
bool result = false; bool result = PBSIsPbsSignal(tile, trackdir);
DiagDirection direction = GetDepotDirection(tile,TRANSPORT_RAIL); DiagDirection direction = TrackdirToExitdir(trackdir);//GetDepotDirection(tile,TRANSPORT_RAIL);
int i; int i;
ssd.cur = 0; ssd.cur = 0;

11
pbs.h

@ -72,12 +72,13 @@ bool PBSIsPbsSignal(TileIndex tile, Trackdir trackdir);
* @return True when there are pbs signals on that tile * @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. * Checks if a signal/depot leads to 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. * 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 depot tile to check * @param tile The tile to check
* @return True when the depot is inside a pbs block. * @param trackdir The direction in which to check
* @return True when the depot is inside a pbs block
*/ */
#endif #endif

@ -1801,6 +1801,7 @@ static bool CheckTrainStayInDepot(Vehicle *v)
return false; return false;
if (v->u.rail.force_proceed == 0) { if (v->u.rail.force_proceed == 0) {
byte trackdir = GetVehicleTrackdir(v);
if (++v->load_unload_time_rem < 37) { if (++v->load_unload_time_rem < 37) {
InvalidateWindowClasses(WC_TRAINS_LIST); InvalidateWindowClasses(WC_TRAINS_LIST);
return true; return true;
@ -1808,8 +1809,7 @@ static bool CheckTrainStayInDepot(Vehicle *v)
v->load_unload_time_rem = 0; v->load_unload_time_rem = 0;
if (PBSIsPbsDepot(v->tile)) { if (PBSIsPbsSegment(v->tile, trackdir)) {
byte trackdir = GetVehicleTrackdir(v);
NPFFindStationOrTileData fstd; NPFFindStationOrTileData fstd;
NPFFoundTargetData ftd; NPFFoundTargetData ftd;

Loading…
Cancel
Save