summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatric Stout <truebrain@openttd.org>2021-03-10 13:57:52 +0100
committerGitHub <noreply@github.com>2021-03-10 13:57:52 +0100
commit4866e438624bda4ccba2e3d7cc601f262a17545f (patch)
tree4f62982a0a142e1780289b68b30389e749508128
parent14b61bfa6fb6812bdc9739402956c3dfa3a4c12b (diff)
downloadopenttd-4866e438624bda4ccba2e3d7cc601f262a17545f.tar.xz
Codechange: rework codeflow introduced in 098d5b22 (#8837)
It didn't sit well to me, how I wrote the commit initially. First casting a variable into another, only to write it back into the originally feels wrong. This flow makes a bit more sense to me.
-rw-r--r--src/gfx.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/gfx.cpp b/src/gfx.cpp
index 6bcee66b1..d540f4dfe 100644
--- a/src/gfx.cpp
+++ b/src/gfx.cpp
@@ -1873,9 +1873,11 @@ 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>(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;
+ /* Ensure the gui_zoom is clamped between min/max. Change the
+ * _gui_zoom_cfg if it isn't, as this is used to visually show the
+ * selection in the Game Options. */
+ _gui_zoom_cfg = Clamp(_gui_zoom_cfg, _settings_client.gui.zoom_min, _settings_client.gui.zoom_max);
+ _gui_zoom = static_cast<ZoomLevel>(_gui_zoom_cfg);
}
/* Determine real font zoom to use. */