core/ConsoleDetours.h
author David Anderson <dvander@alliedmods.net>
Fri Oct 02 03:47:42 2009 -0700 (2009-10-02)
changeset 2815 2c7137f077fe
parent 2807 973290878e2f
child 2841 dde3dd0b4b8b
permissions -rw-r--r--
Re-enabled PDB files.
dvander@2807
     1
/**
dvander@2807
     2
 * vim: set ts=4 sw=4 tw=99 noet :
dvander@2807
     3
 * =============================================================================
dvander@2807
     4
 * SourceMod
dvander@2807
     5
 * Copyright (C) 2004-2009 AlliedModders LLC.  All rights reserved.
dvander@2807
     6
 * =============================================================================
dvander@2807
     7
 *
dvander@2807
     8
 * This program is free software; you can redistribute it and/or modify it under
dvander@2807
     9
 * the terms of the GNU General Public License, version 3.0, as published by the
dvander@2807
    10
 * Free Software Foundation.
dvander@2807
    11
 * 
dvander@2807
    12
 * This program is distributed in the hope that it will be useful, but WITHOUT
dvander@2807
    13
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
dvander@2807
    14
 * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
dvander@2807
    15
 * details.
dvander@2807
    16
 *
dvander@2807
    17
 * You should have received a copy of the GNU General Public License along with
dvander@2807
    18
 * this program.  If not, see <http://www.gnu.org/licenses/>.
dvander@2807
    19
 *
dvander@2807
    20
 * As a special exception, AlliedModders LLC gives you permission to link the
dvander@2807
    21
 * code of this program (as well as its derivative works) to "Half-Life 2," the
dvander@2807
    22
 * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
dvander@2807
    23
 * by the Valve Corporation.  You must obey the GNU General Public License in
dvander@2807
    24
 * all respects for all other code used.  Additionally, AlliedModders LLC grants
dvander@2807
    25
 * this exception to all derivative works.  AlliedModders LLC defines further
dvander@2807
    26
 * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
dvander@2807
    27
 * or <http://www.sourcemod.net/license.php>.
dvander@2807
    28
 *
dvander@2807
    29
 * Version: $Id$
dvander@2807
    30
 */
dvander@2807
    31
#ifndef _INCLUDE_SOURCEMOD_CONSOLE_DETOURS_H_
dvander@2807
    32
#define _INCLUDE_SOURCEMOD_CONSOLE_DETOURS_H_
dvander@2807
    33
dvander@2807
    34
#include "sm_globals.h"
dvander@2807
    35
#include "sourcemm_api.h"
dvander@2807
    36
#include "ForwardSys.h"
dvander@2807
    37
#include <sm_trie_tpl.h>
dvander@2807
    38
dvander@2807
    39
class ConsoleDetours : public SMGlobalClass
dvander@2807
    40
{
dvander@2807
    41
	friend class PlayerManager;
dvander@2807
    42
	friend class GenericCommandHooker;
dvander@2807
    43
dvander@2807
    44
	struct Listener
dvander@2807
    45
	{
dvander@2807
    46
		IChangeableForward *forward;
dvander@2807
    47
	};
dvander@2807
    48
public:
dvander@2807
    49
	ConsoleDetours();
dvander@2807
    50
public: //SMGlobalClass
dvander@2807
    51
	void OnSourceModAllInitialized();
dvander@2807
    52
	void OnSourceModShutdown();
dvander@2807
    53
public:
dvander@2807
    54
	bool AddListener(IPluginFunction *fun, const char *command);
dvander@2807
    55
	bool RemoveListener(IPluginFunction *fun, const char *command);
dvander@2807
    56
private:
dvander@2807
    57
	cell_t InternalDispatch(int client, const CCommand& args);
dvander@2807
    58
#if SOURCE_ENGINE >= SE_ORANGEBOX
dvander@2807
    59
	static cell_t Dispatch(ConCommand *pBase, const CCommand& args);
dvander@2807
    60
#else
dvander@2807
    61
	static cell_t Dispatch(ConCommand *pBase);
dvander@2807
    62
#endif
dvander@2807
    63
	bool IsAvailable();
dvander@2807
    64
public:
dvander@2807
    65
	inline bool IsEnabled()
dvander@2807
    66
	{
dvander@2807
    67
		return isEnabled;
dvander@2807
    68
	}
dvander@2807
    69
private:
dvander@2807
    70
	bool triedToEnable;
dvander@2807
    71
	bool isEnabled;
dvander@2807
    72
	IChangeableForward *m_pForward;
dvander@2807
    73
	KTrie<Listener*> m_CmdLookup;
dvander@2807
    74
	List<Listener*> m_Listeners;
dvander@2807
    75
};
dvander@2807
    76
dvander@2807
    77
extern ConsoleDetours g_ConsoleDetours;
dvander@2807
    78
dvander@2807
    79
#endif /* _INCLUDE_SOURCEMOD_CONSOLE_DETOURS_H_ */
dvander@2807
    80