FS#1128 — Timetable based auto-separation patch
Attached to Project— OpenTTD
Opened by Sylvain Devidal (MagicBuzz) - Tuesday, 14 August 2007, 08:35PM
Opened by Sylvain Devidal (MagicBuzz) - Tuesday, 14 August 2007, 08:35PM
| Patch | |
| Vehicles | |
| New | |
| No-one | |
| All |
| Medium | |
| Normal | |
| Devel (specify rev) | |
| Undecided | |
| Undecided | |
![]() |
With timetable feature added to the trunk, the main feature I expected to find was an auto-separation system.
But it doesn't exist, so I created this patch.
It will change the timetable feature : there is no option flag, it is just activated when using timetable option and shared orders vehicles.
Features:
- Automatically reorder the shared vehicle chain according the actual order of passage to the station. This chain order is checked when a vehicle enters the first "stop" station in the shared order table. This uses a new <list> in the Station class in order to store the last vehicle of each shared order chain that visited the station (applies only to the first "stop" station in the shared order tables).
- Compute the waiting time at the first "stop" station of the shared order table. This time is computed from the timetable total duration, the number of vehiclessharing the order, and the current theorical separation with the first vehicle of the shared order chain (includes its lateness counter). This waiting time does not apply to the first vehicle of the chain, as its the referential for separation feature.
- After this time, the vehicle lateness counter is updated with "remaining waiting time" * -1 : if the vehicle uses proper separation, it's 0, if the separation with the first vehicle of the chain is too big, then it's the lateness the vehicle have against it's theorical position if correctly separated.
This patch does NOT affect the savegame format.
Tests :
- Works as expected with road vehicles
- Works as expected with planes
- Works as expected with ships (I think it's the best thing that patch can do)
- Works as expected with trains
- Tested with multiplayer game (only 1 client plus the server, machine) and did not throw any problem
Patch is made from source code revision 10887 (and applies without any warning on the 10892 revision)
I hope you'll enjoy this patch, I do ;)
But it doesn't exist, so I created this patch.
It will change the timetable feature : there is no option flag, it is just activated when using timetable option and shared orders vehicles.
Features:
- Automatically reorder the shared vehicle chain according the actual order of passage to the station. This chain order is checked when a vehicle enters the first "stop" station in the shared order table. This uses a new <list> in the Station class in order to store the last vehicle of each shared order chain that visited the station (applies only to the first "stop" station in the shared order tables).
- Compute the waiting time at the first "stop" station of the shared order table. This time is computed from the timetable total duration, the number of vehiclessharing the order, and the current theorical separation with the first vehicle of the shared order chain (includes its lateness counter). This waiting time does not apply to the first vehicle of the chain, as its the referential for separation feature.
- After this time, the vehicle lateness counter is updated with "remaining waiting time" * -1 : if the vehicle uses proper separation, it's 0, if the separation with the first vehicle of the chain is too big, then it's the lateness the vehicle have against it's theorical position if correctly separated.
This patch does NOT affect the savegame format.
Tests :
- Works as expected with road vehicles
- Works as expected with planes
- Works as expected with ships (I think it's the best thing that patch can do)
- Works as expected with trains
- Tested with multiplayer game (only 1 client plus the server, machine) and did not throw any problem
Patch is made from source code revision 10887 (and applies without any warning on the 10892 revision)
I hope you'll enjoy this patch, I do ;)
This task depends upon
This task blocks these from closing

timetable_separation.patch
Update :
- Removed the list I added to the sation class. Replaced by an "on the fly" compute.
- Fix : A minor bug making the second vehicle separation lower than expected in some cases.
New patch made from trunk r10908
Fix : There were an issue when the vehicles where computing separation while another vehicle was waiting at the station. Now it works all the time and the separation works fine.
(sorry, lastest patch is for trunk r10977)
- Fix : The bug fixed in 10977 wasn't correctly handled. Not it is completely corrected.
r01980
- Optimisation : Separation computation code moved from HandleLoading() to BeginLoading() function in order to save CPU. Now the separation computation is done only one time when the vehicle enters the first route station.
Still r10980
Small update : added a patch option to enable/disable the feature.
r10990
Although I am unsure this patch is really useful, for sure it fails codestyle.
- Don't include any other language than english.txt
- Use spaces to align english.txt
- Follow coding style.
- Don't do: ++index; Do: index++;
- Don't use doxygen comments inside functions
- Single line comments are: /* */. Not ///
- ... (the list is pretty long ;) Look up the wiki please)
Patch update against trunk r12032.
Fixed those small remarks.
ignore last file.
here is the lastest r12032 patch file.
New update. This times it should not remain any issue about comments and coding style rules
r12059
The patch was replacing the simple function "IsSharedOrderList(const Vehicle *v)" to a Vehicle method class, but now the trunk already contains this change (r12040), so I removed the change from the patch.