Fix music names longer than 6 chars not being truncated anymore

This commit is contained in:
GenericHeroGuy 2025-06-27 23:33:59 +02:00
parent 92c59ddbcb
commit 76daf2f0e0
3 changed files with 25 additions and 9 deletions

View file

@ -1842,9 +1842,16 @@ boolean S_MusicInfo(char *mname, UINT16 *mflags, boolean *looping)
return (boolean)mname[0];
}
static lumpnum_t S_GetMusicLumpNum(const char *mname)
{
char *n = va("O_%s", mname);
strupr(n); // yep, you can do that
return W_CheckNumForNamePrefix(n, 8);
}
boolean S_MusicExists(const char *mname)
{
return W_CheckNumForLongName(va("O_%s", mname)) != LUMPERROR;
return S_GetMusicLumpNum(mname) != LUMPERROR;
}
/// ------------------------
@ -2178,14 +2185,6 @@ boolean S_RecallMusic(UINT16 status, boolean fromfirst)
/// Music Playback
/// ------------------------
static lumpnum_t S_GetMusicLumpNum(const char *mname)
{
if (S_MusicExists(mname))
return W_GetNumForLongName(va("O_%s", mname));
else
return LUMPERROR;
}
static boolean S_LoadMusic(const char *mname)
{
lumpnum_t mlumpnum;

View file

@ -1198,6 +1198,7 @@ UINT16 W_CheckNumForLongNamePwad(const char *name, UINT16 wad, UINT16 startlump)
}
// same as W_CheckNumForNamePwad, but only checks for a name PREFIX
// this does NOT uppercase the search string, do it yourself!
UINT16 W_CheckNumForNamePrefixPwad(const char *name, size_t namelen, UINT16 wad, UINT16 startlump)
{
UINT16 i;
@ -1411,6 +1412,21 @@ lumpnum_t W_CheckNumForMap(const char *name)
return (i << 16) + check;
}
// again, no uppercasing. see pwad version
lumpnum_t W_CheckNumForNamePrefix(const char *name, size_t namelen)
{
INT32 i;
UINT16 check;
for (i = numwadfiles - 1; i >= 0; i--)
{
check = W_CheckNumForNamePrefixPwad(name, namelen, i, 0);
if (check != LUMPERROR)
return (i << 16) + check;
}
return LUMPERROR;
}
//
// W_GetNumForLongName
//

View file

@ -133,6 +133,7 @@ UINT16 W_CheckNumForFullNamePK3(const char *name, UINT16 wad, UINT16 startlump);
lumpnum_t W_CheckNumForMap(const char *name);
lumpnum_t W_CheckNumForLongName(const char *name);
lumpnum_t W_CheckNumForNamePrefix(const char *name, size_t namelen);
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.