summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2008-08-31 20:08:24 +0000
committerpeter1138 <peter1138@openttd.org>2008-08-31 20:08:24 +0000
commit744b3527e56da8dd982dc310f1574485809371f0 (patch)
treec44abc289939568773ce63096bd58ef10c781be5
parentdc2ace2494ca544b940c4b0017d41543d1ebc672 (diff)
downloadopenttd-744b3527e56da8dd982dc310f1574485809371f0.tar.xz
(svn r14208) -Fix (r14197): Crash if no .obg files are found.
-rw-r--r--src/gfxinit.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/gfxinit.cpp b/src/gfxinit.cpp
index f76e90968..d1195803a 100644
--- a/src/gfxinit.cpp
+++ b/src/gfxinit.cpp
@@ -169,9 +169,9 @@ static bool FileMD5(const MD5File file)
* 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 @@ static void DetermineGraphicsPack()
}
_used_graphics_set = best;
+ return _used_graphics_set != NULL;
}
/**
@@ -191,6 +192,7 @@ static void DetermineGraphicsPack()
*/
static void DeterminePalette()
{
+ assert(_used_graphics_set != NULL);
if (_use_palette < MAX_PAL) return;
_use_palette = _used_graphics_set->palette;
@@ -203,7 +205,6 @@ static void DeterminePalette()
*/
void CheckExternalFiles()
{
- DetermineGraphicsPack();
DeterminePalette();
static const size_t ERROR_MESSAGE_LENGTH = 128;
@@ -468,7 +469,7 @@ void FindGraphicsSets()
bool SetGraphicsSet(const char *name)
{
if (StrEmpty(name)) {
- DetermineGraphicsPack();
+ if (!DetermineGraphicsPack()) return false;
CheckExternalFiles();
return true;
}