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