[Patch] Long Reserve PBS signal

Forum for technical discussions regarding development. If you have a general suggestion, problem or comment, please use one of the other forums.

Moderator: OpenTTD Developers

Jafinto
Engineer
Engineer
Posts: 10
Joined: 04 Apr 2009 12:35
Location: The Hague, The Netherlands

[Patch] Long Reserve PBS signal

Post by Jafinto » 04 Apr 2009 14:02

This patch adds another signal to the game: the Long Reserve PBS signal (I'm still looking for a better name).

This signal can be used to prioritize trains from a line, as is often needed when connecting lines with a main-line (coop-style). This can be done with the old blocksignals (see picture 1). But, when giving the train from the low priority line the choice between multiple high-priority lines, there are problems (I thought I saw a post about it on openttdcoop's blog, but I can't find it).

With the LR PBS signal, a train driving past it will try to reserve as much LR PBS signals in front of it (see picture 2). This also happens when the LR signal is already green.

So what do you guys think?
Attachments
1normal.png
Prioritizing trains using normal block signals
1normal.png (106.99 KiB) Viewed 11536 times
2LRPBS.png
Prioritizing trains using LR PBS signals
2LRPBS.png (91.26 KiB) Viewed 11535 times
LRv1r15954.diff
(16.82 KiB) Downloaded 198 times
Last edited by Jafinto on 07 Apr 2009 19:27, edited 1 time in total.

Forked
Engineer
Engineer
Posts: 43
Joined: 13 Jan 2008 20:36

Re: [Patch] Long Reserve PBS signal

Post by Forked » 04 Apr 2009 14:41

win32 binary attached

edit: nice one :) I like the idea.

edit2: binary removed due to GPL violation (it was missing the LICENSE, readme.txt etc.. this was not on purpose)
Last edited by Forked on 18 Apr 2009 00:21, edited 1 time in total.

Eddi
Tycoon
Tycoon
Posts: 7412
Joined: 17 Jan 2007 00:14

Re: [Patch] Long Reserve PBS signal

Post by Eddi » 04 Apr 2009 14:59

have you checked advance signals?
You might not exactly be interested in Ferion, but if you are, have fun :)

Jafinto
Engineer
Engineer
Posts: 10
Joined: 04 Apr 2009 12:35
Location: The Hague, The Netherlands

Re: [Patch] Long Reserve PBS signal

Post by Jafinto » 04 Apr 2009 15:12

Eddi wrote:have you checked advance signals?
That patch seems to have the same goal as my patch. It is strange though that it hasn't got a topic (as noted here. Is there any documentation on that patch available (ie. what do the different signals mean)?

Eddi
Tycoon
Tycoon
Posts: 7412
Joined: 17 Jan 2007 00:14

Re: [Patch] Long Reserve PBS signal

Post by Eddi » 04 Apr 2009 15:21

might find something in the IRC logs (that and the next few dates, probably)
You might not exactly be interested in Ferion, but if you are, have fun :)

audigex
Tycoon
Tycoon
Posts: 1919
Joined: 09 Dec 2007 21:28
Contact:

Re: [Patch] Long Reserve PBS signal

Post by audigex » 04 Apr 2009 20:33

I really like this idea, can you give more information on the signals? I can't quite work out what's going on from your pictures.

My idea on how to work it would be to have three types of signal.
1) Normal, bog standard PBS signals, work exactly as now and reserving one block.
2) Long-reserve signals which reserve as many blocks as possible (empty blocks up to a maximum or #3 signal, possibly with a setting, default at maybe 3/5)
3) No-reserve signals. Work as a standard PBS signal but a long-reserve signal will not reserve any blocks past this signal. Eg

2,1,1,1,1,1, will reserve 6 blocks
2,1,1,3,1,1 will serserve 3 blocks
Jon

Jafinto
Engineer
Engineer
Posts: 10
Joined: 04 Apr 2009 12:35
Location: The Hague, The Netherlands

Re: [Patch] Long Reserve PBS signal

Post by Jafinto » 04 Apr 2009 21:51

audigex wrote:I really like this idea, can you give more information on the signals? I can't quite work out what's going on from your pictures.

My idea on how to work it would be to have three types of signal.
1) Normal, bog standard PBS signals, work exactly as now and reserving one block.
2) Long-reserve signals which reserve as many blocks as possible (empty blocks up to a maximum or #3 signal, possibly with a setting, default at maybe 3/5)
3) No-reserve signals. Work as a standard PBS signal but a long-reserve signal will not reserve any blocks past this signal. Eg

2,1,1,1,1,1, will reserve 6 blocks
2,1,1,3,1,1 will serserve 3 blocks
I combined signals one and 3. A long-reserve signal will reserve as many blocks starting with another LR signal as possible. If it is not possible, for example when a train is in the way, it will try to reserve these blocks when it passes another LR signal. It doesn't matter if that signal is red or green (see pictures 1 and 2).

So, to stay in your terminology: the only 2 (important) signals are what you called signal 1 and 2. So in your examples:
2,1,1,1,1,1, will reserve 1 blocks
2,2,2,1,1,1 will reserve 3 blocks

Note that the LR signal is not a one-way signal, i.e. it can be passed from the back. I thought that wouldn't be a problem, since the most reasonably usage is after a normal PBS signal.

I like michi's solution though. If I understand it correctly, the frequency of a special signal indicates how many blocks have to be reserved.
Attachments
2LRPBS.png
1: Note that the train at bottom of the rightmost line couldn't reserve all the LR blocks in front of it.
2LRPBS.png (91.26 KiB) Viewed 11238 times
3extendingLR.png
2: After driving past the first LR signal, it reserves the rest of the path, even though the signal itself was green. (note that the view moved a bit to the right)
3extendingLR.png (86.92 KiB) Viewed 11248 times

audigex
Tycoon
Tycoon
Posts: 1919
Joined: 09 Dec 2007 21:28
Contact:

Re: [Patch] Long Reserve PBS signal

Post by audigex » 04 Apr 2009 21:57

Ah i get it now! I thought the signals with the red points either side were a special signal too :-)

A 1-way version could be useful too though, depending on track layout.
Jon

Jafinto
Engineer
Engineer
Posts: 10
Joined: 04 Apr 2009 12:35
Location: The Hague, The Netherlands

Re: [Patch] Long Reserve PBS signal

Post by Jafinto » 04 Apr 2009 22:02

audigex wrote:Ah i get it now! I thought the signals with the red points either side were a special signal too :-)

A 1-way version could be useful too though, depending on track layout.
Those with the red are the default one way signals in OTTD. About the 1-way version, that's the reason I liked michi's version, you can choose witch type of signal you like to use. On the other side, you do have to place (many) extra signals, and it will not reserve after you've passed the signals.

Jafinto
Engineer
Engineer
Posts: 10
Joined: 04 Apr 2009 12:35
Location: The Hague, The Netherlands

Re: [Patch] Long Reserve PBS signal

Post by Jafinto » 07 Apr 2009 19:40

New version, with loads of bug fixes. The patch of michi was quite useful, looking at his code and seeing where my logic failed :oops:. There are still some parts I have written myself though :wink:.

There is still a bug there somewhere, and I haven't got a clue how I can change the sprites of the signal (there are a few good unused signal sprites in openttd(d|w).grf). I guess I'll have to search the code some more.

Any suggestions for improvements?
Attachments
LRv2R15969.diff
(28.27 KiB) Downloaded 150 times

Kelytha
Engineer
Engineer
Posts: 2
Joined: 08 Apr 2009 00:01

Re: [Patch] Long Reserve PBS signal

Post by Kelytha » 08 Apr 2009 00:45

Works like a charm and the Combined North American Signals set has replacement for the sprites you used, so it not only works good, but also looks nice.

I hope this idea will get into the main branch one day, possibly together with a few other new signal types... you can just never have enough of them and each adds more possibilities to creative constructions. 8)

audigex
Tycoon
Tycoon
Posts: 1919
Joined: 09 Dec 2007 21:28
Contact:

Re: [Patch] Long Reserve PBS signal

Post by audigex » 08 Apr 2009 02:40

Jafinto wrote:
audigex wrote:Ah i get it now! I thought the signals with the red points either side were a special signal too :-)

A 1-way version could be useful too though, depending on track layout.
Those with the red are the default one way signals in OTTD. About the 1-way version, that's the reason I liked michi's version, you can choose witch type of signal you like to use. On the other side, you do have to place (many) extra signals, and it will not reserve after you've passed the signals.
I'm still using an older version of trunk, the PBS signals just look like old 1-way start pre-signals :-)

I'd really love this feature in trunk, it's one of the few things missing from YAPP.
Jon

Forked
Engineer
Engineer
Posts: 43
Joined: 13 Jan 2008 20:36

Re: [Patch] Long Reserve PBS signal

Post by Forked » 08 Apr 2009 05:42

win32 binary for v2
built against r15979

edit: binary removed due to GPL violation (it was missing the LICENSE, readme.txt etc.. this was not on purpose)
Last edited by Forked on 18 Apr 2009 00:20, edited 1 time in total.

Jafinto
Engineer
Engineer
Posts: 10
Joined: 04 Apr 2009 12:35
Location: The Hague, The Netherlands

Re: [Patch] Long Reserve PBS signal

Post by Jafinto » 08 Apr 2009 15:32

audigex wrote:I'm still using an older version of trunk, the PBS signals just look like old 1-way start pre-signals :-)

I'd really love this feature in trunk, it's one of the few things missing from YAPP.
Actually, it is the old 1-way pre-signal in the newer revision to ;). I just couldn't figure out where I could change it. Guess I'll have to look into it when I've got some free time.

User avatar
Expresso
Tycoon
Tycoon
Posts: 1730
Joined: 09 Aug 2004 00:14
Location: Gouda, the Netherlands

Re: [Patch] Long Reserve PBS signal

Post by Expresso » 09 Apr 2009 13:27

Nice patch. I'd love to see this in trunk (when it's reasonably bug-free).

Maybe you'd want your patch to change the save game version? So people testing this patch will get a nice error, instead of an assert, when they accidentally load a save game made with your patch applied in an unpatched openttd.

There's also some trailing whitespace in your patch, could you get rid of that?

el koeno
Route Supervisor
Route Supervisor
Posts: 454
Joined: 24 Sep 2004 15:47

Re: [Patch] Long Reserve PBS signal

Post by el koeno » 14 Apr 2009 12:46

I like the idea, I have one issue though:
Santa Ana Transport, 11th Jun 1930 (Medium).png
Santa Ana Transport, 11th Jun 1930 (Medium).png (241.87 KiB) Viewed 10044 times
In the screen shot there's a "main line" and a "side line". The train on the sideline is supposed to wait for the train on the main line. It does, for one train, but as soon as that one clear the merge block, the side line gets a green, blocking the second main line train, which was in the middle of its block, and thus unable to get a reservation for the merge block. Because the sideline train has to accelerate etc. it will block the main line, even though I built a prio-system that was supposed to avoid these problems.

I hope I made myself clear enough, otherwise feel free to ask for clarification. :)

Jafinto
Engineer
Engineer
Posts: 10
Joined: 04 Apr 2009 12:35
Location: The Hague, The Netherlands

Re: [Patch] Long Reserve PBS signal

Post by Jafinto » 14 Apr 2009 15:27

el koeno wrote:The train on the sideline is supposed to wait for the train on the main line. It does, for one train, but as soon as that one clear the merge block, the side line gets a green, blocking the second main line train, which was in the middle of its block, and thus unable to get a reservation for the merge block.
This is intended behaviour. At the start of the LR PBS block, the train will reserve as much LR-signals as possible. If it can't reserve past a certain signal, it will simply stop the reservation at that point. The train does try to extend its reservation when it passes another LR-signal though.

If I understand your problem correctly, you'd like either an immediate reservation when a block is free. I have no intention of coding such a thing. You could approximate the effect though, by putting a LR-signal on every track on the main line and leaving quite some space between the signals on the side line. There will still be some trains from the side line getting in front of trains from the main line, but way less.

Anyway, here is another update that fixes a bug with trains that couldn't find a path to their destination but could find a 'safe' path. Oh, I also changed the save game version ;)

I've also looked into the signals, but that is taking some more time because 1) I can't draw and 2) I do not understand the way OTTD loads the signals from the grf file. Any suggestions (especially on the latter) would be appreciated :P
Attachments
LRv3R16057.diff
(29.21 KiB) Downloaded 206 times

el koeno
Route Supervisor
Route Supervisor
Posts: 454
Joined: 24 Sep 2004 15:47

Re: [Patch] Long Reserve PBS signal

Post by el koeno » 14 Apr 2009 16:02

Jafinto wrote:
el koeno wrote:The train on the sideline is supposed to wait for the train on the main line. It does, for one train, but as soon as that one clear the merge block, the side line gets a green, blocking the second main line train, which was in the middle of its block, and thus unable to get a reservation for the merge block.
This is intended behaviour. At the start of the LR PBS block, the train will reserve as much LR-signals as possible. If it can't reserve past a certain signal, it will simply stop the reservation at that point. The train does try to extend its reservation when it passes another LR-signal though.

If I understand your problem correctly, you'd like either an immediate reservation when a block is free. I have no intention of coding such a thing. You could approximate the effect though, by putting a LR-signal on every track on the main line and leaving quite some space between the signals on the side line. There will still be some trains from the side line getting in front of trains from the main line, but way less.

...
Well, the thing is I'd like to create a priority system. Right now, if a set of trains comes along the main line, the first one will have priority over the side line. The next ones only stand a fifty-fifty chance (not sure about this) of getting priority over the side line if they happen to be at a signal at the exact moment the first train passes the merge block. Which is a big if. So if this is intended behaviour, your system is unfit to serve as a priority system, and I personally see little use for it.

Jafinto
Engineer
Engineer
Posts: 10
Joined: 04 Apr 2009 12:35
Location: The Hague, The Netherlands

Re: [Patch] Long Reserve PBS signal

Post by Jafinto » 14 Apr 2009 16:22

el koeno wrote:Well, the thing is I'd like to create a priority system. Right now, if a set of trains comes along the main line, the first one will have priority over the side line. The next ones only stand a fifty-fifty chance (not sure about this) of getting priority over the side line if they happen to be at a signal at the exact moment the first train passes the merge block. Which is a big if. So if this is intended behaviour, your system is unfit to serve as a priority system, and I personally see little use for it.
I understand what you want, but I do not see little use for a system you propose ;). In the games that I play, the chance of two trains waiting for another one to clear from a junction is pretty low. If it happens a lot at one junction, I've gotten to much traffic on to little track and I'll have to increase the amount of tracks. That's where my patch comes in handy: when there two or more tracks to choose from that all go the same way.

User avatar
Ammler
President
President
Posts: 953
Joined: 18 Jun 2006 18:18
Location: Switzerland
Contact:

Re: [Patch] Long Reserve PBS signal

Post by Ammler » 14 Apr 2009 17:30

Basically, he (and we) would like to replace prio systems with presignals like here: http://www.openttdcoop.org/wiki/Prio#Pa ... _presignal

Greets
Ammler

Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: einsteinyh, Google Adsense [Bot] and 7 guests