better handling of illegal mode values

This commit is contained in:
Ludwig Nussel 2008-04-13 08:30:51 +00:00
parent 89a5a6429e
commit 53fc214d00

View file

@ -423,7 +423,7 @@ static void GraphicsOptions_CheckConfig( void )
continue; continue;
if ( s_ivo_templates[i].driver != s_graphicsoptions.driver.curvalue ) if ( s_ivo_templates[i].driver != s_graphicsoptions.driver.curvalue )
continue; continue;
if ( s_ivo_templates[i].mode != s_graphicsoptions.mode.curvalue ) if ( GraphicsOptions_FindDetectedResolution(s_ivo_templates[i].mode) != s_graphicsoptions.mode.curvalue )
continue; continue;
if ( s_ivo_templates[i].fullscreen != s_graphicsoptions.fs.curvalue ) if ( s_ivo_templates[i].fullscreen != s_graphicsoptions.fs.curvalue )
continue; continue;
@ -555,7 +555,12 @@ static void GraphicsOptions_ApplyChanges( void *unused, int notification )
if( resolutionsDetected ) if( resolutionsDetected )
{ {
// search for builtin mode that matches the detected mode // search for builtin mode that matches the detected mode
int mode = GraphicsOptions_FindBuiltinResolution( s_graphicsoptions.mode.curvalue ); int mode;
if ( s_graphicsoptions.mode.curvalue == -1
|| s_graphicsoptions.mode.curvalue >= sizeof(detectedResolutions)/sizeof(detectedResolutions[0]) )
s_graphicsoptions.mode.curvalue = 0;
mode = GraphicsOptions_FindBuiltinResolution( s_graphicsoptions.mode.curvalue );
if( mode == -1 ) if( mode == -1 )
{ {
char w[ 16 ], h[ 16 ]; char w[ 16 ], h[ 16 ];
@ -633,7 +638,7 @@ static void GraphicsOptions_Event( void* ptr, int event ) {
case ID_LIST: case ID_LIST:
ivo = &s_ivo_templates[s_graphicsoptions.list.curvalue]; ivo = &s_ivo_templates[s_graphicsoptions.list.curvalue];
s_graphicsoptions.mode.curvalue = ivo->mode; s_graphicsoptions.mode.curvalue = GraphicsOptions_FindDetectedResolution(ivo->mode);
s_graphicsoptions.tq.curvalue = ivo->tq; s_graphicsoptions.tq.curvalue = ivo->tq;
s_graphicsoptions.lighting.curvalue = ivo->lighting; s_graphicsoptions.lighting.curvalue = ivo->lighting;
s_graphicsoptions.colordepth.curvalue = ivo->colordepth; s_graphicsoptions.colordepth.curvalue = ivo->colordepth;