Allow ZScript to control saving and the automap

This commit is contained in:
nashmuhandes 2023-04-09 03:52:58 +08:00 committed by Christoph Oelckers
parent 1bae44c39b
commit 0dbf988d35
9 changed files with 68 additions and 0 deletions

View file

@ -1547,6 +1547,12 @@ void DAutomap::Ticker ()
if (!automapactive)
return;
if ((primaryLevel->flags9 & LEVEL9_NOAUTOMAP))
{
AM_ToggleMap();
return;
}
amclock++;
}
@ -3449,6 +3455,9 @@ void AM_ToggleMap()
if (!primaryLevel || !primaryLevel->automap)
return;
if (!automapactive && (primaryLevel->flags9 & LEVEL9_NOAUTOMAP))
return;
if (!automapactive)
{
// Reset AM buttons

View file

@ -700,6 +700,12 @@ UNSAFE_CCMD (load)
UNSAFE_CCMD(save)
{
if ((primaryLevel->flags9 & LEVEL9_NOUSERSAVE))
{
Printf("%s\n", GStrings("SAVEDEAD"));
return;
}
if (argv.argc() < 2 || argv.argc() > 3 || argv[1][0] == 0)
{
Printf ("usage: save <filename> [description]\n");

View file

@ -2197,6 +2197,9 @@ CUSTOM_CVAR (Int, quicksaverotationcount, 4, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
void G_DoAutoSave ()
{
if ((primaryLevel->flags9 & LEVEL9_NOUSERSAVE))
return;
FString description;
FString file;
// Keep up to four autosaves at a time

View file

@ -607,6 +607,7 @@ public:
uint32_t flags;
uint32_t flags2;
uint32_t flags3;
uint32_t flags9;
uint32_t fadeto; // The color the palette fades to (usually black)
uint32_t outsidefog; // The fog for sectors with sky ceilings

View file

@ -1694,6 +1694,9 @@ enum EMIType
MITYPE_SETFLAG3,
MITYPE_CLRFLAG3,
MITYPE_SCFLAGS3,
MITYPE_SETFLAG9,
MITYPE_CLRFLAG9,
MITYPE_SCFLAGS9,
MITYPE_COMPATFLAG,
MITYPE_CLRCOMPATFLAG,
};
@ -1792,6 +1795,8 @@ MapFlagHandlers[] =
{ "nolightfade", MITYPE_SETFLAG3, LEVEL3_NOLIGHTFADE, 0 },
{ "nocoloredspritelighting", MITYPE_SETFLAG3, LEVEL3_NOCOLOREDSPRITELIGHTING, 0 },
{ "forceworldpanning", MITYPE_SETFLAG3, LEVEL3_FORCEWORLDPANNING, 0 },
{ "nousersave", MITYPE_SETFLAG9, LEVEL9_NOUSERSAVE, 0 },
{ "noautomap", MITYPE_SETFLAG9, LEVEL9_NOAUTOMAP, 0 },
{ "propermonsterfallingdamage", MITYPE_SETFLAG3, LEVEL3_PROPERMONSTERFALLINGDAMAGE, 0 },
{ "disableshadowmap", MITYPE_SETFLAG3, LEVEL3_NOSHADOWMAP, 0 },
{ "enableshadowmap", MITYPE_CLRFLAG3, LEVEL3_NOSHADOWMAP, 0 },
@ -1953,6 +1958,29 @@ void FMapInfoParser::ParseMapDefinition(level_info_t &info)
info.flags3 = (info.flags3 & handler->data2) | handler->data1;
break;
case MITYPE_SETFLAG9:
if (!CheckAssign())
{
info.flags9 |= handler->data1;
}
else
{
sc.MustGetNumber();
if (sc.Number) info.flags9 |= handler->data1;
else info.flags9 &= ~handler->data1;
}
info.flags9 |= handler->data2;
break;
case MITYPE_CLRFLAG9:
info.flags9 &= ~handler->data1;
info.flags9 |= handler->data2;
break;
case MITYPE_SCFLAGS9:
info.flags9 = (info.flags9 & handler->data2) | handler->data1;
break;
case MITYPE_CLRCOMPATFLAG:
info.compatflags &= ~handler->data1;
info.compatflags2 &= ~handler->data2;

View file

@ -270,6 +270,10 @@ enum ELevelFlags : unsigned int
LEVEL3_AVOIDMELEE = 0x00020000, // global flag needed for proper MBF support.
LEVEL3_NOJUMPDOWN = 0x00040000, // only for MBF21. Inverse of MBF's dog_jumping flag.
LEVEL3_LIGHTCREATED = 0x00080000, // a light had been created in the last frame
// Deliberately skip ahead...
LEVEL9_NOUSERSAVE = 0x00000001,
LEVEL9_NOAUTOMAP = 0x00000002,
};
@ -342,6 +346,7 @@ struct level_info_t
int32_t flags;
uint32_t flags2;
uint32_t flags3;
uint32_t flags9;
FString Music;
FString LevelName;

View file

@ -68,6 +68,7 @@
#include "shiftstate.h"
#include "s_music.h"
#include "hwrenderer/scene/hw_drawinfo.h"
#include "g_levellocals.h"
EXTERN_CVAR(Int, cl_gfxlocalization)
EXTERN_CVAR(Bool, m_quickexit)
@ -251,6 +252,13 @@ bool M_SetSpecialMenu(FName& menu, int param)
M_StartMessage (GStrings("SAVEDEAD"), 1);
return false;
}
if ((primaryLevel->flags9 & LEVEL9_NOUSERSAVE))
{
M_StartMessage(GStrings("SAVEDEAD"), 1);
return false;
}
break;
case NAME_Quitmenu:
@ -473,6 +481,9 @@ CCMD (quicksave)
return;
}
if ((primaryLevel->flags9 & LEVEL9_NOUSERSAVE))
return;
if (gamestate != GS_LEVEL)
return;

View file

@ -2851,6 +2851,8 @@ DEFINE_FIELD_BIT(FLevelLocals, flags2, infinite_flight, LEVEL2_INFINITE_FLIGHT)
DEFINE_FIELD_BIT(FLevelLocals, flags2, no_dlg_freeze, LEVEL2_CONV_SINGLE_UNFREEZE)
DEFINE_FIELD_BIT(FLevelLocals, flags2, keepfullinventory, LEVEL2_KEEPFULLINVENTORY)
DEFINE_FIELD_BIT(FLevelLocals, flags3, removeitems, LEVEL3_REMOVEITEMS)
DEFINE_FIELD_BIT(FLevelLocals, flags9, nousersave, LEVEL9_NOUSERSAVE)
DEFINE_FIELD_BIT(FLevelLocals, flags9, noautomap, LEVEL9_NOAUTOMAP)
DEFINE_FIELD_X(Sector, sector_t, floorplane)
DEFINE_FIELD_X(Sector, sector_t, ceilingplane)

View file

@ -472,6 +472,9 @@ struct LevelLocals native
native readonly int compatflags2;
native readonly LevelInfo info;
native bool nousersave;
native bool noautomap;
native String GetUDMFString(int type, int index, Name key);
native int GetUDMFInt(int type, int index, Name key);
native double GetUDMFFloat(int type, int index, Name key);