First of let me explain why my timetable looks the way it does. I usually record it with the very first vehicle (of a certain type) when the station aren't initialized yet, so the vehicle runs the first round empty. Of course when I change vehicle types (new bus/train comes out or something) I have to rerecord the timetable. Also the timetable examples from my savegame have surely been rerecorded as they've stopped working at least once before.
For me the whole point of any system trying to keep distance between vehicles should be self-regulating if at all possible. If I have to use the timetable I don't want the waiting times to be longer than the minimum, even though I usually can't be bothered to adjust those by hand, so they are whatever happens to be recorded. There is little point in my eyes in waiting at a certain station for 5 days just because when I had 2 fewer vehicles it was overcrowded and that time was needed, but now another station generates more passengers and dictates the amount of vehicles. So I'd rather have stop times of 1 days for every stop and artificially inflated travel times between stops by the amount that would normally be added to the stops.
So let me suggest something a little more radical, which could make the whole system self-regulating while keeping the current flexibility (if not increasing it). Basically there are two approaches I can offer, one requiring very little coding (more of a quick fix, if you will), the other with most likely more effort would reduce the functionality of (what is currently) timetables to just keeping distance.
"Quick Fix" version: Let me start by saying that the actual timetable function, trying to keep a vehicle to a global schedule is completely useless for keeping a constant distance between vehicles. I honestly don't even know what the original intent for it's use is. But the fact remains that you currently use the mechanics provided through timetables to adjust the separation of vehicles. The simplest solution that can remove the effect from that timetable implementation as a problem and have the thing work at least approximately right over long periods of time would be to just either constantly reset the vehicle lateness (either at every stop or at the first stop, I'm unaware of how such actions would affect your implementation), or stop "keeping score" with a general timetable in the literal sense in the first place (i.e. never change the early/late entry in the first place and/or disregard any value it may contain). Even after changing vehicles the separation would more or less work as intended, just with either too small or too big gaps, but still quite functional.
Tailored Functionality: This would either re-purpose the timetable functionality to (only) do vehicle separation, or provide an additional mode operating independently from timetables. Because what is actually needed to keep vehicles at equal distance is relatively little: The number of vehicles currently running a route (trivial) and time it takes to complete the route has to be known (not as trivial, but not complicated either). To get the second let every vehicle record the time it need to get from every stop on it's order list to the next. Adding this up and averaging over all vehicles on a route gives the travel time. If this value is kept and modified whenever a vehicle completes a leg or it's order list with "val = a*new + (1-a)*old" this avoid any jumpy behavior due to breakdowns. This can either be per leg/section of the route or for the entire route at once (in the end only the total time for the route is relevant, so whichever is easier to implement I guess).
Now that the time required for a route is known (and automatically readjusted for faster and slower vehicles alike) the only thing that is still needed is to actually keep the distance. This can be done quite easily as I mentioned in the previous post: Whenever a vehicle is ready to leave a station (i.e. done loading) there is a check when the last vehicle from the order list left the station. If it is less than (total route time)/(vehicle count) ago, it is held back (still loading, like the timetable does) until this time is reached.
This system should never
ever break, as the total time (on which waiting is based upon) is dependent only on the travel times between stops, which is never modified by waiting.
The most complicated thing about this is to figure out the UI, since this can easily coexist with the current timetable implementation (for anyone who wants to still use that). For example anyone can set waiting times at stops if (s)he so desires, the separation timer check would just come after the timetabled waiting is completed. The UI could be sort of merged into the timetable like it is now, but it could also be placed in the order-view in a sub-frame on the right much like it is now on the timetable view. All that is needed is effectively an "on/off" switch, that's all. It could also be a button to the left of the "timetable"-switch at the top, it just says "separation" and when pressed turns it on for that (shared) order list (and it would be disabled for orders which aren't shared). Or that same thing but somewhere between all the buttons at the bottom (between 'delete' and 'go to'?).
So to summarize, the following data would need to be collected/updated for this:
- For every (shared) order list
- Total average completion time (averaged over all vehicles, possibly averaged over time)
- last departure time of a vehicle for every stop
- For every vehicle on such a list
- Time taken to get from every stop to the next
Since it's very little effort the tracking can also be active for orders that include just 1 vehicle. If a second one is added the whole system already runs smoothly and no need to wait again for any vehicle to complete the order list. Generally keeping distance can be activated as soon as there is at least 1 value for all of the travel times tracked by vehicles. Precision will increase as more vehicles contribute their values.