diff --git a/src/dehacked.c b/src/dehacked.c index cc3f196a6..f56726c44 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -1339,7 +1339,19 @@ static void readlevelheader(MYFILE *f, INT32 num) else 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")) diff --git a/src/doomstat.h b/src/doomstat.h index f1b7d2169..29ba7e13c 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -237,6 +237,7 @@ typedef struct 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? 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 menuflags; ///< LF2_flags: options that affect record attack / nights mode menus diff --git a/src/lua_maplib.c b/src/lua_maplib.c index f1bfcb8f1..d61342435 100644 --- a/src/lua_maplib.c +++ b/src/lua_maplib.c @@ -1784,6 +1784,8 @@ static int mapheaderinfo_get(lua_State *L) lua_pushinteger(L, header->levelselect); else if (fastcmp(field,"bonustype")) lua_pushinteger(L, header->bonustype); + else if (fastcmp(field,"savemode")) + lua_pushinteger(L, header->savemode); else if (fastcmp(field,"levelflags")) lua_pushinteger(L, header->levelflags); else if (fastcmp(field,"menuflags")) diff --git a/src/p_setup.c b/src/p_setup.c index 6df103255..023c6fdf3 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -246,6 +246,8 @@ 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); @@ -2960,9 +2962,8 @@ boolean P_SetupLevel(boolean skipprecip) P_RunCachedActions(); if (!(netgame || multiplayer || demoplayback || demorecording || metalrecording || modeattacking || players[consoleplayer].lives <= 0) - && (!modifiedgame || savemoddata) && cursaveslot >= 0 && !ultimatemode - && !(mapheaderinfo[gamemap-1]->menuflags & LF2_HIDEINMENU) - && (!G_IsSpecialStage(gamemap)) && gamemap != lastmapsaved && (mapheaderinfo[gamemap-1]->actnum < 2 || gamecomplete)) + && (!modifiedgame || savemoddata) && cursaveslot >= 0 && !ultimatemode && !(G_IsSpecialStage(gamemap)) && !(mapheaderinfo[gamemap-1]->savemode == 2) + && ((mapheaderinfo[gamemap-1]->savemode == 1) || (!(mapheaderinfo[gamemap-1]->menuflags & LF2_HIDEINMENU) && gamemap != lastmapsaved && (mapheaderinfo[gamemap-1]->actnum < 2 || gamecomplete)))) G_SaveGame((UINT32)cursaveslot); if (savedata.lives > 0)