ref: 7f7a72d67a97c2a4419cdb0a0673c4c99a639553
parent: 1e606b8a6179da1e3071a3fd20cd4938049bdee8
parent: c247ce4a3c8c35ad6e41fab67cb38c6e53689030
author: Fabian Greffrath <[email protected]>
date: Fri Jan 25 03:31:46 EST 2019
Merge pull request #1130 from chocolate-doom/defaultsavename default save name is map name and containing WAD file name
--- a/src/doom/m_menu.c
+++ b/src/doom/m_menu.c
@@ -49,6 +49,7 @@
#include "m_argv.h"
#include "m_controls.h"
#include "p_saveg.h"
+#include "p_setup.h"
#include "s_sound.h"
@@ -634,8 +635,19 @@
//
static void SetDefaultSaveName(int slot)
{
- M_snprintf(savegamestrings[itemOn], SAVESTRINGSIZE - 1,
- "JOYSTICK SLOT %i", itemOn + 1);
+ // map from IWAD or PWAD?
+ if (W_IsIWADLump(maplumpinfo))
+ {
+ M_snprintf(savegamestrings[itemOn], SAVESTRINGSIZE,
+ "%s", maplumpinfo->name);
+ }
+ else
+ {
+ M_snprintf(savegamestrings[itemOn], SAVESTRINGSIZE,
+ "%s: %s", W_WadNameForLump(maplumpinfo),
+ maplumpinfo->name);
+ }
+ M_ForceUppercase(savegamestrings[itemOn]);
joypadSave = false;
}
--- a/src/doom/p_setup.c
+++ b/src/doom/p_setup.c
@@ -760,6 +760,9 @@
}
}
+// pointer to the current map lump info struct
+lumpinfo_t *maplumpinfo;
+
//
// P_SetupLevel
//
@@ -816,6 +819,8 @@
lumpnum = W_GetNumForName (lumpname);
+ maplumpinfo = lumpinfo[lumpnum];
+
leveltime = 0;
// note: most of this ordering is important
--- a/src/doom/p_setup.h
+++ b/src/doom/p_setup.h
@@ -20,8 +20,10 @@
#ifndef __P_SETUP__
#define __P_SETUP__
+#include "w_wad.h"
+extern lumpinfo_t *maplumpinfo;
// NOT called by W_Ticker. Fixme.
void
--- a/src/w_wad.c
+++ b/src/w_wad.c
@@ -618,3 +618,12 @@
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;
+}
--- a/src/w_wad.h
+++ b/src/w_wad.h
@@ -72,4 +72,7 @@
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