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

Fix: Round up deltas for smooth scrolling, so that target will eventually be reached #7040

Merged
merged 1 commit into from Jan 20, 2019

Conversation

@btzy
Copy link
Contributor

btzy commented Jan 12, 2019

When smooth scrolling is enabled, the original code rounds the deltas toward zero. This means that the scroll position will never actually reach the destination scroll position (when the difference is 3, there will be no more scrolling in the original code). Rounding away from zero fixes this problem.

This bug also causes the cargo flow legend overlay to not be redrawn when smooth scrolling is enabled, because variable update_overlay in function UpdateViewportPosition never becomes true.

To observe the bug in the original code:

  1. Enable smooth scrolling in the settings.
  2. Zoom to the default zoom level.
  3. Open a station window by clicking on a station.
  4. Scroll the viewport to somewhere else.
  5. Click the "Location" button on the station window.
  6. Wait until the scrolling stops.
  7. Disable smooth scrolling in the settings.
  8. Click the "Location" button. Observe that the screen moves slightly despite supposedly already being scrolled to the station.
@btzy btzy force-pushed the btzy:round-up-smooth-scrolling branch from 9afea7f to a18c825 Jan 12, 2019
src/core/math_func.hpp Outdated Show resolved Hide resolved
@btzy btzy force-pushed the btzy:round-up-smooth-scrolling branch from a18c825 to 9b884f0 Jan 13, 2019
@btzy btzy force-pushed the btzy:round-up-smooth-scrolling branch from 9b884f0 to 312b971 Jan 13, 2019
@LordAro LordAro dismissed their stale review Jan 19, 2019

outdated

@LordAro LordAro merged commit 9d75600 into OpenTTD:master Jan 20, 2019
1 check passed
1 check passed
OpenTTD CI Build #20190113.5 succeeded
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.