mirror of
https://github.com/fabiangreffrath/woof.git
synced 2025-09-27 06:54:23 -04:00
generate a default save slot name when the user saves to an empty slot
This commit is contained in:
parent
16fc9af24d
commit
222f202110
@ -51,6 +51,8 @@
|
|||||||
#include "d_deh.h"
|
#include "d_deh.h"
|
||||||
#include "m_misc.h"
|
#include "m_misc.h"
|
||||||
#include "m_misc2.h" // [FG] M_StringDuplicate()
|
#include "m_misc2.h" // [FG] M_StringDuplicate()
|
||||||
|
#include "p_setup.h" // [FG] maplumpnum
|
||||||
|
#include "w_wad.h" // [FG] W_IsIWADLump() / W_WadNameForLump()
|
||||||
|
|
||||||
extern patch_t* hu_font[HU_FONTSIZE];
|
extern patch_t* hu_font[HU_FONTSIZE];
|
||||||
extern boolean message_dontfuckwithme;
|
extern boolean message_dontfuckwithme;
|
||||||
@ -919,6 +921,56 @@ void M_DoSave(int slot)
|
|||||||
quickSaveSlot = slot;
|
quickSaveSlot = slot;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// [FG] generate a default save slot name when the user saves to an empty slot
|
||||||
|
static void SetDefaultSaveName (int slot)
|
||||||
|
{
|
||||||
|
// map from IWAD or PWAD?
|
||||||
|
if (W_IsIWADLump(maplumpnum))
|
||||||
|
{
|
||||||
|
snprintf(savegamestrings[itemOn], SAVESTRINGSIZE,
|
||||||
|
"%s", lumpinfo[maplumpnum].name);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
char *wadname = M_StringDuplicate(W_WadNameForLump(maplumpnum));
|
||||||
|
char *ext = strrchr(wadname, '.');
|
||||||
|
|
||||||
|
if (ext != NULL)
|
||||||
|
{
|
||||||
|
*ext = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
snprintf(savegamestrings[itemOn], SAVESTRINGSIZE,
|
||||||
|
"%s (%s)", lumpinfo[maplumpnum].name,
|
||||||
|
wadname);
|
||||||
|
(free)(wadname);
|
||||||
|
}
|
||||||
|
|
||||||
|
M_ForceUppercase(savegamestrings[itemOn]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// [FG] override savegame name if it already starts with a map identifier
|
||||||
|
static boolean StartsWithMapIdentifier (char *str)
|
||||||
|
{
|
||||||
|
M_ForceUppercase(str);
|
||||||
|
|
||||||
|
if (strlen(str) >= 4 &&
|
||||||
|
str[0] == 'E' && isdigit(str[1]) &&
|
||||||
|
str[2] == 'M' && isdigit(str[3]))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strlen(str) >= 5 &&
|
||||||
|
str[0] == 'M' && str[1] == 'A' && str[2] == 'P' &&
|
||||||
|
isdigit(str[3]) && isdigit(str[4]))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// User wants to save. Start string input for M_Responder
|
// User wants to save. Start string input for M_Responder
|
||||||
//
|
//
|
||||||
@ -929,8 +981,13 @@ void M_SaveSelect(int choice)
|
|||||||
|
|
||||||
saveSlot = choice;
|
saveSlot = choice;
|
||||||
strcpy(saveOldString,savegamestrings[choice]);
|
strcpy(saveOldString,savegamestrings[choice]);
|
||||||
if (!strcmp(savegamestrings[choice],s_EMPTYSTRING)) // Ty 03/27/98 - externalized
|
// [FG] override savegame name if it already starts with a map identifier
|
||||||
|
if (!strcmp(savegamestrings[choice],s_EMPTYSTRING) || // Ty 03/27/98 - externalized
|
||||||
|
StartsWithMapIdentifier(savegamestrings[choice]))
|
||||||
|
{
|
||||||
savegamestrings[choice][0] = 0;
|
savegamestrings[choice][0] = 0;
|
||||||
|
SetDefaultSaveName(choice);
|
||||||
|
}
|
||||||
saveCharIndex = strlen(savegamestrings[choice]);
|
saveCharIndex = strlen(savegamestrings[choice]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1024,6 +1024,9 @@ static void P_LoadReject(int lumpnum)
|
|||||||
//
|
//
|
||||||
// killough 5/3/98: reformatted, cleaned up
|
// killough 5/3/98: reformatted, cleaned up
|
||||||
|
|
||||||
|
// [FG] current map lump number
|
||||||
|
int maplumpnum = -1;
|
||||||
|
|
||||||
void P_SetupLevel(int episode, int map, int playermask, skill_t skill)
|
void P_SetupLevel(int episode, int map, int playermask, skill_t skill)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@ -1139,6 +1142,9 @@ void P_SetupLevel(int episode, int map, int playermask, skill_t skill)
|
|||||||
// preload graphics
|
// preload graphics
|
||||||
if (precache)
|
if (precache)
|
||||||
R_PrecacheLevel();
|
R_PrecacheLevel();
|
||||||
|
|
||||||
|
// [FG] current map lump number
|
||||||
|
maplumpnum = lumpnum;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -45,6 +45,8 @@ extern int bmapheight; // in mapblocks
|
|||||||
extern fixed_t bmaporgx;
|
extern fixed_t bmaporgx;
|
||||||
extern fixed_t bmaporgy; // origin of block map
|
extern fixed_t bmaporgy; // origin of block map
|
||||||
extern mobj_t **blocklinks; // for thing chains
|
extern mobj_t **blocklinks; // for thing chains
|
||||||
|
// [FG] current map lump number
|
||||||
|
extern int maplumpnum;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -32,6 +32,8 @@
|
|||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
#include "w_wad.h"
|
#include "w_wad.h"
|
||||||
|
#include "m_misc2.h" // [FG] M_BaseName()
|
||||||
|
#include "d_main.h" // [FG] wadfiles
|
||||||
|
|
||||||
//
|
//
|
||||||
// GLOBALS
|
// GLOBALS
|
||||||
@ -213,6 +215,8 @@ static void W_AddFile(const char *name) // killough 1/31/98: static, const
|
|||||||
lump_p->data = NULL; // killough 1/31/98
|
lump_p->data = NULL; // killough 1/31/98
|
||||||
lump_p->namespace = ns_global; // killough 4/17/98
|
lump_p->namespace = ns_global; // killough 4/17/98
|
||||||
strncpy (lump_p->name, fileinfo->name, 8);
|
strncpy (lump_p->name, fileinfo->name, 8);
|
||||||
|
// [FG] WAD file that contains the lump
|
||||||
|
lump_p->wad_file = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
free(fileinfo2free); // killough
|
free(fileinfo2free); // killough
|
||||||
@ -560,6 +564,21 @@ void WritePredefinedLumpWad(const char *filename)
|
|||||||
I_Error("Cannot open predefined lumps wad %s for output\n", filename);
|
I_Error("Cannot open predefined lumps wad %s for output\n", filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// [FG] name of the WAD file that contains the lump
|
||||||
|
const char *W_WadNameForLump (const int lump)
|
||||||
|
{
|
||||||
|
return (lump >= 0 && lump < numlumps) ?
|
||||||
|
(lumpinfo[lump].wad_file ?
|
||||||
|
M_BaseName(lumpinfo[lump].wad_file) :
|
||||||
|
"predefined") : "invalid";
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean W_IsIWADLump (const int lump)
|
||||||
|
{
|
||||||
|
return lump >= 0 && lump < numlumps &&
|
||||||
|
lumpinfo[lump].wad_file == wadfiles[0];
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// $Log: w_wad.c,v $
|
// $Log: w_wad.c,v $
|
||||||
|
@ -74,6 +74,9 @@ typedef struct
|
|||||||
|
|
||||||
int handle;
|
int handle;
|
||||||
int position;
|
int position;
|
||||||
|
|
||||||
|
// [FG] WAD file that contains the lump
|
||||||
|
const char *wad_file;
|
||||||
} lumpinfo_t;
|
} lumpinfo_t;
|
||||||
|
|
||||||
// killough 1/31/98: predefined lumps
|
// killough 1/31/98: predefined lumps
|
||||||
@ -108,6 +111,10 @@ void I_BeginRead(unsigned int bytes), I_EndRead(void); // killough 10/98
|
|||||||
// Function to write all predefined lumps to a PWAD if requested
|
// Function to write all predefined lumps to a PWAD if requested
|
||||||
extern void WritePredefinedLumpWad(const char *filename); // jff 5/6/98
|
extern void WritePredefinedLumpWad(const char *filename); // jff 5/6/98
|
||||||
|
|
||||||
|
// [FG] name of the WAD file that contains the lump
|
||||||
|
const char *W_WadNameForLump (const int lump);
|
||||||
|
boolean W_IsIWADLump (const int lump);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
Loading…
x
Reference in New Issue
Block a user