LF_SAVEGAME flag instead of savemode

Also always save on file creation
This commit is contained in:
TehRealSalt 2017-08-06 16:36:55 -04:00
parent e24b8b917a
commit a5ca158622
3 changed files with 14 additions and 30 deletions

View File

@ -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"))
{

View File

@ -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

View File

@ -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.