YAPP - Yet Another PBS Patch (now in trunk!)

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

Michi_cc
OpenTTD Developer
OpenTTD Developer
Posts: 619
Joined: 14 Jun 2004 23:27
Location: Berlin, Germany
Contact:

Re: YAPP - Yet Another PBS Patch

Post by Michi_cc »

peter1138 wrote:

Code: Select all

SDT_CONDVAR(Patches, default_signal_type, SLE_UINT8, 87, SL_MAX_VERSION,
     N,MS, 0, 0, 2, 1, STR_CONFIG_PATCHES_DEFAULT_SIGNAL_TYPE,      NULL),
SDT_CONDVAR(Patches, cycle_signal_types,  SLE_UINT8, 87, SL_MAX_VERSION,
     N,MS, 0, 0, 2, 1, STR_CONFIG_PATCHES_CYCLE_SIGNAL_TYPES,       NULL),
Why should these be saved in the savegame? They're client-side so should be like the other client-side options and only saved in the config.
Because I might not have understod the saveload code fully? :) If you think the right way is to have them client-side only I will change it.
Mchl wrote: I disagree. This could make it impossible to modify rail network under heavy traffic.
Wouldn't better solution be to check which train has reserved bath to the current tile, and then find a new path for it?
And if no path can be reserved? What should be done then? Keep in mind that the goal of this patch is the create a more realistic signaling system and path reservation is only a means to an end. In reality, trains only stop in front of red signals and normally don't stop suddenly somewhere else. So if your train can't get another path, it might either continue and crash anyway or might suddenly stop for no reason, which is not very realistic. Just stop your trains before extensivly remodelling a junction.
Tekky wrote: Also, I don't recommend mixing traditonal and PBS signals or to at least keep them on seperate track networks. Otherwise, you will have many issues with train collisions, because they seem to not be compatible.
Traditional and PBS signals are only compatible in certain situations. The main problem is that a signal block ends at any signal, including pbs signals. Changing that might cause severe performance problems. So if no train is in the block, a normal signal will be green, even though another train may enter the tile trough the back of a two-way pbs signal. The second problem is that a train entering a block through a normal signal will not reserve a path and is thus not seen by a train entering through a pbs signal.

Together this means that the entry signals into a block should only be of one kind, either normal or pbs, but not both at the same time. Secondly, only use one-way pbs signals as block exit signals for a block which has normal entry signals so no train can enter the block without being seen by the normal signals.

-- Michael Lutz
-- Michael Lutz
Roujin
Tycoon
Tycoon
Posts: 1884
Joined: 08 Apr 2007 04:07

Re: YAPP - Yet Another PBS Patch

Post by Roujin »

That savegame explained a lot to me - thanks A LOT @Tekky :D

@Michi_cc:
as said before, great patch! Good luck with bugfixing and codestylefixing if needed and hope it gets accepted to trunk 8) *pat on shoulder*
* @Belugas wonders what is worst... a mom or a wife...
<Lakie> Well, they do the same thing but the code is different.

______________
My patches
check my wiki page (sticky button) for a complete list

ImageImage
ImageImageImageImageImageImageImage
User avatar
Zephyris
Tycoon
Tycoon
Posts: 2890
Joined: 16 May 2007 16:59

Re: YAPP - Yet Another PBS Patch

Post by Zephyris »

Tekky wrote:
Zephyris wrote:
Tekky wrote:The other important rule is that you should always place a signal in front of every platform to prevent a train from leaving the platform when the track is not clear. I had several crashes because I had forgotten to do this :-)
If the track is not clear surely the train should not have gone into the station in the first place...
If the track was clear when it enters a station then that doesn't necessarily mean that it will be still clear when leaving a station. Therefore, a train may have to wait before it leaves a station platform, otherwise a collision may occur. For this reason, it is important to place a signal for all trains leaving a platform.
That seems immensely counterintuitive, a train (in the openttd world) should never go through signals to somewhere it would be able to crash... The station should be acting as a straight piece of track, by the sound of it there is an unprotected end of signalling block at each end of the platform.
Noldo
Engineer
Engineer
Posts: 75
Joined: 16 Jun 2005 13:17
Location: Lappeenranta, Finland

Re: YAPP - Yet Another PBS Patch

Post by Noldo »

"by the sound of it there is an unprotected end of signalling block at each end of the platform."

There is no blocks.

The fix might be to make the train reserve to the next signal even though it's going to stop on the way.
Other solution would be not to move from station before new reservations are made. I wonder how it works when you stop trains and restart them because there is the same problem basically.
peter1138
OpenTTD Developer
OpenTTD Developer
Posts: 1729
Joined: 30 Mar 2005 09:43

Re: YAPP - Yet Another PBS Patch

Post by peter1138 »

Possibly each end of a platform could become an implicit 'pbs' signal so that reservation and waiting occurs, like depots.
He's like, some kind of OpenTTD developer.
Tekky
Route Supervisor
Route Supervisor
Posts: 420
Joined: 19 Dec 2006 04:24

Re: YAPP - Yet Another PBS Patch

Post by Tekky »

That's also how this problem was solved in wolfc's PBS patch. Another possible solution would be to make a train not start moving until it has reserved a route to a safe waiting location, such as a signal, depot or another station. This might be the best solution, because then you could also make trains not start moving after reversing until they have reserved a route to a safe waiting location. This would prevent many crashes from occuring. This behavior also is realistic, because in reality, trains must seek permission before reversing.

It is very unrealistic for trains to be forcefully stopped in places where there is no signal. Therefore, trains should generally only wait in front of signals. However, I think that trains should be allowed to wait before starting to move, for example when leaving a station platform or after reversing.
peter1138
OpenTTD Developer
OpenTTD Developer
Posts: 1729
Joined: 30 Mar 2005 09:43

Re: YAPP - Yet Another PBS Patch

Post by peter1138 »

Mmm, that would probably help a lot.

One of the reasonings for removing the original PBS was the fact that trains could crash without user intervention, so it would be good to solve this. Currently it's fairly easy to cause a crash with an 'incorrect' layout.
He's like, some kind of OpenTTD developer.
User avatar
prissi
Chief Executive
Chief Executive
Posts: 647
Joined: 15 Nov 2004 19:46
Location: Berlin, Germany
Contact:

Re: YAPP - Yet Another PBS Patch

Post by prissi »

The current simutrans implementation of signaling is more or less exactly like this one here (all blocks removed, only PBS). Also at every waypoint, depot exit, platform or any other situation which (re-)starts a train, an implicit signal existst, i.e. a train (re-)start only, if it can secure the PBS track until next implicits/explicit signal.

In order to have a fully funtional system, also "longblock signals" (signals reserving a track through all those implicit stops until the train reaches the next signal) were needed to avoid deadlocks on two-way single track with stations (thus implicit signals) like a classical block. These signals will only allow a train to enter a block, if there is no train on this and all next stretches until the next regular signal.

[The presignals in simutrans just checked up to the next implicit stop or the second signal on the path. Probably one may be able to do without with little changes to layout.]

BTW, I wonder about the two way statement: I think, there are situations were two way signals are useful, if used correctly. And surely they are needed to load old games ... (at least I had to use them in Simutrans for that purpose.)
I like to look at great maps and see how things flow. A little like a finished model railway, but it is evolving and actually never finished. http://www.simutrans.com
Michi_cc
OpenTTD Developer
OpenTTD Developer
Posts: 619
Joined: 14 Jun 2004 23:27
Location: Berlin, Germany
Contact:

Re: YAPP - Yet Another PBS Patch

Post by Michi_cc »

peter1138 wrote:Mmm, that would probably help a lot.

One of the reasonings for removing the original PBS was the fact that trains could crash without user intervention, so it would be good to solve this. Currently it's fairly easy to cause a crash with an 'incorrect' layout.
In a very wide sense, an incorrect layout is a user intervention, but yeah, only in a very very wide sense.

The best compromise probably is to inhibit trains from restarting after a stop until a reservation could be obtained.
prissi wrote: BTW, I wonder about the two way statement: I think, there are situations were two way signals are useful, if used correctly. And surely they are needed to load old games ... (at least I had to use them in Simutrans for that purpose.)
I don't want to exclude any usefullness of two-sided signals, and that it the reason why they are indeed buildable. I just meant that a well-designed network will probably never need them. And compatibility isn't an argument as the old signals aren't removed.

-- Michael Lutz
-- Michael Lutz
Mchl
Director
Director
Posts: 611
Joined: 05 Jan 2007 15:50
Location: Poland
Contact:

Re: YAPP - Yet Another PBS Patch

Post by Mchl »

This is THE patch that made me download BuildOTTD.

What can I say?

It actually works (I mean both BuiltOTTD and Advanced Signals)!!!!!

Really good work. I hope it'll get included YouKnowWhere soon. :D

[edit]

Now there's something I don't understand. See save attached. You will see a train #1 going north. It's out of its route (went to the nearest depot for servicing and now has to get back to its normal route somehow). As it approaches the crossing it fails to make a reservation (no dark path) resulting in a near miss with train #9. (Actually, if you move one of the signals one tile towards train #9 it'll result in head-on collision, even if the signal is one way).
Attachments
Presignal this! :P
Presignal this! :P
Teningpool Transport, 25th Aug 1932.png (209.46 KiB) Viewed 1454 times
crash2.sav
(345.57 KiB) Downloaded 155 times
Near miss.
Near miss.
Teningpool Transport, 22nd Sep 1934.png (96.67 KiB) Viewed 1367 times
Last edited by Mchl on 05 Feb 2008 20:02, edited 1 time in total.
Tekky
Route Supervisor
Route Supervisor
Posts: 420
Joined: 19 Dec 2006 04:24

Re: YAPP - Yet Another PBS Patch

Post by Tekky »

@Mchl:

Hehe, how about presignaling this? :)

Unfortunately, there are only 3 trains on the junction, theoretically I could have up to 4 trains....
Attachments
presignal_this.png
presignal_this.png (59.03 KiB) Viewed 1450 times
Mchl
Director
Director
Posts: 611
Joined: 05 Jan 2007 15:50
Location: Poland
Contact:

Re: YAPP - Yet Another PBS Patch

Post by Mchl »

Yeah, seen this savegame and played with it a little as well ;)
I've edited my previous post while you've written yours. Please take a look at it.
T-Unit
Transport Coordinator
Transport Coordinator
Posts: 368
Joined: 03 Feb 2007 18:53
Location: Leeds, England

Re: YAPP - Yet Another PBS Patch

Post by T-Unit »

This looks great. Just ive never compiled a patch. Will have to look at BuildOTTD...
Mchl
Director
Director
Posts: 611
Joined: 05 Jan 2007 15:50
Location: Poland
Contact:

Re: YAPP - Yet Another PBS Patch

Post by Mchl »

T-Unit wrote:This looks great. Just ive never compiled a patch. Will have to look at BuildOTTD...
Go for it. It is realy easy.
The biggest problem for me was finding patch file that would actually be accepted by BuildOTTD.
It's this one: http://www.tt-forums.net/download/file.php?id=85483 (from page 3 of this topic).


As for the save I attached a few posts above. If you follow train #1 you'll notice it will crash on the next station...
Seems that YAPF has some problems with runaway trains. I remember they didn't obey presignals as well.
spets
Engineer
Engineer
Posts: 8
Joined: 29 Jan 2008 19:03

Re: YAPP - Yet Another PBS Patch

Post by spets »

Great patch, I love it!

argh, too bad the when trains go to service they go to the nearest depot available even if it is on the wrong track line. the fact that I can make my junctions simpler with PBS caused a few deadlocks with trains going to the wrong depot for servicing. grr.
Tekky
Route Supervisor
Route Supervisor
Posts: 420
Joined: 19 Dec 2006 04:24

Re: YAPP - Yet Another PBS Patch

Post by Tekky »

@Mchl: As far as I can tell, both the collision and the near-collision you described seem to be a bug. I could not find anything wrong with your track layout.

@spets: The behavior of depots is a bit buggy. Trains want to go to a depot but fail, I think because they continue on on their previous reservation and then cannot turn around anymore, after having passed the depot. However, I have not had any deadlocks occur because of this. May I see your track layout?
Michi_cc
OpenTTD Developer
OpenTTD Developer
Posts: 619
Joined: 14 Jun 2004 23:27
Location: Berlin, Germany
Contact:

Re: YAPP - Yet Another PBS Patch

Post by Michi_cc »

Mchl wrote:As for the save I attached a few posts above. If you follow train #1 you'll notice it will crash on the next station...
Seems that YAPF has some problems with runaway trains. I remember they didn't obey presignals as well.
Problem found. Will be fixed in the next release.

-- Michael Lutz
-- Michael Lutz
Mchl
Director
Director
Posts: 611
Joined: 05 Jan 2007 15:50
Location: Poland
Contact:

Re: YAPP - Yet Another PBS Patch

Post by Mchl »

Great! :D
T-Unit
Transport Coordinator
Transport Coordinator
Posts: 368
Joined: 03 Feb 2007 18:53
Location: Leeds, England

Re: YAPP - Yet Another PBS Patch

Post by T-Unit »

Okay. So ive had a go at compiling it and got two outputs:

Code: Select all

But the loading bar is still going. Sorry if i sounds pathetic but please help.
Last edited by T-Unit on 05 Feb 2008 21:45, edited 1 time in total.
Mchl
Director
Director
Posts: 611
Joined: 05 Jan 2007 15:50
Location: Poland
Contact:

Re: YAPP - Yet Another PBS Patch

Post by Mchl »

JUst wait till it says Compile Complete.
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 14 guests