extensions/sdktools/extension.h
author David Anderson <dvander@alliedmods.net>
Sun Aug 30 01:54:45 2009 -0700 (2009-08-30)
changeset 2790 6dd851ba15fd
parent 2783 5f333027ef04
child 2796 cd0bf02b99cf
permissions -rw-r--r--
Fixed extension version reporting.
     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 /**
    55  * @brief Implementation of the SDK Tools extension.
    56  * Note: Uncomment one of the pre-defined virtual functions in order to use it.
    57  */
    58 class SDKTools : 
    59 	public SDKExtension, 
    60 	public IHandleTypeDispatch,
    61 	public IConCommandBaseAccessor,
    62 	public IClientListener,
    63 	public ICommandTargetProcessor
    64 {
    65 public: //public IHandleTypeDispatch
    66 	void OnHandleDestroy(HandleType_t type, void *object);
    67 public: //public SDKExtension
    68 	virtual bool SDK_OnLoad(char *error, size_t maxlength, bool late);
    69 	virtual void SDK_OnUnload();
    70 	virtual void SDK_OnAllLoaded();
    71 	//virtual void SDK_OnPauseChange(bool paused);
    72 	virtual bool QueryRunning(char *error, size_t maxlength);
    73 	virtual bool QueryInterfaceDrop(SMInterface *pInterface);
    74 	virtual void NotifyInterfaceDrop(SMInterface *pInterface);
    75 	virtual void OnCoreMapStart(edict_t *pEdictList, int edictCount, int clientMax);
    76 	const char *GetExtensionVerString();
    77 	const char *GetExtensionDateString();
    78 public:
    79 #if defined SMEXT_CONF_METAMOD
    80 	virtual bool SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlen, bool late);
    81 	//virtual bool SDK_OnMetamodUnload(char *error, size_t maxlen);
    82 	//virtual bool SDK_OnMetamodPauseChange(bool paused, char *error, size_t maxlen);
    83 #endif
    84 public: //IConCommandBaseAccessor
    85 	bool RegisterConCommandBase(ConCommandBase *pVar);
    86 public: //IClientListner
    87 	void OnClientPutInServer(int client);
    88 	void OnClientDisconnecting(int client);
    89 public: // IVoiceServer
    90 	bool OnSetClientListening(int iReceiver, int iSender, bool bListen);
    91 	void VoiceInit();
    92 public: //ICommandTargetProcessor
    93 	bool ProcessCommandTarget(cmd_target_info_t *info);
    94 public:
    95 	bool LevelInit(char const *pMapName, char const *pMapEntities, char const *pOldLevel, char const *pLandmarkName, bool loadGame, bool background);
    96 	void OnServerActivate(edict_t *pEdictList, int edictCount, int clientMax);
    97 };
    98 
    99 extern SDKTools g_SdkTools;
   100 /* Interfaces from engine or gamedll */
   101 extern IServerGameEnts *gameents;
   102 extern IEngineTrace *enginetrace;
   103 extern IEngineSound *engsound;
   104 extern INetworkStringTableContainer *netstringtables;
   105 extern IServerPluginHelpers *pluginhelpers;
   106 extern IServerGameClients *serverClients;
   107 extern IVoiceServer *voiceserver;
   108 extern IPlayerInfoManager *playerinfomngr;
   109 extern ICvar *icvar;
   110 extern IServer *iserver;
   111 extern CGlobalVars *gpGlobals;
   112 /* Interfaces from SourceMod */
   113 extern IBinTools *g_pBinTools;
   114 extern IGameConfig *g_pGameConf;
   115 extern IGameHelpers *g_pGameHelpers;
   116 /* Handle types */
   117 extern HandleType_t g_CallHandle;
   118 extern HandleType_t g_TraceHandle;
   119 /* Call Wrappers */
   120 extern ICallWrapper *g_pAcceptInput;
   121 /* Call classes */
   122 extern SourceHook::CallClass<IVEngineServer> *enginePatch;
   123 extern SourceHook::CallClass<IEngineSound> *enginesoundPatch;
   124 
   125 #include <compat_wrappers.h>
   126 
   127 #define ENGINE_CALL(func)		SH_CALL(enginePatch, &IVEngineServer::func)
   128 
   129 #endif //_INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_