- enable cvar blacklisting for defcvars for certain platform variables

This commit is contained in:
Rachael Alexanderson 2021-09-05 10:27:06 -04:00
parent 42d948f2fe
commit f56ad02716
2 changed files with 54 additions and 2 deletions

View File

@ -34,6 +34,8 @@
#include "c_console.h"
#include "d_main.h"
#include "version.h"
#include "d_defcvars.h"
void D_GrabCVarDefaults()
{
@ -104,9 +106,30 @@ void D_GrabCVarDefaults()
break;
}
bool blacklisted = false;
SHOULD_BLACKLIST(disablecrashlog)
SHOULD_BLACKLIST(gl_control_tear)
SHOULD_BLACKLIST(in_mouse)
SHOULD_BLACKLIST(joy_dinput)
SHOULD_BLACKLIST(joy_ps2raw)
SHOULD_BLACKLIST(joy_xinput)
SHOULD_BLACKLIST(k_allowfullscreentoggle)
SHOULD_BLACKLIST(k_mergekeys)
SHOULD_BLACKLIST(m_swapbuttons)
SHOULD_BLACKLIST(queryiwad_key)
SHOULD_BLACKLIST(vid_gpuswitch)
SHOULD_BLACKLIST(vr_enable_quadbuffered)
var = FindCVar(CurrentFindCVar, NULL);
if (var != NULL)
if (blacklisted)
{
sc.ScriptMessage("Cannot set cvar default for blacklisted cvar '%s'", sc.String);
sc.MustGetString(); // to ignore the value of the cvar
}
else if (var != NULL)
{
if (var->GetFlags() & CVAR_ARCHIVE)
{
UCVarValue val;
@ -115,14 +138,16 @@ void D_GrabCVarDefaults()
val.String = const_cast<char*>(sc.String);
var->SetGenericRepDefault(val, CVAR_String);
}
else
else
{
sc.ScriptMessage("Cannot set cvar default for non-config cvar '%s'", sc.String);
sc.MustGetString(); // to ignore the value of the cvar
}
}
else
{
sc.ScriptMessage("Unknown cvar '%s' in defcvars", sc.String);
sc.MustGetString(); // to ignore the value of the cvar
}
}
}

27
src/d_defcvars.h Normal file
View File

@ -0,0 +1,27 @@
//-----------------------------------------------------------------------------
// Copyright 2021 Rachael Alexanderson
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see http://www.gnu.org/licenses/
//
//
// DESCRIPTION:
// defcvars loader split from d_main.cpp
//
//-----------------------------------------------------------------------------
#define SHOULD_BLACKLIST(name) \
if (#name[0]==CurrentFindCVar[0]) \
if (strcmp(CurrentFindCVar, #name) == 0) \
blacklisted = true;