--- CriticalMass-1.0.2/game/Selectable.hpp 2005-08-15 03:06:37.000000000 +0200 +++ CriticalMass-1.0.2.foo/game/Selectable.hpp 2010-07-12 15:33:57.229790590 +0200 @@ -139,7 +139,7 @@ string text; bool operator==(Resolution &r1) { - return (r1.width=width) && (r1.height==height); + return (r1.width==width) && (r1.height==height); } bool operator!=(Resolution &r1) { --- CriticalMass-1.0.2/game/Video.cpp 2006-07-16 01:43:57.000000000 +0200 +++ CriticalMass-1.0.2.foo/game/Video.cpp 2010-07-12 16:40:16.377919418 +0200 @@ -124,10 +124,9 @@ _fpsStepSize = 1.0f/(float)_maxFPS; } - ConfigS::instance()->getBoolean( "fullscreen", _isFullscreen); - if( !setVideoMode()) { + SDL_QuitSubSystem( SDL_INIT_VIDEO); return false; } @@ -247,6 +246,8 @@ bool Video::setVideoMode( void) { int videoFlags = SDL_OPENGL; + + ConfigS::instance()->getBoolean( "fullscreen", _isFullscreen); if( _isFullscreen) { LOG_INFO << "Fullscreen request." << endl; @@ -279,14 +280,12 @@ if( ! ::init("libGL.so.1")) { LOG_ERROR << "SDL Error: " << SDL_GetError() << endl; - SDL_QuitSubSystem( SDL_INIT_VIDEO); return false; } if( SDL_SetVideoMode( _width, _height, _bpp, videoFlags ) == NULL ) { LOG_ERROR << "Video Mode: failed #" << SDL_GetError() << endl; - SDL_QuitSubSystem( SDL_INIT_VIDEO); return false; } glViewport(0,0, _width, _height); @@ -304,16 +303,20 @@ return true; } -void Video::updateSettings( void) +bool Video::updateSettings( void) { - bool fullscreen = _isFullscreen; - ConfigS::instance()->getBoolean( "fullscreen", _isFullscreen); + bool isFullscreen, oldIsFullscreen; + int width, height, oldWidth, oldHeight; + + isFullscreen = oldIsFullscreen = _isFullscreen; + width = oldWidth = _width; + height = oldHeight = _height; - int width = 0; + ConfigS::instance()->getBoolean( "fullscreen", isFullscreen); ConfigS::instance()->getInteger( "width", width); - int height = 0; ConfigS::instance()->getInteger( "height", height); - if( (fullscreen != _isFullscreen) || (width != _width) || (height != _height)) + + if( (isFullscreen != oldIsFullscreen) || (width != oldWidth) || (height != oldHeight)) { #ifdef DYNAMIC_GL SDL_QuitSubSystem( SDL_INIT_VIDEO); @@ -322,7 +325,22 @@ LOG_ERROR << "Update Video: failed # " << SDL_GetError() << endl; } #endif - setVideoMode(); + if (!setVideoMode()) { + // Try again with old settings. + Value *fs = new Value( oldIsFullscreen); + Value *w = new Value( oldWidth); + Value *h = new Value( oldHeight); + + ConfigS::instance()->updateKeyword( "fullscreen", fs); + ConfigS::instance()->updateKeyword( "width", w); + ConfigS::instance()->updateKeyword( "height", h); + + if (!setVideoMode()) { + SDL_QuitSubSystem(SDL_INIT_VIDEO); + GameState::isAlive = false; + return false; + } + } reload(); #ifdef DYNAMIC_GL //hide&grab cursor and warp to centre @@ -345,6 +363,8 @@ ConfigS::instance()->getBoolean( "showStarfield", _showStarfield); ConfigS::instance()->getBoolean( "showNebulas", _showNebulas); + + return true; } void Video::updateLogic( void) @@ -360,7 +380,8 @@ float thisTime = Timer::getTime(); if( thisTime > nextTime) { - updateSettings(); + if (!updateSettings()) + return false; nextTime = thisTime+0.5f; } --- CriticalMass-1.0.2/game/Video.hpp 2005-12-31 01:37:26.000000000 +0100 +++ CriticalMass-1.0.2.foo/game/Video.hpp 2010-07-12 16:37:20.560170285 +0200 @@ -52,7 +52,7 @@ Video &operator=(const Video&); void reload( void); - void updateSettings( void); + bool updateSettings( void); bool setVideoMode( void); bool _isFullscreen;