FS#1128 - Timetable based auto-separation patch

Attached to Project: OpenTTD
Opened by Sylvain Devidal (MagicBuzz) - Tuesday, 14 August 2007, 18:35 GMT
Last edited by Ingo von Borstel (planetmaker) - Wednesday, 04 September 2013, 00:10 GMT
Type Patch
Category Vehicles
Status Closed
Assigned To No-one
Operating System All
Severity Medium
Priority Normal
Reported Version trunk
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 21
  • Alex Antonov (aantono) (2013-06-30)
  • Alexandros (fumantsu) (2013-06-17)
  • Morten Lied Johansen (Epcylon) (2012-05-29)
  • Jonathan (JonAce) (2012-03-08)
  • lugo (lugo) (2011-12-09)
  • Trevor Green (trumpi) (2011-09-04)
  • Stefan Linnemann (Mazur) (2011-01-06)
  • Angelo Locritani (alocritani) (2010-12-15)
  • miller (Miller) (2010-10-14)
  • private_paula (private_paula) (2010-08-16)
  • Lukas G. (Skyruner2) (2010-08-05)
  • Someone (eliberatorM) (2010-07-27)
  • Kogut (Kogut) (2010-06-13)
  • Jordi (simnl) (2010-05-25)
  • Xander Hoogendoorn (xahodo) (2010-04-02)
  • Steve-N (steven) (2010-02-07)
  • A. Lam (2006TTD) (2009-11-21)
  • Adam Olsen (Rhamphoryncus) (2009-11-03)
  • Mark Jones (welshdragon) (2009-10-22)
  • Timitry (Timitry) (2009-01-09)
  • James Denholm (James.Denholm) (2008-10-06)
Private No


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.

- 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

Closed by  Ingo von Borstel (planetmaker)
Wednesday, 04 September 2013, 00:10 GMT
Reason for closing:  Implemented
Additional comments about closing:  Somewhere along the way... before r25557
2016-12-28: A request to re-open the task has been made. Reason for request: I cannot find any evidence of auto-separation in the 1.6.1 release (r27609) so I do not understand how you can claim this feature is "Implemented". Control-clicking "Start date" is the exact opposite of *auto*-separation, in case that wasn't obvious.
Comment by Sylvain Devidal (MagicBuzz) - Wednesday, 15 August 2007, 21:07 GMT
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
Comment by Sylvain Devidal (MagicBuzz) - Saturday, 25 August 2007, 09:09 GMT
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.
Comment by Sylvain Devidal (MagicBuzz) - Saturday, 25 August 2007, 09:10 GMT
(sorry, lastest patch is for trunk r10977)
Comment by Sylvain Devidal (MagicBuzz) - Sunday, 26 August 2007, 09:45 GMT
- Fix : The bug fixed in 10977 wasn't correctly handled. Not it is completely corrected.

Comment by Sylvain Devidal (MagicBuzz) - Sunday, 26 August 2007, 10:57 GMT
- 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
Comment by Sylvain Devidal (MagicBuzz) - Monday, 27 August 2007, 18:48 GMT
Small update : added a patch option to enable/disable the feature.

Comment by Patric Stout (TrueBrain) - Saturday, 03 November 2007, 23:22 GMT
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)
Comment by Sylvain Devidal (MagicBuzz) - Friday, 01 February 2008, 14:56 GMT
Patch update against trunk r12032.

Fixed those small remarks.
Comment by Sylvain Devidal (MagicBuzz) - Friday, 01 February 2008, 16:08 GMT
ignore last file.

here is the lastest r12032 patch file.
Comment by Sylvain Devidal (MagicBuzz) - Saturday, 02 February 2008, 00:37 GMT
New update. This times it should not remain any issue about comments and coding style rules
Comment by Sylvain Devidal (MagicBuzz) - Monday, 04 February 2008, 18:56 GMT

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.
Comment by Steve-N (steven) - Sunday, 07 February 2010, 10:21 GMT
Updated to r19051.

(Note that the configuration option actually will not be saved in this revision, thus loading a game will always have timetable separation enabled).