Close adjacent level crossings

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

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

Close adjacent level crossings

Post by Eddi » 02 Dec 2009 01:13

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)
Attachments
adjacent_crossings_3_r22664.diff
(4.2 KiB) Downloaded 540 times
Last edited by Eddi on 14 Jul 2011 11:35, edited 1 time in total.
You might not exactly be interested in Ferion, but if you are, have fun :)

User avatar
Zhall
Tycoon
Tycoon
Posts: 1244
Joined: 17 Jul 2007 01:36
Skype: moonray_zdo
Location: Teh matrix, duh.
Contact:

Re: Close adjacent level crossings

Post by Zhall » 02 Dec 2009 04:12

Or, build a bridge for epic efficiency. :D

User avatar
Gremnon
Tycoon
Tycoon
Posts: 1517
Joined: 16 Sep 2005 12:23
Skype: the_gremnon
Location: /home
Contact:

Re: Close adjacent level crossings

Post by Gremnon » 02 Dec 2009 12:34

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.

User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: Close adjacent level crossings

Post by Zuu » 02 Dec 2009 12:49

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)

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

Re: Close adjacent level crossings

Post by Eddi » 02 Dec 2009 12:56

Well, i know how to break it, even with existing crossings ;)

I'm not entirely sure how to handle map edges...
You might not exactly be interested in Ferion, but if you are, have fun :)

User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: Close adjacent level crossings

Post by Zuu » 02 Dec 2009 13:06

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.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)

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

Re: Close adjacent level crossings

Post by Eddi » 02 Dec 2009 13:12

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]
You might not exactly be interested in Ferion, but if you are, have fun :)

petert
Tycoon
Tycoon
Posts: 3008
Joined: 02 Apr 2009 22:43
Location: Massachusetts, USA

Re: Close adjacent level crossings

Post by petert » 02 Dec 2009 20:55

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.

Kogut
Tycoon
Tycoon
Posts: 2493
Joined: 26 Aug 2009 06:33
Location: Poland

Re: Close adjacent level crossings

Post by Kogut » 31 Jul 2010 13:56

Is it planned to do sth with that kind of trap?
Attachments
Przechwytywanie.PNG
Przechwytywanie.PNG (11.96 KiB) Viewed 17953 times
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD

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

Re: Close adjacent level crossings

Post by Eddi » 31 Jul 2010 16:17

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.
You might not exactly be interested in Ferion, but if you are, have fun :)

Grandmaster
Engineer
Engineer
Posts: 72
Joined: 11 Feb 2007 21:10
Location: Rotterdam, Netherlands

Re: Close adjacent level crossings

Post by Grandmaster » 31 Jul 2010 22:08

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.

User avatar
Sensation Lover
Transport Coordinator
Transport Coordinator
Posts: 334
Joined: 26 Feb 2009 09:17
Skype: Aron Bogdan Silviu
Location: Torino, Italy
Contact:

Re: Close adjacent level crossings

Post by Sensation Lover » 30 Nov 2010 19:59

any update?
I was in:
Austria,Belgium,Brazil,China,France,Germany,Hungary,Indonesia,Italy,Luxemburg,Malaysia,Netherlands,Norway,Panamà,Poland,Romania,
Saudi Arabia,Singapore,Slovenia,Spain,Switzerland,Thailand,U.K.,Ukraine,U.S.A.

Kogut
Tycoon
Tycoon
Posts: 2493
Joined: 26 Aug 2009 06:33
Location: Poland

Re: Close adjacent level crossings

Post by Kogut » 30 Nov 2010 20:05

no, it would be announced here
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD

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

Re: Close adjacent level crossings

Post by Eddi » 14 Jul 2011 11:36

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)
You might not exactly be interested in Ferion, but if you are, have fun :)

Lockwood
Engineer
Engineer
Posts: 57
Joined: 14 Aug 2005 17:24

Re: Close adjacent level crossings

Post by Lockwood » 15 Jul 2011 10:26

Effectivly making the crossing act like AHB/AOCB? You can't/shouldn't enter it, but you can leave it.

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

Re: Close adjacent level crossings

Post by Eddi » 15 Jul 2011 11:23

yes. this should help the issue that Kogut posted.
You might not exactly be interested in Ferion, but if you are, have fun :)


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

Re: Close adjacent level crossings

Post by Eddi » 19 Jul 2011 12:32

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 ;))
You might not exactly be interested in Ferion, but if you are, have fun :)

Lockwood
Engineer
Engineer
Posts: 57
Joined: 14 Aug 2005 17:24

Re: Close adjacent level crossings

Post by Lockwood » 19 Jul 2011 23:15

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.

User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: Close adjacent level crossings

Post by Zuu » 23 Jul 2011 09:35

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:
Attachments
openttd.pdb.zip
Only needed to read dump files when/if the binary crashes.
(3.72 MiB) Downloaded 195 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 230 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)

Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 4 guests