[Patch] ATC speed control
Moderator: OpenTTD Developers
[Patch] ATC speed control
Ever been annoyed by fast trains stopping and starting when trapped behind a slow freight train? With this patch, you can emulate a certain behaviour of the ATC system heavily utilized in Scandinavia: Trains trapped behind a slower train (up to one signal block or 20 tiles away) will automatically slow down to match the speed of the slower train. This eliminates the stopping-and-starting, making the train move a lot smoother. AFAIK it has no real impact on game mechanics.
Patch applies to r21666, there are no major bugs that I know of.
Patch applies to r21666, there are no major bugs that I know of.
- Attachments
-
- ATC-speed-control-r21666.diff
- (5.57 KiB) Downloaded 1067 times
- Dwight_K._Schrute
- Traffic Manager
- Posts: 209
- Joined: 01 Sep 2010 11:29
Re: [Patch] ATC speed control
Wow it sounded great and my first test pointed out that it seems to be so...
I compiled a Windows version for other possible testers:
I compiled a Windows version for other possible testers:
Re: [Patch] ATC speed control
Only thing I can say is: if it's as good as I hope it is, PLEASE INCLUDE IT IN 1.1
. Gonna test it now.

Re: [Patch] ATC speed control
Using Dwight's Binary, there is a clash with one setting
Go under Trains in advanced settings. Go to sparks/steam/smoke effect. Set it to the left all the way.
Picture is here for your benefit.
Go under Trains in advanced settings. Go to sparks/steam/smoke effect. Set it to the left all the way.
Picture is here for your benefit.
- Attachments
-
- Unnamed, 1st Jan 5000000.png
- (58.51 KiB) Downloaded 5 times
Something goes here, hell if I know.
Re: [Patch] ATC speed control
Seems like an issue with english.txt, should be fixed.
As for the patch being included in 1.1.0, I'll get a task up in flyspray tomorrow if there aren't any horrible bugs. After that, it's up to the devs
As for the patch being included in 1.1.0, I'll get a task up in flyspray tomorrow if there aren't any horrible bugs. After that, it's up to the devs

- Attachments
-
- ATC-speed-control-r21666.diff
- String in english.txt fixed. Do NOT apply over the previous patch, apply over clean trunk.
- (5.44 KiB) Downloaded 790 times
Re: [Patch] ATC speed control
I managed to trigger strange behaviour, see attached screen shot. A split track, one is empty, one is occupied with a slow train. The follow up train, a fast one, slows down, speeds up, slows down, speeds up, etc.
- Attachments
-
- Drieburg Transport, 2005-04-07.png
- (50.2 KiB) Downloaded 5 times
Re: [Patch] ATC speed control
One thing i can say is that you will probably have to get rid of all references to 'ATC' as many people (including me) will not know what that means...
AroAI - A really feeble attempt at an AI
It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration. --Edsger Dijkstra
It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration. --Edsger Dijkstra
- planetmaker
- OpenTTD Developer
- Posts: 9432
- Joined: 07 Nov 2007 22:44
- Location: Sol d
Re: [Patch] ATC speed control
It's a nice idea.
A few remarks and thoughts, though:
- you totally break savegame compatibiliy. In settings.h you remove existing lines without comment, necessity and on the penalty of breaking the loading of old savegames. Nor do you bump the savegame version when introducing your new setting which alone also needs this savegame bump. Thus it needs taking care also in the saveload code.
- it doesn't fulfill its purpose flawlessly. Trains also slow down if they pass a slow train on a two-track arrangement or "see" a train in a depot (see screenshot and let two trains run on a similar thing). As this flaws became obvious after looking at a new game in 5 minutes I expect many other cases to fail or suffer from similar bugs.
- As a result of the above point, my guess is that you'll have to integrate this into the path finder - and worse - have a train know about the paths of other trains. The performance impact of this will need assessment.
- Especially in settings.h but also elsewhere you should watch the coding style. Indentation is done by tabs, avoid trailing and leading white space.
A few remarks and thoughts, though:
- you totally break savegame compatibiliy. In settings.h you remove existing lines without comment, necessity and on the penalty of breaking the loading of old savegames. Nor do you bump the savegame version when introducing your new setting which alone also needs this savegame bump. Thus it needs taking care also in the saveload code.
- it doesn't fulfill its purpose flawlessly. Trains also slow down if they pass a slow train on a two-track arrangement or "see" a train in a depot (see screenshot and let two trains run on a similar thing). As this flaws became obvious after looking at a new game in 5 minutes I expect many other cases to fail or suffer from similar bugs.
- As a result of the above point, my guess is that you'll have to integrate this into the path finder - and worse - have a train know about the paths of other trains. The performance impact of this will need assessment.
- Especially in settings.h but also elsewhere you should watch the coding style. Indentation is done by tabs, avoid trailing and leading white space.
- Attachments
-
- Senwood Transport, 10-07-2000.png (153.2 KiB) Viewed 23218 times
OpenTTD: manual | online content | translations | Wanted contributions and patches
#openttdcoop: blog | wiki | public server | DevZone | NewGRF web translator
DevZone - home of the free NewGRFs: OpenSFX | OpenMSX | OpenGFX | Swedish Rails | OpenGFX+ Trains|RV|Industries|Airports|Landscape | NML
Re: [Patch] ATC speed control
Hm, I can't seem to reproduce this. Under certain conditions, however, acceleration may cause the train to break too much, increasing the number of signal blocks between the trains, causing it to accelerate and so forth, making it oscillate between two different values. It could also be that the train leaves the 20-tile "search radius".Arie- wrote:I managed to trigger strange behaviour, see attached screen shot. A split track, one is empty, one is occupied with a slow train. The follow up train, a fast one, slows down, speeds up, slows down, speeds up, etc.
It may also behave strangely when two trains are heading for a head-on collision. I may include a check for this.
At stations, it may appear to be behaving strangely, since it'll slow down oncoming trains to arrival speed (24km/h). I'm not sure how to fix it though, I could add a check for station tiles, or I could increase the lower speed limit for which the rule is applied. I'm not a big fan of magic numbers, so the first option is probably the way to go.
Thanks, I'll have a look at these things.planetmaker wrote:A few remarks and thoughts, though:
- you totally break savegame compatibiliy. In settings.h you remove existing lines without comment, necessity and on the penalty of breaking the loading of old savegames. Nor do you bump the savegame version when introducing your new setting which alone also needs this savegame bump. Thus it needs taking care also in the saveload code.
- it doesn't fulfill its purpose flawlessly. Trains also slow down if they pass a slow train on a two-track arrangement or "see" a train in a depot (see screenshot and let two trains run on a similar thing). As this flaws became obvious after looking at a new game in 5 minutes I expect many other cases to fail or suffer from similar bugs.
- As a result of the above point, my guess is that you'll have to integrate this into the path finder - and worse - have a train know about the paths of other trains. The performance impact of this will need assessment.
- Especially in settings.h but also elsewhere you should watch the coding style. Indentation is done by tabs, avoid trailing and leading white space.
Edit: I've looked over the code, bumped the savegame version and fixed most (all?) style issues. The problem concerning stations should also be fixed (a train is no longer considered if it is braking), as should the dual-track issue (search stops when a switch is encountered, this is an ugly solution but it's the best I can do without meddling with the pathfinder... I think). Obviously this needs more testing, and I appreciate any input I receive.
- Attachments
-
- ATC-speed-control-r21669.diff
- Fixed patch against r21669
- (5.88 KiB) Downloaded 541 times
Re: [Patch] ATC speed control
I've fixed it up further, so that the algorithm now makes a more conscious choice when it encounters switches. It tries to follow its reserved path, which should improve things in certain conditions. If there isn't a reserved path, searching stops at the switch. Trains are also ignored if they travel in the opposite direction.
Still not perfect, but this should take care of most issues. I'd like it to check all possible paths so that instead of simply not limiting speed when switches are encountered, it tries to actually follow all tracks and limit the speed anyway if they're occupied. I fear that may be too computationally expensive though, even if it could be done without meddling with the pathfinder (through a recursive search with a limited depth).
Still not perfect, but this should take care of most issues. I'd like it to check all possible paths so that instead of simply not limiting speed when switches are encountered, it tries to actually follow all tracks and limit the speed anyway if they're occupied. I fear that may be too computationally expensive though, even if it could be done without meddling with the pathfinder (through a recursive search with a limited depth).
- Attachments
-
- ATC-speed-control-r21674.diff
- Patch against r21674.
- (6.88 KiB) Downloaded 681 times
Re: [Patch] ATC speed control
This project dead? I NEED this patch 

- planetmaker
- OpenTTD Developer
- Posts: 9432
- Joined: 07 Nov 2007 22:44
- Location: Sol d
Re: [Patch] ATC speed control
I suggest you get better working on it thenFesken wrote:This project dead? I NEED this patch

OpenTTD: manual | online content | translations | Wanted contributions and patches
#openttdcoop: blog | wiki | public server | DevZone | NewGRF web translator
DevZone - home of the free NewGRFs: OpenSFX | OpenMSX | OpenGFX | Swedish Rails | OpenGFX+ Trains|RV|Industries|Airports|Landscape | NML
- Vaulter
- Traffic Manager
- Posts: 185
- Joined: 21 Dec 2004 05:35
- Skype: andrey-zaharov
- Location: St. Petersburg, Russia
- Contact:
Re: [Patch] ATC speed control
Updated to trunk
- Attachments
-
- atc.r22604M.patch
- (7 KiB) Downloaded 735 times
Re: [Patch] ATC speed control
WOW nice! Thank you!Vaulter wrote:Updated to trunk

Re: [Patch] ATC speed control
What is the current status of this patch?
Is it working properly (in most cases)? Are there still bugs?
Is it working properly (in most cases)? Are there still bugs?
Re: [Patch] ATC speed control
The status is the same as that of 31 Dec 2010, 16:00.
Re: [Patch] ATC speed control
Are there any plans on putting this in openttd? or will this remain a patch here on the forum forever?
This could be *very* useful.
This could be *very* useful.
Re: [Patch] ATC speed control
With a status of "still not perfect", chances that this will be put into OpenTTD are close to zero.
That doesn't mean it's a bad idea. It just means that the implementation doesn't meet the standards yet.
That doesn't mean it's a bad idea. It just means that the implementation doesn't meet the standards yet.
Re: [Patch] ATC speed control
What are the current problems that still need to be fixed?
The thread isn't entirely clear on that.
The thread isn't entirely clear on that.
Re: [Patch] ATC speed control
With the author having left 1.5 years ago, probably nobody knows, so why not try it yourself and find out?
Who is online
Users browsing this forum: No registered users and 13 guests