r1320 - trunk/code/q3_ui

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Sun Apr 13 04:30:51 EDT 2008


Author: ludwig
Date: 2008-04-13 04:30:51 -0400 (Sun, 13 Apr 2008)
New Revision: 1320

Modified:
   trunk/code/q3_ui/ui_video.c
Log:
better handling of illegal mode values


Modified: trunk/code/q3_ui/ui_video.c
===================================================================
--- trunk/code/q3_ui/ui_video.c	2008-04-13 08:30:48 UTC (rev 1319)
+++ trunk/code/q3_ui/ui_video.c	2008-04-13 08:30:51 UTC (rev 1320)
@@ -423,7 +423,7 @@
 			continue;
 		if ( s_ivo_templates[i].driver != s_graphicsoptions.driver.curvalue )
 			continue;
-		if ( s_ivo_templates[i].mode != s_graphicsoptions.mode.curvalue )
+		if ( GraphicsOptions_FindDetectedResolution(s_ivo_templates[i].mode) != s_graphicsoptions.mode.curvalue )
 			continue;
 		if ( s_ivo_templates[i].fullscreen != s_graphicsoptions.fs.curvalue )
 			continue;
@@ -555,7 +555,12 @@
 	if( resolutionsDetected )
 	{
 		// 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 )
 		{
 			char w[ 16 ], h[ 16 ];
@@ -633,7 +638,7 @@
 	case ID_LIST:
 		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.lighting.curvalue    = ivo->lighting;
 		s_graphicsoptions.colordepth.curvalue  = ivo->colordepth;




More information about the quake3-commits mailing list