foxygit / doom Log in
commit db86887cf6d5e11e161c27805d212c8cdff5a010
Author:     Simon Howard <fraggle@gmail.com>
AuthorDate: Sun Jan 22 21:17:56 2006 +0000
Commit:     Simon Howard <fraggle@gmail.com>
CommitDate: Sun Jan 22 21:17:56 2006 +0000

    Catch calls to DEH_String before DEH_Init is called

    Subversion-branch: /trunk/chocolate-doom
    Subversion-revision: 314
---
 src/deh_text.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/deh_text.c b/src/deh_text.c
index 6d95944b..ad61613a 100644
--- 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 @@ typedef struct

 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

@@ -82,6 +85,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;

     while (hash_table[entry] != NULL)