diff --git a/core/ConCmdManager.cpp b/core/ConCmdManager.cpp index 4493d7ff..a1954825 100644 --- a/core/ConCmdManager.cpp +++ b/core/ConCmdManager.cpp @@ -559,44 +559,6 @@ bool ConCmdManager::CheckAccess(int client, const char *cmd, AdminCmdInfo *pAdmi return false; } -bool ConCmdManager::AddConsoleCommand(IPluginFunction *pFunction, - const char *name, - const char *description, - int flags) -{ - ConCmdInfo *pInfo = AddOrFindCommand(name, description, flags); - - if (!pInfo) - { - return false; - } - - CmdHook *pHook = new CmdHook(); - - pHook->pf = pFunction; - if (description && description[0]) - { - pHook->helptext.assign(description); - } - pInfo->conhooks.push_back(pHook); - - /* Add to the plugin */ - CmdList *pList; - IPlugin *pPlugin = g_PluginSys.GetPluginByCtx(pFunction->GetParentContext()->GetContext()); - if (!pPlugin->GetProperty("CommandList", (void **)&pList)) - { - pList = new CmdList(); - pPlugin->SetProperty("CommandList", pList); - } - PlCmdInfo info; - info.pInfo = pInfo; - info.type = Cmd_Console; - info.pHook = pHook; - AddToPlCmdList(pList, info); - - return true; -} - bool ConCmdManager::AddAdminCommand(IPluginFunction *pFunction, const char *name, const char *group, @@ -658,7 +620,6 @@ bool ConCmdManager::AddAdminCommand(IPluginFunction *pFunction, /* Finally, add the hook */ pInfo->conhooks.push_back(pHook); pInfo->admin = *(pHook->pAdmin); - pInfo->is_admin_set = true; /* Now add to the plugin */ CmdList *pList; @@ -803,7 +764,6 @@ void ConCmdManager::UpdateAdminCmdFlags(const char *cmd, OverrideType type, Flag pInfo->admin = *(pHook->pAdmin); } } - pInfo->is_admin_set = true; } else if (type == Override_CommandGroup) { @@ -837,7 +797,6 @@ void ConCmdManager::UpdateAdminCmdFlags(const char *cmd, OverrideType type, Flag } } } - pInfo->is_admin_set = true; } } @@ -905,7 +864,7 @@ bool ConCmdManager::LookForCommandAdminFlags(const char *cmd, FlagBits *pFlags) *pFlags = pInfo->admin.eflags; - return pInfo->is_admin_set; + return true; } ConCmdInfo *ConCmdManager::AddOrFindCommand(const char *name, const char *description, int flags) @@ -942,7 +901,6 @@ ConCmdInfo *ConCmdManager::AddOrFindCommand(const char *name, const char *descri } pInfo->pCmd = pCmd; - pInfo->is_admin_set = false; sm_trie_insert(m_pCmds, name, pInfo); AddToCmdList(pInfo); @@ -995,13 +953,9 @@ void ConCmdManager::OnRootConsoleCommand(const char *cmdname, const CCommand &co { type = "server"; } - else if (cmd.type == Cmd_Console) - { - type = "console"; - } else if (cmd.type == Cmd_Admin) { - type = "admin"; + type = (cmd.pInfo->admin.eflags == 0)?"console":"admin"; } name = cmd.pInfo->pCmd->GetName(); if (cmd.pHook->helptext.size()) diff --git a/core/ConCmdManager.h b/core/ConCmdManager.h index 38ee6b96..48f3c5f7 100644 --- a/core/ConCmdManager.h +++ b/core/ConCmdManager.h @@ -48,7 +48,6 @@ using namespace SourceHook; enum CmdType { Cmd_Server, - Cmd_Console, Cmd_Admin, }; @@ -89,7 +88,6 @@ struct ConCmdInfo List srvhooks; /**< Hooks as a server command */ List conhooks; /**< Hooks as a console command */ AdminCmdInfo admin; /**< Admin info, if any */ - bool is_admin_set; /**< Whether or not admin info is set */ }; typedef List ConCmdList; @@ -119,7 +117,6 @@ public: //IConCommandTracker void OnUnlinkConCommandBase(ConCommandBase *pBase, const char *name, bool is_read_safe); public: bool AddServerCommand(IPluginFunction *pFunction, const char *name, const char *description, int flags); - bool AddConsoleCommand(IPluginFunction *pFunction, const char *name, const char *description, int flags); bool AddAdminCommand(IPluginFunction *pFunction, const char *name, const char *group, diff --git a/core/CoreConfig.cpp b/core/CoreConfig.cpp index 010667db..f9d3141f 100644 --- a/core/CoreConfig.cpp +++ b/core/CoreConfig.cpp @@ -193,17 +193,30 @@ void CoreConfig::OnRootConsoleCommand(const char *cmdname, const CCommand &comma if (res == ConfigResult_Reject) { - g_RootMenu.ConsolePrint("[SM] Could not set config option \"%s\" to \"%s\" (%s)", option, value, error); + g_RootMenu.ConsolePrint("[SM] Could not set config option \"%s\" to \"%s\". (%s)", option, value, error); } else if (res == ConfigResult_Ignore) { g_RootMenu.ConsolePrint("[SM] No such config option \"%s\" exists.", option); } else { - g_RootMenu.ConsolePrint("Config option \"%s\" successfully set to \"%s.\"", option, value); + g_RootMenu.ConsolePrint("[SM] Config option \"%s\" successfully set to \"%s\".", option, value); } + return; + } else if (argcount >= 3) { + const char *option = command.Arg(2); + + const char *value = GetCoreConfigValue(option); + + if (value == NULL) + { + g_RootMenu.ConsolePrint("[SM] No such config option \"%s\" exists.", option); + } else { + g_RootMenu.ConsolePrint("[SM] Config option \"%s\" is set to \"%s\".", option, value); + } + return; } - g_RootMenu.ConsolePrint("[SM] Usage: sm config