core/ConsoleDetours.h
author David Anderson <dvander@alliedmods.net>
Mon Dec 30 17:51:01 2013 -0500 (2013-12-30)
changeset 4191 16418a751d51
parent 4139 de7d1cd00703
permissions -rw-r--r--
Various build fixes (bug 5997 part 14, r=ds).
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"
skamonkey@4139
    36
#include <IForwardSys.h>
dvander@4071
    37
#include <sm_stringhashmap.h>
dvander@2807
    38
dvander@2841
    39
class ConsoleDetours :
dvander@2841
    40
	public SMGlobalClass,
dvander@2841
    41
	public IFeatureProvider
dvander@2807
    42
{
dvander@2807
    43
	friend class PlayerManager;
dvander@2807
    44
	friend class GenericCommandHooker;
dvander@2807
    45
dvander@2807
    46
public:
dvander@2807
    47
	ConsoleDetours();
dvander@2807
    48
public: //SMGlobalClass
dvander@2807
    49
	void OnSourceModAllInitialized();
dvander@2807
    50
	void OnSourceModShutdown();
dvander@2841
    51
public: //IFeatureProvider
dvander@2841
    52
	FeatureStatus GetFeatureStatus(FeatureType type, const char *name);
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
public:
dvander@2841
    64
	FeatureStatus GetStatus();
dvander@2841
    65
	bool IsEnabled()
dvander@2807
    66
	{
dvander@2841
    67
		return status == FeatureStatus_Available;
dvander@2807
    68
	}
dvander@2807
    69
private:
dvander@2841
    70
	FeatureStatus status;
dvander@2807
    71
	IChangeableForward *m_pForward;
dvander@4071
    72
	StringHashMap<IChangeableForward *> m_Listeners;
dvander@2807
    73
};
dvander@2807
    74
dvander@2807
    75
extern ConsoleDetours g_ConsoleDetours;
dvander@2807
    76
dvander@2807
    77
#endif /* _INCLUDE_SOURCEMOD_CONSOLE_DETOURS_H_ */
dvander@2807
    78