Page 1 of 23

Path Based Signalling!!! (pbs v080)

Posted: 11 Mar 2005 20:27
by Hackykid
I've been working on path based signaling (a brilliant idea from the ttdpatch people) recently and i decided to post the patch here so people can test it, and help a bit with finding bugs of course :wink:

Path based signaling will allow more then 1 train on a junction at a time, provided their paths don't cross. This works by letting the trains 'reserve' the path they are planning to take. Reserved tracks are shown darker as normal tracks. (see screenshot)

You build such a PBS-junction by making all signals (entrance and exit) to that junctions PBS signals, you do this by ctrl-clicking 4 times on a normal signal.

For this patch to work, you need to put nsignalsw.grf (made by Michael Blunck) in your /data directory.
Get this file at Michael's site -> Download -> nsignalsw.zip , or in the 'new graphics' section at the TTDPatch Website.

Its best to only use 2-way signals at dead end exits, like terminus stations.

Also, PBS needs NPF (new pathfinder) enabled, otherwise it won't work.

Known bugs:
  • - the darkened track don't display 100% correctly on all tiles (not really a bug, just a gfx glitch)
    - [fixed] a crashed train wont release the tracks it has reserved
If you find any other bugs, post here or contact me at IRC.

Posted: 11 Mar 2005 20:40
by Horse
Wow that seems great.

Maybe a new great featuere for this great game. :D

Posted: 11 Mar 2005 20:51
by Zahl
Could anyone compile it for win32? :)

Posted: 11 Mar 2005 21:27
by Hackykid
I have added a build for windows, see first post.

Posted: 12 Mar 2005 00:43
by Zahl
Thanks!

First impression is very good, this really could revolutionize railbuilding ;)
It seems in some cases reserved track won't be released after a train
used it. Most time this happened on big junctions/stations (used older
savegames), but I got this bug appear on a small junction,
see screenshot. The train will wait there forever.

Posted: 12 Mar 2005 01:12
by Hackykid
hmm, yes, i see

Unfortunately i cant really see what would cause that from the screenshot.

Did you have NPF enabled? ( i forgot to mention this at first, but it is really needed)

Otherwise, i cant really see what could have caused this...

Hmm, i'll try building a similar setup and see if it happens to me too...

EDIT:
ok, i think i know what caused this

the problems started with the pieces of straight track between the station and the junction. because it has semaphores on each end, its treated as a pbs-block, and that setup can cause grid-locks.
This will lead to a train timing out at a signal and reversing, and reversing is not properly handled yet.

So, what you can do, it place a normal signal on those straight tracks, or remove the semaphores on the straight tracks.

Also demolishing a square (with the dynamite) and then rebuilding the track will reset the 'reserved' status.

Posted: 12 Mar 2005 01:41
by Dextro
looking good, can't wait to try this out :mrgreen: (I'll wait until development is almost finished, I like my subsidiaries patch :oops: )

btw any hopes of getting this merged into the trunk when it's done? :roll:

Posted: 12 Mar 2005 09:30
by tecxx
hackykid, are the semaphore signals just for style or are they necessary? :=) (in other words: can i use normal signals?)

Posted: 12 Mar 2005 12:20
by StavrosG
I've noticed that, on a busy pbs block, if the (only)line a train entering the block is blocked (red signal at the exit), the train will go somewhere else, instead of just waiting, reverse when it has the chance, and come back to the junction.

Here's a pic:
The grain train on the junction is going to the left exit. When it entered the block, the signal was red because of the livestock train on the left, so the grain train went straight ahead. Shortly after, the signal went green so the train changed its path to go where it should. But if the track wasn't freed quickly enough, the train would continue to the wrong direction.
I should add that they don't go very far off to reverse, but still, its anoying.

Posted: 12 Mar 2005 12:55
by Hackykid
hmm, yes, that is indeed a problem....

Ok, I've thought of a way too fix this, but it'll be a bit of work, I'll probably start working on it today.

Until its finished, I'll add this to the known bugs list.

Posted: 12 Mar 2005 15:39
by Dextro
tecxx wrote:hackykid, are the semaphore signals just for style or are they necessary? :=) (in other words: can i use normal signals?)
now here's something I would like to know aswell :roll:

Posted: 12 Mar 2005 15:44
by Zahl
OK, with normal signals on the track it works. Maybe tracks
with just 1 exit (2 ends) should never be treated as pbs junctions...
I also realized that removing reserved track does not work
(at least sometimes..) In the savegame from the example, I
tried to remove the dark track. I heard the removing-sound,
but the track was still there (only on the screen). when I
tried to remove it again, it said there is no track to remove.
Only demolishing works.

EDIT:
Got a similar problem to that of StavrosG. Same junction as
above, with signals on the straight track. One train coming from
the bottom wanted to go to the station. As the exit semaphore was red
because of another train on the track, the train reserved the track
to the exit top right. Just in that moment, the exit semaphore to the
station turned to green, so the train changed its way, but did not release
the old track.

Maybe a little workaround would be to auto-release reserved tracks after
let's say 30 seconds.

EDIT2: I was not able to reproduce this bug, maybe there were some
other circumstances.

Posted: 12 Mar 2005 17:15
by Darkvater
Dextro wrote:
tecxx wrote:hackykid, are the semaphore signals just for style or are they necessary? :=) (in other words: can i use normal signals?)
now here's something I would like to know aswell :roll:
Currently you use Semaphore signals to identify a PBS block. So yes, they are neccessary!

When it's done it'll be merged.

Posted: 12 Mar 2005 17:52
by Patchman
Hackykid wrote:hmm, yes, that is indeed a problem....

Ok, I've thought of a way too fix this, but it'll be a bit of work, I'll probably start working on it today.

Until its finished, I'll add this to the known bugs list.
One algorithm that helped with this in TTDPatch PBS was to call the pathfinding twice, once the regular pathfinding, and once ignoring reserved pieces and red one-way signals. If the second call gives a much better (shorter) route, I tell the train to wait before entering the PBS block until this route becomes available, instead of taking the worse route right away.

Not sure if that's still feasible with OTTD's pathfinding, but it might be an idea to try.

Posted: 12 Mar 2005 18:48
by Hackykid
Zahl wrote:Just in that moment, the exit semaphore to the
station turned to green, so the train changed its way, but did not release
the old track.
hmm, when a train changes its way, it should defenately release all tracks it had reserved previously, are you sure this is what happened?

I know about trains going the wrong way when the only singal leading to where they go is red, and I'm almost done with a fix for that, I'll probably post it tonight.

Posted: 12 Mar 2005 18:57
by Dextro
Darkvater wrote:
Dextro wrote:
tecxx wrote:hackykid, are the semaphore signals just for style or are they necessary? :=) (in other words: can i use normal signals?)
now here's something I would like to know aswell :roll:
Currently you use Semaphore signals to identify a PBS block. So yes, they are neccessary!

When it's done it'll be merged.
great, can't wait to get my subsidiaries with this :mrgreen:

It's a pity you need to use semaphores though, but I can understand why :?

Posted: 12 Mar 2005 20:29
by Hackykid
UPDATE:
new version (v050), the bug where trains would go the wrong way when the way they wanted to go was red, is fixed now,

look at the start post for the .diff and the windows build


btw, this version changes my implementation quite a bit, and has not been tested as extensively, so there *may* be more other bugs introduced by it.....

Posted: 13 Mar 2005 02:20
by markr
Just tested this.

Looking good, but if a train breaks down at a certain point, the next train crashes straight into it.

In this savegame, the train on the LHS of the screen is just about to go through a red light, find a free path (which is covered by a broken train) and crash.

Mark

Posted: 13 Mar 2005 11:49
by Hackykid
ah, well, your problem is not that trains are breaking down, but that they enter a pbs block without reserving tracks when they cant find a route to their destination.

You placed one of your signals the wrong way, which meant the train could not find a path.

I have now fixed this, trains who cant find their destination wont enter PBS-blocks. (v051)

The .diff and the windows build are in the start post.

Posted: 13 Mar 2005 15:34
by StavrosG
I've been suffering from a very nasty bug in v050, which ends in an Assertion fail:

Code: Select all

[16:06]stavrosg@lorien trunk$ ./openttd
openttd: train_cmd.c:2943: TrainCheckIfLineEnds: Assertion `trackdir != 0xff' failed.
Ακυρώθηκε
[16:50]stavrosg@lorien trunk$
Savegame + config file in archive: Watch Train 14.