Close adjacent level crossings
Moderator: OpenTTD Developers
Close adjacent level crossings
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)
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)
- Attachments
-
- adjacent_crossings_3_r22664.diff
- (4.2 KiB) Downloaded 1166 times
Last edited by Eddi on 14 Jul 2011 11:35, edited 1 time in total.
- Zhall
- Tycoon
- Posts: 1237
- Joined: 17 Jul 2007 01:36
- Skype: moonray_zdo
- Location: Teh matrix, duh.
- Contact:
Re: Close adjacent level crossings
Or, build a bridge for epic efficiency. 

Formerly known as Sapphire United.
Learn Openttd
Learn Planetary Annihilation
Learn Orbit
Whose poo?
Learn Openttd
Learn Planetary Annihilation
Learn Orbit
Whose poo?
Re: Close adjacent level crossings
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.
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
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.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Junctioneer (a traffic intersection simulator)
Re: Close adjacent level crossings
Well, i know how to break it, even with existing crossings 
I'm not entirely sure how to handle map edges...

I'm not entirely sure how to handle map edges...
Re: Close adjacent level crossings
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.
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.
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.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Junctioneer (a traffic intersection simulator)
Re: Close adjacent level crossings
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
Eddi knows what he is doing, so making a patch like this has a reason.Sapphire united wrote:Or, build a bridge for epic efficiency.
Re: Close adjacent level crossings
Is it planned to do sth with that kind of trap?
- Attachments
-
- Przechwytywanie.PNG (11.96 KiB) Viewed 36550 times
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD
AIAI - AI for OpenTTD
Re: Close adjacent level crossings
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.
i haven't digged that deeply into it yet, but it should be doable.
-
- Engineer
- Posts: 72
- Joined: 11 Feb 2007 21:10
- Location: Rotterdam, Netherlands
Re: Close adjacent level crossings
It is very needed, because long trucks, buses and trams will then always be the loser. They do not fit between 2 rails.Eddi wrote:needs road vehicles ignoring closed level crossings, if they are already on a closed level crossing.
- Sensation Lover
- Transport Coordinator
- Posts: 338
- Joined: 26 Feb 2009 09:17
- Skype: Aron Bogdan Silviu
- Location: Torino, Italy
- Contact:
Re: Close adjacent level crossings
any update?
I was in:
Austria,Belgium,Brazil,China,France,Germany,Hungary,Indonesia,Italy,Luxemburg,Malaysia,Mexico,Netherlands,Norway,Panamà,Poland,Romania,
Saudi Arabia,Singapore,Slovenia,Spain,Switzerland,Thailand,U.K.,Ukraine,U.S.A.
Austria,Belgium,Brazil,China,France,Germany,Hungary,Indonesia,Italy,Luxemburg,Malaysia,Mexico,Netherlands,Norway,Panamà,Poland,Romania,
Saudi Arabia,Singapore,Slovenia,Spain,Switzerland,Thailand,U.K.,Ukraine,U.S.A.
Re: Close adjacent level crossings
no, it would be announced here
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD
AIAI - AI for OpenTTD
Re: Close adjacent level crossings
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)
(patch in first post)
Re: Close adjacent level crossings
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
yes. this should help the issue that Kogut posted.
Re: Close adjacent level crossings
I like this. Would be nice to have in trunk 

Re: Close adjacent level crossings
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
)

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
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.
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
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!
Edit: Updated the zip file, now including the actual exe file!

- Attachments
-
- openttd.pdb.zip
- Only needed to read dump files when/if the binary crashes.
- (3.72 MiB) Downloaded 814 times
-
- adjacent_crossings_3_r22664_win32.zip
- Win32 build using Visual Studio 2008, this time including the openttd.exe file! (that I forgot - see later posts)
- (4.62 MiB) Downloaded 755 times
Last edited by Zuu on 01 Aug 2011 16:17, edited 1 time in total.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Junctioneer (a traffic intersection simulator)
Who is online
Users browsing this forum: No registered users and 10 guests