Menus: "Clean Up Obsolete Saves"

git-svn-id: https://svn.eduke32.com/eduke32@6749 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
hendricks266 2018-03-08 03:55:41 +00:00
parent d3882d2c2c
commit 10d67bdf9e
4 changed files with 30 additions and 0 deletions

View file

@ -1223,10 +1223,13 @@ static MenuEntry_t ME_SAVESETUP_AUTOSAVEDELETION = MAKE_MENUENTRY( "Auto-Delete:
static MenuRangeInt32_t MEO_SAVESETUP_MAXAUTOSAVES = MAKE_MENURANGE( &ud.maxautosaves, &MF_Redfont, 1, 10, 0, 10, 1 );
static MenuEntry_t ME_SAVESETUP_MAXAUTOSAVES = MAKE_MENUENTRY( "Limit:", &MF_Redfont, &MEF_BigOptions_Apply, &MEO_SAVESETUP_MAXAUTOSAVES, RangeInt32 );
static MenuEntry_t ME_SAVESETUP_CLEANUP = MAKE_MENUENTRY( "Clean Up Saves", &MF_Redfont, &MEF_BigOptionsRt, &MEO_NULL, Link );
static MenuEntry_t *MEL_SAVESETUP[] = {
&ME_SAVESETUP_AUTOSAVE,
&ME_SAVESETUP_AUTOSAVEDELETION,
&ME_SAVESETUP_MAXAUTOSAVES,
&ME_SAVESETUP_CLEANUP,
};
@ -3024,6 +3027,10 @@ static void Menu_EntryLinkActivate(MenuEntry_t *entry)
if (ud.config.MusicToggle)
S_RestartMusic();
}
else if (entry == &ME_SAVESETUP_CLEANUP)
{
G_DeleteOldSaves();
}
else if (entry == &ME_COLCORR_RESET)
{
vid_gamma = DEFAULT_GAMMA;

View file

@ -27,6 +27,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "demo.h" // g_firstDemoFile[]
#include "cheats.h"
#include "sbar.h"
#include "savegame.h"
#ifdef LUNATIC
# include "lunatic_game.h"
@ -1410,6 +1411,13 @@ static int32_t osdcmd_kickban(osdfuncparm_t const * const parm)
}
#endif
static int32_t osdcmd_sv_cleanup(osdfuncparm_t const * const UNUSED(parm))
{
UNREFERENCED_CONST_PARAMETER(parm);
G_DeleteOldSaves();
return OSDCMD_OK;
}
static int32_t osdcmd_printtimes(osdfuncparm_t const * const UNUSED(parm))
{
UNREFERENCED_CONST_PARAMETER(parm);
@ -1776,6 +1784,8 @@ int32_t registerosdcommands(void)
OSD_RegisterFunction("disconnect","disconnect: disconnects from the local multiplayer game", osdcmd_disconnect);
#endif
OSD_RegisterFunction("sv_cleanup", "sv_cleanup: deletes obsolete and unreadable save files", osdcmd_sv_cleanup);
for (i=0; i<NUMGAMEFUNCTIONS; i++)
{
char *t;

View file

@ -494,6 +494,18 @@ void G_DeleteSave(savebrief_t const & sv)
unlink(temp);
}
void G_DeleteOldSaves(void)
{
ReadSaveGameHeaders();
for (size_t x = 0; x < g_numinternalsaves; ++x)
{
menusave_t const & msv = g_internalsaves[x];
if (msv.isOldVer || msv.isUnreadable)
G_DeleteSave(msv.brief);
}
}
int32_t G_SavePlayer(savebrief_t & sv, bool isAutoSave)
{
#ifdef __ANDROID__

View file

@ -116,6 +116,7 @@ int32_t sv_loadsnapshot(int32_t fil, int32_t spot, savehead_t *h);
int32_t sv_saveandmakesnapshot(FILE *fil, char const *name, int8_t spot, int8_t recdiffsp, int8_t diffcompress, int8_t synccompress, bool isAutoSave = false);
void sv_freemem();
void G_DeleteSave(savebrief_t const & sv);
void G_DeleteOldSaves(void);
int32_t G_SavePlayer(savebrief_t & sv, bool isAutoSave);
int32_t G_LoadPlayer(savebrief_t & sv);
int32_t G_LoadSaveHeaderNew(char const *fn, savehead_t *saveh);