summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon Howard2010-11-27 19:39:14 +0000
committerSimon Howard2010-11-27 19:39:14 +0000
commitcd116c36b611ffca0a4326130ac58504ce4b8f45 (patch)
tree8e2946eb6b2587d87dac9ad72a43fa1325c02391 /src
parent79446c49acfeb8b97fc535268cea4d9343cbaadf (diff)
downloadchocolate-doom-cd116c36b611ffca0a4326130ac58504ce4b8f45.tar.gz
chocolate-doom-cd116c36b611ffca0a4326130ac58504ce4b8f45.tar.bz2
chocolate-doom-cd116c36b611ffca0a4326130ac58504ce4b8f45.zip
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
Diffstat (limited to 'src')
-rw-r--r--src/r_data.c20
1 files 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];
}
}