extensions/cstrike/sdk/smsdk_ext.h
branchsourcemod-1.1.0
changeset 2283 03a67e41afbc
parent 1951 c7b4237fff50
child 2287 017a725c9d17
     1.1 --- a/extensions/cstrike/sdk/smsdk_ext.h	Fri Mar 28 06:21:34 2008 +0000
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,310 +0,0 @@
     1.4 -/**
     1.5 - * vim: set ts=4 :
     1.6 - * =============================================================================
     1.7 - * SourceMod Base Extension Code
     1.8 - * Copyright (C) 2004-2007 AlliedModders LLC.  All rights reserved.
     1.9 - * =============================================================================
    1.10 - *
    1.11 - * This program is free software; you can redistribute it and/or modify it under
    1.12 - * the terms of the GNU General Public License, version 3.0, as published by the
    1.13 - * Free Software Foundation.
    1.14 - * 
    1.15 - * This program is distributed in the hope that it will be useful, but WITHOUT
    1.16 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    1.17 - * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
    1.18 - * details.
    1.19 - *
    1.20 - * You should have received a copy of the GNU General Public License along with
    1.21 - * this program.  If not, see <http://www.gnu.org/licenses/>.
    1.22 - *
    1.23 - * As a special exception, AlliedModders LLC gives you permission to link the
    1.24 - * code of this program (as well as its derivative works) to "Half-Life 2," the
    1.25 - * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
    1.26 - * by the Valve Corporation.  You must obey the GNU General Public License in
    1.27 - * all respects for all other code used.  Additionally, AlliedModders LLC grants
    1.28 - * this exception to all derivative works.  AlliedModders LLC defines further
    1.29 - * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
    1.30 - * or <http://www.sourcemod.net/license.php>.
    1.31 - *
    1.32 - * Version: $Id$
    1.33 - */
    1.34 -
    1.35 -#ifndef _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_
    1.36 -#define _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_
    1.37 -
    1.38 -/**
    1.39 - * @file smsdk_ext.h
    1.40 - * @brief Contains wrappers for making Extensions easier to write.
    1.41 - */
    1.42 -
    1.43 -#include "smsdk_config.h"
    1.44 -#include <IExtensionSys.h>
    1.45 -#include <IHandleSys.h>
    1.46 -#include <sp_vm_api.h>
    1.47 -#include <sm_platform.h>
    1.48 -#include <ISourceMod.h>
    1.49 -#if defined SMEXT_ENABLE_FORWARDSYS
    1.50 -#include <IForwardSys.h>
    1.51 -#endif //SMEXT_ENABLE_FORWARDSYS
    1.52 -#if defined SMEXT_ENABLE_PLAYERHELPERS
    1.53 -#include <IPlayerHelpers.h>
    1.54 -#endif //SMEXT_ENABLE_PlAYERHELPERS
    1.55 -#if defined SMEXT_ENABLE_DBMANAGER
    1.56 -#include <IDBDriver.h>
    1.57 -#endif //SMEXT_ENABLE_DBMANAGER
    1.58 -#if defined SMEXT_ENABLE_GAMECONF
    1.59 -#include <IGameConfigs.h>
    1.60 -#endif
    1.61 -#if defined SMEXT_ENABLE_MEMUTILS
    1.62 -#include <IMemoryUtils.h>
    1.63 -#endif
    1.64 -#if defined SMEXT_ENABLE_GAMEHELPERS
    1.65 -#include <IGameHelpers.h>
    1.66 -#endif
    1.67 -#if defined SMEXT_ENABLE_TIMERSYS
    1.68 -#include <ITimerSystem.h>
    1.69 -#endif
    1.70 -#if defined SMEXT_ENABLE_ADTFACTORY
    1.71 -#include <IADTFactory.h>
    1.72 -#endif
    1.73 -#if defined SMEXT_ENABLE_THREADER
    1.74 -#include <IThreader.h>
    1.75 -#endif
    1.76 -#if defined SMEXT_ENABLE_LIBSYS
    1.77 -#include <ILibrarySys.h>
    1.78 -#endif
    1.79 -#if defined SMEXT_ENABLE_USERMSGS
    1.80 -#include <IUserMessages.h>
    1.81 -#endif
    1.82 -
    1.83 -#if defined SMEXT_CONF_METAMOD
    1.84 -#include <ISmmPlugin.h>
    1.85 -#include <eiface.h>
    1.86 -#endif
    1.87 -
    1.88 -#if !defined METAMOD_PLAPI_VERSION
    1.89 -	#include <metamod_wrappers.h>
    1.90 -#endif
    1.91 -
    1.92 -using namespace SourceMod;
    1.93 -using namespace SourcePawn;
    1.94 -
    1.95 -class SDKExtension : 
    1.96 -#if defined SMEXT_CONF_METAMOD
    1.97 -	public ISmmPlugin,
    1.98 -#endif
    1.99 -	public IExtensionInterface
   1.100 -{
   1.101 -public:
   1.102 -	/** Constructor */
   1.103 -	SDKExtension();
   1.104 -public:
   1.105 -	/**
   1.106 -	 * @brief This is called after the initial loading sequence has been processed.
   1.107 -	 *
   1.108 -	 * @param error		Error message buffer.
   1.109 -	 * @param maxlength	Size of error message buffer.
   1.110 -	 * @param late		Whether or not the module was loaded after map load.
   1.111 -	 * @return			True to succeed loading, false to fail.
   1.112 -	 */
   1.113 -	virtual bool SDK_OnLoad(char *error, size_t maxlength, bool late);
   1.114 -	
   1.115 -	/**
   1.116 -	 * @brief This is called right before the extension is unloaded.
   1.117 -	 */
   1.118 -	virtual void SDK_OnUnload();
   1.119 -
   1.120 -	/**
   1.121 -	 * @brief This is called once all known extensions have been loaded.
   1.122 -	 */
   1.123 -	virtual void SDK_OnAllLoaded();
   1.124 -
   1.125 -	/**
   1.126 -	 * @brief Called when the pause state is changed.
   1.127 -	 */
   1.128 -	virtual void SDK_OnPauseChange(bool paused);
   1.129 -
   1.130 -#if defined SMEXT_CONF_METAMOD
   1.131 -	/**
   1.132 -	 * @brief Called when Metamod is attached, before the extension version is called.
   1.133 -	 *
   1.134 -	 * @param error			Error buffer.
   1.135 -	 * @param maxlength		Maximum size of error buffer.
   1.136 -	 * @param late			Whether or not Metamod considers this a late load.
   1.137 -	 * @return				True to succeed, false to fail.
   1.138 -	 */
   1.139 -	virtual bool SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlength, bool late);
   1.140 -
   1.141 -	/**
   1.142 -	 * @brief Called when Metamod is detaching, after the extension version is called.
   1.143 -	 * NOTE: By default this is blocked unless sent from SourceMod.
   1.144 -	 *
   1.145 -	 * @param error			Error buffer.
   1.146 -	 * @param maxlength		Maximum size of error buffer.
   1.147 -	 * @return				True to succeed, false to fail.
   1.148 -	 */
   1.149 -	virtual bool SDK_OnMetamodUnload(char *error, size_t maxlength);
   1.150 -
   1.151 -	/**
   1.152 -	 * @brief Called when Metamod's pause state is changing.
   1.153 -	 * NOTE: By default this is blocked unless sent from SourceMod.
   1.154 -	 *
   1.155 -	 * @param paused		Pause state being set.
   1.156 -	 * @param error			Error buffer.
   1.157 -	 * @param maxlength		Maximum size of error buffer.
   1.158 -	 * @return				True to succeed, false to fail.
   1.159 -	 */
   1.160 -	virtual bool SDK_OnMetamodPauseChange(bool paused, char *error, size_t maxlength);
   1.161 -#endif
   1.162 -
   1.163 -public: //IExtensionInterface
   1.164 -	virtual bool OnExtensionLoad(IExtension *me, IShareSys *sys, char *error, size_t maxlength, bool late);
   1.165 -	virtual void OnExtensionUnload();
   1.166 -	virtual void OnExtensionsAllLoaded();
   1.167 -
   1.168 -	/** Returns whether or not this is a Metamod-based extension */
   1.169 -	virtual bool IsMetamodExtension();
   1.170 -
   1.171 -	/**
   1.172 -	 * @brief Called when the pause state changes.
   1.173 -	 * 
   1.174 -	 * @param state			True if being paused, false if being unpaused.
   1.175 -	 */
   1.176 -	virtual void OnExtensionPauseChange(bool state);
   1.177 -
   1.178 -	/** Returns name */
   1.179 -	virtual const char *GetExtensionName();
   1.180 -	/** Returns URL */
   1.181 -	virtual const char *GetExtensionURL();
   1.182 -	/** Returns log tag */
   1.183 -	virtual const char *GetExtensionTag();
   1.184 -	/** Returns author */
   1.185 -	virtual const char *GetExtensionAuthor();
   1.186 -	/** Returns version string */
   1.187 -	virtual const char *GetExtensionVerString();
   1.188 -	/** Returns description string */
   1.189 -	virtual const char *GetExtensionDescription();
   1.190 -	/** Returns date string */
   1.191 -	virtual const char *GetExtensionDateString();
   1.192 -#if defined SMEXT_CONF_METAMOD
   1.193 -public: //ISmmPlugin
   1.194 -	/** Called when the extension is attached to Metamod. */
   1.195 -	virtual bool Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlength, bool late);
   1.196 -	/** Returns the author to MM */
   1.197 -	virtual const char *GetAuthor();
   1.198 -	/** Returns the name to MM */
   1.199 -	virtual const char *GetName();
   1.200 -	/** Returns the description to MM */
   1.201 -	virtual const char *GetDescription();
   1.202 -	/** Returns the URL to MM */
   1.203 -	virtual const char *GetURL();
   1.204 -	/** Returns the license to MM */
   1.205 -	virtual const char *GetLicense();
   1.206 -	/** Returns the version string to MM */
   1.207 -	virtual const char *GetVersion();
   1.208 -	/** Returns the date string to MM */
   1.209 -	virtual const char *GetDate();
   1.210 -	/** Returns the logtag to MM */
   1.211 -	virtual const char *GetLogTag();
   1.212 -	/** Called on unload */
   1.213 -	virtual bool Unload(char *error, size_t maxlength);
   1.214 -	/** Called on pause */
   1.215 -	virtual bool Pause(char *error, size_t maxlength);
   1.216 -	/** Called on unpause */
   1.217 -	virtual bool Unpause(char *error, size_t maxlength);
   1.218 -private:
   1.219 -	bool m_SourceMMLoaded;
   1.220 -	bool m_WeAreUnloaded;
   1.221 -	bool m_WeGotPauseChange;
   1.222 -#endif
   1.223 -};
   1.224 -
   1.225 -extern SDKExtension *g_pExtensionIface;
   1.226 -extern IExtension *myself;
   1.227 -
   1.228 -extern IShareSys *g_pShareSys;
   1.229 -extern IShareSys *sharesys;				/* Note: Newer name */
   1.230 -extern ISourceMod *g_pSM;
   1.231 -extern ISourceMod *smutils;				/* Note: Newer name */
   1.232 -
   1.233 -/* Optional interfaces are below */
   1.234 -#if defined SMEXT_ENABLE_FORWARDSYS
   1.235 -extern IForwardManager *g_pForwards;
   1.236 -extern IForwardManager *forwards;		/* Note: Newer name */
   1.237 -#endif //SMEXT_ENABLE_FORWARDSYS
   1.238 -#if defined SMEXT_ENABLE_HANDLESYS
   1.239 -extern IHandleSys *g_pHandleSys;
   1.240 -extern IHandleSys *handlesys;			/* Note: Newer name */
   1.241 -#endif //SMEXT_ENABLE_HANDLESYS
   1.242 -#if defined SMEXT_ENABLE_PLAYERHELPERS
   1.243 -extern IPlayerManager *playerhelpers;
   1.244 -#endif //SMEXT_ENABLE_PLAYERHELPERS
   1.245 -#if defined SMEXT_ENABLE_DBMANAGER
   1.246 -extern IDBManager *dbi;
   1.247 -#endif //SMEXT_ENABLE_DBMANAGER
   1.248 -#if defined SMEXT_ENABLE_GAMECONF
   1.249 -extern IGameConfigManager *gameconfs;
   1.250 -#endif //SMEXT_ENABLE_DBMANAGER
   1.251 -#if defined SMEXT_ENABLE_MEMUTILS
   1.252 -extern IMemoryUtils *memutils;
   1.253 -#endif
   1.254 -#if defined SMEXT_ENABLE_GAMEHELPERS
   1.255 -extern IGameHelpers *gamehelpers;
   1.256 -#endif
   1.257 -#if defined SMEXT_ENABLE_TIMERSYS
   1.258 -extern ITimerSystem *timersys;
   1.259 -#endif
   1.260 -#if defined SMEXT_ENABLE_ADTFACTORY
   1.261 -extern IADTFactory *adtfactory;
   1.262 -#endif
   1.263 -#if defined SMEXT_ENABLE_THREADER
   1.264 -extern IThreader *threader;
   1.265 -#endif
   1.266 -#if defined SMEXT_ENABLE_LIBSYS
   1.267 -extern ILibrarySys *libsys;
   1.268 -#endif
   1.269 -#if defined SMEXT_ENABLE_USERMSGS
   1.270 -extern IUserMessages *usermsgs;
   1.271 -#endif
   1.272 -
   1.273 -#if defined SMEXT_CONF_METAMOD
   1.274 -PLUGIN_GLOBALVARS();
   1.275 -extern IVEngineServer *engine;
   1.276 -extern IServerGameDLL *gamedll;
   1.277 -#endif
   1.278 -
   1.279 -/** Creates a SourceMod interface macro pair */
   1.280 -#define SM_MKIFACE(name) SMINTERFACE_##name##_NAME, SMINTERFACE_##name##_VERSION
   1.281 -/** Automates retrieving SourceMod interfaces */
   1.282 -#define SM_GET_IFACE(prefix, addr) \
   1.283 -	if (!g_pShareSys->RequestInterface(SM_MKIFACE(prefix), myself, (SMInterface **)&addr)) \
   1.284 -	{ \
   1.285 -		if (error != NULL && maxlength) \
   1.286 -		{ \
   1.287 -			size_t len = snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \
   1.288 -			if (len >= maxlength) \
   1.289 -			{ \
   1.290 -				error[maxlength - 1] = '\0'; \
   1.291 -			} \
   1.292 -		} \
   1.293 -		return false; \
   1.294 -	}
   1.295 -/** Automates retrieving SourceMod interfaces when needed outside of SDK_OnLoad() */
   1.296 -#define SM_GET_LATE_IFACE(prefix, addr) \
   1.297 -	g_pShareSys->RequestInterface(SM_MKIFACE(prefix), myself, (SMInterface **)&addr)
   1.298 -/** Validates a SourceMod interface pointer */
   1.299 -#define SM_CHECK_IFACE(prefix, addr) \
   1.300 -	if (!addr) \
   1.301 -	{ \
   1.302 -		if (error != NULL && maxlength) \
   1.303 -		{ \
   1.304 -			size_t len = snprintf(error, maxlength, "Could not find interface: %s", SMINTERFACE_##prefix##_NAME); \
   1.305 -			if (len >= maxlength) \
   1.306 -			{ \
   1.307 -				error[maxlength - 1] = '\0'; \
   1.308 -			} \
   1.309 -		} \
   1.310 -		return false; \
   1.311 -	}
   1.312 -
   1.313 -#endif // _INCLUDE_SOURCEMOD_EXTENSION_BASESDK_H_