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

Ships with max speed overflow to near-zero speed #8177

Closed
hewimp opened this issue May 31, 2020 · 5 comments
Closed

Ships with max speed overflow to near-zero speed #8177

hewimp opened this issue May 31, 2020 · 5 comments
Labels
bug Something isn't working component: NewGRF This issue is related to NewGRFs

Comments

@hewimp
Copy link

hewimp commented May 31, 2020

Version of OpenTTD

1.10.1 (and possibly others)

Expected result

Ships travel at specified speed.

Actual result

Ships with maximum possible speed (128 km/h) end up traveling incredibly slow.

Steps to reproduce

Start a game with the NewGRF redFISH 0.4, configure it to have ship speed "Cheating".
Set the game year past 2012, where the ship model Mount Blaze Fast Ferry should be available.
Build a Mount Blaze Fast Ferry and a Matsushima Hydrofoil and assign them to the same route.
Observe that the Fast Ferry appears to not move at all at normal game speed, and on fast-forward only moves one pixel every several days.

@hewimp
Copy link
Author

hewimp commented May 31, 2020

Ships Redfish has a Ideal and a Cheat speed. The ship work fine as long its going at an angle soon as it go in straight line hits 80 the ship just stops. can hit Stop and go it go until hits 80 again but only not at an angle tried it on 3 or so version including the newest 10.1 still same issue thanks.
hewimp@hiotmail.com Would like to get a Grf made how dose one do that with 0 Exp in doing them.
any help would be aprecited

@nielsmh
Copy link
Contributor

nielsmh commented May 31, 2020

Okay so yes, the redFISH NewGRF has a setting to make ships faster, and the fastest ship (Mount Blaze Fast Ferry) has a specified speed of 128 km/h. This apparently causes an overflow somewhere, and causes it to move absurdly slow.

That sounds like a real bug in OpenTTD.

@nielsmh nielsmh changed the title Ships Ships with max speed overflow to near-zero speed May 31, 2020
@nielsmh nielsmh added backport requested This PR should be backport to current release (RC / stable) bug Something isn't working and removed backport requested This PR should be backport to current release (RC / stable) labels May 31, 2020
@FLHerne
Copy link
Contributor

FLHerne commented May 31, 2020

I believe this is as specified.

Ship speed (prop 0B) is a byte property, measured in half km/h-ish, so the maximum representable value is 127km/h-ish. This is a known limition, as complained about by ekranoplan coders here.

Road vehicles originally had the same limitation, but a new prop15 was added to allow higher maximum speeds. This has never been done for ships, presumably because very fast ships are rare.

This may be a bug in NML if the grf specifies a constant speed above 127km/h and no warnings are given.

@Yexo
Copy link
Contributor

Yexo commented May 31, 2020

The specified speed in the item-block is 60.0mph, but there is a callback that adjust the speed. I don't think NML supports unit-conversion in callbacks, but even if it does that is not used.

RedFish returns 256 as speed value from the callback. OpenTTD stores that correctly in vcache.cached_max_speed. ShipAccelerate later casts this uint16 back to a byte when actually moving the ship.

At max speed a ship moves exactly 1 unit per tick. To allow higher max speeds, ShipController would have to be called multiple times per tick.

@hewimp On how to create your own NewGRF: start with https://www.tt-wiki.net/wiki/NMLTutorial, ask questions on https://www.tt-forums.net/viewforum.php?f=68.

@nielsmh
Copy link
Contributor

nielsmh commented May 31, 2020

So either OpenTTD should be changed so this speed works, or OpenTTD should be changed so it reports a warning about the GRF being buggy.

@TrueBrain TrueBrain added the component: NewGRF This issue is related to NewGRFs label Jan 8, 2021
Kuhnovic added a commit to Kuhnovic/OpenTTD that referenced this issue Apr 23, 2023
Kuhnovic added a commit to Kuhnovic/OpenTTD that referenced this issue Apr 23, 2023
Kuhnovic added a commit to Kuhnovic/OpenTTD that referenced this issue Apr 26, 2023
Kuhnovic added a commit to Kuhnovic/OpenTTD that referenced this issue Apr 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working component: NewGRF This issue is related to NewGRFs
Projects
None yet
Development

No branches or pull requests

5 participants