diff --git a/src/deh_tables.c b/src/deh_tables.c index 9d8cd1641..9bcf7aacb 100644 --- a/src/deh_tables.c +++ b/src/deh_tables.c @@ -62,7 +62,10 @@ const char *DEH_MenutypeName(menutype_t i) mobjtype_t DEH_FindMobjtype(const char *word) { mobjtype_t i; + UINT32 hash = HASH32(word, strlen(word)); for (i = 0; i < nummobjtypes; i++) { + if (hash != mobjinfo[i].namehash) + continue; if (fastcmp(word, DEH_MobjtypeName(i))) return i; } @@ -72,7 +75,10 @@ mobjtype_t DEH_FindMobjtype(const char *word) statenum_t DEH_FindState(const char *word) { statenum_t i; + UINT32 hash = HASH32(word, strlen(word)); for (i = 0; i < numstates; i++) { + if (hash != states[i].namehash) + continue; if (fastcmp(word, DEH_StateName(i))) return i; } @@ -82,7 +88,10 @@ statenum_t DEH_FindState(const char *word) skincolornum_t DEH_FindSkincolor(const char *word) { skincolornum_t i; + UINT32 hash = HASH32(word, strlen(word)); for (i = 0; i < numskincolors; i++) { + if (hash != skincolors[i].namehash) + continue; if (fastcmp(word, DEH_SkincolorName(i))) return i; } @@ -92,7 +101,10 @@ skincolornum_t DEH_FindSkincolor(const char *word) menutype_t DEH_FindMenutype(const char *word) { menutype_t i; + UINT32 hash = HASH32(word, strlen(word)); for (i = 0; i < nummenutypes; i++) { + if (hash != menudefs[i].namehash) + continue; if (fastcmp(word, DEH_MenutypeName(i))) return i; } diff --git a/src/dehacked.c b/src/dehacked.c index bc8bf9d2c..e98bd5e0e 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -218,6 +218,7 @@ INT32 DEH_ReadFreeslot(const char *type, const char *word, INT32 *out) if (!states[i].nameofs) { CONS_Printf("State S_%s allocated.\n",word); states[i].nameofs = strbuf_append(&statenames, word); + states[i].namehash = HASH32(word, strlen(word)); numstates++; freeslotusage[0][0]++; *out = i; @@ -232,6 +233,7 @@ INT32 DEH_ReadFreeslot(const char *type, const char *word, INT32 *out) if (!mobjinfo[i].nameofs) { CONS_Printf("MobjType MT_%s allocated.\n",word); mobjinfo[i].nameofs = strbuf_append(&mobjnames, word); + mobjinfo[i].namehash = HASH32(word, strlen(word)); nummobjtypes++; freeslotusage[1][0]++; *out = i; @@ -246,6 +248,7 @@ INT32 DEH_ReadFreeslot(const char *type, const char *word, INT32 *out) if (!skincolors[i].nameofs) { CONS_Printf("Skincolor SKINCOLOR_%s allocated.\n",word); skincolors[i].nameofs = strbuf_append(&skincolornames, word); + skincolors[i].namehash = HASH32(word, strlen(word)); M_AddMenuColor(numskincolors++); K_ReloadHUDColorCvar(); *out = i; @@ -326,6 +329,7 @@ INT32 DEH_ReadFreeslot(const char *type, const char *word, INT32 *out) if (!menudefs[i].nameofs) { CONS_Printf("Menu MN_%s allocated.\n",word); menudefs[i].nameofs = strbuf_append(&menunames, word); + menudefs[i].namehash = HASH32(word, strlen(word)); nummenutypes++; *out = i; return 0; diff --git a/src/doomdef.h b/src/doomdef.h index 497b5cfa3..5622a0021 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -222,6 +222,7 @@ extern char logfilename[1024]; struct skincolor_t { + UINT32 namehash; // Hash for internal name UINT32 nameofs; // Offset for internal name char name[MAXCOLORNAME+1]; // Skincolor name UINT8 ramp[COLORRAMPSIZE]; // Colormap ramp diff --git a/src/info.c b/src/info.c index bc0774fc4..7ad593a1c 100644 --- a/src/info.c +++ b/src/info.c @@ -153,8 +153,10 @@ void P_ResetData(INT32 flags) Z_Free(statenames); statenames = strbuf_alloc(); name = hardcodestates; - for (i = 0; i < S_FIRSTFREESLOT; i++, name += strlen(name)+1) + for (i = 0; i < S_FIRSTFREESLOT; i++, name += strlen(name)+1) { states[i].nameofs = strbuf_append(&statenames, name); + states[i].namehash = HASH32(name, strlen(name)); + } if (!init) { @@ -175,8 +177,10 @@ void P_ResetData(INT32 flags) Z_Free(mobjnames); mobjnames = strbuf_alloc(); name = hardcodemobjs; - for (i = 0; i < MT_FIRSTFREESLOT; i++, name += strlen(name)+1) + for (i = 0; i < MT_FIRSTFREESLOT; i++, name += strlen(name)+1) { mobjinfo[i].nameofs = strbuf_append(&mobjnames, name); + mobjinfo[i].namehash = HASH32(name, strlen(name)); + } for (i = MT_FIRSTFREESLOT; i <= MT_LASTFREESLOT; i++) mobjinfo[i].doomednum = -1; @@ -198,8 +202,10 @@ void P_ResetData(INT32 flags) Z_Free(skincolornames); skincolornames = strbuf_alloc(); name = hardcodeskincolors; - for (i = 0; i < SKINCOLOR_FIRSTFREESLOT; i++, name += strlen(name)+1) + for (i = 0; i < SKINCOLOR_FIRSTFREESLOT; i++, name += strlen(name)+1) { skincolors[i].nameofs = strbuf_append(&skincolornames, name); + skincolors[i].namehash = HASH32(name, strlen(name)); + } for (i = SKINCOLOR_FIRSTFREESLOT; i <= SKINCOLOR_LASTFREESLOT; i++) { @@ -227,7 +233,9 @@ void P_ResetData(INT32 flags) Z_Free(menunames); menunames = strbuf_alloc(); name = hardcodemenus; - for (i = 0; i < MN_FIRSTFREESLOT; i++, name += strlen(name)+1) + for (i = 0; i < MN_FIRSTFREESLOT; i++, name += strlen(name)+1) { menudefs[i].nameofs = strbuf_append(&menunames, name); + menudefs[i].namehash = HASH32(name, strlen(name)); + } } } diff --git a/src/info.h b/src/info.h index 45c6785d1..e6a716483 100644 --- a/src/info.h +++ b/src/info.h @@ -79,7 +79,7 @@ typedef enum state struct state_t { - UINT32 nameofs; + UINT32 namehash, nameofs; spritenum_t sprite; UINT32 frame; // we use the upper 16 bits for translucency and other shade effects @@ -110,7 +110,7 @@ typedef enum mobj_type struct mobjinfo_t { - UINT32 nameofs; + UINT32 namehash, nameofs; INT32 doomednum; statenum_t spawnstate; diff --git a/src/m_menu.h b/src/m_menu.h index 0d0024373..01de92f5d 100644 --- a/src/m_menu.h +++ b/src/m_menu.h @@ -247,7 +247,7 @@ struct menuitem_t struct menu_t { - UINT32 nameofs; + UINT32 namehash, nameofs; const char *headerpic; INT16 numitems; // # of menu items menuitem_t *menuitems; // menu items