foxygit / doom Log in
commit c247ce4a3c8c35ad6e41fab67cb38c6e53689030
Author:     Fabian Greffrath <fabian@greffrath.com>
AuthorDate: Fri Jan 25 08:31:05 2019 +0100
Commit:     Fabian Greffrath <fabian@greffrath.com>
CommitDate: Fri Jan 25 08:31:05 2019 +0100

    factor out some lumpinfo query into separate functions
---
 src/doom/m_menu.c | 4 ++--
 src/w_wad.c       | 9 +++++++++
 src/w_wad.h       | 3 +++
 3 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/src/doom/m_menu.c b/src/doom/m_menu.c
index 8587e027..ee9e6719 100644
--- a/src/doom/m_menu.c
+++ b/src/doom/m_menu.c
@@ -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]);
diff --git a/src/w_wad.c b/src/w_wad.c
index a9ba74b0..ebf89677 100644
--- a/src/w_wad.c
+++ b/src/w_wad.c
@@ -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;
+}
diff --git a/src/w_wad.h b/src/w_wad.h
index 2f4ab129..ae5977a2 100644
--- a/src/w_wad.h
+++ b/src/w_wad.h
@@ -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