core/CConCmdManager.h
author David Anderson <dvander@alliedmods.net>
Fri Feb 16 03:47:10 2007 +0000 (2007-02-16)
changeset 501 e209a7296936
parent 500 868e9b19a872
child 513 0c299b5ad420
permissions -rw-r--r--
removed this potential feature, not useful enough
     1 /**
     2  * vim: set ts=4 :
     3  * ===============================================================
     4  * SourceMod (C)2004-2007 AlliedModders LLC.  All rights reserved.
     5  * ===============================================================
     6  *
     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
    11  *
    12  * Version: $Id$
    13  */
    14 
    15 #ifndef _INCLUDE_SOURCEMOD_CCONCMDMANAGER_H_
    16 #define _INCLUDE_SOURCEMOD_CCONCMDMANAGER_H_
    17 
    18 #include "sm_globals.h"
    19 #include "sourcemm_api.h"
    20 #include "ForwardSys.h"
    21 #include "sm_trie.h"
    22 #include <sh_list.h>
    23 #include <IRootConsoleMenu.h>
    24 
    25 using namespace SourceHook;
    26 
    27 enum CmdType
    28 {
    29 	Cmd_Server,
    30 	Cmd_Console,
    31 	Cmd_Client
    32 };
    33 
    34 struct ConCmdInfo
    35 {
    36 	ConCmdInfo()
    37 	{
    38 		sourceMod = false;
    39 		pCmd = NULL;
    40 		srvhooks = NULL;
    41 		conhooks = NULL;
    42 	}
    43 	bool sourceMod;					/**< Determines whether or not concmd was created by a SourceMod plugin */
    44 	ConCommand *pCmd;				/**< Pointer to the command itself */
    45 	IChangeableForward *srvhooks;	/**< Hooks on this name as a server command */
    46 	IChangeableForward *conhooks;	/**< Hooks on this name as a console command */
    47 };
    48 
    49 class CConCmdManager :
    50 	public SMGlobalClass,
    51 	public IRootConsoleCommand,
    52 	public IPluginsListener
    53 {
    54 	friend void CommandCallback();
    55 public:
    56 	CConCmdManager();
    57 	~CConCmdManager();
    58 public: //SMGlobalClass
    59 	void OnSourceModAllInitialized();
    60 	void OnSourceModShutdown();
    61 public: //IPluginsListener
    62 	void OnPluginLoaded(IPlugin *plugin);
    63 	void OnPluginDestroyed(IPlugin *plugin);
    64 public: //IRootConsoleCommand
    65 	void OnRootConsoleCommand(const char *command, unsigned int argcount);
    66 public:
    67 	void AddServerCommand(IPluginFunction *pFunction, const char *name, const char *description, int flags);
    68 	void AddConsoleCommand(IPluginFunction *pFunction, const char *name, const char *description, int flags);
    69 	ResultType DispatchClientCommand(int client, ResultType type);
    70 private:
    71 	void InternalDispatch();
    72 	ConCmdInfo *AddOrFindCommand(const char *name, const char *description, int flags);
    73 	void SetCommandClient(int client);
    74 	void AddToCmdList(ConCmdInfo *info);
    75 	void RemoveConCmd(ConCmdInfo *info);
    76 private:
    77 	Trie *m_pCmds;
    78 	List<ConCmdInfo *> m_CmdList;
    79 	int m_CmdClient;
    80 };
    81 
    82 extern CConCmdManager g_ConCmds;
    83 
    84 #endif // _INCLUDE_SOURCEMOD_CCONCMDMANAGER_H_
    85