3 * ===============================================================
4 * SourceMod (C)2004-2007 AlliedModders LLC. All rights reserved.
5 * ===============================================================
7 * This file is not open source and may not be copied without explicit
8 * written permission of AlliedModders LLC. This file may not be redistributed
9 * in whole or significant part.
10 * For information, see LICENSE.txt or http://www.sourcemod.net/license.php
15 #ifndef _INCLUDE_SOURCEMOD_CCONCMDMANAGER_H_
16 #define _INCLUDE_SOURCEMOD_CCONCMDMANAGER_H_
18 #include "sm_globals.h"
19 #include "sourcemm_api.h"
20 #include "ForwardSys.h"
22 #include "sm_memtable.h"
24 #include <sh_string.h>
25 #include <IRootConsoleMenu.h>
26 #include <IAdminSystem.h>
28 using namespace SourceHook;
45 int cmdGrpId; /* index into cmdgroup string table */
46 FlagBits flags; /* default flags */
47 FlagBits eflags; /* effective flags */
57 IPluginFunction *pf; /* function hook */
58 String helptext; /* help text */
59 AdminCmdInfo *pAdmin; /* admin requirements, if any */
69 bool sourceMod; /**< Determines whether or not concmd was created by a SourceMod plugin */
70 ConCommand *pCmd; /**< Pointer to the command itself */
71 List<CmdHook *> srvhooks; /**< Hooks as a server command */
72 List<CmdHook *> conhooks; /**< Hooks as a console command */
75 class CConCmdManager :
77 public IRootConsoleCommand,
78 public IPluginsListener
80 friend void CommandCallback();
84 public: //SMGlobalClass
85 void OnSourceModAllInitialized();
86 void OnSourceModShutdown();
87 public: //IPluginsListener
88 void OnPluginDestroyed(IPlugin *plugin);
89 public: //IRootConsoleCommand
90 void OnRootConsoleCommand(const char *command, unsigned int argcount);
92 void AddServerCommand(IPluginFunction *pFunction, const char *name, const char *description, int flags);
93 void AddConsoleCommand(IPluginFunction *pFunction, const char *name, const char *description, int flags);
94 bool AddAdminCommand(IPluginFunction *pFunction,
98 const char *description,
100 ResultType DispatchClientCommand(int client, ResultType type);
101 void UpdateAdminCmdFlags(const char *cmd, OverrideType type, FlagBits bits);
103 void InternalDispatch();
104 ResultType RunAdminCommand(ConCmdInfo *pInfo, int client, int args);
105 ConCmdInfo *AddOrFindCommand(const char *name, const char *description, int flags);
106 void SetCommandClient(int client);
107 void AddToCmdList(ConCmdInfo *info);
108 void RemoveConCmd(ConCmdInfo *info);
109 void RemoveConCmds(List<CmdHook *> &cmdlist, IPluginContext *pContext);
110 bool CheckAccess(int client, const char *cmd, AdminCmdInfo *pAdmin);
112 Trie *m_pCmds; /* command lookup */
113 Trie *m_pCmdGrps; /* command group lookup */
114 List<ConCmdInfo *> m_CmdList; /* command list */
115 int m_CmdClient; /* current client */
116 BaseStringTable m_Strings; /* string table */
119 extern CConCmdManager g_ConCmds;
121 #endif // _INCLUDE_SOURCEMOD_CCONCMDMANAGER_H_