From fa60c1f8b94dd5584a5d5331de277ca23a203422 Mon Sep 17 00:00:00 2001 From: Michael Lutz Date: Thu, 14 Jan 2021 21:53:06 +0100 Subject: Feature: Choose a sensible window size on a fresh OTTD config file. (#8536) --- src/openttd.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'src/openttd.cpp') diff --git a/src/openttd.cpp b/src/openttd.cpp index 9d28a3fe5..352a653be 100644 --- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -708,14 +708,12 @@ int openttd_main(int argc, char *argv[]) if (resolution.width != 0) _cur_resolution = resolution; - /* - * The width and height must be at least 1 pixel and width times - * height times bytes per pixel must still fit within a 32 bits - * integer, even for 32 bpp video modes. This way all internal - * drawing routines work correctly. - */ - _cur_resolution.width = ClampU(_cur_resolution.width, 1, UINT16_MAX / 2); - _cur_resolution.height = ClampU(_cur_resolution.height, 1, UINT16_MAX / 2); + /* Limit width times height times bytes per pixel to fit a 32 bit + * integer, This way all internal drawing routines work correctly. + * A resolution that has one component as 0 is treated as a marker to + * auto-detect a good window size. */ + _cur_resolution.width = std::min(_cur_resolution.width, UINT16_MAX / 2u); + _cur_resolution.height = std::min(_cur_resolution.height, UINT16_MAX / 2u); /* Assume the cursor starts within the game as not all video drivers * get an event that the cursor is within the window when it is opened. -- cgit v1.2.3-54-g00ecf