mirror of
https://github.com/YGGverse/xash3d-fwgs.git
synced 2025-01-13 00:28:15 +00:00
engine: cvar: move common checks if cvar can be updated into generic function
This commit is contained in:
parent
c111a59639
commit
6c3fee7f27
@ -563,6 +563,27 @@ void Cvar_RegisterVariable( convar_t *var )
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static qboolean Cvar_CanSet( const convar_t *cv )
|
||||||
|
{
|
||||||
|
if( FBitSet( cv->flags, FCVAR_READ_ONLY ))
|
||||||
|
{
|
||||||
|
Con_Printf( "%s is read-only.\n", cv->name );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( FBitSet( cv->flags, FCVAR_CHEAT ) && !host.allow_cheats )
|
||||||
|
{
|
||||||
|
Con_Printf( "%s is cheat protected.\n", cv->name );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// just tell user about deferred changes
|
||||||
|
if( FBitSet( cv->flags, FCVAR_LATCH ) && ( SV_Active() || CL_Active( )))
|
||||||
|
Con_Printf( "%s will be changed upon restarting.\n", cv->name );
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
============
|
============
|
||||||
Cvar_Set2
|
Cvar_Set2
|
||||||
@ -633,21 +654,8 @@ static convar_t *Cvar_Set2( const char *var_name, const char *value )
|
|||||||
|
|
||||||
if( !force )
|
if( !force )
|
||||||
{
|
{
|
||||||
if( FBitSet( var->flags, FCVAR_READ_ONLY ))
|
if( !Cvar_CanSet( var ))
|
||||||
{
|
|
||||||
Con_Printf( "%s is read-only.\n", var->name );
|
|
||||||
return var;
|
return var;
|
||||||
}
|
|
||||||
|
|
||||||
if( FBitSet( var->flags, FCVAR_CHEAT ) && !host.allow_cheats )
|
|
||||||
{
|
|
||||||
Con_Printf( "%s is cheat protected.\n", var->name );
|
|
||||||
return var;
|
|
||||||
}
|
|
||||||
|
|
||||||
// just tell user about deferred changes
|
|
||||||
if( FBitSet( var->flags, FCVAR_LATCH ) && ( SV_Active() || CL_Active( )))
|
|
||||||
Con_Printf( "%s will be changed upon restarting.\n", var->name );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pszValue = Cvar_ValidateString( var, value );
|
pszValue = Cvar_ValidateString( var, value );
|
||||||
@ -694,21 +702,8 @@ void Cvar_DirectSet( convar_t *var, const char *value )
|
|||||||
return; // how this possible?
|
return; // how this possible?
|
||||||
}
|
}
|
||||||
|
|
||||||
if( FBitSet( var->flags, FCVAR_READ_ONLY ))
|
if( !Cvar_CanSet( var ))
|
||||||
{
|
|
||||||
Con_Printf( "%s is read-only.\n", var->name );
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
if( FBitSet( var->flags, FCVAR_CHEAT ) && !host.allow_cheats )
|
|
||||||
{
|
|
||||||
Con_Printf( "%s is cheat protected.\n", var->name );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// just tell user about deferred changes
|
|
||||||
if( FBitSet( var->flags, FCVAR_LATCH ) && ( SV_Active() || CL_Active( )))
|
|
||||||
Con_Printf( "%s will be changed upon restarting.\n", var->name );
|
|
||||||
|
|
||||||
// check value
|
// check value
|
||||||
if( !value )
|
if( !value )
|
||||||
|
Loading…
Reference in New Issue
Block a user