Page 1 of 3

Close adjacent level crossings

Posted: 02 Dec 2009 01:13
by Eddi
This is a small patch that closes the level crossings on parallel tracks if a train is approaching, should make them a little safer for road vehicles.

note: this is a prototype, and known to break if you try too hard.

Update: New feature: road vehicles ignore closed crossings if they are already on a closed crossing (leads to fewer death traps, but you need to put path signals further away to allow more time for the crossing to clear)

Re: Close adjacent level crossings

Posted: 02 Dec 2009 04:12
by Zhall
Or, build a bridge for epic efficiency. :D

Re: Close adjacent level crossings

Posted: 02 Dec 2009 12:34
by Gremnon
Or tunnel.
But there are times when I'd prefer to use level crossings.
Problem still remains that RV's still get caught once in a while though, but a little fancy signalling solves that one.

Re: Close adjacent level crossings

Posted: 02 Dec 2009 12:49
by Zuu
I've looked at the code and to me it looks reasonable. Nice that you loop away from the current crossing so that it is not just the adjacent track but also the track adjacent to the adjacent track and so forth. Until bended crossings appear which could form cycles that is probably safe.

Re: Close adjacent level crossings

Posted: 02 Dec 2009 12:56
by Eddi
Well, i know how to break it, even with existing crossings ;)

I'm not entirely sure how to handle map edges...

Re: Close adjacent level crossings

Posted: 02 Dec 2009 13:06
by Zuu
An additional condition in the for-loop? Eg && < map edge. If you instead of using the direction from the current tile (t), use the direction of the tile (function argument) tile, you could before the for loop cache which edge to check for and have just one edge-check. Or keep the robustness of the current code for future bending crossings and check for all four edges.

Code: Select all

+	for (TileIndex t = tile; !is_forced && IsTileType(t, MP_ROAD) && IsLevelCrossingTile(t); t = TileAddByDiagDir(t, AxisToDiagDir(GetCrossingRoadAxis(t)))) {
+		is_forced |= CheckLevelCrossing(t);
+	}

Hmm, now I see each level crossing look around in the neighborhood if they should be forced to show red. Initially I though that a crossing looped over the neighbors and forced their barred status on the neighbors. That does however not really change anything fundamental.

Re: Close adjacent level crossings

Posted: 02 Dec 2009 13:12
by Eddi
the first two loops look left and right, if any of the level crossings would be closed with the current check, then in the later two loops, it sets all level crossings to that state. [all closed if any should be closed, or all open if none should be closed]

Re: Close adjacent level crossings

Posted: 02 Dec 2009 20:55
by petert
Sapphire united wrote:Or, build a bridge for epic efficiency. :D
Eddi knows what he is doing, so making a patch like this has a reason.

Re: Close adjacent level crossings

Posted: 31 Jul 2010 13:56
by Kogut
Is it planned to do sth with that kind of trap?

Re: Close adjacent level crossings

Posted: 31 Jul 2010 16:17
by Eddi
needs road vehicles ignoring closed level crossings, if they are already on a closed level crossing.

i haven't digged that deeply into it yet, but it should be doable.

Re: Close adjacent level crossings

Posted: 31 Jul 2010 22:08
by Grandmaster
Eddi wrote:needs road vehicles ignoring closed level crossings, if they are already on a closed level crossing.
It is very needed, because long trucks, buses and trams will then always be the loser. They do not fit between 2 rails.

Re: Close adjacent level crossings

Posted: 30 Nov 2010 19:59
by Sensation Lover
any update?

Re: Close adjacent level crossings

Posted: 30 Nov 2010 20:05
by Kogut
no, it would be announced here

Re: Close adjacent level crossings

Posted: 14 Jul 2011 11:36
by Eddi
i am pleased to announce an update at this time, which allows road vehicles trapped inbetween closed crossings to leave that crossing.

(patch in first post)

Re: Close adjacent level crossings

Posted: 15 Jul 2011 10:26
by Lockwood
Effectivly making the crossing act like AHB/AOCB? You can't/shouldn't enter it, but you can leave it.

Re: Close adjacent level crossings

Posted: 15 Jul 2011 11:23
by Eddi
yes. this should help the issue that Kogut posted.

Re: Close adjacent level crossings

Posted: 15 Jul 2011 16:25
by FooBar
I like this. Would be nice to have in trunk :D

Re: Close adjacent level crossings

Posted: 19 Jul 2011 12:32
by Eddi
i promise i submit this for review as soon as some useful testing results come in ;)

savegames should be trunk-compatible (backwards and forwards)
(except some odd crossing being wrongfully closed, or some road vehicle crashing if it is unattended ;))

Re: Close adjacent level crossings

Posted: 19 Jul 2011 23:15
by Lockwood
Since we can do lever things with level crossings and PBS (incuding making massive snaking tracks crossing competitor roads and taking possession over every crossing at once), can we get it to go the other way, if you have a vehicle on a crossing, ie stopped/broken down,it will set the signal to danger until it has cleared. This'd work quite well with the suggestions before of having yellow signals and braking distances.
There'd still be some risk of collision,but it would help reduce the occurance and make them act a bit more like AOCR which they seem to be emulating.

Re: Close adjacent level crossings

Posted: 23 Jul 2011 09:35
by Zuu
Here is a windows 32bit binary. Hope it helps for anyone who want to try out this patch and provide feedback to Eddi.


Edit: Updated the zip file, now including the actual exe file! :oops: