diff options
author | rubidium <rubidium@openttd.org> | 2009-06-30 12:42:43 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2009-06-30 12:42:43 +0000 |
commit | b7c8026a3d180deb6a5b4faa7c68da755815a416 (patch) | |
tree | 5f39223e8cc865970d01043311d674cac0768bc1 /src | |
parent | c29afac0a7264b7a3ab2cb3880abd5ba5ad4a8b5 (diff) | |
download | openttd-b7c8026a3d180deb6a5b4faa7c68da755815a416.tar.xz |
(svn r16701) -Fix [FS#3001]: limit the screen's resolution to 65535x65535 so the dirty pixels stay within bounds of a 32 bits integer
Diffstat (limited to 'src')
-rw-r--r-- | src/openttd.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/openttd.cpp b/src/openttd.cpp index 9f9fd127d..6f2cc4814 100644 --- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -553,10 +553,13 @@ int ttd_main(int argc, char *argv[]) if (startyear != INVALID_YEAR) _settings_newgame.game_creation.starting_year = startyear; if (generation_seed != GENERATE_NEW_SEED) _settings_newgame.game_creation.generation_seed = generation_seed; - /* The width and height must be at least 1 pixel, this - * way all internal drawing routines work correctly. */ - if (_cur_resolution.width == 0) _cur_resolution.width = 1; - if (_cur_resolution.height == 0) _cur_resolution.height = 1; + /* + * The width and height must be at least 1 pixel and width times + * height must still fit within a 32 bits integer, this way all + * internal drawing routines work correctly. + */ + _cur_resolution.width = ClampU(_cur_resolution.width, 1, UINT16_MAX); + _cur_resolution.height = ClampU(_cur_resolution.height, 1, UINT16_MAX); #if defined(ENABLE_NETWORK) if (dedicated_host) { |