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_CONCMDMANAGER_H_
16 #define _INCLUDE_SOURCEMOD_CONCMDMANAGER_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 */
77 public IRootConsoleCommand,
78 public IPluginsListener
80 friend void CommandCallback();
84 public: //SMGlobalClass
85 void OnSourceModAllInitialized();
86 void OnSourceModShutdown();
87 void OnSourceModPluginsLoaded();
88 public: //IPluginsListener
89 void OnPluginDestroyed(IPlugin *plugin);
90 public: //IRootConsoleCommand
91 void OnRootConsoleCommand(const char *command, unsigned int argcount);
93 bool AddServerCommand(IPluginFunction *pFunction, const char *name, const char *description, int flags);
94 bool AddConsoleCommand(IPluginFunction *pFunction, const char *name, const char *description, int flags);
95 bool AddAdminCommand(IPluginFunction *pFunction,
99 const char *description,
101 ResultType DispatchClientCommand(int client, ResultType type);
102 void UpdateAdminCmdFlags(const char *cmd, OverrideType type, FlagBits bits);
103 void NotifyExecDone(const char *file);
105 void InternalDispatch();
106 ResultType RunAdminCommand(ConCmdInfo *pInfo, int client, int args);
107 ConCmdInfo *AddOrFindCommand(const char *name, const char *description, int flags);
108 void SetCommandClient(int client);
109 void AddToCmdList(ConCmdInfo *info);
110 void RemoveConCmd(ConCmdInfo *info);
111 void RemoveConCmds(List<CmdHook *> &cmdlist, IPluginContext *pContext);
112 bool CheckAccess(int client, const char *cmd, AdminCmdInfo *pAdmin);
115 inline int GetCommandClient()
120 Trie *m_pCmds; /* command lookup */
121 Trie *m_pCmdGrps; /* command group lookup */
122 List<ConCmdInfo *> m_CmdList; /* command list */
123 int m_CmdClient; /* current client */
124 BaseStringTable m_Strings; /* string table */
125 ConVar *m_pServerCfgFile; /* servercfgfile cvar */
126 ConCommand *m_pExecCmd; /* "exec" command */
127 IForward *m_pServerCfgFwd; /* server config forward */
128 bool m_bServerCfgDone; /* marks whether a servercfg was detected */
131 extern ConCmdManager g_ConCmds;
133 #endif // _INCLUDE_SOURCEMOD_CONCMDMANAGER_H_