The timetable feature was added into the trunk and I think it's quite useless without an automatic separation system.
So I designed a small patch that adds an auto-separation system to the timetable feature.This patch is part of the ChrisIN since r11046
How to use it ? It's fully automatic. (See documentation bellow)
- First create a shared route with a few vehicles.
- Then autofill the timetable.
- When the timetable is filled, ajust the values in order to add some extra at loading/unload for each station (this will ensure late vehicles can catch up their lateness in order to ensure proper separation)
- (Mostly for savegames or after problems due to construction) Check is the first vehicle of the shared route lateness is 0. If it's not, reset the counter as the separation is based on the first vehicle of the shared route theorical time position in the route.
I recommand you use the "display timetable in ticks rather than day" option in order to fine tune the loading times. Although, the patch works with day rounded values in order to remain compatible with the "day" display.
How does it works ?
- When the second vehicle is about to leave the first station of the shared order, it checks the total timetable duration against the count of vehicle before him in the shared order chain.
- Next, it calculate since how much time the first vehicle* left the station : wait_time = (total_time / count_vehicle) * count_vehicle_before - first_vehicle_time
- If wait_time is higher than 0, then the vehicle waits until it is 0 : the separation isn't enougth with the previous vehicle
- If wait_time is 0, then the vehicle is on time, then it can leave the station and run the timetable as usual
- If wait_time is below 0, then the vehicle is late. It leaves immediately, and its lateness counter is set up with wait_time * -1 : by this way, it will try to reduce the lateness by running the timetable with a correct lateness value
The first vehicle of the shared route won't check for separation, only the following will try to follow it with correct separation. But the first vehicle will automatically adjusts the route timetable when there are changes (construction, heavy loaded station, new vehicle, etc.)
Ensure the first vehicle shared of the shared route runs on time (add enought extra wait time to station), or all vehicles will be flaged "late" and the separation won't work correctly until the first vehicle is on time.
What are the limitations ?
- Separation is not immediate. It need the vehicle enter the first station in order to reset it's separation counter. If it's late, the vehicle will try to catch up the late. As a result, for long courses and big lateness, it can take some time to obtain the correct separation.
- Separation works per routes (because I think it's the way it must work). So heavy loaded stations desserved by serval different routes could remain heavy loaded and won't seem to be correctly regulated. But vehicles of each routes will come regulary, and not by "packets".
Regardless of these limitations, I hope you'll enjoy this small patch.
Limitations resoled :
- there were a problem with the route chain order. When you injected vehicle somewhere else than the last position, the separation was quite impossible to optain. to fix that problem, the vehicle just checks his position when entering the first order station, then reorder the chain if needed.
- there is no problem anymore with orders that start with something else than a station where the vehicles load/unload.
r10386 : Fix - Now each vehicle ensure its separation basing on the first vehicle in the shared orders chain. This avoid getting very hight lateness values, and a very long time for separation to be ok.
r10386 bis : Fix - No functional change, just code and comments cleanup to fit the OTTD coding style rules.
r10877 : Complete rewrite of the code, and add shared order list reorder control.
r10885 : Fix - The game doesn't crash anymore when using boats.
r10887 : All separation tests and chain order tests were moved to the "first stop station order" instead of the first order. As a result, you can start a route with a "no-stop" flag, a waypoint or a buoy, then the separation will start correctly at the first station where the vehicle actually stops.
r10908 : Removed the list of last vehicles that visited the stations. This was used for the chain reorder, but I found a better system (thanks l_Blue_l for the suggestion). Also fixed the separation counter, as I introduced a small bug when added first order destination other than a station support.
r10977 : Fix - A lot of code rewrite, and a major fix: in some cases (most cases) the separation was absolutely stuck and vehicles were just ensuring they didn't use correct separation. This bug is fixed now.
r10980 : Fix - The bug in the chain reorder process was still exist. Now it's definately corrected.
r10980 bis : Optimisation - Moved the separation computation from HandleLoading() function to BeginLoading() function. By this way the separation is computed only one time when the vehicle enters the first route station instead of many times while loading at this station.
r10990 : Added - The separation feature is now a patch option located in the vehicle section under the timetable option. It needs the timetable function enabled in order to work.
r10990 ChrisIN : Added - The separation feature is now a patch option located in the ChrisIN section under the timetable option. It needs the timetable function (vehicle section) enabled in order to work. This diff contains the ChrisIN-r10982. See the ChrisIN topic for more information. viewtopic.php?f=33&t=32698
r12032 : Update - Fixed some problems dues to trunk code structure changes. Also "cleaned" some part of code... A last hope to get integrated in the trunk.
r12038 : Update - Code cleaning to fit coding style rules
r12059 : Update - Belugas added the IsSharedListOrder class member method to replace the simple function of the same name in trunk according the patch. removed the method from the patch.
r13704 : Refresh - Tiberius did a refresh of this patch in order to comply with the current trunk.
Flyspray report opened since r10887http://bugs.openttd.org/task/1128
Still need to test :
- Network support : I did a few tests alone, and it seems to work correctly. I'm confident as this patch stores nothing anywhere.
If anyone is playing with this patch activated on network games, please send some feedback in order to fix any problem, or confirm it works correctly. This may be one of the reason it's still not in trunk.