core/ConCmdManager.h
changeset 4112 31f38e6aae4e
parent 4076 a1aeeac165e7
child 4113 12e7f3b54c35
     1.1 --- a/core/ConCmdManager.h	Sat Aug 31 11:50:28 2013 -0700
     1.2 +++ b/core/ConCmdManager.h	Sat Aug 31 11:51:23 2013 -0700
     1.3 @@ -43,15 +43,11 @@
     1.4  #include "concmd_cleaner.h"
     1.5  #include <sm_stringhashmap.h>
     1.6  #include <am-utility.h>
     1.7 +#include <am-inlinelist.h>
     1.8 +#include <am-linkedlist.h>
     1.9  
    1.10  using namespace SourceHook;
    1.11  
    1.12 -enum CmdType
    1.13 -{
    1.14 -	Cmd_Server,
    1.15 -	Cmd_Admin,
    1.16 -};
    1.17 -
    1.18  struct AdminCmdInfo
    1.19  {
    1.20  	AdminCmdInfo()
    1.21 @@ -65,30 +61,44 @@
    1.22  	FlagBits eflags;		/* effective flags */
    1.23  };
    1.24  
    1.25 -struct CmdHook
    1.26 +struct ConCmdInfo;
    1.27 +
    1.28 +struct CmdHook : public ke::InlineListNode<CmdHook>
    1.29  {
    1.30 -	CmdHook()
    1.31 +	enum Type {
    1.32 +		Server,
    1.33 +		Client
    1.34 +	};
    1.35 +
    1.36 +	CmdHook(Type type, ConCmdInfo *cmd, IPluginFunction *fun, const char *description)
    1.37 +		: type(type),
    1.38 +		  info(cmd),
    1.39 +		  pf(fun),
    1.40 +		  helptext(description)
    1.41  	{
    1.42 -		pf = NULL;
    1.43 -		pAdmin = NULL;
    1.44  	}
    1.45 -	IPluginFunction *pf;	/* function hook */
    1.46 -	String helptext;		/* help text */
    1.47 -	AdminCmdInfo *pAdmin;	/* admin requirements, if any */
    1.48 +
    1.49 +	Type type;
    1.50 +	ConCmdInfo *info;
    1.51 +	IPluginFunction *pf;				/* function hook */
    1.52 +	ke::AString helptext;				/* help text */
    1.53 +	ke::AutoPtr<AdminCmdInfo> admin;	/* admin requirements, if any */
    1.54  };
    1.55  
    1.56 +typedef ke::InlineList<CmdHook> CmdHookList;
    1.57 +
    1.58  struct ConCmdInfo
    1.59  {
    1.60  	ConCmdInfo()
    1.61  	{
    1.62  		sourceMod = false;
    1.63  		pCmd = NULL;
    1.64 +		eflags = 0;
    1.65  	}
    1.66  	bool sourceMod;					/**< Determines whether or not concmd was created by a SourceMod plugin */
    1.67  	ConCommand *pCmd;				/**< Pointer to the command itself */
    1.68 -	List<CmdHook *> srvhooks;		/**< Hooks as a server command */
    1.69 -	List<CmdHook *> conhooks;		/**< Hooks as a console command */
    1.70 -	AdminCmdInfo admin;				/**< Admin info, if any */
    1.71 +	CmdHookList hooks;				/**< Hook list */
    1.72 +	FlagBits eflags;				/**< Effective admin flags */
    1.73  };
    1.74  
    1.75  typedef List<ConCmdInfo *> ConCmdList;
    1.76 @@ -139,8 +149,6 @@
    1.77  	void SetCommandClient(int client);
    1.78  	void AddToCmdList(ConCmdInfo *info);
    1.79  	void RemoveConCmd(ConCmdInfo *info, const char *cmd, bool is_read_safe, bool untrack);
    1.80 -	void RemoveConCmds(List<CmdHook *> &cmdlist);
    1.81 -	void RemoveConCmds(List<CmdHook *> &cmdlist, IPluginContext *pContext);
    1.82  	bool CheckAccess(int client, const char *cmd, AdminCmdInfo *pAdmin);
    1.83  
    1.84  	// Case insensitive