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

Timetable / maximum speed #5079

Closed
DorpsGek opened this issue Feb 22, 2012 · 4 comments
Closed

Timetable / maximum speed #5079

DorpsGek opened this issue Feb 22, 2012 · 4 comments
Labels
flyspray This issue is imported from FlySpray (https://bugs.openttd.org/)

Comments

@DorpsGek
Copy link
Member

KasperVld opened the ticket and wrote:

L.S.,

A small bug appears when using the new maximum speed function in 1.2.0 RC1: the speed limit is sometimes set at 1kmph or 1mph lower than the entered value

To reproduce:
2. Create a vehicle (road vehicle, boat, train)
3. Create a route with a speed limit

- This problem occurs with all vehicle types (exept aeroplanes ofcourse).
- In SI units the problem always appears
- In imperial and metric units the problem is less frequent, it's for example not present with a set speed of 45mph, but it is with 44 (which is automatically changed to 43); in kmph the same is true for speed limits of 76kmph (not present) and 75kmph (present).

Reported version: 1.2.0-RC1
Operating system: All


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

KasperVld wrote:

typo!

there are only 2 reproduction steps, just ignore the missing 1.


This comment was imported from FlySpray: https://bugs.openttd.org/task/5079#comment10922

@DorpsGek
Copy link
Member Author

michi_cc wrote:

This is a rounding problem because the internal speed unit of OpenTTD is neither mph nor exactly km/h. And even if it were one of them, that would just means the other units would show bigger rounding problems. No easy way to fix.


This comment was imported from FlySpray: https://bugs.openttd.org/task/5079#comment10924

@DorpsGek
Copy link
Member Author

Rhamphoryncus wrote:

It's easy to fix. Round up when converting to kmish/h and round down when converting back.

Strictly speaking I haven't changed the behaviour of ConvertKmhishSpeedToDisplaySpeed, but for clarity I made it mirror ConvertDisplaySpeedToKmhishSpeed.

Caveat: although this works perfectly for mph and m/s, that is because they are coarser than kmish/h. In contrast km/h is very slightly finer and there are a small number of speeds that cannot be stored. Thus, 171 km/h becomes 172, 343 becomes 344, and 514 becomes 515.

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/5079#comment10937

@DorpsGek
Copy link
Member Author

michi_cc closed the ticket.

Reason for closing: Fixed

In r23955, at least as far as possible within the limits of the internal units of OpenTTD.


This comment was imported from FlySpray: https://bugs.openttd.org/task/5079

@DorpsGek DorpsGek added Core flyspray This issue is imported from FlySpray (https://bugs.openttd.org/) labels Apr 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flyspray This issue is imported from FlySpray (https://bugs.openttd.org/)
Projects
None yet
Development

No branches or pull requests

1 participant