diff src/gfxinit.cpp @ 11130:2770c4f89a05 draft

(svn r15476) -Fix [FS#2630]: crash when opening the game options when the currently loaded base graphics pack has less than 2 valid graphics files. For example when someone replaces all his/her original base graphics with custom work (but keeps the name) or renames the dos ones to windows or vice versa.
author rubidium <rubidium@openttd.org>
date Sat, 14 Feb 2009 01:42:12 +0000
parents da73fac03cd6
children 699a0f6a1407
line wrap: on
line diff
--- a/src/gfxinit.cpp
+++ b/src/gfxinit.cpp
@@ -577,7 +577,7 @@
 {
 	int n = 0;
 	for (const GraphicsSet *g = _available_graphics_sets; g != NULL; g = g->next) {
-		if (g->found_grfs <= 1) continue;
+		if (g != _used_graphics_set && g->found_grfs <= 1) continue;
 		n++;
 	}
 	return n;
@@ -590,8 +590,8 @@
 {
 	int n = 0;
 	for (const GraphicsSet *g = _available_graphics_sets; g != NULL; g = g->next) {
+		if (g == _used_graphics_set) return n;
 		if (g->found_grfs <= 1) continue;
-		if (g == _used_graphics_set) return n;
 		n++;
 	}
 	return -1;
@@ -603,7 +603,7 @@
 const char *GetGraphicsSetName(int index)
 {
 	for (const GraphicsSet *g = _available_graphics_sets; g != NULL; g = g->next) {
-		if (g->found_grfs <= 1) continue;
+		if (g != _used_graphics_set && g->found_grfs <= 1) continue;
 		if (index == 0) return g->name;
 		index--;
 	}