factor out some lumpinfo query into separate functions

This commit is contained in:
Fabian Greffrath 2019-01-25 08:31:05 +01:00
parent fff2e0e058
commit c247ce4a3c
3 changed files with 14 additions and 2 deletions

View file

@ -636,7 +636,7 @@ void M_DoSave(int slot)
static void SetDefaultSaveName(int slot)
{
// map from IWAD or PWAD?
if (maplumpinfo->wad_file == lumpinfo[0]->wad_file)
if (W_IsIWADLump(maplumpinfo))
{
M_snprintf(savegamestrings[itemOn], SAVESTRINGSIZE,
"%s", maplumpinfo->name);
@ -644,7 +644,7 @@ static void SetDefaultSaveName(int slot)
else
{
M_snprintf(savegamestrings[itemOn], SAVESTRINGSIZE,
"%s: %s", M_BaseName(maplumpinfo->wad_file->path),
"%s: %s", W_WadNameForLump(maplumpinfo),
maplumpinfo->name);
}
M_ForceUppercase(savegamestrings[itemOn]);

View file

@ -618,3 +618,12 @@ void W_Reload(void)
W_GenerateHashTable();
}
const char *W_WadNameForLump(const lumpinfo_t *lump)
{
return M_BaseName(lump->wad_file->path);
}
boolean W_IsIWADLump(const lumpinfo_t *lump)
{
return lump->wad_file == lumpinfo[0]->wad_file;
}

View file

@ -72,4 +72,7 @@ extern unsigned int W_LumpNameHash(const char *s);
void W_ReleaseLumpNum(lumpindex_t lump);
void W_ReleaseLumpName(const char *name);
const char *W_WadNameForLump(const lumpinfo_t *lump);
boolean W_IsIWADLump(const lumpinfo_t *lump);
#endif