From 6d614af4f4087929c2956d9d47da663043b38469 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 16 Dec 2010 09:13:06 +0000 Subject: [PATCH] - added a 'noautosavehint' MAPINFO option. This does not actually block the autosave from happening. It just does not increase the autosave counter so any subsequent autosave in the same session will overwrite the last one which was saved with this hint on. SVN r3050 (trunk) --- src/g_game.cpp | 20 ++++++++++++++++++-- src/g_level.h | 1 + src/g_mapinfo.cpp | 1 + src/p_lnspec.cpp | 1 + 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/g_game.cpp b/src/g_game.cpp index 85bc45fce..1d735ee03 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -1904,6 +1904,7 @@ FString G_BuildSaveName (const char *prefix, int slot) } CVAR (Int, autosavenum, 0, CVAR_NOSET|CVAR_ARCHIVE|CVAR_GLOBALCONFIG) +static int nextautosave = -1; CVAR (Int, disableautosave, 0, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) CUSTOM_CVAR (Int, autosavecount, 4, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) { @@ -1924,10 +1925,25 @@ void G_DoAutoSave () const char *readableTime; int count = autosavecount != 0 ? autosavecount : 1; - num.Int = (autosavenum + 1) % count; + if (nextautosave == -1) + { + nextautosave = (autosavenum + 1) % count; + } + + num.Int = nextautosave; autosavenum.ForceSet (num, CVAR_Int); - file = G_BuildSaveName ("auto", num.Int); + file = G_BuildSaveName ("auto", nextautosave); + + if (!(level.flags2 & LEVEL2_NOAUTOSAVEHINT)) + { + nextautosave = (nextautosave + 1) % count; + } + else + { + // This flag can only be used once per level + level.flags2 &= ~LEVEL2_NOAUTOSAVEHINT; + } readableTime = myasctime (); strcpy (description, "Autosave "); diff --git a/src/g_level.h b/src/g_level.h index 6cb9d8441..34c2bf5f8 100644 --- a/src/g_level.h +++ b/src/g_level.h @@ -212,6 +212,7 @@ enum ELevelFlags LEVEL2_NOSTATISTICS = 0x10000000, // This level should not have statistics collected LEVEL2_ENDGAME = 0x20000000, // This is an epilogue level that cannot be quit. + LEVEL2_NOAUTOSAVEHINT = 0x40000000, // tell the game that an autosave for this level does not need to be kept }; diff --git a/src/g_mapinfo.cpp b/src/g_mapinfo.cpp index 4199305d3..b4183ef2f 100644 --- a/src/g_mapinfo.cpp +++ b/src/g_mapinfo.cpp @@ -1238,6 +1238,7 @@ MapFlagHandlers[] = { "resethealth", MITYPE_SETFLAG2, LEVEL2_RESETHEALTH, 0 }, { "endofgame", MITYPE_SETFLAG2, LEVEL2_ENDGAME, 0 }, { "nostatistics", MITYPE_SETFLAG2, LEVEL2_NOSTATISTICS, 0 }, + { "noautosavehint", MITYPE_SETFLAG2, LEVEL2_NOAUTOSAVEHINT, 0 }, { "unfreezesingleplayerconversations",MITYPE_SETFLAG2, LEVEL2_CONV_SINGLE_UNFREEZE, 0 }, { "nobotnodes", MITYPE_IGNORE, 0, 0 }, // Skulltag option: nobotnodes { "compat_shorttex", MITYPE_COMPATFLAG, COMPATF_SHORTTEX}, diff --git a/src/p_lnspec.cpp b/src/p_lnspec.cpp index ac7520170..1b3f627a4 100644 --- a/src/p_lnspec.cpp +++ b/src/p_lnspec.cpp @@ -2798,6 +2798,7 @@ FUNC(LS_Autosave) { if (gameaction != ga_savegame) { + level.flags2 &= ~LEVEL2_NOAUTOSAVEHINT; Net_WriteByte (DEM_CHECKAUTOSAVE); } return true;