extensions/sdktools/extension.h
author Fyren <fyrenmoo@gmail.com>
Mon Sep 07 17:09:28 2009 -0700 (2009-09-07)
changeset 2796 cd0bf02b99cf
parent 2790 6dd851ba15fd
child 2838 d0b440ee7a64
permissions -rw-r--r--
Respect clientside mutes and add fixed client listening API (bug 3818, r=pred,dvander).
ds@783
     1
/**
ds@783
     2
 * vim: set ts=4 :
ds@1330
     3
 * =============================================================================
dvander@1233
     4
 * SourceMod SDKTools Extension
ds@1947
     5
 * Copyright (C) 2004-2008 AlliedModders LLC.  All rights reserved.
ds@1330
     6
 * =============================================================================
ds@783
     7
 *
ds@1330
     8
 * This program is free software; you can redistribute it and/or modify it under
ds@1330
     9
 * the terms of the GNU General Public License, version 3.0, as published by the
ds@1330
    10
 * Free Software Foundation.
dvander@1233
    11
 * 
ds@1330
    12
 * This program is distributed in the hope that it will be useful, but WITHOUT
ds@1330
    13
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
ds@1330
    14
 * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
ds@1330
    15
 * details.
dvander@1233
    16
 *
ds@1330
    17
 * You should have received a copy of the GNU General Public License along with
ds@1330
    18
 * this program.  If not, see <http://www.gnu.org/licenses/>.
dvander@1233
    19
 *
ds@1330
    20
 * As a special exception, AlliedModders LLC gives you permission to link the
ds@1330
    21
 * code of this program (as well as its derivative works) to "Half-Life 2," the
ds@1330
    22
 * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
ds@1330
    23
 * by the Valve Corporation.  You must obey the GNU General Public License in
ds@1330
    24
 * all respects for all other code used.  Additionally, AlliedModders LLC grants
ds@1330
    25
 * this exception to all derivative works.  AlliedModders LLC defines further
ds@1330
    26
 * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
ds@1330
    27
 * or <http://www.sourcemod.net/license.php>.
ds@783
    28
 *
ds@783
    29
 * Version: $Id$
ds@783
    30
 */
ds@783
    31
ds@783
    32
#ifndef _INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_
ds@783
    33
#define _INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_
ds@783
    34
ds@783
    35
/**
ds@783
    36
 * @file extension.h
ds@783
    37
 * @brief SDK Tools extension code header.
ds@783
    38
 */
ds@783
    39
ds@783
    40
#include "smsdk_ext.h"
ds@783
    41
#include <IBinTools.h>
ds@783
    42
#include <IPlayerHelpers.h>
faluco@1031
    43
#include <IGameHelpers.h>
faluco@1075
    44
#include <IEngineTrace.h>
dvander@1047
    45
#include <IEngineSound.h>
teame06@1236
    46
#include <ivoiceserver.h>
teame06@1239
    47
#include <iplayerinfo.h>
ds@2051
    48
#include <server_class.h>
ds@2051
    49
#include <datamap.h>
dvander@1052
    50
#include <convar.h>
faluco@1769
    51
#include <iserver.h>
faluco@1769
    52
#include <cdll_int.h>
ds@783
    53
ds@783
    54
/**
ds@783
    55
 * @brief Implementation of the SDK Tools extension.
ds@783
    56
 * Note: Uncomment one of the pre-defined virtual functions in order to use it.
ds@783
    57
 */
dvander@1052
    58
class SDKTools : 
dvander@1052
    59
	public SDKExtension, 
dvander@1052
    60
	public IHandleTypeDispatch,
teame06@1235
    61
	public IConCommandBaseAccessor,
dvander@1628
    62
	public IClientListener,
dvander@1628
    63
	public ICommandTargetProcessor
ds@783
    64
{
dvander@1052
    65
public: //public IHandleTypeDispatch
dvander@950
    66
	void OnHandleDestroy(HandleType_t type, void *object);
dvander@1052
    67
public: //public SDKExtension
ds@783
    68
	virtual bool SDK_OnLoad(char *error, size_t maxlength, bool late);
dvander@950
    69
	virtual void SDK_OnUnload();
ds@783
    70
	virtual void SDK_OnAllLoaded();
ds@783
    71
	//virtual void SDK_OnPauseChange(bool paused);
ds@783
    72
	virtual bool QueryRunning(char *error, size_t maxlength);
dvander@1023
    73
	virtual bool QueryInterfaceDrop(SMInterface *pInterface);
dvander@1023
    74
	virtual void NotifyInterfaceDrop(SMInterface *pInterface);
faluco@1993
    75
	virtual void OnCoreMapStart(edict_t *pEdictList, int edictCount, int clientMax);
dvander@2790
    76
	const char *GetExtensionVerString();
dvander@2790
    77
	const char *GetExtensionDateString();
ds@783
    78
public:
ds@783
    79
#if defined SMEXT_CONF_METAMOD
ds@783
    80
	virtual bool SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlen, bool late);
ds@783
    81
	//virtual bool SDK_OnMetamodUnload(char *error, size_t maxlen);
ds@783
    82
	//virtual bool SDK_OnMetamodPauseChange(bool paused, char *error, size_t maxlen);
ds@783
    83
#endif
dvander@1052
    84
public: //IConCommandBaseAccessor
dvander@1052
    85
	bool RegisterConCommandBase(ConCommandBase *pVar);
teame06@1235
    86
public: //IClientListner
pred@2711
    87
	void OnClientPutInServer(int client);
teame06@1235
    88
	void OnClientDisconnecting(int client);
teame06@1235
    89
public: // IVoiceServer
teame06@1235
    90
	bool OnSetClientListening(int iReceiver, int iSender, bool bListen);
dvander@2044
    91
	void VoiceInit();
fyrenmoo@2796
    92
#if SOURCE_ENGINE >= SE_ORANGEBOX
fyrenmoo@2796
    93
	void OnClientCommand(edict_t *pEntity, const CCommand &args);
fyrenmoo@2796
    94
#else
fyrenmoo@2796
    95
	void OnClientCommand(edict_t *pEntity);
fyrenmoo@2796
    96
#endif
fyrenmoo@2796
    97
dvander@1628
    98
public: //ICommandTargetProcessor
dvander@1628
    99
	bool ProcessCommandTarget(cmd_target_info_t *info);
faluco@1262
   100
public:
faluco@1262
   101
	bool LevelInit(char const *pMapName, char const *pMapEntities, char const *pOldLevel, char const *pLandmarkName, bool loadGame, bool background);
faluco@1613
   102
	void OnServerActivate(edict_t *pEdictList, int edictCount, int clientMax);
ds@783
   103
};
ds@783
   104
teame06@1235
   105
extern SDKTools g_SdkTools;
ds@1114
   106
/* Interfaces from engine or gamedll */
ds@783
   107
extern IServerGameEnts *gameents;
faluco@1075
   108
extern IEngineTrace *enginetrace;
ds@1114
   109
extern IEngineSound *engsound;
ds@1114
   110
extern INetworkStringTableContainer *netstringtables;
dvander@1169
   111
extern IServerPluginHelpers *pluginhelpers;
faluco@1219
   112
extern IServerGameClients *serverClients;
teame06@1235
   113
extern IVoiceServer *voiceserver;
teame06@1239
   114
extern IPlayerInfoManager *playerinfomngr;
faluco@1560
   115
extern ICvar *icvar;
faluco@1769
   116
extern IServer *iserver;
ds@2400
   117
extern CGlobalVars *gpGlobals;
ds@1114
   118
/* Interfaces from SourceMod */
ds@783
   119
extern IBinTools *g_pBinTools;
dvander@950
   120
extern IGameConfig *g_pGameConf;
faluco@1031
   121
extern IGameHelpers *g_pGameHelpers;
ds@1114
   122
/* Handle types */
dvander@950
   123
extern HandleType_t g_CallHandle;
faluco@1075
   124
extern HandleType_t g_TraceHandle;
faluco@1498
   125
/* Call Wrappers */
faluco@1498
   126
extern ICallWrapper *g_pAcceptInput;
faluco@1735
   127
/* Call classes */
faluco@1735
   128
extern SourceHook::CallClass<IVEngineServer> *enginePatch;
faluco@1735
   129
extern SourceHook::CallClass<IEngineSound> *enginesoundPatch;
faluco@1735
   130
ds@2400
   131
#include <compat_wrappers.h>
ds@2400
   132
faluco@1735
   133
#define ENGINE_CALL(func)		SH_CALL(enginePatch, &IVEngineServer::func)
ds@783
   134
ds@783
   135
#endif //_INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_