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 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.

src/core/math_func.hpp Outdated Show resolved Hide resolved
@LordAro LordAro merged commit 9d75600 into OpenTTD:master Jan 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants