diff --git a/src/console.c b/src/console.c index 855386b5c..91da5f27d 100644 --- a/src/console.c +++ b/src/console.c @@ -299,7 +299,7 @@ void CON_SetupBackColormapEx(INT32 color, boolean prompt) { UINT16 i, palsum; UINT8 j, palindex; - lumpnum_t lump = W_GetNumForName(GetPalette()); + lumpnum_t lump = W_GetNumForLongName(GetPalette()); UINT8 *pal = W_CacheLumpNum(lump, PU_CACHE); INT32 shift = 6; diff --git a/src/r_textures.c b/src/r_textures.c index ec68362a5..1c9f13759 100644 --- a/src/r_textures.c +++ b/src/r_textures.c @@ -1493,7 +1493,7 @@ static texpatch_t *R_ParsePatch(boolean actuallyLoadPatch) char *texturesToken; size_t texturesTokenLength; char *endPos; - char *patchName = NULL; + char patchName[SHORTNAMELEN+1]; INT16 patchXPos; INT16 patchYPos; UINT8 flip = 0; @@ -1509,19 +1509,13 @@ static texpatch_t *R_ParsePatch(boolean actuallyLoadPatch) I_Error("Error parsing TEXTURES lump: Unexpected end of file where patch name should be"); } texturesTokenLength = strlen(texturesToken); - if (texturesTokenLength>8) + if (texturesTokenLength >= sizeof(patchName)) { - I_Error("Error parsing TEXTURES lump: Patch name \"%s\" exceeds 8 characters",texturesToken); + I_Error("Error parsing TEXTURES lump: Patch name \"%s\" exceeds %zu characters", texturesToken, sizeof(patchName) - 1); } else { - if (patchName != NULL) - { - Z_Free(patchName); - } - patchName = (char *)Z_Malloc((texturesTokenLength+1)*sizeof(char),PU_STATIC,NULL); - M_Memcpy(patchName,texturesToken,texturesTokenLength*sizeof(char)); - patchName[texturesTokenLength] = '\0'; + strcpy(patchName, texturesToken); } // Comma 1 @@ -1660,7 +1654,7 @@ static texpatch_t *R_ParsePatch(boolean actuallyLoadPatch) if (actuallyLoadPatch == true) { // Check lump exists - patchLumpNum = W_GetNumForName(patchName); + patchLumpNum = W_GetNumForLongName(patchName); // If so, allocate memory for texpatch_t and fill 'er up resultPatch = (texpatch_t *)Z_Malloc(sizeof(texpatch_t),PU_STATIC,NULL); resultPatch->originx = patchXPos; @@ -1670,14 +1664,11 @@ static texpatch_t *R_ParsePatch(boolean actuallyLoadPatch) resultPatch->flip = flip; resultPatch->alpha = alpha; resultPatch->style = style; - // Clean up a little after ourselves - Z_Free(patchName); // Then return it return resultPatch; } else { - Z_Free(patchName); return NULL; } } diff --git a/src/s_sound.c b/src/s_sound.c index f4f5079e1..d615cbc28 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -313,22 +313,17 @@ static void SetChannelsNum(void) // lumpnum_t S_GetSfxLumpNum(sfxinfo_t *sfx) { - char namebuf[9]; lumpnum_t sfxlump; - sprintf(namebuf, "ds%s", sfx->name); - - sfxlump = W_CheckNumForName(namebuf); + sfxlump = W_CheckNumForLongName(va("DS%s", sfx->name)); if (sfxlump != LUMPERROR) return sfxlump; - strlcpy(namebuf, sfx->name, sizeof namebuf); - - sfxlump = W_CheckNumForName(namebuf); + sfxlump = W_CheckNumForLongName(sfx->name); if (sfxlump != LUMPERROR) return sfxlump; - return W_GetNumForName("dsthok"); + return W_GetNumForLongName("DSTHOK"); } // @@ -2186,7 +2181,7 @@ boolean S_RecallMusic(UINT16 status, boolean fromfirst) static lumpnum_t S_GetMusicLumpNum(const char *mname) { if (S_MusicExists(mname)) - return W_GetNumForName(va("o_%s", mname)); + return W_GetNumForLongName(va("O_%s", mname)); else return LUMPERROR; } diff --git a/src/v_video.c b/src/v_video.c index 36a4df30a..5cad2c959 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -313,7 +313,7 @@ UINT32 V_GammaCorrect(UINT32 input, double power) // keep a copy of the palette so that we can get the RGB value for a color index at any time. static void LoadPalette(const char *lumpname) { - lumpnum_t lumpnum = W_GetNumForName(lumpname); + lumpnum_t lumpnum = W_GetNumForLongName(lumpname); size_t i, palsize = W_LumpLength(lumpnum)/3; UINT8 *pal; @@ -408,22 +408,15 @@ void V_CubeApply(UINT8 *red, UINT8 *green, UINT8 *blue) *blue = (UINT8)(working[0][2]); } -const char *R_GetPalname(UINT16 num) -{ - static char palname[9]; - char newpal[9] = "PLAYPAL"; - - if (num > 0 && num <= 10000) - snprintf(newpal, 8, "PAL%04u", num-1); - - strncpy(palname, newpal, 8); - return palname; -} - const char *GetPalette(void) { - if (gamestate == GS_LEVEL) - return R_GetPalname((encoremode ? mapheaderinfo[gamemap-1]->encorepal : mapheaderinfo[gamemap-1]->palette)); + UINT16 num = encoremode ? mapheaderinfo[gamemap-1]->encorepal : mapheaderinfo[gamemap-1]->palette; + if (gamestate == GS_LEVEL && num > 0 && num <= 10000) + { + static char palname[SHORTNAMELEN+1]; + sprintf(palname, "PAL%04u", num-1); + return palname; + } return "PLAYPAL"; } @@ -1667,7 +1660,7 @@ void V_DrawCustomFadeScreen(const char *lump, UINT8 strength) lighttable_t *clm = NULL; if (lump != NULL) - lumpnum = W_GetNumForName(lump); + lumpnum = W_GetNumForLongName(lump); else return; diff --git a/src/v_video.h b/src/v_video.h index 1a17cd84c..5b82d3814 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -68,7 +68,6 @@ void V_SetPalette(INT32 palettenum); void V_SetPaletteLump(const char *pal); -const char *R_GetPalname(UINT16 num); const char *GetPalette(void); extern RGBA_t *pLocalPalette; diff --git a/src/w_wad.h b/src/w_wad.h index cdac87884..d87be6605 100644 --- a/src/w_wad.h +++ b/src/w_wad.h @@ -156,7 +156,6 @@ UINT16 W_CheckNumForFolderEndPK3(const char *name, UINT16 wad, UINT16 startlump) lumpnum_t W_CheckNumForMap(const char *name); #define W_CheckNumForName(name) W_CheckNumForLongName(W_ShortName(name)) lumpnum_t W_CheckNumForLongName(const char *name); -#define W_GetNumForName(name) W_GetNumForLongName(W_ShortName(name)) lumpnum_t W_GetNumForLongName(const char *name); lumpnum_t W_CheckNumForNameInFolder(const char *lump, const char *folder); UINT8 W_LumpExists(const char *name); // Lua uses this.