You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
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).
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.
One more thing. After reversing train keeps subtile progress which doesn't seem right either. Because at this point leftover progress means extra time, not distance. And after reverse it has 0 speed so it covers almost no distance in that extra time. Currently if train is lucky it can cover half(or mb even more) of subtile instantly after reverse because of this.
Thanks for this. There's been no activity on this for some time, and as it stands, it doesn't look likely that it will go any further. I'm closing it as we try to keep the issue count low for OpenTTD, it helps us focus on things that are important and fun. Feel free to discuss in irc or request re-opening if you disagree. Thanks for contributing!
Maybe a separate bug but I guess I'll leave it here for now:
Some trains can crash while reversing into a water tile.
For example 1 x 1/8, 1 x 2/8, 4 x 4/8, 8 x 2/8.
dp opened the ticket and wrote:
Attachments
Reported version: 1.6.1
Operating system: All
This issue was imported from FlySpray: https://bugs.openttd.org/task/6503
The text was updated successfully, but these errors were encountered: