diff options
author | Michael Lutz <michi@icosahedron.de> | 2021-01-14 21:53:06 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-14 21:53:06 +0100 |
commit | fa60c1f8b94dd5584a5d5331de277ca23a203422 (patch) | |
tree | 7849166d1c2ee40f4d48f4fc4442af1ee24b3b2f /src/openttd.cpp | |
parent | 711723d7387df67b1abe98ca9ed4d7f2bd7de57d (diff) | |
download | openttd-fa60c1f8b94dd5584a5d5331de277ca23a203422.tar.xz |
Feature: Choose a sensible window size on a fresh OTTD config file. (#8536)
Diffstat (limited to 'src/openttd.cpp')
-rw-r--r-- | src/openttd.cpp | 14 |
1 files changed, 6 insertions, 8 deletions
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. |