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:
+25
-2
@@ -1413,7 +1413,7 @@ static cell_t sm_CommandIteratorNext(IPluginContext *pContext, const cell_t *par
|
||||
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;
|
||||
HandleError err;
|
||||
@@ -1434,6 +1434,27 @@ static cell_t sm_CommandIteratorFlags(IPluginContext *pContext, const cell_t *pa
|
||||
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)
|
||||
{
|
||||
GlobCmdIter *iter;
|
||||
@@ -1574,7 +1595,9 @@ REGISTER_NATIVES(consoleNatives)
|
||||
{"CommandIterator.Next", sm_CommandIteratorNext},
|
||||
{"CommandIterator.GetDescription", sm_CommandIteratorGetDesc},
|
||||
{"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},
|
||||
|
||||
{NULL, NULL}
|
||||
|
||||
Reference in New Issue
Block a user