From b7c8026a3d180deb6a5b4faa7c68da755815a416 Mon Sep 17 00:00:00 2001 From: rubidium Date: Tue, 30 Jun 2009 12:42:43 +0000 Subject: (svn r16701) -Fix [FS#3001]: limit the screen's resolution to 65535x65535 so the dirty pixels stay within bounds of a 32 bits integer --- src/openttd.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src') 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) { -- cgit v1.2.3-70-g09d2