mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-10 23:01:50 +00:00
make nosave standalone CVar flag, alongside server and user
This commit is contained in:
parent
f85e3fb9a0
commit
7973ab9c6b
4 changed files with 47 additions and 35 deletions
|
@ -191,14 +191,7 @@ void FBaseCVar::SetGenericRep (UCVarValue value, ECVarType type)
|
|||
Flags &= ~CVAR_UNSAFECONTEXT;
|
||||
return;
|
||||
}
|
||||
if (Flags & CVAR_NOSAVEGAME)
|
||||
{
|
||||
ForceSet (value, type);
|
||||
}
|
||||
else
|
||||
{
|
||||
D_SendServerInfoChange (this, value, type);
|
||||
}
|
||||
D_SendServerInfoChange (this, value, type);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1259,7 +1252,7 @@ FString C_GetMassCVarString (uint32_t filter, bool compact)
|
|||
{
|
||||
for (cvar = CVars; cvar != NULL; cvar = cvar->m_Next)
|
||||
{
|
||||
if ((cvar->Flags & filter) && !(cvar->Flags & (CVAR_NOSAVE|CVAR_IGNORE|CVAR_NOSAVEGAME)))
|
||||
if ((cvar->Flags & filter) && !(cvar->Flags & (CVAR_NOSAVE|CVAR_IGNORE)))
|
||||
{
|
||||
UCVarValue val = cvar->GetGenericRep(CVAR_String);
|
||||
dump << '\\' << cvar->GetName() << '\\' << val.String;
|
||||
|
@ -1280,7 +1273,7 @@ void C_SerializeCVars(FSerializer &arc, const char *label, uint32_t filter)
|
|||
{
|
||||
for (cvar = CVars; cvar != NULL; cvar = cvar->m_Next)
|
||||
{
|
||||
if ((cvar->Flags & filter) && !(cvar->Flags & (CVAR_NOSAVE | CVAR_IGNORE | CVAR_NOSAVEGAME)))
|
||||
if ((cvar->Flags & filter) && !(cvar->Flags & (CVAR_NOSAVE | CVAR_IGNORE | CVAR_CONFIG_ONLY)))
|
||||
{
|
||||
UCVarValue val = cvar->GetGenericRep(CVAR_String);
|
||||
char* c = const_cast<char*>(val.String);
|
||||
|
@ -1292,7 +1285,7 @@ void C_SerializeCVars(FSerializer &arc, const char *label, uint32_t filter)
|
|||
{
|
||||
for (cvar = CVars; cvar != NULL; cvar = cvar->m_Next)
|
||||
{
|
||||
if ((cvar->Flags & filter) && !(cvar->Flags & (CVAR_NOSAVE | CVAR_IGNORE | CVAR_NOSAVEGAME)))
|
||||
if ((cvar->Flags & filter) && !(cvar->Flags & (CVAR_NOSAVE | CVAR_IGNORE | CVAR_CONFIG_ONLY)))
|
||||
{
|
||||
UCVarValue val;
|
||||
char *c = nullptr;
|
||||
|
@ -1600,7 +1593,7 @@ void C_ArchiveCVars (FConfigFile *f, uint32_t filter)
|
|||
while (cvar)
|
||||
{
|
||||
if ((cvar->Flags &
|
||||
(CVAR_GLOBALCONFIG|CVAR_ARCHIVE|CVAR_MOD|CVAR_AUTO|CVAR_USERINFO|CVAR_SERVERINFO|CVAR_NOSAVE))
|
||||
(CVAR_GLOBALCONFIG|CVAR_ARCHIVE|CVAR_MOD|CVAR_AUTO|CVAR_USERINFO|CVAR_SERVERINFO|CVAR_NOSAVE|CVAR_CONFIG_ONLY))
|
||||
== filter)
|
||||
{
|
||||
cvarlist.Push(cvar);
|
||||
|
|
|
@ -48,26 +48,29 @@ CVARS (console variables)
|
|||
|
||||
enum
|
||||
{
|
||||
CVAR_ARCHIVE = 1, // set to cause it to be saved to config
|
||||
CVAR_USERINFO = 2, // added to userinfo when changed
|
||||
CVAR_SERVERINFO = 4, // added to serverinfo when changed
|
||||
CVAR_NOSET = 8, // don't allow change from console at all,
|
||||
// but can be set from the command line
|
||||
CVAR_LATCH = 16, // save changes until server restart
|
||||
CVAR_UNSETTABLE = 32, // can unset this var from console
|
||||
CVAR_DEMOSAVE = 64, // save the value of this cvar in a demo
|
||||
CVAR_ISDEFAULT = 128, // is cvar unchanged since creation?
|
||||
CVAR_AUTO = 256, // allocated; needs to be freed when destroyed
|
||||
CVAR_NOINITCALL = 512, // don't call callback at game start
|
||||
CVAR_GLOBALCONFIG = 1024, // cvar is saved to global config section
|
||||
CVAR_VIDEOCONFIG = 2048, // cvar is saved to video config section (not implemented)
|
||||
CVAR_NOSAVE = 4096, // when used with CVAR_SERVERINFO, do not save var to savegame and config.
|
||||
CVAR_MOD = 8192, // cvar was defined by a mod
|
||||
CVAR_IGNORE = 16384,// do not send cvar across the network/inaccesible from ACS (dummy mod cvar)
|
||||
CVAR_CHEAT = 32768,// can be set only when sv_cheats is enabled
|
||||
CVAR_UNSAFECONTEXT = 65536,// cvar value came from unsafe context
|
||||
CVAR_VIRTUAL = 0x20000, // do not invoke the callback recursively so it can be used to mirror an external variable.
|
||||
CVAR_NOSAVEGAME = 0x40000, // do not save var to savegame.
|
||||
CVAR_ARCHIVE = 1, // set to cause it to be saved to config.
|
||||
CVAR_USERINFO = 1 << 1, // added to userinfo when changed.
|
||||
CVAR_SERVERINFO = 1 << 2, // added to serverinfo when changed.
|
||||
CVAR_NOSET = 1 << 3, // don't allow change from console at all,
|
||||
// but can be set from the command line.
|
||||
CVAR_LATCH = 1 << 4, // save changes until server restart.
|
||||
CVAR_UNSETTABLE = 1 << 5, // can unset this var from console.
|
||||
CVAR_DEMOSAVE = 1 << 6, // save the value of this cvar in a demo.
|
||||
CVAR_ISDEFAULT = 1 << 7, // is cvar unchanged since creation?
|
||||
CVAR_AUTO = 1 << 8, // allocated; needs to be freed when destroyed.
|
||||
CVAR_NOINITCALL = 1 << 9, // don't call callback at game start.
|
||||
CVAR_GLOBALCONFIG = 1 << 10, // cvar is saved to global config section.
|
||||
CVAR_VIDEOCONFIG = 1 << 11, // cvar is saved to video config section (not implemented).
|
||||
CVAR_NOSAVE = 1 << 12, // when used with CVAR_SERVERINFO, do not save var to savegame
|
||||
// and config.
|
||||
CVAR_MOD = 1 << 13, // cvar was defined by a mod.
|
||||
CVAR_IGNORE = 1 << 14, // do not send cvar across the network/inaccesible from ACS
|
||||
// (dummy mod cvar).
|
||||
CVAR_CHEAT = 1 << 15, // can be set only when sv_cheats is enabled.
|
||||
CVAR_UNSAFECONTEXT = 1 << 16, // cvar value came from unsafe context.
|
||||
CVAR_VIRTUAL = 1 << 17, // do not invoke the callback recursively so it can be used to
|
||||
// mirror an external variable.
|
||||
CVAR_CONFIG_ONLY = 1 << 18, // do not save var to savegame and do not send it across network.
|
||||
};
|
||||
|
||||
union UCVarValue
|
||||
|
|
|
@ -1479,7 +1479,7 @@ void ParseCVarInfo()
|
|||
}
|
||||
else if (stricmp(sc.String, "nosave") == 0)
|
||||
{
|
||||
cvarflags |= CVAR_NOSAVEGAME;
|
||||
cvarflags |= CVAR_CONFIG_ONLY;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1487,11 +1487,22 @@ void ParseCVarInfo()
|
|||
}
|
||||
sc.MustGetAnyToken();
|
||||
}
|
||||
|
||||
// Possibility of defining a cvar as 'server nosave' or 'user nosave' is kept for
|
||||
// compatibility reasons.
|
||||
if (cvarflags & CVAR_CONFIG_ONLY)
|
||||
{
|
||||
cvarflags &= ~CVAR_SERVERINFO;
|
||||
cvarflags &= ~CVAR_USERINFO;
|
||||
}
|
||||
|
||||
// Do some sanity checks.
|
||||
if ((cvarflags & (CVAR_SERVERINFO|CVAR_USERINFO)) == 0 ||
|
||||
// No need to check server-nosave and user-nosave combinations because they
|
||||
// are made impossible right above.
|
||||
if ((cvarflags & (CVAR_SERVERINFO|CVAR_USERINFO|CVAR_CONFIG_ONLY)) == 0 ||
|
||||
(cvarflags & (CVAR_SERVERINFO|CVAR_USERINFO)) == (CVAR_SERVERINFO|CVAR_USERINFO))
|
||||
{
|
||||
sc.ScriptError("One of 'server' or 'user' must be specified");
|
||||
sc.ScriptError("One of 'server', 'user', or 'nosave' must be specified");
|
||||
}
|
||||
// The next token must be the cvar type.
|
||||
if (sc.TokenType == TK_Bool)
|
||||
|
|
|
@ -756,6 +756,11 @@ void FGameConfigFile::ArchiveGameData (const char *gamename)
|
|||
}
|
||||
}
|
||||
|
||||
strncpy (subsection, "ConfigOnlyVariables", sublen);
|
||||
SetSection (section, true);
|
||||
ClearCurrentSection ();
|
||||
C_ArchiveCVars (this, CVAR_ARCHIVE|CVAR_AUTO|CVAR_MOD|CVAR_CONFIG_ONLY);
|
||||
|
||||
strncpy (subsection, "UnknownConsoleVariables", sublen);
|
||||
SetSection (section, true);
|
||||
ClearCurrentSection ();
|
||||
|
|
Loading…
Reference in a new issue