diff options
author | Patric Stout <truebrain@openttd.org> | 2021-03-10 13:39:03 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-10 13:39:03 +0100 |
commit | 098d5b22395e123e4990b73a2ad7bf703adf068b (patch) | |
tree | 74d932a0fb268851e90693a1fc9ee64f8dbc4f70 /src | |
parent | 160a5f2fdda791f24b6b8ed990ac0285f193cd5a (diff) | |
download | openttd-098d5b22395e123e4990b73a2ad7bf703adf068b.tar.xz |
Fix #8711: having gui_zoom lower than zoom_min causes crashes (#8835)
gui_zoom was never clamp'd between zoom_min/zoom_max.
zoom_min controls how zoomed-in we load sprites. For a value of 1,
no quad-sizes sprites are loaded. If gui_zoom would be 0, meaning
it wants quad-sized sprites to display, it was printing random
stuff to the screen, which could or could not result in crashes.
Diffstat (limited to 'src')
-rw-r--r-- | src/gfx.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/gfx.cpp b/src/gfx.cpp index 826f93f54..3189b8d96 100644 --- a/src/gfx.cpp +++ b/src/gfx.cpp @@ -1893,7 +1893,9 @@ void UpdateGUIZoom() if (_gui_zoom_cfg == ZOOM_LVL_CFG_AUTO) { _gui_zoom = static_cast<ZoomLevel>(Clamp(VideoDriver::GetInstance()->GetSuggestedUIZoom(), _settings_client.gui.zoom_min, _settings_client.gui.zoom_max)); } else { - _gui_zoom = static_cast<ZoomLevel>(_gui_zoom_cfg); + _gui_zoom = static_cast<ZoomLevel>(Clamp(_gui_zoom_cfg, _settings_client.gui.zoom_min, _settings_client.gui.zoom_max)); + /* Write the value back in case it was not between min/max. */ + _gui_zoom_cfg = _gui_zoom; } /* Determine real font zoom to use. */ |