Remove W_CheckNumForName

NOW long menuitem patches are supported lol
Staff ghosts support long map names now
The runsoc command and linedef special 415 support longnames now
This commit is contained in:
GenericHeroGuy 2025-06-26 01:22:08 +02:00
parent 146ac557ba
commit 24de618653
16 changed files with 44 additions and 54 deletions

View file

@ -3146,13 +3146,11 @@ void readmaincfg(MYFILE *f)
else
{
lumpnum_t lumpnum;
char newname[9];
char newname[SHORTNAMELEN+1];
strncpy(newname, word2, 8);
strlcpy(newname, word2, sizeof(newname));
newname[8] = '\0';
lumpnum = W_CheckNumForName(newname);
lumpnum = W_CheckNumForLongName(newname);
if (lumpnum == LUMPERROR || W_LumpLength(lumpnum) == 0)
CONS_Debug(DBG_SETUP, "SOC Error: script lump %s not found/not valid.\n", newname);

View file

@ -1616,7 +1616,7 @@ void F_TitleScreenTicker(boolean run)
if (vLump == NULL)
{
if (((W_CheckNumForName(va("%sS%02u", mapheaderinfo[mapnum]->lumpname, numstaff)))) != LUMPERROR)
if (((W_CheckNumForLongName(va("%sS%02u", mapheaderinfo[mapnum]->lumpname, numstaff)))) != LUMPERROR)
sprintf(dname, "%sS%02u", mapheaderinfo[mapnum]->lumpname, numstaff);
else
{

View file

@ -102,7 +102,7 @@ static fixed_t paldiv;
* \return fademask_t for lump
*/
static fademask_t *F_GetFadeMask(UINT8 masknum, UINT8 scrnnum) {
static char lumpname[9] = "FADEmmss";
static char lumpname[SHORTNAMELEN+1] = "FADEmmss";
static fademask_t fm = {NULL,0,0,0,0,0};
lumpnum_t lumpnum;
UINT8 *lump, *mask;
@ -112,16 +112,9 @@ static fademask_t *F_GetFadeMask(UINT8 masknum, UINT8 scrnnum) {
if (masknum > 99 || scrnnum > 99)
goto freemask;
// SRB2Kart: This suddenly triggers ERRORMODE now
//sprintf(&lumpname[4], "%.2hu%.2hu", (UINT16)masknum, (UINT16)scrnnum);
sprintf(&lumpname[4], "%.2hu%.2hu", (UINT16)masknum, (UINT16)scrnnum);
lumpname[4] = '0'+(masknum/10);
lumpname[5] = '0'+(masknum%10);
lumpname[6] = '0'+(scrnnum/10);
lumpname[7] = '0'+(scrnnum%10);
lumpnum = W_CheckNumForName(lumpname);
lumpnum = W_CheckNumForLongName(lumpname);
if (lumpnum == LUMPERROR)
goto freemask;
@ -429,7 +422,7 @@ tic_t F_GetWipeLength(UINT8 wipetype)
(void)wipetype;
return 0;
#else
static char lumpname[10] = "FADEmmss";
static char lumpname[SHORTNAMELEN+1] = "FADEmmss";
lumpnum_t lumpnum;
UINT8 wipeframe;
@ -440,7 +433,7 @@ tic_t F_GetWipeLength(UINT8 wipetype)
{
sprintf(&lumpname[4], "%.2hu%.2hu", (UINT16)wipetype, (UINT16)wipeframe);
lumpnum = W_CheckNumForName(lumpname);
lumpnum = W_CheckNumForLongName(lumpname);
if (lumpnum == LUMPERROR)
return --wipeframe;
}
@ -456,7 +449,7 @@ boolean F_WipeExists(UINT8 wipetype)
(void)wipetype;
return false;
#else
static char lumpname[10] = "FADEmm00";
static char lumpname[SHORTNAMELEN+1] = "FADEmm00";
lumpnum_t lumpnum;
if (wipetype > 99)
@ -464,7 +457,7 @@ boolean F_WipeExists(UINT8 wipetype)
sprintf(&lumpname[4], "%.2hu00", (UINT16)wipetype);
lumpnum = W_CheckNumForName(lumpname);
lumpnum = W_CheckNumForLongName(lumpname);
return !(lumpnum == LUMPERROR);
#endif
}

View file

@ -2868,11 +2868,12 @@ void G_DeferedPlayDemo(const char *name)
#define SKIPERRORS
void G_DoPlayDemo(char *defdemoname)
void G_DoPlayDemo(const char *defdemoname)
{
UINT8 i, p;
lumpnum_t l;
char skin[17],color[MAXCOLORNAME+1],follower[17],mapname[MAXMAPLUMPNAME],*n,*pdemoname;
char skin[17],color[MAXCOLORNAME+1],follower[17],mapname[MAXMAPLUMPNAME],*pdemoname;
const char *n;
UINT8 version,subversion;
UINT32 randseed;
char msg[1024];
@ -2927,7 +2928,7 @@ void G_DoPlayDemo(char *defdemoname)
if (n == defdemoname)
{
// Raw lump.
if ((l = W_CheckNumForName(defdemoname)) == LUMPERROR)
if ((l = W_CheckNumForLongName(defdemoname)) == LUMPERROR)
{
snprintf(msg, 1024, M_GetText("Failed to read lump '%s'.\n"), defdemoname);
CONS_Alert(CONS_ERROR, "%s", msg);
@ -3381,11 +3382,12 @@ void G_DoPlayDemo(char *defdemoname)
demo.deferstart = true;
}
void G_AddGhost(char *defdemoname)
void G_AddGhost(const char *defdemoname)
{
INT32 i;
lumpnum_t l;
char name[17],skin[17],color[MAXCOLORNAME+1],*n,*pdemoname;
char name[17],skin[17],color[MAXCOLORNAME+1],*pdemoname;
const char *n;
UINT64 demohash;
demoghost *gh;
UINT8 flags;
@ -3420,7 +3422,7 @@ void G_AddGhost(char *defdemoname)
p = buffer;
}
// load demo resource from WAD
else if ((l = W_CheckNumForName(defdemoname)) == LUMPERROR)
else if ((l = W_CheckNumForLongName(defdemoname)) == LUMPERROR)
{
CONS_Alert(CONS_ERROR, M_GetText("Failed to read lump '%s'.\n"), defdemoname);
Z_Free(pdemoname);
@ -3799,7 +3801,7 @@ void G_DoPlayMetal(void)
// it's an internal demo
// TODO: Use map header to determine lump name
if ((l = W_CheckNumForName(va("%sMS",G_BuildMapName(gamemap)))) == LUMPERROR)
if ((l = W_CheckNumForLongName(va("%sMS",G_BuildMapName(gamemap)))) == LUMPERROR)
{
CONS_Alert(CONS_WARNING, M_GetText("No bot recording for this map.\n"));
return;

View file

@ -179,9 +179,9 @@ extern demoghost *ghosts;
#define DFILE_ERROR_EXTRAFILES 0x05 // Extra files outside of the replay's file list are loaded.
void G_DeferedPlayDemo(const char *demo);
void G_DoPlayDemo(char *defdemoname);
void G_DoPlayDemo(const char *defdemoname);
void G_TimeDemo(const char *name);
void G_AddGhost(char *defdemoname);
void G_AddGhost(const char *defdemoname);
void G_UpdateStaffGhostName(lumpnum_t l);
void G_FreeGhosts(void);
void G_DoneLevelLoad(void);

View file

@ -6494,7 +6494,7 @@ static lumpnum_t wipelumpnum;
// puts wipe lumpname in wipename[9]
static boolean HWR_WipeCheck(UINT8 wipenum, UINT8 scrnnum)
{
static char lumpname[9] = "FADEmmss";
static char lumpname[SHORTNAMELEN+1] = "FADEmmss";
size_t lsize;
// not a valid wipe number
@ -6506,7 +6506,7 @@ static boolean HWR_WipeCheck(UINT8 wipenum, UINT8 scrnnum)
lumpname[5] = '0'+(wipenum%10);
lumpname[6] = '0'+(scrnnum/10);
lumpname[7] = '0'+(scrnnum%10);
wipelumpnum = W_CheckNumForName(lumpname);
wipelumpnum = W_CheckNumForLongName(lumpname);
// again, shouldn't be here really
if (wipelumpnum == LUMPERROR)

View file

@ -310,7 +310,7 @@ void HU_Init(void)
patch_t *HU_UpdateOrBlankPatch(patch_t **user, boolean required, const char *format, ...)
{
va_list ap;
char buffer[9];
char buffer[SHORTNAMELEN+1];
lumpnum_t lump = LUMPERROR;
patch_t *patch;
@ -326,7 +326,7 @@ patch_t *HU_UpdateOrBlankPatch(patch_t **user, boolean required, const char *for
while ((lump == LUMPERROR) && ((--fileref) >= partadd_earliestfile))
{
lump = W_CheckNumForNamePwad(buffer, fileref, 0);
lump = W_CheckNumForLongNamePwad(buffer, fileref, 0);
}
/* no update in this wad */
@ -339,7 +339,7 @@ patch_t *HU_UpdateOrBlankPatch(patch_t **user, boolean required, const char *for
}
else
{
lump = W_CheckNumForName(buffer);
lump = W_CheckNumForLongName(buffer);
if (lump == LUMPERROR)
{

View file

@ -4285,14 +4285,14 @@ void MD_DrawPlaybackMenu(void)
if (i != itemOn)
inactivemap = R_GetTranslationColormap(players[ply].skin, players[ply].skincolor, GTC_MENUCACHE);
}
else if (currentMenu->menuitems[i].patch && W_CheckNumForName(currentMenu->menuitems[i].patch) != LUMPERROR)
else if (currentMenu->menuitems[i].patch && W_CheckNumForLongName(currentMenu->menuitems[i].patch) != LUMPERROR)
icon = W_CachePatchLongName(currentMenu->menuitems[i].patch, PU_CACHE);
else
icon = W_CachePatchLongName("PLAYRANK", PU_CACHE); // temp
}
else if (currentMenu->menuitems[i].status & IT_HIDDEN)
continue;
else if (currentMenu->menuitems[i].patch && W_CheckNumForName(currentMenu->menuitems[i].patch) != LUMPERROR)
else if (currentMenu->menuitems[i].patch && W_CheckNumForLongName(currentMenu->menuitems[i].patch) != LUMPERROR)
icon = W_CachePatchLongName(currentMenu->menuitems[i].patch, PU_CACHE);
else
icon = W_CachePatchLongName("PLAYRANK", PU_CACHE); // temp
@ -5697,7 +5697,7 @@ INT32 MR_ChooseTimeAttack(INT32 choice)
INT32 MR_ReplayStaff(INT32 choice)
{
(void)choice;
lumpnum_t l = W_CheckNumForName(va("%sS%02u",G_BuildMapName(cv_nextmap.value),cv_dummystaff.value));
lumpnum_t l = W_CheckNumForLongName(va("%sS%02u",G_BuildMapName(cv_nextmap.value),cv_dummystaff.value));
if (l == LUMPERROR)
return false;

View file

@ -8104,13 +8104,11 @@ static void P_RunLevelScript(const char *scriptname)
if (!(mapheaderinfo[gamemap-1]->levelflags & LF_SCRIPTISFILE))
{
lumpnum_t lumpnum;
char newname[9];
char newname[SHORTNAMELEN+1];
strncpy(newname, scriptname, 8);
strlcpy(newname, scriptname, sizeof(newname));
newname[8] = '\0';
lumpnum = W_CheckNumForName(newname);
lumpnum = W_CheckNumForLongName(newname);
if (lumpnum == LUMPERROR || W_LumpLength(lumpnum) == 0)
{
@ -9017,7 +9015,7 @@ boolean P_RunSOC(const char *socfilename)
if (strstr(socfilename, ".soc") != NULL)
return P_AddWadFile(socfilename, WC_AUTO);
lump = W_CheckNumForName(socfilename);
lump = W_CheckNumForLongName(socfilename);
if (lump == LUMPERROR)
return false;

View file

@ -2975,7 +2975,7 @@ boolean P_ProcessSpecial(activator_t *activator, INT16 special, INT32 *args, cha
case 415: // Run a script
if (cv_runscripts.value)
{
lumpnum_t lumpnum = W_CheckNumForName(stringargs[0]);
lumpnum_t lumpnum = W_CheckNumForLongName(stringargs[0]);
if (lumpnum == LUMPERROR || W_LumpLength(lumpnum) == 0)
CONS_Debug(DBG_SETUP, "Line type 415 Executor: script lump %s not found/not valid.\n", stringargs[0]);

View file

@ -110,9 +110,9 @@ static void Sk_SetDefaultValue(skin_t *skin)
skin->flags = 0;
strcpy(skin->realname, "Someone");
strncpy(skin->facerank, "MISSING", 9);
strncpy(skin->facewant, "MISSING", 9);
strncpy(skin->facemmap, "MISSING", 9);
strcpy(skin->facerank, "MISSING");
strcpy(skin->facewant, "MISSING");
strcpy(skin->facemmap, "MISSING");
skin->starttranscolor = 96;
skin->prefcolor = SKINCOLOR_GREEN;
skin->supercolor = SKINCOLOR_SUPER1;
@ -586,7 +586,7 @@ static boolean R_ProcessPatchableFields(skin_t *skin, char *stoken, char *value)
GETFLAG(OLDDEATH)
#undef GETFLAG
#define GETPATCH(field) else if (compat && !stricmp(stoken, #field)) strncpy(skin->field, value, 8);
#define GETPATCH(field) else if (compat && !stricmp(stoken, #field)) strlcpy(skin->field, value, sizeof(skin->field));
GETPATCH(facerank)
GETPATCH(facewant)
GETPATCH(facemmap)

View file

@ -42,7 +42,7 @@ struct skin_t
skinflags_t flags;
char realname[SKINNAMESIZE+1]; // Display name for level completion.
char facerank[9], facewant[9], facemmap[9]; // Arbitrarily named patch lumps
char facerank[SHORTNAMELEN+1], facewant[SHORTNAMELEN+1], facemmap[SHORTNAMELEN+1]; // Arbitrarily named patch lumps
// SRB2kart
UINT8 kartspeed;

View file

@ -271,7 +271,7 @@ void R_AddKartFaces(skin_t *skin)
spritedef_t *sd = &skin->sprites[SPR2_XTRA];
for (size_t f = 0; f < NUMFACES; f++)
{
lumpnum_t lumpnum = W_CheckNumForName(reinterpret_cast<char *>(skin) + KART_FACES[f]); // how do you do, fellow C++ers?
lumpnum_t lumpnum = W_CheckNumForLongName(reinterpret_cast<char *>(skin) + KART_FACES[f]); // how do you do, fellow C++ers?
if (lumpnum == LUMPERROR)
I_Error("R_AddKartFaces: missing patch %s for skin %s", reinterpret_cast<char *>(skin) + KART_FACES[f], skin->name);
R_InstallSpriteLump(WADFILENUM(lumpnum), LUMPNUM(lumpnum), numspritelumps, f, 0, 0);

View file

@ -1844,7 +1844,7 @@ boolean S_MusicInfo(char *mname, UINT16 *mflags, boolean *looping)
boolean S_MusicExists(const char *mname)
{
return W_CheckNumForName(va("O_%s", mname)) != LUMPERROR;
return W_CheckNumForLongName(va("O_%s", mname)) != LUMPERROR;
}
/// ------------------------

View file

@ -1537,7 +1537,7 @@ static void I_CleanupGME(void *userdata)
static boolean I_StartGMESong(const char *musicname, boolean looping)
{
char filename[9];
char filename[SHORTNAMELEN+1];
void *data;
lumpnum_t lumpnum;
size_t lumplength;
@ -1552,7 +1552,7 @@ static boolean I_StartGMESong(const char *musicname, boolean looping)
snprintf(filename, sizeof filename, "o_%s", musicname);
lumpnum = W_CheckNumForName(filename);
lumpnum = W_CheckNumForLongName(filename);
if (lumpnum == LUMPERROR)
{

View file

@ -154,7 +154,6 @@ UINT16 W_CheckNumForFolderStartPK3(const char *name, UINT16 wad, UINT16 startlum
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);
lumpnum_t W_GetNumForLongName(const char *name);
lumpnum_t W_CheckNumForNameInFolder(const char *lump, const char *folder);