Hello,
I think I found an issue with timetable and especially separation patch.
On long routes (about 50 000 ticks to complete) I often have trains with an enormous early timer instead of being a bit late.
After a very quick look in the code (not actually in the involved code, but some random lines about timetable and late counter) I found some strange types used.
The Ticks type is an alias of int32.
2147483647 ticks for a timetable is very enougth. Even for a complete game I guess.
But when I look at timetable computing, other types are involved :
Code: Select all
this->timetable_duration += o->GetTimetabledWait() + o->GetTimetabledTravel();
GetTimetabledWait() returns a uint16, so 65536 as max value.
GetTimetabledTravel() returns a uint16 too.
So if there is more 65536 ticks between two orders, there will be an overflow. And when computing lateness or separation, the whole table length is analyzed, so if using uint16 where will be problems.
Thus, I'm not sure, but when doing some subtraction between uint16, the values might be casted to int16 before calculation in order to handle properly negative values.
Vehicle lateness_counter is a int32.
I don't know exactly what happens and where, but I'm almost sure there is an overflow somewhere.
In any case, IMHO all time related variables and properties should be expressed in Ticks rather than int32, uint16, etc.
Here is a save game with the problem.