Save mode

Lets modders set how the game should be saved. Likely useless for
vanilla, but helpful for other mods. This was spawned out of selfishness
for SUGOI to make it only save at the hub, but mods like Boss Mayhem,
which has a hidden map and an act 3 (without any other acts) in the
normal SP campaign, and other mods where the default is detrimental
would benefit as well.

0 for default, 1 for always, 2 for never (no constants because bonustype
doesn't have them either). Won't save if the game is modified, if using
a no-save slot, if playing ultimate mode, or if in a special stage, even
if savemode is set to always.
This commit is contained in:
TehRealSalt 2017-03-29 18:25:09 -04:00
parent 80195b033e
commit a84eed162d
4 changed files with 19 additions and 3 deletions

View file

@ -1339,7 +1339,19 @@ static void readlevelheader(MYFILE *f, INT32 num)
else else
deh_warning("Level header %d: invalid bonus type number %d", num, i); 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")) else if (fastcmp(word, "LEVELFLAGS"))
mapheaderinfo[num-1]->levelflags = (UINT8)i; mapheaderinfo[num-1]->levelflags = (UINT8)i;
else if (fastcmp(word, "MENUFLAGS")) else if (fastcmp(word, "MENUFLAGS"))

View file

@ -237,6 +237,7 @@ typedef struct
SINT8 unlockrequired; ///< Is an unlockable required to play this level? -1 if no. SINT8 unlockrequired; ///< Is an unlockable required to play this level? -1 if no.
UINT8 levelselect; ///< Is this map available in the level select? If so, which map list is it available in? UINT8 levelselect; ///< Is this map available in the level select? If so, which map list is it available in?
SINT8 bonustype; ///< What type of bonus does this level have? (-1 for null.) SINT8 bonustype; ///< What type of bonus does this level have? (-1 for null.)
UINT8 savemode; ///< Handles whenever or not the game should save at a level. (0 = default, 1 = always, 2 = never)
UINT8 levelflags; ///< LF_flags: merged eight booleans into one UINT8 for space, see below UINT8 levelflags; ///< LF_flags: merged eight booleans into one UINT8 for space, see below
UINT8 menuflags; ///< LF2_flags: options that affect record attack / nights mode menus UINT8 menuflags; ///< LF2_flags: options that affect record attack / nights mode menus

View file

@ -1784,6 +1784,8 @@ static int mapheaderinfo_get(lua_State *L)
lua_pushinteger(L, header->levelselect); lua_pushinteger(L, header->levelselect);
else if (fastcmp(field,"bonustype")) else if (fastcmp(field,"bonustype"))
lua_pushinteger(L, header->bonustype); lua_pushinteger(L, header->bonustype);
else if (fastcmp(field,"savemode"))
lua_pushinteger(L, header->savemode);
else if (fastcmp(field,"levelflags")) else if (fastcmp(field,"levelflags"))
lua_pushinteger(L, header->levelflags); lua_pushinteger(L, header->levelflags);
else if (fastcmp(field,"menuflags")) else if (fastcmp(field,"menuflags"))

View file

@ -246,6 +246,8 @@ static void P_ClearSingleMapHeaderInfo(INT16 i)
mapheaderinfo[num]->levelselect = 0; mapheaderinfo[num]->levelselect = 0;
DEH_WriteUndoline("BONUSTYPE", va("%d", mapheaderinfo[num]->bonustype), UNDO_NONE); DEH_WriteUndoline("BONUSTYPE", va("%d", mapheaderinfo[num]->bonustype), UNDO_NONE);
mapheaderinfo[num]->bonustype = 0; 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); DEH_WriteUndoline("LEVELFLAGS", va("%d", mapheaderinfo[num]->levelflags), UNDO_NONE);
mapheaderinfo[num]->levelflags = 0; mapheaderinfo[num]->levelflags = 0;
DEH_WriteUndoline("MENUFLAGS", va("%d", mapheaderinfo[num]->menuflags), UNDO_NONE); DEH_WriteUndoline("MENUFLAGS", va("%d", mapheaderinfo[num]->menuflags), UNDO_NONE);
@ -2960,9 +2962,8 @@ boolean P_SetupLevel(boolean skipprecip)
P_RunCachedActions(); P_RunCachedActions();
if (!(netgame || multiplayer || demoplayback || demorecording || metalrecording || modeattacking || players[consoleplayer].lives <= 0) if (!(netgame || multiplayer || demoplayback || demorecording || metalrecording || modeattacking || players[consoleplayer].lives <= 0)
&& (!modifiedgame || savemoddata) && cursaveslot >= 0 && !ultimatemode && (!modifiedgame || savemoddata) && cursaveslot >= 0 && !ultimatemode && !(G_IsSpecialStage(gamemap)) && !(mapheaderinfo[gamemap-1]->savemode == 2)
&& !(mapheaderinfo[gamemap-1]->menuflags & LF2_HIDEINMENU) && ((mapheaderinfo[gamemap-1]->savemode == 1) || (!(mapheaderinfo[gamemap-1]->menuflags & LF2_HIDEINMENU) && gamemap != lastmapsaved && (mapheaderinfo[gamemap-1]->actnum < 2 || gamecomplete))))
&& (!G_IsSpecialStage(gamemap)) && gamemap != lastmapsaved && (mapheaderinfo[gamemap-1]->actnum < 2 || gamecomplete))
G_SaveGame((UINT32)cursaveslot); G_SaveGame((UINT32)cursaveslot);
if (savedata.lives > 0) if (savedata.lives > 0)