summaryrefslogtreecommitdiff
path: root/npf.c
diff options
context:
space:
mode:
authorhackykid <hackykid@openttd.org>2005-07-17 20:09:02 +0000
committerhackykid <hackykid@openttd.org>2005-07-17 20:09:02 +0000
commit1d11bbb34da6bb1cfd8d8351f61940c92027ed55 (patch)
tree2aa47a2f10516c02b42213645730108be6987d02 /npf.c
parenteabc48218413f5d3e9e26d3675e32055af8cfc61 (diff)
downloadopenttd-1d11bbb34da6bb1cfd8d8351f61940c92027ed55.tar.xz
(svn r2625) - Fix: [pbs] Store the end of a train's reserved path explicitly. Prevents trains from unreserving eachothers paths in some cases.
- CodeChange: Use the TrackdirToTrack function instead of &7, and remove an unneeded variable.
Diffstat (limited to 'npf.c')
-rw-r--r--npf.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/npf.c b/npf.c
index 81601cb97..a1f5e52df 100644
--- a/npf.c
+++ b/npf.c
@@ -180,27 +180,35 @@ void NPFReservePBSPath(AyStar *as)
* BUT, you have to have a pretty fucked up junction layout for this to happen,
* so we'll just stop this train, the user will eventually notice, so he can fix it.
*/
- PBSClearPath(start, trackdir);
+ PBSClearPath(start, trackdir, curr->node.tile, curr->node.direction);
NPFSetFlag(&ftd->node, NPF_FLAG_PBS_BLOCKED, true);
DEBUG(pbs, 1) ("PBS: Self-crossing path!!!");
return;
};
- PBSReserveTrack(curr->node.tile, (curr->node.direction & 7) );
-
- /* we want to reserve the last tile (with the signal) on the path too */
- if (prev != NULL && start == INVALID_TILE) {
- PBSReserveTrack(prev->node.tile, (prev->node.direction & 7) );
- start = prev->node.tile;
- trackdir = ReverseTrackdir(prev->node.direction);
+ PBSReserveTrack(curr->node.tile, TrackdirToTrack(curr->node.direction) );
+
+ /* we want to reserve the last tile (with the signal) on the path too
+ also remember this tile, cause its the end of the path (where we exit the block) */
+ if (start == INVALID_TILE) {
+ if (prev != NULL) {
+ PBSReserveTrack(prev->node.tile, TrackdirToTrack(prev->node.direction) );
+ start = prev->node.tile;
+ trackdir = ReverseTrackdir(prev->node.direction);
+ } else {
+ start = curr->node.tile;
+ trackdir = curr->node.direction;
+ }
}
}
prev = curr;
curr = curr->parent;
} while (curr != NULL);
+ // we remember the tile/track where this path leaves the pbs junction
+ ftd->node.tile = start;
+ ftd->node.direction = trackdir;
}
-
}