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:
parent
aab8c6ac9f
commit
02f188899e
@ -1413,7 +1413,7 @@ static cell_t sm_CommandIteratorNext(IPluginContext *pContext, const cell_t *par
|
|||||||
return iter->iter != cmds.end();
|
return iter->iter != cmds.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
static cell_t sm_CommandIteratorFlags(IPluginContext *pContext, const cell_t *params)
|
static cell_t sm_CommandIteratorAdminFlags(IPluginContext *pContext, const cell_t *params)
|
||||||
{
|
{
|
||||||
GlobCmdIter *iter;
|
GlobCmdIter *iter;
|
||||||
HandleError err;
|
HandleError err;
|
||||||
@ -1434,6 +1434,27 @@ static cell_t sm_CommandIteratorFlags(IPluginContext *pContext, const cell_t *pa
|
|||||||
return pInfo->eflags;
|
return pInfo->eflags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static cell_t sm_CommandIteratorConVarFlags(IPluginContext *pContext, const cell_t *params)
|
||||||
|
{
|
||||||
|
GlobCmdIter *iter;
|
||||||
|
HandleError err;
|
||||||
|
HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);
|
||||||
|
|
||||||
|
if ((err = handlesys->ReadHandle(params[1], hCmdIterType, &sec, (void **)&iter))
|
||||||
|
!= HandleError_None)
|
||||||
|
{
|
||||||
|
return pContext->ThrowNativeError("Invalid CommandIterator Handle %x", params[1]);
|
||||||
|
}
|
||||||
|
const List<ConCmdInfo *> &cmds = g_ConCmds.GetCommandList();
|
||||||
|
if (!iter->started || iter->iter == cmds.end())
|
||||||
|
{
|
||||||
|
return pContext->ThrowNativeError("Invalid CommandIterator position");
|
||||||
|
}
|
||||||
|
|
||||||
|
ConCmdInfo *pInfo = (*(iter->iter));
|
||||||
|
return pInfo->pCmd->m_nFlags;
|
||||||
|
}
|
||||||
|
|
||||||
static cell_t sm_CommandIteratorGetDesc(IPluginContext *pContext, const cell_t *params)
|
static cell_t sm_CommandIteratorGetDesc(IPluginContext *pContext, const cell_t *params)
|
||||||
{
|
{
|
||||||
GlobCmdIter *iter;
|
GlobCmdIter *iter;
|
||||||
@ -1574,7 +1595,9 @@ REGISTER_NATIVES(consoleNatives)
|
|||||||
{"CommandIterator.Next", sm_CommandIteratorNext},
|
{"CommandIterator.Next", sm_CommandIteratorNext},
|
||||||
{"CommandIterator.GetDescription", sm_CommandIteratorGetDesc},
|
{"CommandIterator.GetDescription", sm_CommandIteratorGetDesc},
|
||||||
{"CommandIterator.GetName", sm_CommandIteratorGetName},
|
{"CommandIterator.GetName", sm_CommandIteratorGetName},
|
||||||
{"CommandIterator.Flags.get", sm_CommandIteratorFlags},
|
{"CommandIterator.Flags.get", sm_CommandIteratorAdminFlags},
|
||||||
|
{"CommandIterator.AdminFlags.get", sm_CommandIteratorAdminFlags},
|
||||||
|
{"CommandIterator.ConVarFlags.get", sm_CommandIteratorConVarFlags},
|
||||||
{"CommandIterator.Plugin.get", sm_CommandIteratorPlugin},
|
{"CommandIterator.Plugin.get", sm_CommandIteratorPlugin},
|
||||||
|
|
||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
|
@ -98,7 +98,7 @@ public Action HelpCmd(int client, int args)
|
|||||||
cmdIter.GetName(name, sizeof(name));
|
cmdIter.GetName(name, sizeof(name));
|
||||||
cmdIter.GetDescription(desc, sizeof(desc));
|
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);
|
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));
|
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++;
|
i++;
|
||||||
}
|
}
|
||||||
@ -142,7 +142,7 @@ public Action HelpCmd(int client, int args)
|
|||||||
cmdIter.GetName(name, sizeof(name));
|
cmdIter.GetName(name, sizeof(name));
|
||||||
cmdIter.GetDescription(desc, sizeof(desc));
|
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++;
|
i++;
|
||||||
PrintToConsole(client, "[%03d] %s - %s", i+StartCmd, name, (desc[0] == '\0') ? noDesc : desc);
|
PrintToConsole(client, "[%03d] %s - %s", i+StartCmd, name, (desc[0] == '\0') ? noDesc : desc);
|
||||||
|
@ -555,12 +555,29 @@ methodmap CommandIterator < Handle {
|
|||||||
public native get();
|
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.
|
// @error Invalid iterator position.
|
||||||
|
// @deprecated Use .AdminFlags instead.
|
||||||
|
#pragma deprecated Use .AdminFlags instead.
|
||||||
property int Flags {
|
property int Flags {
|
||||||
public native get();
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user