FS#6503 - Abnormalities in train subtile coordinates when reversing at the end of line
I was investigating train movement mechanics and noticed some abnormalities. Opening this bug to sum up what I found so far.
I made python script(in attachment) to visualize train path in subtile coordinates. And apparently its location jumps one subtile when it reverses at the end of line (see attached image, loco lenght is 6 subtiles). From what I can tell it's a combination of several bugs:
1. Train goes one subtile too far before stopping. Speed also confirms it going 25->5->7...->25 on that extra subtile (that's not showing in gui though).
2. Reversing is wrong. It keeps coordinates unchanged and only flips direction. Because of _initial_tile_subcoord, real train position actually depends on train direction(dx,dy): real_x = pos_x + int(dx == -1) + dx * progress%, same for y. So flipping direction moves the train and x,y should be changed to compensate for it.
Just playing around with code I found that adding 1 to condition in TrainApproachingLineEnd fixes #1. And removing TrainCheckIfLineEnds call in TrainLocoHandler somehow fixes #2. But I didn't dig into it enough to understand what's going on there, so not sure if it's a right way to fix it (especially #2).
Also I ran out of time I can spend on this for now. Hope someone can pick it up from where I left it ;) Also can be useful to check subpixel movement for other situations and vehicle types.
P.S. Also attaching diff that outputs coordinates for python script from game and save that I used to generate the image.
This task depends upon