revert to LF_SAVEGAME system code, removing all traces of saveoverride

(I believe Sal wanted us to do this anyway, so...)
This commit is contained in:
Monster Iestyn 2019-01-08 17:14:21 +00:00
parent a050ed956a
commit f3796dc7f6
4 changed files with 11 additions and 45 deletions

View File

@ -1216,19 +1216,6 @@ static void readlevelheader(MYFILE *f, INT32 num)
else if (fastcmp(word, "MAXBONUSLIVES"))
mapheaderinfo[num-1]->maxbonuslives = (SINT8)i;
else if (fastcmp(word, "SAVEOVERRIDE"))
{
if (fastcmp(word2, "DEFAULT")) i = SAVE_DEFAULT;
else if (fastcmp(word2, "ALWAYS")) i = SAVE_ALWAYS;
else if (fastcmp(word2, "NEVER")) i = SAVE_NEVER;
if (i >= SAVE_NEVER && i <= SAVE_ALWAYS)
mapheaderinfo[num-1]->saveoverride = (SINT8)i;
else
deh_warning("Level header %d: invalid save override number %d", num, i);
}
else if (fastcmp(word, "LEVELFLAGS"))
mapheaderinfo[num-1]->levelflags = (UINT8)i;
else if (fastcmp(word, "MENUFLAGS"))
@ -7894,11 +7881,6 @@ struct {
{"LF2_NOVISITNEEDED",LF2_NOVISITNEEDED},
{"LF2_WIDEICON",LF2_WIDEICON},
// Save override
{"SAVE_NEVER",SAVE_NEVER},
{"SAVE_DEFAULT",SAVE_DEFAULT},
{"SAVE_ALWAYS",SAVE_ALWAYS},
// NiGHTS grades
{"GRADE_F",GRADE_F},
{"GRADE_E",GRADE_E},

View File

@ -304,7 +304,6 @@ typedef struct
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 maxbonuslives; ///< How many bonus lives to award at Intermission? (-1 for unlimited.)
SINT8 saveoverride; ///< Set how the game is allowed to save (1 for always, -1 for never, 0 is 2.1 default)
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
@ -340,11 +339,6 @@ typedef struct
#define LF2_NOVISITNEEDED 16 ///< Available in time attack/nights mode without visiting the level
#define LF2_WIDEICON 32 ///< If you're in a circumstance where it fits, use a wide map icon
// Save override
#define SAVE_NEVER -1
#define SAVE_DEFAULT 0
#define SAVE_ALWAYS 1
extern mapheader_t* mapheaderinfo[NUMMAPS];
enum TypeOfLevel

View File

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

View File

@ -230,7 +230,6 @@ static void P_ClearSingleMapHeaderInfo(INT16 i)
mapheaderinfo[num]->levelselect = 0;
mapheaderinfo[num]->bonustype = 0;
mapheaderinfo[num]->maxbonuslives = -1;
mapheaderinfo[num]->saveoverride = SAVE_DEFAULT;
mapheaderinfo[num]->levelflags = 0;
mapheaderinfo[num]->menuflags = 0;
#if 1 // equivalent to "FlickyList = DEMO"
@ -2632,27 +2631,19 @@ static void P_SetupCamera(void)
}
}
static boolean P_CanSave(void)
static boolean CanSaveLevel(INT32 mapnum)
{
// Saving is completely ignored under these conditions:
if ((cursaveslot < 0) // Playing without saving
|| (modifiedgame && !savemoddata) // Game is modified
|| (netgame || multiplayer) // Not in single-player
|| (demoplayback || demorecording || metalrecording) // Currently in demo
|| (players[consoleplayer].lives <= 0) // Completely dead
|| (modeattacking || ultimatemode || G_IsSpecialStage(gamemap))) // Specialized instances
if (ultimatemode) // never save in ultimate (probably redundant with cursaveslot also being checked)
return false;
if (mapheaderinfo[gamemap-1]->saveoverride == SAVE_ALWAYS
|| (mapheaderinfo[gamemap-1]->levelflags & LF_SAVEGAME))
return true; // Saving should ALWAYS happen!
else if (mapheaderinfo[gamemap-1]->saveoverride == SAVE_NEVER)
return false; // Saving should NEVER happen!
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;
// Default condition: In a non-hidden map, at the beginning of a zone or on a completed save-file, and not on save reload.
return (!(mapheaderinfo[gamemap-1]->menuflags & LF2_HIDEINMENU)
&& (mapheaderinfo[gamemap-1]->actnum < 2 || gamecomplete)
&& (gamemap != lastmaploaded));
// 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.
@ -3176,7 +3167,8 @@ boolean P_SetupLevel(boolean skipprecip)
P_RunCachedActions();
if (P_CanSave())
if (!(netgame || multiplayer || demoplayback || demorecording || metalrecording || modeattacking || players[consoleplayer].lives <= 0)
&& (!modifiedgame || savemoddata) && cursaveslot > 0 && CanSaveLevel(gamemap))
G_SaveGame((UINT32)cursaveslot);
lastmaploaded = gamemap; // HAS to be set after saving!!