(svn r14208) -Fix (r14197): Crash if no .obg files are found.
authorpeter1138
Sun, 31 Aug 2008 20:08:24 +0000
changeset 10048 a0e67d110e5a
parent 10047 a5c34dea770c
child 10049 754a2d1e0e94
(svn r14208) -Fix (r14197): Crash if no .obg files are found.
src/gfxinit.cpp
--- a/src/gfxinit.cpp	Sun Aug 31 19:56:52 2008 +0000
+++ b/src/gfxinit.cpp	Sun Aug 31 20:08:24 2008 +0000
@@ -169,9 +169,9 @@
  * Determine the graphics pack that has to be used.
  * The one with the most correct files wins.
  */
-static void DetermineGraphicsPack()
+static bool DetermineGraphicsPack()
 {
-	if (_used_graphics_set != NULL) return;
+	if (_used_graphics_set != NULL) return true;
 
 	const GraphicsSet *best = _available_graphics_sets;
 	for (const GraphicsSet *c = _available_graphics_sets; c != NULL; c = c->next) {
@@ -182,6 +182,7 @@
 	}
 
 	_used_graphics_set = best;
+	return _used_graphics_set != NULL;
 }
 
 /**
@@ -191,6 +192,7 @@
  */
 static void DeterminePalette()
 {
+	assert(_used_graphics_set != NULL);
 	if (_use_palette < MAX_PAL) return;
 
 	_use_palette = _used_graphics_set->palette;
@@ -203,7 +205,6 @@
  */
 void CheckExternalFiles()
 {
-	DetermineGraphicsPack();
 	DeterminePalette();
 
 	static const size_t ERROR_MESSAGE_LENGTH = 128;
@@ -468,7 +469,7 @@
 bool SetGraphicsSet(const char *name)
 {
 	if (StrEmpty(name)) {
-		DetermineGraphicsPack();
+		if (!DetermineGraphicsPack()) return false;
 		CheckExternalFiles();
 		return true;
 	}