From 9ba03f7f0a7e99349c5e5e54a665c15464ee2e30 Mon Sep 17 00:00:00 2001 From: mcmartin Date: Mon, 28 Mar 2005 06:30:16 +0000 Subject: [PATCH] Reverts if you can't produce a graphics mode requested from setup menu Fixes bug #695. git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@1600 8092fc87-c524-0410-9efc-e669fe64eaf9 --- sc2/ChangeLog | 4 +++- .../sc2code/libs/graphics/sdl/sdl_common.c | 22 +++++++++++++++---- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/sc2/ChangeLog b/sc2/ChangeLog index e1a4e5694..5e1e8bc2a 100644 --- a/sc2/ChangeLog +++ b/sc2/ChangeLog @@ -1,6 +1,8 @@ Changes towards version 0.4: +- Attempting to set to a mode that Doesn't Work in Setup no longer ends + the program (bug #695) - Michael - Fixed segfault when shutting down because video could not be initialized - (bug #683), - Michael + (bug #683) - Michael - Fixed crash when restarting Sa-Matra battle after abort (bug #700) -Alex - Some cleanups, enabling successful build with GCC 4 (bug #710), mostly from Ville Skyttà - SvdB diff --git a/sc2/src/sc2code/libs/graphics/sdl/sdl_common.c b/sc2/src/sc2code/libs/graphics/sdl/sdl_common.c index 58bd87cdb..bdd389936 100644 --- a/sc2/src/sc2code/libs/graphics/sdl/sdl_common.c +++ b/sc2/src/sc2code/libs/graphics/sdl/sdl_common.c @@ -732,10 +732,24 @@ TFB_FlushGraphics () // Only call from main thread!! ClearSemaphore (DC.data.sendsignal.sem); break; case TFB_DRAWCOMMANDTYPE_REINITVIDEO: - TFB_ReInitGraphics (DC.data.reinitvideo.driver, DC.data.reinitvideo.flags, - DC.data.reinitvideo.width, DC.data.reinitvideo.height, - DC.data.reinitvideo.bpp); - break; + { + int oldDriver = GraphicsDriver; + int oldBpp = ScreenColorDepth; + if (TFB_ReInitGraphics (DC.data.reinitvideo.driver, DC.data.reinitvideo.flags, + DC.data.reinitvideo.width, DC.data.reinitvideo.height, + DC.data.reinitvideo.bpp)) + { + fprintf (stderr, "Could not provide requested mode: reverting to last known driver and bpp.\n"); + if (TFB_ReInitGraphics (oldDriver, DC.data.reinitvideo.flags, + DC.data.reinitvideo.width, DC.data.reinitvideo.height, + oldBpp)) + { + fprintf (stderr, "Couldn't reinit at that point either. Your video has been somehow tied in knots.\n"); + exit (-1); + } + } + break; + } } }