Don't crash on settings->video

This commit is contained in:
Joel de Vahl 2007-07-23 17:43:01 +00:00
parent ab192f794e
commit 8be353d62c
2 changed files with 1068 additions and 766 deletions

File diff suppressed because one or more lines are too long

View file

@ -784,11 +784,13 @@ static int settings_controls_render()
return 0; return 0;
} }
static const unsigned MAX_RESOLUTIONS = 8;
static int settings_video_render() static int settings_video_render()
{ {
static int resolution_count[2] = {0}; static int resolution_count[2] = {0};
static int resolutions[2][10][2] = {0}; static int resolutions[2][MAX_RESOLUTIONS][2] = {0};
static char resolution_names[2][10][128] = {0}; static char resolution_names[2][MAX_RESOLUTIONS][128] = {0};
static bool inited = false; static bool inited = false;
if (!inited) if (!inited)
@ -817,10 +819,14 @@ static int settings_video_render()
} }
int resolution_index = resolution_count[depth_index]; int resolution_index = resolution_count[depth_index];
resolution_count[depth_index]++; if(resolution_index < MAX_RESOLUTIONS)
resolutions[depth_index][resolution_index][0] = mode.width; {
resolutions[depth_index][resolution_index][1] = mode.height; resolution_count[depth_index]++;
sprintf(resolution_names[depth_index][resolution_index], "%ix%i", mode.width, mode.height); 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; inited = true;