Add CommandIterator.ConVarFlags property (#1869)

* Add CommandIterator.ConVarFlags property

Allow to access the convar flags `FCVAR_*` value from the iterator.
The CommandIterator.Flags property should have been called `AdminFlags`,
but it's too late to change that now.

* Switch admin help menu to use CommandIterator.ConVarFlags

No need to lookup the convar again.

* Deprecate CommandIterator.Flags

Rename it to .AdminFlags now that we have two kinds of flags exposed
on the iterator.
This commit is contained in:
peace-maker
2022-12-04 12:24:56 +01:00
committed by GitHub
parent aab8c6ac9f
commit 02f188899e
3 changed files with 46 additions and 6 deletions
+3 -3
View File
@@ -98,7 +98,7 @@ public Action HelpCmd(int client, int args)
cmdIter.GetName(name, sizeof(name));
cmdIter.GetDescription(desc, sizeof(desc));
if ((StrContains(name, arg, false) != -1) && ((FindConVar(name).Flags & FCVAR_HIDDEN) == 0) && CheckCommandAccess(client, name, cmdIter.Flags))
if ((StrContains(name, arg, false) != -1) && ((cmdIter.ConVarFlags & FCVAR_HIDDEN) == 0) && CheckCommandAccess(client, name, cmdIter.Flags))
{
PrintToConsole(client, "[%03d] %s - %s", i++, name, (desc[0] == '\0') ? noDesc : desc);
}
@@ -120,7 +120,7 @@ public Action HelpCmd(int client, int args)
{
cmdIter.GetName(name, sizeof(name));
if (((FindConVar(name).Flags & FCVAR_HIDDEN) == 0) && CheckCommandAccess(client, name, cmdIter.Flags))
if (((cmdIter.ConVarFlags & FCVAR_HIDDEN) == 0) && CheckCommandAccess(client, name, cmdIter.Flags))
{
i++;
}
@@ -142,7 +142,7 @@ public Action HelpCmd(int client, int args)
cmdIter.GetName(name, sizeof(name));
cmdIter.GetDescription(desc, sizeof(desc));
if (((FindConVar(name).Flags & FCVAR_HIDDEN) == 0) && CheckCommandAccess(client, name, cmdIter.Flags))
if (((cmdIter.ConVarFlags & FCVAR_HIDDEN) == 0) && CheckCommandAccess(client, name, cmdIter.Flags))
{
i++;
PrintToConsole(client, "[%03d] %s - %s", i+StartCmd, name, (desc[0] == '\0') ? noDesc : desc);
+18 -1
View File
@@ -555,12 +555,29 @@ methodmap CommandIterator < Handle {
public native get();
}
// Retrieves the command's default flags
// This property is deprecated. Use .AdminFlags instead.
// Retrieves the command's effective admin flags.
//
// @error Invalid iterator position.
// @deprecated Use .AdminFlags instead.
#pragma deprecated Use .AdminFlags instead.
property int Flags {
public native get();
}
// Retrieves the command's effective admin flags.
//
// @error Invalid iterator position.
property int AdminFlags {
public native get();
}
// Retrieves the command's convar flags.
//
// @error Invalid iterator position.
property int ConVarFlags {
public native get();
}
}
/**