sourcemm/ISmmPluginExt.h
changeset 513 ed5a3e60826a
parent 488 c05bc47b2ecd
child 523 6f1630519b81
     1.1 --- a/sourcemm/ISmmPluginExt.h	Mon Feb 18 03:57:26 2008 +0000
     1.2 +++ b/sourcemm/ISmmPluginExt.h	Mon Feb 18 23:11:25 2008 +0000
     1.3 @@ -1,156 +1,157 @@
     1.4 -/**
     1.5 - * vim: set ts=4 :
     1.6 - * ======================================================
     1.7 - * Metamod:Source
     1.8 - * Copyright (C) 2004-2007 AlliedModders LLC and authors.
     1.9 - * All rights reserved.
    1.10 - * ======================================================
    1.11 - *
    1.12 - * This software is provided 'as-is', without any express or implied warranty.
    1.13 - * In no event will the authors be held liable for any damages arising from 
    1.14 - * the use of this software.
    1.15 - * 
    1.16 - * Permission is granted to anyone to use this software for any purpose, 
    1.17 - * including commercial applications, and to alter it and redistribute it 
    1.18 - * freely, subject to the following restrictions:
    1.19 - *
    1.20 - * 1. The origin of this software must not be misrepresented; you must not 
    1.21 - * claim that you wrote the original software. If you use this software in a 
    1.22 - * product, an acknowledgment in the product documentation would be 
    1.23 - * appreciated but is not required.
    1.24 - * 2. Altered source versions must be plainly marked as such, and must not be
    1.25 - * misrepresented as being the original software.
    1.26 - * 3. This notice may not be removed or altered from any source distribution.
    1.27 - *
    1.28 - * Version: $Id$
    1.29 - */
    1.30 -
    1.31 -#ifndef _INCLUDE_METAMOD_SOURCE_PLUGIN_EXT_H_
    1.32 -#define _INCLUDE_METAMOD_SOURCE_PLUGIN_EXT_H_
    1.33 -
    1.34 -#include <stddef.h>
    1.35 -
    1.36 -/**
    1.37 - * @file ISmmPluginExt.h 	Definitions for extended plugin exposure syntax.
    1.38 - * @brief Provides an alternate method for loading plugins, without needing to 
    1.39 - * 		  include the default headers and all their Half-Life baggage.
    1.40 - */
    1.41 -
    1.42 -#define SOURCE_ENGINE_UNKNOWN			0				/**< Could not determine the engine version */
    1.43 -#define SOURCE_ENGINE_ORIGINAL			1				/**< Original Source Engine (used by The Ship) */
    1.44 -#define SOURCE_ENGINE_EPISODEONE		2				/**< Episode 1 Source Engine (second major SDK) */
    1.45 -#define SOURCE_ENGINE_ORANGEBOX			3				/**< Orange Box Source Engine (third major SDK) */
    1.46 -
    1.47 -#define METAMOD_PLAPI_VERSION			14				/**< Version of this header file */
    1.48 -#define METAMOD_PLAPI_NAME				"ISmmPlugin"	/**< Name of the plugin interface */
    1.49 -
    1.50 -namespace SourceMM
    1.51 -{
    1.52 -	class ISmmPlugin;
    1.53 -	class ISmmAPI;
    1.54 -
    1.55 +/*
    1.56 + * vim: set ts=4 :
    1.57 + * ======================================================
    1.58 + * Metamod:Source
    1.59 + * Copyright (C) 2004-2007 AlliedModders LLC and authors.
    1.60 + * All rights reserved.
    1.61 + * ======================================================
    1.62 + *
    1.63 + * This software is provided 'as-is', without any express or implied warranty.
    1.64 + * In no event will the authors be held liable for any damages arising from 
    1.65 + * the use of this software.
    1.66 + * 
    1.67 + * Permission is granted to anyone to use this software for any purpose, 
    1.68 + * including commercial applications, and to alter it and redistribute it 
    1.69 + * freely, subject to the following restrictions:
    1.70 + *
    1.71 + * 1. The origin of this software must not be misrepresented; you must not 
    1.72 + * claim that you wrote the original software. If you use this software in a 
    1.73 + * product, an acknowledgment in the product documentation would be 
    1.74 + * appreciated but is not required.
    1.75 + * 2. Altered source versions must be plainly marked as such, and must not be
    1.76 + * misrepresented as being the original software.
    1.77 + * 3. This notice may not be removed or altered from any source distribution.
    1.78 + *
    1.79 + * Version: $Id$
    1.80 + */
    1.81 +
    1.82 +#ifndef _INCLUDE_METAMOD_SOURCE_PLUGIN_EXT_H_
    1.83 +#define _INCLUDE_METAMOD_SOURCE_PLUGIN_EXT_H_
    1.84 +
    1.85 +#include <stddef.h>
    1.86 +
    1.87 +/**
    1.88 + * @file ISmmPluginExt.h Provides an alternate method for loading plugins, 
    1.89 + * without needing to include the default headers and all their Half-Life baggage.
    1.90 + *
    1.91 + * @brief Definitions for extended plugin loading.
    1.92 + */
    1.93 +
    1.94 +#define SOURCE_ENGINE_UNKNOWN			0				/**< Could not determine the engine version */
    1.95 +#define SOURCE_ENGINE_ORIGINAL			1				/**< Original Source Engine (used by The Ship) */
    1.96 +#define SOURCE_ENGINE_EPISODEONE		2				/**< Episode 1 Source Engine (second major SDK) */
    1.97 +#define SOURCE_ENGINE_ORANGEBOX			3				/**< Orange Box Source Engine (third major SDK) */
    1.98 +
    1.99 +#define METAMOD_PLAPI_VERSION			14				/**< Version of this header file */
   1.100 +#define METAMOD_PLAPI_NAME				"ISmmPlugin"	/**< Name of the plugin interface */
   1.101 +
   1.102 +namespace SourceMM
   1.103 +{
   1.104 +	class ISmmPlugin;
   1.105 +	class ISmmAPI;
   1.106 +
   1.107  	/**
   1.108  	 * @brief Used to uniquely identify plugins.
   1.109  	 */
   1.110 -	typedef int PluginId;
   1.111 -
   1.112 -	#define METAMOD_FAIL_API_V1			7				/**< Minimum API version to detect for V1 */
   1.113 -	#define METAMOD_FAIL_API_V2			14				/**< Minimum API version to detect for V2 */
   1.114 -
   1.115 -	/**
   1.116 -	 * Use this to instantiate a plugin that will always fail.
   1.117 -	 * This class definition works against major API versions 1 and 2.
   1.118 -	 */
   1.119 -	class ISmmFailPlugin
   1.120 -	{
   1.121 -	public:
   1.122 -		/**
   1.123 -		 * @brief You must return METAMOD_FAIL_API_V1 or METAMOD_FAIL_API_V2 here, 
   1.124 -		 * depending on which Metamod:Source version you detected.
   1.125 -		 */
   1.126 -		virtual int GetApiVersion() = 0;
   1.127 -
   1.128 -		/**
   1.129 -		 * @brief Do not change.
   1.130 -		 */
   1.131 -		virtual ~ISmmFailPlugin()
   1.132 -		{
   1.133 -		}
   1.134 -
   1.135 -		/**
   1.136 -		 * @brief Return false here -- fill in the error buffer appropriately.
   1.137 -		 *
   1.138 -		 * Do not ever return true.  If you do, MM:S will crash because the class layout is 
   1.139 -		 * incomplete against ISmmPlugin.
   1.140 -		 * 
   1.141 -		 * @param id			Ignore.
   1.142 -		 * @param ismm			Ignore.
   1.143 -		 * @param error			Error buffer (must be filled).
   1.144 -		 * @param maxlength		Maximum size of error buffer.
   1.145 -		 * @param late			Ignore.
   1.146 -		 * @return				Must return false.
   1.147 -		 */
   1.148 -		virtual bool Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlength, bool late) =0;
   1.149 -	};
   1.150 -}
   1.151 -
   1.152 -typedef SourceMM::ISmmPlugin METAMOD_PLUGIN;
   1.153 -
   1.154 -/**
   1.155 - * @brief Contains version information.
   1.156 - */
   1.157 -struct MetamodVersionInfo
   1.158 -{
   1.159 -	int api_major;			/**< ISmmAPI major version */
   1.160 -	int api_minor;			/**< ISmmAPI minor version */
   1.161 -	int sh_iface;			/**< SourceHook interface version */
   1.162 -	int sh_impl;			/**< SourceHook implementation version */
   1.163 -	int pl_min;				/**< Plugin API minimum version */
   1.164 -	int pl_max;				/**< Plugin API maximum version */
   1.165 -	int source_engine;		/**< Source Engine version (SOURCE_* constants) */
   1.166 -};
   1.167 -
   1.168 -/**
   1.169 - * @brief Contains information about loading a plugin.
   1.170 - */
   1.171 -struct MetamodLoaderInfo
   1.172 -{
   1.173 -	const char *pl_file;	/**< File path to the plugin being loaded. */
   1.174 -	const char *pl_path;	/**< Folder path containing the plugin. */
   1.175 -};
   1.176 -
   1.177 -/**
   1.178 - * @brief If a function of this type is exposed as "CreateInterface_MMS", then
   1.179 - * Metamod:Source will attempt to call this function before calling 
   1.180 - * CreateInterface.  If this function returns a valid ISmmPlugin pointer, then 
   1.181 - * CreateInterface will not be called.
   1.182 - *
   1.183 - * This is useful for implementing a mini-loader plugin for multiple versions.
   1.184 - *
   1.185 - * @param mvi				MetamodVersionInfo structure.
   1.186 - * @param mli				MetamodLoaderInfo structure.
   1.187 - * @return					ISmmAPI pointer, or NULL if none.
   1.188 - */
   1.189 -typedef METAMOD_PLUGIN *(*METAMOD_FN_LOAD)(const MetamodVersionInfo *mvi, 
   1.190 -										   const MetamodLoaderInfo *mli);
   1.191 -
   1.192 -/**
   1.193 - * @brief If a function of this type is exposed as "UnloadInterface_MMS", then
   1.194 - * Metamod:Source will attempt to call this function after calling 
   1.195 - * ISmmAPI::Unload(), and before closing the library.  This lets loader plugins 
   1.196 - * clean up before exiting.
   1.197 - *
   1.198 - * Note: This function will be ignored unless CreateInterfce_MMS was exposed.
   1.199 - * It may be called even if ISmmAPI::Unload() could not be called.
   1.200 - */
   1.201 -typedef void (*METAMOD_FN_UNLOAD)();
   1.202 -
   1.203 -/**
   1.204 - * @brief Original type of load function.  CreateInterfaceFn from Valve.
   1.205 - * 
   1.206 - * Plugins will expose this as "CreateInterface".
   1.207 - */
   1.208 -typedef void *(*METAMOD_FN_ORIG_LOAD)(const char *, int *);
   1.209 -
   1.210 -#endif //INCLUDE_METAMOD_SOURCE_PLUGIN_EXT_H_
   1.211 -
   1.212 +	typedef int PluginId;
   1.213 +
   1.214 +	#define METAMOD_FAIL_API_V1			7				/**< Minimum API version to detect for V1 */
   1.215 +	#define METAMOD_FAIL_API_V2			14				/**< Minimum API version to detect for V2 */
   1.216 +
   1.217 +	/**
   1.218 +	 * Use this to instantiate a plugin that will always fail.
   1.219 +	 * This class definition works against major API versions 1 and 2.
   1.220 +	 */
   1.221 +	class ISmmFailPlugin
   1.222 +	{
   1.223 +	public:
   1.224 +		/**
   1.225 +		 * @brief You must return METAMOD_FAIL_API_V1 or METAMOD_FAIL_API_V2 here, 
   1.226 +		 * depending on which Metamod:Source version you detected.
   1.227 +		 */
   1.228 +		virtual int GetApiVersion() = 0;
   1.229 +
   1.230 +		/**
   1.231 +		 * @brief Do not change.
   1.232 +		 */
   1.233 +		virtual ~ISmmFailPlugin()
   1.234 +		{
   1.235 +		}
   1.236 +
   1.237 +		/**
   1.238 +		 * @brief Return false here -- fill in the error buffer appropriately.
   1.239 +		 *
   1.240 +		 * Do not ever return true.  If you do, MM:S will crash because the class layout is 
   1.241 +		 * incomplete against ISmmPlugin.
   1.242 +		 * 
   1.243 +		 * @param id			Ignore.
   1.244 +		 * @param ismm			Ignore.
   1.245 +		 * @param error			Error buffer (must be filled).
   1.246 +		 * @param maxlength		Maximum size of error buffer.
   1.247 +		 * @param late			Ignore.
   1.248 +		 * @return				Must return false.
   1.249 +		 */
   1.250 +		virtual bool Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlength, bool late) =0;
   1.251 +	};
   1.252 +}
   1.253 +
   1.254 +typedef SourceMM::ISmmPlugin METAMOD_PLUGIN;
   1.255 +
   1.256 +/**
   1.257 + * @brief Contains version information.
   1.258 + */
   1.259 +struct MetamodVersionInfo
   1.260 +{
   1.261 +	int api_major;			/**< ISmmAPI major version */
   1.262 +	int api_minor;			/**< ISmmAPI minor version */
   1.263 +	int sh_iface;			/**< SourceHook interface version */
   1.264 +	int sh_impl;			/**< SourceHook implementation version */
   1.265 +	int pl_min;				/**< Plugin API minimum version */
   1.266 +	int pl_max;				/**< Plugin API maximum version */
   1.267 +	int source_engine;		/**< Source Engine version (SOURCE_* constants) */
   1.268 +};
   1.269 +
   1.270 +/**
   1.271 + * @brief Contains information about loading a plugin.
   1.272 + */
   1.273 +struct MetamodLoaderInfo
   1.274 +{
   1.275 +	const char *pl_file;	/**< File path to the plugin being loaded. */
   1.276 +	const char *pl_path;	/**< Folder path containing the plugin. */
   1.277 +};
   1.278 +
   1.279 +/**
   1.280 + * @brief If a function of this type is exposed as "CreateInterface_MMS", then
   1.281 + * Metamod:Source will attempt to call this function before calling 
   1.282 + * CreateInterface.  If this function returns a valid ISmmPlugin pointer, then 
   1.283 + * CreateInterface will not be called.
   1.284 + *
   1.285 + * This is useful for implementing a mini-loader plugin for multiple versions.
   1.286 + *
   1.287 + * @param mvi				MetamodVersionInfo structure.
   1.288 + * @param mli				MetamodLoaderInfo structure.
   1.289 + * @return					ISmmAPI pointer, or NULL if none.
   1.290 + */
   1.291 +typedef METAMOD_PLUGIN *(*METAMOD_FN_LOAD)(const MetamodVersionInfo *mvi, 
   1.292 +										   const MetamodLoaderInfo *mli);
   1.293 +
   1.294 +/**
   1.295 + * @brief If a function of this type is exposed as "UnloadInterface_MMS", then
   1.296 + * Metamod:Source will attempt to call this function after calling 
   1.297 + * ISmmAPI::Unload(), and before closing the library.  This lets loader plugins 
   1.298 + * clean up before exiting.
   1.299 + *
   1.300 + * Note: This function will be ignored unless CreateInterfce_MMS was exposed.
   1.301 + * It may be called even if ISmmAPI::Unload() could not be called.
   1.302 + */
   1.303 +typedef void (*METAMOD_FN_UNLOAD)();
   1.304 +
   1.305 +/**
   1.306 + * @brief Original type of load function.  CreateInterfaceFn from Valve.
   1.307 + * 
   1.308 + * Plugins will expose this as "CreateInterface".
   1.309 + */
   1.310 +typedef void *(*METAMOD_FN_ORIG_LOAD)(const char *, int *);
   1.311 +
   1.312 +#endif //INCLUDE_METAMOD_SOURCE_PLUGIN_EXT_H_
   1.313 +