commit cd116c36b611ffca0a4326130ac58504ce4b8f45
Author: Simon Howard <fraggle@gmail.com>
AuthorDate: Sat Nov 27 19:39:14 2010 +0000
Commit: Simon Howard <fraggle@gmail.com>
CommitDate: Sat Nov 27 19:39:14 2010 +0000
When generating the texture name lookup hash table, add new entries to
the end of chains. This way, entries earlier in the texture list trump
later entries with the same name.
This fixes a bug with the wrong sky being shown in Spooky01.wad (thanks
Porsche Monty).
Subversion-branch: /trunk/chocolate-doom
Subversion-revision: 2172
---
src/r_data.c | 20 +++++++++++++++++---
1 file changed, 17 insertions(+), 3 deletions(-)
diff --git a/src/r_data.c b/src/r_data.c
index d03becd5..ccfc5efe 100644
--- a/src/r_data.c
+++ b/src/r_data.c
@@ -413,6 +413,7 @@ R_GetColumn
static void GenerateTextureHashTable(void)
{
+ texture_t **rover;
int i;
int key;
@@ -429,12 +430,25 @@ static void GenerateTextureHashTable(void)
textures[i]->index = i;
- // Hook into hash table
+ // Vanilla Doom does a linear search of the texures array
+ // and stops at the first entry it finds. If there are two
+ // entries with the same name, the first one in the array
+ // wins. The new entry must therefore be added at the end
+ // of the hash chain, so that earlier entries win.
key = W_LumpNameHash(textures[i]->name) % numtextures;
- textures[i]->next = textures_hashtable[key];
- textures_hashtable[key] = textures[i];
+ rover = &textures_hashtable[key];
+
+ while (*rover != NULL)
+ {
+ rover = &(*rover)->next;
+ }
+
+ // Hook into hash table
+
+ textures[i]->next = NULL;
+ *rover = textures[i];
}
}