Prevent CV_NOSHOWHELP cvars from being accessed or modified through the console at all

This commit is contained in:
James R 2024-03-01 07:34:20 -08:00
parent f7f98ff6d1
commit a9e181cde5
2 changed files with 21 additions and 5 deletions

View file

@ -1374,9 +1374,9 @@ static const char *cv_null_string = "";
*
* \param name Variable to search for.
* \return Pointer to the variable if found, or NULL.
* \sa CV_FindNetVar
* \sa CV_FindVar
*/
consvar_t *CV_FindVar(const char *name)
static consvar_t *CV_FindVarInternal(const char *name)
{
consvar_t *cvar;
@ -1387,6 +1387,22 @@ consvar_t *CV_FindVar(const char *name)
return NULL;
}
/** Searches if a variable has been registered and is visible to the console.
*
* \param name Variable to search for.
* \return Pointer to the variable if found, or NULL.
* \sa CV_FindVarInternal
*/
consvar_t *CV_FindVar(const char *name)
{
consvar_t *cvar = CV_FindVarInternal(name);
if (cvar && (cvar->flags & CV_NOSHOWHELP))
return NULL;
return cvar;
}
/** Finds a net variable based on its identifier number.
*
* \param netid The variable's identifier number.
@ -1418,7 +1434,7 @@ static void Setvalue(consvar_t *var, const char *valstr, boolean stealth);
void CV_RegisterVar(consvar_t *variable)
{
// first check to see if it has already been defined
if (CV_FindVar(variable->name))
if (CV_FindVarInternal(variable->name))
{
CONS_Printf(M_GetText("Variable %s is already defined\n"), variable->name);
return;
@ -1792,7 +1808,7 @@ ReadDemoVar (const UINT8 **p, const char **return_value, boolean *return_stealth
SKIPSTRING (*p);
stealth = READUINT8 (*p);
cvar = CV_FindVar(name);
cvar = CV_FindVarInternal(name);
if (cvar)
{

View file

@ -134,7 +134,7 @@ typedef enum
CV_MODIFIED = 64, // this bit is set when cvar is modified
CV_SHOWMODIF = 128, // say something when modified
CV_SHOWMODIFONETIME = 256, // same but will be reset to 0 when modified, set in toggle
CV_NOSHOWHELP = 512, // Don't show variable in the HELP list Tails 08-13-2002
CV_NOSHOWHELP = 512, // Cannot be accessed by the console, but it still exists in the cvar list
CV_HIDDEN = 1024, // variable is not part of the cvar list so cannot be accessed by the console
// can only be set when we have the pointer to it
// used on menus