about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorJoel de Vahl <joel@stalverk80.se>2007-07-23 17:43:01 +0000
committerJoel de Vahl <joel@stalverk80.se>2007-07-23 17:43:01 +0000
commit8be353d62c3f2247485e7ab4940feee5b8f349ab (patch)
treea849581c03be002a40f231af4055113b2599db44 /src
parentab192f794e5e4f87933b07763861790f269f501a (diff)
downloadzcatch-8be353d62c3f2247485e7ab4940feee5b8f349ab.tar.gz
zcatch-8be353d62c3f2247485e7ab4940feee5b8f349ab.zip
Don't crash on settings->video
Diffstat (limited to 'src')
-rw-r--r--src/game/client/menu.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/game/client/menu.cpp b/src/game/client/menu.cpp
index 1d87a688..4eef008c 100644
--- a/src/game/client/menu.cpp
+++ b/src/game/client/menu.cpp
@@ -784,11 +784,13 @@ static int settings_controls_render()
 	return 0;
 }
 
+static const unsigned MAX_RESOLUTIONS = 8;
+
 static int settings_video_render()
 {
 	static int resolution_count[2] = {0};
-	static int resolutions[2][10][2] = {0};
-	static char resolution_names[2][10][128] = {0};
+	static int resolutions[2][MAX_RESOLUTIONS][2] = {0};
+	static char resolution_names[2][MAX_RESOLUTIONS][128] = {0};
 
 	static bool inited = false;
 	if (!inited)
@@ -817,10 +819,14 @@ static int settings_video_render()
 			}
 
 			int resolution_index = resolution_count[depth_index];
-			resolution_count[depth_index]++;
-			resolutions[depth_index][resolution_index][0] = mode.width;
-			resolutions[depth_index][resolution_index][1] = mode.height;
-			sprintf(resolution_names[depth_index][resolution_index], "%ix%i", mode.width, mode.height);
+			if(resolution_index < MAX_RESOLUTIONS)
+			{
+				resolution_count[depth_index]++;
+				resolutions[depth_index][resolution_index][0] = mode.width;
+				resolutions[depth_index][resolution_index][1] = mode.height;
+				dbg_msg("res", "%ix%i", mode.width, mode.height);
+				sprintf(resolution_names[depth_index][resolution_index], "%ix%i", mode.width, mode.height);
+			}
 		}
 
 		inited = true;