Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Abnormalities in train subtile coordinates when reversing at the end of line #6503

Open
DorpsGek opened this issue Sep 1, 2016 · 4 comments
Labels
bug Something isn't working flyspray This issue is imported from FlySpray (https://bugs.openttd.org/) stale Stale issues

Comments

@DorpsGek
Copy link
Member

DorpsGek commented Sep 1, 2016

dp opened the ticket and wrote:

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.

Attachments

Reported version: 1.6.1
Operating system: All


This issue was imported from FlySpray: https://bugs.openttd.org/task/6503
@DorpsGek
Copy link
Member Author

DorpsGek commented Sep 2, 2016

dp wrote:

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.


This comment was imported from FlySpray: https://bugs.openttd.org/task/6503#comment14264

@DorpsGek DorpsGek added Core flyspray This issue is imported from FlySpray (https://bugs.openttd.org/) labels Apr 7, 2018
@frosch123 frosch123 removed the Core label Apr 14, 2018
@andythenorth andythenorth added the stale Stale issues label Jan 5, 2019
@andythenorth
Copy link
Contributor

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!

@LordAro LordAro reopened this Feb 26, 2021
@ldpl
Copy link
Contributor

ldpl commented Sep 3, 2021

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.
Screenshot from 2021-09-03 22-44-01

@LordAro
Copy link
Member

LordAro commented Sep 3, 2021

Possibly the same issue as #8424 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working flyspray This issue is imported from FlySpray (https://bugs.openttd.org/) stale Stale issues
Projects
None yet
Development

No branches or pull requests

6 participants