diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 6294508d6..753510f4b 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -6658,23 +6658,19 @@ skip_lump: if (PK3) { - shader_lumpname = Z_Malloc(strlen(value) + 12, PU_STATIC, NULL); - strcpy(shader_lumpname, "Shaders/sh_"); - strcat(shader_lumpname, value); + shader_lumpname = xva("Shaders/sh_%s", value); shader_lumpnum = W_CheckNumForFullNamePK3(shader_lumpname, wadnum, 0); } else { - shader_lumpname = Z_Malloc(strlen(value) + 4, PU_STATIC, NULL); - strcpy(shader_lumpname, "SH_"); - strcat(shader_lumpname, value); - shader_lumpnum = W_CheckNumForNamePwad(shader_lumpname, wadnum, 0); + shader_lumpname = xva("SH_%.5s", value); + shader_lumpnum = W_CheckNumForLongNamePwad(shader_lumpname, wadnum, 0); } if (shader_lumpnum == LUMPERROR) { CONS_Alert(CONS_ERROR, "HWR_LoadCustomShadersFromFile: Missing shader source %s (file %s, line %d)\n", shader_lumpname, wadfiles[wadnum]->filename, linenum); - Z_Free(shader_lumpname); + free(shader_lumpname); continue; } @@ -6685,7 +6681,7 @@ skip_lump: HWD.pfnLoadCustomShader(shaderxlat[i].id, shader_source, shader_size, (shadertype == 2)); Z_Free(shader_source); - Z_Free(shader_lumpname); + free(shader_lumpname); } } diff --git a/src/w_wad.h b/src/w_wad.h index 53d6a90de..8f7491c16 100644 --- a/src/w_wad.h +++ b/src/w_wad.h @@ -133,18 +133,7 @@ const char *W_CheckFullNameForNum(lumpnum_t lumpnum); UINT16 W_FindNextEmptyInPwad(UINT16 wad, UINT16 startlump); // checks only in one pwad -// helper for old functions that use 8-char names -// careful, you might be dealing with a non-terminated string! -static inline const char *W_ShortName(const char *name) -{ - static char shortname[8+1]; - strncpy(shortname, name, 8); - shortname[8] = '\0'; - return shortname; -} - UINT16 W_CheckNumForMapPwad(const char *name, UINT32 hash, UINT16 wad, UINT16 startlump); -#define W_CheckNumForNamePwad(name, wad, start) W_CheckNumForLongNamePwad(W_ShortName(name), wad, start) UINT16 W_CheckNumForLongNamePwad(const char *name, UINT16 wad, UINT16 startlump); UINT16 W_CheckNumForNamePrefixPwad(const char *name, size_t namelen, UINT16 wad, UINT16 startlump); UINT16 W_CheckNumForNameMultiPrefixPwad(const lumpprefixes_t *prefixes, size_t numprefixes, UINT16 wad, UINT16 startlump);