Clean up a few uses of the hash table functions to account for hash_findcase() working properly now

git-svn-id: https://svn.eduke32.com/eduke32@7366 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2019-03-02 23:21:21 +00:00
parent 3775bce3d7
commit db51740d3d
3 changed files with 3 additions and 34 deletions

View file

@ -46,23 +46,10 @@ hashtable_t h_gamefuncs = { NUMGAMEFUNCTIONS<<1, NULL };
int32_t CONFIG_FunctionNameToNum(const char *func) int32_t CONFIG_FunctionNameToNum(const char *func)
{ {
int32_t i;
if (!func) if (!func)
return -1; return -1;
i = hash_find(&h_gamefuncs,func); return hash_findcase(&h_gamefuncs, func);
if (i < 0)
{
char *str = Bstrtolower(Xstrdup(func));
i = hash_find(&h_gamefuncs,str);
Bfree(str);
return i;
}
return i;
} }

View file

@ -6243,10 +6243,7 @@ int app_main(int argc, char const * const * argv)
if (gamefunctions[i][0] == '\0') if (gamefunctions[i][0] == '\0')
continue; continue;
char *str = Bstrtolower(Xstrdup(gamefunctions[i]));
hash_add(&h_gamefuncs,gamefunctions[i],i,0); hash_add(&h_gamefuncs,gamefunctions[i],i,0);
hash_add(&h_gamefuncs,str,i,0);
Bfree(str);
} }
#ifdef STARTUP_SETUP_WINDOW #ifdef STARTUP_SETUP_WINDOW

View file

@ -5195,12 +5195,7 @@ repeatcase:
i = 0; i = 0;
{ hash_delete(&h_gamefuncs, gamefunctions[j]);
hash_delete(&h_gamefuncs, gamefunctions[j]);
char *str = Bstrtolower(Xstrdup(gamefunctions[j]));
hash_delete(&h_gamefuncs, str);
Bfree(str);
}
while (*textptr != 0x0a && *textptr != 0x0d && *textptr != 0) while (*textptr != 0x0a && *textptr != 0x0d && *textptr != 0)
{ {
@ -5225,11 +5220,6 @@ repeatcase:
} }
gamefunctions[j][i] = '\0'; gamefunctions[j][i] = '\0';
hash_add(&h_gamefuncs,gamefunctions[j],j,0); hash_add(&h_gamefuncs,gamefunctions[j],j,0);
{
char *str = Bstrtolower(Xstrdup(gamefunctions[j]));
hash_add(&h_gamefuncs,str,j,0);
Bfree(str);
}
continue; continue;
@ -5248,12 +5238,7 @@ repeatcase:
continue; continue;
} }
{ hash_delete(&h_gamefuncs, gamefunctions[j]);
hash_delete(&h_gamefuncs, gamefunctions[j]);
char *str = Bstrtolower(Xstrdup(gamefunctions[j]));
hash_delete(&h_gamefuncs, str);
Bfree(str);
}
gamefunctions[j][0] = '\0'; gamefunctions[j][0] = '\0';