[Patch] Longer pbs reservations

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

Gastje33
Engineer
Engineer
Posts: 22
Joined: 05 Aug 2004 14:06
Location: Netherlands

[Patch] Longer pbs reservations

Post by Gastje33 »

This patch will eventually add some useful signal types to the game. Currently, it is a mere update of Jafinto's long reserve patch.

Long reserve PBS signals can be chosen in the signal gui (the most right, with the vertical gray bar). Trains try to extend the reserved path to a normal signal.
How this can help to prioritize lines. The train coming from the south has to wait for the train on the main line.
How this can help to prioritize lines. The train coming from the south has to wait for the train on the main line.
Kollumelmuiden Transport, 17 Apr 1950.png (59.92 KiB) Viewed 1575 times
History:
0.1 - Loaded with bugs...
0.2 - Adds long reserve PBS signals. Based on Jafinto's work.

Roadmap:
0.3 - Real pre-signals: signals that can only show yellow and green, and are not safe waiting places.
0.4 - Graphics for the new signal types.
0.5 - Combination between normal PBS and pre-signals (red, yellow and green states)?
Attachments
longer reservations 0.1.patch
Should work with any current trunk. Patch made with Mercurial.
(11.11 KiB) Downloaded 151 times
long_reserve_0.2.patch
Based on the work of Jafinto. Made with Git. Apply with patch -p0 to a current version of trunk.
(15.29 KiB) Downloaded 133 times
Last edited by Gastje33 on 23 Dec 2009 01:55, edited 2 times in total.
kvtb
Engineer
Engineer
Posts: 70
Joined: 13 Mar 2005 11:42

Re: [Patch] Longer pbs reservations

Post by kvtb »

Hi, sounds interesting, but do you have an example of a situation (track layout) where I would benefit from having this functionality?
petert
Tycoon
Tycoon
Posts: 3008
Joined: 02 Apr 2009 22:43
Location: Massachusetts, USA

Re: [Patch] Longer pbs reservations

Post by petert »

Here is a bundle built with GCC against r18563, just for testing purposes. Nice looking patch, I see you can reserve the block that a train reserves? Would be good for priorities.
Attachments
longer_reservations_0.1_win32_r18563.rar
(3.49 MiB) Downloaded 105 times
rbn2903
Engineer
Engineer
Posts: 122
Joined: 08 Dec 2007 18:04
Location: Aachen (Aken), Germany

Re: [Patch] Longer pbs reservations

Post by rbn2903 »

I think this is an interesting approach, but in my opinion it would be more useful, if you could set the number of reserved block as a "per-train" (or "per-group")-setting. That way you'd be able to achieve priority for passenger trains over freight trains (for example; or fast passenger trains over slower ones).
Gastje33
Engineer
Engineer
Posts: 22
Joined: 05 Aug 2004 14:06
Location: Netherlands

Re: [Patch] Longer pbs reservations

Post by Gastje33 »

kvtb wrote:Hi, sounds interesting, but do you have an example of a situation (track layout) where I would benefit from having this functionality?
No, not yet. I'm just programming this for yellow signals.
rbn2903 wrote:I think this is an interesting approach, but in my opinion it would be more useful, if you could set the number of reserved block as a "per-train" (or "per-group")-setting. That way you'd be able to achieve priority for passenger trains over freight trains (for example; or fast passenger trains over slower ones).
That is a good idea. After I fixed some bugs, I'll have a look at how hard it is to implement.
rbn2903
Engineer
Engineer
Posts: 122
Joined: 08 Dec 2007 18:04
Location: Aachen (Aken), Germany

Re: [Patch] Longer pbs reservations

Post by rbn2903 »

Gastje33 wrote:That is a good idea. After I fixed some bugs, I'll have a look at how hard it is to implement.
Actually over a year ago there was an interesting thread regarding "priorities" (http://www.tt-forums.net/viewtopic.php? ... it=pps+ppo) and there were two ways mentioned to achieve priority: "priority path order" and "priority path signal". If priority reflects the idea behind your patch, you might be interested in that thread (it's only two pages ;) ) Otherwise I would be interested in what you are trying to achieve with this patch.

I also have two questions: Let's say a train wants to reserve 2 blocks, but only can do one, because the second one is already busy. Would this train reserve the second block as soon as it's free again or only if the trains arrives at the upcoming signal.
And if a train reserves 4 blocks and drives through the next signal, will it eventually change it's previous reservation because a better path got available?

Keep up the good work :]
Gastje33
Engineer
Engineer
Posts: 22
Joined: 05 Aug 2004 14:06
Location: Netherlands

Re: [Patch] Longer pbs reservations

Post by Gastje33 »

rbn2903 wrote: Otherwise I would be interested in what you are trying to achieve with this patch.
Well, I wanted to implement yellow signal state, for that trains need to reserve two blocks. Although, it seems to be a good system for priorities too, if the amount of blocks can be set per train.
rbn2903 wrote: Let's say a train wants to reserve 2 blocks, but only can do one, because the second one is already busy. Would this train reserve the second block as soon as it's free again or only if the trains arrives at the upcoming signal.
Only if the train requests a reservation, which is at the next signal.
rbn2903 wrote: And if a train reserves 4 blocks and drives through the next signal, will it eventually change it's previous reservation because a better path got available?
That would make it much more complicated, I'm just starting to learn the OpenTTD code. :P
rbn2903
Engineer
Engineer
Posts: 122
Joined: 08 Dec 2007 18:04
Location: Aachen (Aken), Germany

Re: [Patch] Longer pbs reservations

Post by rbn2903 »

Hm, OK, I could unterstand it, if you said: I want a train to reserve more than one block, so I need a yellow signal state as an indicator. But the other way around? I'm sorry and I don't want to be harsh: What's the use in having a yellow signal state? :)
Gastje33 wrote:That would make it much more complicated, I'm just starting to learn the OpenTTD code.
Yes, you are right. That may be some option for a future patch.
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: [Patch] Longer pbs reservations

Post by planetmaker »

http://www.icosahedron.de/openttd/patch ... s_v2.patch <-- a patch with ahead-reservation which doesn't crash... - but it's a bit old by now and it probably will need updating.
Dappa
Engineer
Engineer
Posts: 4
Joined: 13 Dec 2009 15:08

Re: [Patch] Longer pbs reservations

Post by Dappa »

Would it be possible to automatically reserve all the following blocks with one entreance and one exit? So we you would get greens from the train up to the next junction. This would indicate an incoming train long before it might enter the screen.
Alberth
OpenTTD Developer
OpenTTD Developer
Posts: 4766
Joined: 09 Sep 2007 05:03
Location: home

Re: [Patch] Longer pbs reservations

Post by Alberth »

That's easy, don't put any signals between junctions.
Dappa
Engineer
Engineer
Posts: 4
Joined: 13 Dec 2009 15:08

Re: [Patch] Longer pbs reservations

Post by Dappa »

Yeah, but if there is a second train (and there usually is), it'll have to wait until the first train clears the entire track. And regular signals are just... always green, not only when a path is reserved.
Gastje33
Engineer
Engineer
Posts: 22
Joined: 05 Aug 2004 14:06
Location: Netherlands

Re: [Patch] Longer pbs reservations

Post by Gastje33 »

rbn2903 wrote:What's the use in having a yellow signal state? :)
It irritates me that trains stop completely if they are behind a slower train. If they first encounter a yellow signal, they only slow down and (hopefully) the next signal is green again.
planetmaker wrote:http://www.icosahedron.de/openttd/patch ... s_v2.patch <-- a patch with ahead-reservation which doesn't crash... - but it's a bit old by now and it probably will need updating.
I should have done some research before I started coding... Thank you for that patch, and of course thanks to the original patch maker.
Dappa wrote:Yeah, but if there is a second train (and there usually is), it'll have to wait until the first train clears the entire track. And regular signals are just... always green, not only when a path is reserved.
In the Netherlands, signals on sections without switches (P-signals) are also always green.
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: [Patch] Longer pbs reservations

Post by planetmaker »

Hehe. The author of the first patch (and the whole PBS stuff as found in trunk for that matter) also made a - by his standards - hacky patch to allow yellow states: http://www.icosahedron.de/openttd/patch ... _hack.diff

But I really like seeing this idea picked up again :-)
Alberth
OpenTTD Developer
OpenTTD Developer
Posts: 4766
Joined: 09 Sep 2007 05:03
Location: home

Re: [Patch] Longer pbs reservations

Post by Alberth »

You seem to contradict yourself:
Dappa wrote:Would it be possible to automatically reserve all the following blocks with one entreance and one exit? So we you would get greens from the train up to the next junction. This would indicate an incoming train long before it might enter the screen.
Dappa wrote:Yeah, but if there is a second train (and there usually is), it'll have to wait until the first train clears the entire track. And regular signals are just... always green, not only when a path is reserved.
Given that reservations mean that no other train can use the reserved blocks, how do you expect the second train to 'reserve all the following blocks with one entreance and one exit?' while the first train is on it?
I see no other solution than to have the second train wait until the first one is at the next junction, which is exactly what happens if you have no signals between junctions.

Edit: Added italics font to the quote for more emphasis.
el koeno
Route Supervisor
Route Supervisor
Posts: 454
Joined: 24 Sep 2004 15:47

Re: [Patch] Longer pbs reservations

Post by el koeno »

This looks very interesting. There are quite a few threads about signals that might or might not be useful to you. Here´s two of them that weren´t linked to yet in this thread:

Multi-Aspect Signals (MAS)
Long Reserve PBS signal
Gastje33 wrote:
rbn2903 wrote: Let's say a train wants to reserve 2 blocks, but only can do one, because the second one is already busy. Would this train reserve the second block as soon as it's free again or only if the trains arrives at the upcoming signal.
Only if the train requests a reservation, which is at the next signal.
If you want to make priorities (which would be the most useful purpose of this idea), they absolutely have to make the next reservation as soon as the block becomes available. However, if you just want the yellow signal state, you´ll be fine. Someone else will have to code it in such a way that it suits priorities. :)
Gastje33
Engineer
Engineer
Posts: 22
Joined: 05 Aug 2004 14:06
Location: Netherlands

Re: [Patch] Longer pbs reservations

Post by Gastje33 »

el koeno wrote:This looks very interesting. There are quite a few threads about signals that might or might not be useful to you. Here´s two of them that weren´t linked to yet in this thread:

Multi-Aspect Signals (MAS)
Long Reserve PBS signal
Those seem very helpful. Thank you.
el koeno wrote:If you want to make priorities (which would be the most useful purpose of this idea), they absolutely have to make the next reservation as soon as the block becomes available. However, if you just want the yellow signal state, you´ll be fine. Someone else will have to code it in such a way that it suits priorities. :)
My first goal is just a yellow signal state. I'm starting to learn the code a bit now, so maybe later I'll add thing like priorities.
Dappa
Engineer
Engineer
Posts: 4
Joined: 13 Dec 2009 15:08

Re: [Patch] Longer pbs reservations

Post by Dappa »

Alberth wrote:You seem to contradict yourself:
Dappa wrote:Would it be possible to automatically reserve all the following blocks with one entreance and one exit? So we you would get greens from the train up to the next junction. This would indicate an incoming train long before it might enter the screen.
Dappa wrote:Yeah, but if there is a second train (and there usually is), it'll have to wait until the first train clears the entire track. And regular signals are just... always green, not only when a path is reserved.
Given that reservations mean that no other train can use the reserved blocks, how do you expect the second train to 'reserve all the following blocks with one entreance and one exit?' while the first train is on it?
I see no other solution than to have the second train wait until the first one is at the next junction, which is exactly what happens if you have no signals between junctions.

Edit: Added italics font to the quote for more emphasis.
Sorry for not being clear. What I meant was the possibility of reserving blocks as fas as possible, with single entrances and exits. This would be up to a junction, or the next train.
Gastje33
Engineer
Engineer
Posts: 22
Joined: 05 Aug 2004 14:06
Location: Netherlands

Re: [Patch] Longer pbs reservations

Post by Gastje33 »

I have stopped working on my original patch. It was too buggy. I've decided to use the patch in this topic as a basis for my intended additions. The patch can be found in the first post. I couldn't upload the Win32 build, I'll give it another try tomorrow.
Last edited by Gastje33 on 23 Dec 2009 01:59, edited 2 times in total.
petert
Tycoon
Tycoon
Posts: 3008
Joined: 02 Apr 2009 22:43
Location: Massachusetts, USA

Re: [Patch] Longer pbs reservations

Post by petert »

That link you posted is to an image of the topic icon... :-P
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: Bing [Bot] and 0 guests