From a5ca15862256a96bdadcd8ebc8e07c7800bbf17e Mon Sep 17 00:00:00 2001 From: TehRealSalt Date: Sun, 6 Aug 2017 16:36:55 -0400 Subject: [PATCH] LF_SAVEGAME flag instead of savemode Also always save on file creation --- src/dehacked.c | 21 ++++++++------------- src/doomstat.h | 1 + src/p_setup.c | 22 +++++----------------- 3 files changed, 14 insertions(+), 30 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index e8fb48763..a00488ccf 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -1288,18 +1288,6 @@ static void readlevelheader(MYFILE *f, INT32 num) deh_warning("Level header %d: invalid bonus type number %d", num, i); } - else if (fastcmp(word, "SAVEMODE")) - { - if (fastcmp(word2, "DEFAULT")) i = 0; - else if (fastcmp(word2, "ALWAYS")) i = 1; - else if (fastcmp(word2, "NEVER")) i = 2; - - if (i >= 0 && i <= 2) - mapheaderinfo[num-1]->savemode = (UINT8)i; - else - deh_warning("Level header %d: invalid save mode number %d", num, i); - } - else if (fastcmp(word, "LEVELFLAGS")) mapheaderinfo[num-1]->levelflags = (UINT8)i; else if (fastcmp(word, "MENUFLAGS")) @@ -1341,7 +1329,14 @@ static void readlevelheader(MYFILE *f, INT32 num) else mapheaderinfo[num-1]->levelflags &= ~LF_NOZONE; } - + else if (fastcmp(word, "SAVEGAME")) + { + if (i || word2[0] == 'T' || word2[0] == 'Y') + mapheaderinfo[num-1]->levelflags |= LF_SAVEGAME; + else + mapheaderinfo[num-1]->levelflags &= ~LF_SAVEGAME; + } + // Individual triggers for menu flags else if (fastcmp(word, "HIDDEN")) { diff --git a/src/doomstat.h b/src/doomstat.h index 992d39a45..93678b9b0 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -265,6 +265,7 @@ typedef struct #define LF_NOSSMUSIC 4 ///< Disable Super Sonic music #define LF_NORELOAD 8 ///< Don't reload level on death #define LF_NOZONE 16 ///< Don't include "ZONE" on level title +#define LF_SAVEGAME 32 ///< Save the game upon loading this level #define LF2_HIDEINMENU 1 ///< Hide in the multiplayer menu #define LF2_HIDEINSTATS 2 ///< Hide in the statistics screen diff --git a/src/p_setup.c b/src/p_setup.c index e89d34b9e..5ba5ae2ab 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -250,8 +250,6 @@ static void P_ClearSingleMapHeaderInfo(INT16 i) mapheaderinfo[num]->levelselect = 0; DEH_WriteUndoline("BONUSTYPE", va("%d", mapheaderinfo[num]->bonustype), UNDO_NONE); mapheaderinfo[num]->bonustype = 0; - DEH_WriteUndoline("SAVEMODE", va("%d", mapheaderinfo[num]->savemode), UNDO_NONE); - mapheaderinfo[num]->savemode = 0; DEH_WriteUndoline("LEVELFLAGS", va("%d", mapheaderinfo[num]->levelflags), UNDO_NONE); mapheaderinfo[num]->levelflags = 0; DEH_WriteUndoline("MENUFLAGS", va("%d", mapheaderinfo[num]->menuflags), UNDO_NONE); @@ -2557,21 +2555,11 @@ static boolean CanSaveLevel(INT32 mapnum) if (G_IsSpecialStage(mapnum) // don't save in special stages || mapnum == lastmaploaded) // don't save if the last map loaded was this one return false; - - // Determine whether the map should save or not from map header's "savemode" option - switch (mapheaderinfo[mapnum-1]->savemode) { - case 1: return true; // ALWAYS - always save, override conditions below - case 2: return false; // NEVER - never save - default: break; // DEFAULT - just do whatever's normal for this kind of map - } - - // Don't save if Hidden = 1 is set in map header - if (mapheaderinfo[mapnum-1]->menuflags & LF2_HIDEINMENU) - return false; - - // Only act 1 levels (or levels with no act number) can save normally. - // If the game is complete for this save slot, any level can save! - return (mapheaderinfo[mapnum-1]->actnum < 2 || gamecomplete); + + // Any levels that have the savegame flag can save normally. + // If the game is complete for this save slot, then any level can save! + // On the other side of the spectrum, if lastmaploaded is 0, then the save file has only just been created and needs to save ASAP! + return (mapheaderinfo[mapnum-1]->levelflags & LF_SAVEGAME || gamecomplete || !lastmaploaded); } /** Loads a level from a lump or external wad.