shithub: choc

Download patch

ref: db86887cf6d5e11e161c27805d212c8cdff5a010
parent: 27055f4b7a9cbb63c5b7e4b77e556c8d13781bdb
author: Simon Howard <fraggle@gmail.com>
date: Sun Jan 22 16:17:56 EST 2006

Catch calls to DEH_String before DEH_Init is called

Subversion-branch: /trunk/chocolate-doom
Subversion-revision: 314

--- a/src/deh_text.c
+++ b/src/deh_text.c
@@ -1,7 +1,7 @@
 // Emacs style mode select   -*- C++ -*- 
 //-----------------------------------------------------------------------------
 //
-// $Id: deh_text.c 175 2005-10-08 20:54:16Z fraggle $
+// $Id: deh_text.c 314 2006-01-22 21:17:56Z fraggle $
 //
 // Copyright(C) 2005 Simon Howard
 //
@@ -21,6 +21,9 @@
 // 02111-1307, USA.
 //
 // $Log$
+// Revision 1.5  2006/01/22 21:17:56  fraggle
+// Catch calls to DEH_String before DEH_Init is called
+//
 // Revision 1.4  2005/10/08 20:54:16  fraggle
 // Proper dehacked error/warning framework.  Catch a load more errors.
 //
@@ -57,7 +60,7 @@
 
 static deh_substitution_t **hash_table;
 static int hash_table_entries;
-static int hash_table_length;
+static int hash_table_length = -1;
 
 // This is the algorithm used by glib
 
@@ -81,6 +84,11 @@
 char *DEH_String(char *s)
 {
     int entry;
+
+    // Fallback if we have not initialised the hash table yet
+
+    if (hash_table_length < 0)
+	return s;
 
     entry = strhash(s) % hash_table_length;