1.1 --- a/sourcemm/IPluginManager.h Mon Oct 08 17:32:28 2007 +0000
1.2 +++ b/sourcemm/IPluginManager.h Mon Oct 08 18:47:31 2007 +0000
1.3 @@ -25,130 +25,135 @@
1.4 * Version: $Id$
1.5 */
1.6
1.7 -#ifndef _INCLUDE_PLUGINMANAGER_H
1.8 -#define _INCLUDE_PLUGINMANAGER_H
1.9 +#ifndef _INCLUDE_METAMOD_IPLUGINMANAGER_H
1.10 +#define _INCLUDE_METAMOD_IPLUGINMANAGER_H
1.11
1.12 /**
1.13 * @brief Plugin Manager interface
1.14 * @file IPluginManager.h
1.15 */
1.16
1.17 -typedef int PluginId;
1.18 -
1.19 -#include "ISmmPlugin.h"
1.20 -
1.21 -/**
1.22 - * @brief Load sources
1.23 - */
1.24 -enum
1.25 -{
1.26 - Pl_BadLoad=0,
1.27 - Pl_Console=-1,
1.28 - Pl_File=-2,
1.29 - Pl_MinId=1,
1.30 -};
1.31 -
1.32 -/**
1.33 - * @brief Status of a plugin at runtime
1.34 - */
1.35 -enum Pl_Status
1.36 +namespace SourceMM
1.37 {
1.38 - Pl_NotFound=-4,
1.39 - Pl_Error=-3,
1.40 - Pl_Refused=-2,
1.41 - Pl_Paused=-1,
1.42 - Pl_Running=0,
1.43 -};
1.44 -
1.45 -typedef int PluginId;
1.46 -struct factories;
1.47 -
1.48 -class ISmmPluginManager
1.49 -{
1.50 -public:
1.51 /**
1.52 - * @brief Loads a plugin and returns its id. If this is called before DLLInit(),
1.53 - * then the plugin is considered to be "hot" - it might refuse its own load later!
1.54 - * Also, a hot plugin might not have an error message.
1.55 - *
1.56 - * @param file String containing file name
1.57 - * @param source Specifies who loaded the plugin
1.58 - * @param status Status of the plugin
1.59 - * @param ismm Pointer to Smm API
1.60 - * @param error String buffer for error messages
1.61 - * @param maxlen Maximum length of buffer
1.62 - * @return Id of plugin
1.63 + * @brief Used to uniquel identify plugins.
1.64 */
1.65 - virtual PluginId Load(const char *file, PluginId source, bool &already, char *error, size_t maxlen) =0;
1.66 -
1.67 - /**
1.68 - * @brief Unloads a plugin
1.69 - *
1.70 - * @param id Id of plugin
1.71 - * @param error String buffer for error messages
1.72 - * @param maxlen Maximum length of buffer
1.73 - * @return True on success, false otherwise
1.74 - */
1.75 - virtual bool Unload(PluginId id, bool force, char *error, size_t maxlen) =0;
1.76 + typedef int PluginId;
1.77
1.78 /**
1.79 - * @brief Pauses a plugin
1.80 - *
1.81 - * @param id Id of plugin
1.82 - * @param error String buffer for error messages
1.83 - * @param maxlen Maximum length of buffer
1.84 - * @return True on success, false otherwise
1.85 + * @brief Load sources
1.86 */
1.87 - virtual bool Pause(PluginId id, char *error, size_t maxlen) =0;
1.88 -
1.89 - /**
1.90 - * @brief Unpauses a plugin
1.91 - *
1.92 - * @param id Id of plugin
1.93 - * @param force If true, forces the plugin to unload
1.94 - * @param error String buffer for error messages
1.95 - * @param maxlen Maximum length of buffer
1.96 - * @return True on success, false otherwise
1.97 - */
1.98 - virtual bool Unpause(PluginId id, char *error, size_t maxlen) =0;
1.99 -
1.100 - /**
1.101 - * @brief Unloads all plugins forcefully
1.102 - *
1.103 - * @return True on success, false otherwise
1.104 - */
1.105 - virtual bool UnloadAll() =0;
1.106 -
1.107 + enum
1.108 + {
1.109 + Pl_BadLoad=0,
1.110 + Pl_Console=-1,
1.111 + Pl_File=-2,
1.112 + Pl_MinId=1,
1.113 + };
1.114 +
1.115 /**
1.116 - * @brief Returns information about a plugin
1.117 - *
1.118 - * @param id Id of plugin
1.119 - * @param file Pointer to file string by reference
1.120 - * @param list Pointer to factories by reference
1.121 - * @param status By reference status of plugin
1.122 - * @param source By reference source of plugin
1.123 - * @return True on success, false if not found
1.124 + * @brief Status of a plugin at runtime
1.125 */
1.126 - virtual bool Query(PluginId id, const char *&file, Pl_Status &status, PluginId &source) =0;
1.127 + enum Pl_Status
1.128 + {
1.129 + Pl_NotFound=-4,
1.130 + Pl_Error=-3,
1.131 + Pl_Refused=-2,
1.132 + Pl_Paused=-1,
1.133 + Pl_Running=0,
1.134 + };
1.135 +
1.136 + class ISmmPluginManager
1.137 + {
1.138 + public:
1.139 + /**
1.140 + * @brief Loads a plugin and returns its id. If this is called before DLLInit(),
1.141 + * then the plugin is considered to be "hot" - it might refuse its own load later!
1.142 + * Also, a hot plugin might not have an error message.
1.143 + *
1.144 + * @param file String containing file name
1.145 + * @param source Specifies who loaded the plugin
1.146 + * @param status Status of the plugin
1.147 + * @param ismm Pointer to Smm API
1.148 + * @param error String buffer for error messages
1.149 + * @param maxlen Maximum length of buffer
1.150 + * @return Id of plugin
1.151 + */
1.152 + virtual PluginId Load(const char *file, PluginId source, bool &already, char *error, size_t maxlen) =0;
1.153
1.154 - /**
1.155 - * @brief Checks another plugin's QueryRunning() status.
1.156 - *
1.157 - * @param id Id of plugin
1.158 - * @param error Message buffer
1.159 - * @param maxlen Size of error buffer
1.160 - * @return Status value
1.161 - */
1.162 - virtual bool QueryRunning(PluginId id, char *error, size_t maxlength) =0;
1.163 + /**
1.164 + * @brief Unloads a plugin
1.165 + *
1.166 + * @param id Id of plugin
1.167 + * @param error String buffer for error messages
1.168 + * @param maxlen Maximum length of buffer
1.169 + * @return True on success, false otherwise
1.170 + */
1.171 + virtual bool Unload(PluginId id, bool force, char *error, size_t maxlen) =0;
1.172 +
1.173 + /**
1.174 + * @brief Pauses a plugin
1.175 + *
1.176 + * @param id Id of plugin
1.177 + * @param error String buffer for error messages
1.178 + * @param maxlen Maximum length of buffer
1.179 + * @return True on success, false otherwise
1.180 + */
1.181 + virtual bool Pause(PluginId id, char *error, size_t maxlen) =0;
1.182 +
1.183 + /**
1.184 + * @brief Unpauses a plugin
1.185 + *
1.186 + * @param id Id of plugin
1.187 + * @param force If true, forces the plugin to unload
1.188 + * @param error String buffer for error messages
1.189 + * @param maxlen Maximum length of buffer
1.190 + * @return True on success, false otherwise
1.191 + */
1.192 + virtual bool Unpause(PluginId id, char *error, size_t maxlen) =0;
1.193 +
1.194 + /**
1.195 + * @brief Unloads all plugins forcefully
1.196 + *
1.197 + * @return True on success, false otherwise
1.198 + */
1.199 + virtual bool UnloadAll() =0;
1.200 +
1.201 + /**
1.202 + * @brief Returns information about a plugin
1.203 + *
1.204 + * @param id Id of plugin
1.205 + * @param file Pointer to file string by reference
1.206 + * @param status By reference status of plugin
1.207 + * @param source By reference source of plugin
1.208 + * @return True on success, false if not found
1.209 + */
1.210 + virtual bool Query(PluginId id, const char *&file, Pl_Status &status, PluginId &source) =0;
1.211 +
1.212 + /**
1.213 + * @brief Checks another plugin's QueryRunning() status.
1.214 + *
1.215 + * @param id Id of plugin
1.216 + * @param error Message buffer
1.217 + * @param maxlen Size of error buffer
1.218 + * @return Status value
1.219 + */
1.220 + virtual bool QueryRunning(PluginId id, char *error, size_t maxlength) =0;
1.221 +
1.222 + /**
1.223 + * @brief Returns the handle of a plugin (OS dependent meaning)
1.224 + *
1.225 + * @param id Id of plugin
1.226 + * @param handle By reference handle of plugin, if any
1.227 + * @return True if plugin id is valid, false otherwise
1.228 + */
1.229 + virtual bool QueryHandle(PluginId id, void *&handle) =0;
1.230 + };
1.231 +}
1.232
1.233 - /**
1.234 - * @brief Returns the handle of a plugin (OS dependent meaning)
1.235 - *
1.236 - * @param id Id of plugin
1.237 - * @param handle By reference handle of plugin, if any
1.238 - * @return True if plugin id is valid, false otherwise
1.239 - */
1.240 - virtual bool QueryHandle(PluginId id, void *&handle) =0;
1.241 -};
1.242 +#if !defined METAMOD_NO_AUTO_NAMESPACE
1.243 +using namespace SourceMM;
1.244 +#endif
1.245
1.246 #endif //_INCLUDE_PLUGINMANAGER_H
1.247 +
2.1 --- a/sourcemm/ISmmAPI.h Mon Oct 08 17:32:28 2007 +0000
2.2 +++ b/sourcemm/ISmmAPI.h Mon Oct 08 18:47:31 2007 +0000
2.3 @@ -37,7 +37,8 @@
2.4 #include <interface.h>
2.5 #include <eiface.h>
2.6 #include <sourcehook.h>
2.7 -#include "IPluginManager.h"
2.8 +#include <IPluginManager.h>
2.9 +#include <ISmmPlugin.h>
2.10
2.11 #if defined __GNUC__
2.12 #if ((__GNUC__ == 3) && (__GNUC_MINOR__ < 4)) || (__GNUC__ < 3)
2.13 @@ -45,10 +46,6 @@
2.14 #endif //version check
2.15 #endif //__GNUC__
2.16
2.17 -class IMetamodListener;
2.18 -class ISmmPluginManager;
2.19 -class ISmmPlugin;
2.20 -
2.21 #define MMIFACE_SOURCEHOOK "ISourceHook" /**< ISourceHook Pointer */
2.22 #define MMIFACE_PLMANAGER "IPluginManager" /**< SourceMM Plugin Functions */
2.23 #define IFACE_MAXNUM 999 /**< Maximum interface version */
2.24 @@ -58,299 +55,316 @@
2.25 #define SOURCE_ENGINE_EPISODEONE 2 /**< Episode 1 Source Engine (second major SDK) */
2.26 #define SOURCE_ENGINE_ORANGEBOX 3 /**< Orange Box Source Engine (third major SDK) */
2.27
2.28 -class ISmmAPI
2.29 +namespace SourceMM
2.30 {
2.31 -public:
2.32 - /**
2.33 - * @brief Logs a message through the HL2 log system.
2.34 - * Note: Newlines are appended automatically.
2.35 - *
2.36 - * @param pl Plugin API pointer (used for tagging message)
2.37 - * @param msg Formatted string.
2.38 - */
2.39 - virtual void LogMsg(ISmmPlugin *pl, const char *msg, ...) =0;
2.40 + class ISmmPlugin;
2.41 + class IMetamodListener;
2.42
2.43 - /**
2.44 - * @brief Returns an interface factory for the HL2 engine.
2.45 - *
2.46 - * @param syn If syn is true, the synthetic wrapper is returned.
2.47 - * If syn is false, the true function is returned.
2.48 - * @return CreateInterfaceFn function pointer.
2.49 - */
2.50 - virtual CreateInterfaceFn GetEngineFactory(bool syn=true) =0;
2.51 -
2.52 - /**
2.53 - * @brief Returns an interface factory for the HL2 physics engine.
2.54 - *
2.55 - * @param syn If syn is true, the synthetic wrapper is returned.
2.56 - * If syn is false, the true function is returned.
2.57 - * @return CreateInterfaceFn function pointer.
2.58 - */
2.59 - virtual CreateInterfaceFn GetPhysicsFactory(bool syn=true) =0;
2.60 + class ISmmAPI
2.61 + {
2.62 + public:
2.63 + /**
2.64 + * @brief Logs a message through the HL2 log system.
2.65 + * Note: Newlines are appended automatically.
2.66 + *
2.67 + * @param pl Plugin API pointer (used for tagging message)
2.68 + * @param msg Formatted string.
2.69 + */
2.70 + virtual void LogMsg(ISmmPlugin *pl, const char *msg, ...) =0;
2.71 +
2.72 + /**
2.73 + * @brief Returns an interface factory for the HL2 engine.
2.74 + *
2.75 + * @param syn If syn is true, the synthetic wrapper is returned.
2.76 + * If syn is false, the true function is returned.
2.77 + * @return CreateInterfaceFn function pointer.
2.78 + */
2.79 + virtual CreateInterfaceFn GetEngineFactory(bool syn=true) =0;
2.80
2.81 - /**
2.82 - * @brief Returns an interface factory for the HL2 file system.
2.83 - *
2.84 - * @param syn If syn is true, the synthetic wrapper is returned.
2.85 - * If syn is false, the true function is returned.
2.86 - * @return CreateInterfaceFn function pointer.
2.87 - */
2.88 - virtual CreateInterfaceFn GetFileSystemFactory(bool syn=true) =0;
2.89 + /**
2.90 + * @brief Returns an interface factory for the HL2 physics engine.
2.91 + *
2.92 + * @param syn If syn is true, the synthetic wrapper is returned.
2.93 + * If syn is false, the true function is returned.
2.94 + * @return CreateInterfaceFn function pointer.
2.95 + */
2.96 + virtual CreateInterfaceFn GetPhysicsFactory(bool syn=true) =0;
2.97 +
2.98 + /**
2.99 + * @brief Returns an interface factory for the HL2 file system.
2.100 + *
2.101 + * @param syn If syn is true, the synthetic wrapper is returned.
2.102 + * If syn is false, the true function is returned.
2.103 + * @return CreateInterfaceFn function pointer.
2.104 + */
2.105 + virtual CreateInterfaceFn GetFileSystemFactory(bool syn=true) =0;
2.106
2.107 - /**
2.108 - * @brief Returns an interface factory for the GameDLL.
2.109 - *
2.110 - * @param syn If syn is true, the synthetic wrapper is returned.
2.111 - * If syn is false, the true function is returned.
2.112 - * @return CreateInterfaceFn function pointer.
2.113 - */
2.114 - virtual CreateInterfaceFn GetServerFactory(bool syn=true) =0;
2.115 + /**
2.116 + * @brief Returns an interface factory for the GameDLL.
2.117 + *
2.118 + * If syn is false, the true function is returned.
2.119 + * @return CreateInterfaceFn function pointer.
2.120 + */
2.121 + virtual CreateInterfaceFn GetServerFactory(bool syn=true) =0;
2.122
2.123 - /**
2.124 - * @brief Returns a CGlobalVars pointer from the HL2 Engine.
2.125 - *
2.126 - * @return CGlobalVars pointer.
2.127 - */
2.128 - virtual CGlobalVars *GetCGlobals() =0;
2.129 + /**
2.130 + * @brief Returns a CGlobalVars pointer from the HL2 Engine.
2.131 + *
2.132 + * @return CGlobalVars pointer.
2.133 + */
2.134 + virtual CGlobalVars *GetCGlobals() =0;
2.135
2.136 - /**
2.137 - * @brief Registers a ConCommandBase.
2.138 - *
2.139 - * @param plugin Parent plugin API pointer.
2.140 - * @param pCommand ConCommandBase to register.
2.141 - * @return True if successful, false otherwise.
2.142 - */
2.143 - virtual bool RegisterConCommandBase(ISmmPlugin *plugin, ConCommandBase *pCommand) =0;
2.144 + /**
2.145 + * @brief Registers a ConCommandBase.
2.146 + *
2.147 + * @param plugin Parent plugin API pointer.
2.148 + * @param pCommand ConCommandBase to register.
2.149 + * @return True if successful, false otherwise.
2.150 + */
2.151 + virtual bool RegisterConCommandBase(ISmmPlugin *plugin, ConCommandBase *pCommand) =0;
2.152
2.153 - /**
2.154 - * @brief Unregisters a ConCommandBase.
2.155 - *
2.156 - * @param plugin Parent plugin API pointer.
2.157 - * @param pCommand ConCommandBase to unlink.
2.158 - */
2.159 - virtual void UnregisterConCommandBase(ISmmPlugin *plugin, ConCommandBase *pCommand) =0;
2.160 + /**
2.161 + * @brief Unregisters a ConCommandBase.
2.162 + *
2.163 + * @param plugin Parent plugin API pointer.
2.164 + * @param pCommand ConCommandBase to unlink.
2.165 + */
2.166 + virtual void UnregisterConCommandBase(ISmmPlugin *plugin, ConCommandBase *pCommand) =0;
2.167
2.168 - /**
2.169 - * @brief Prints an unformatted string to the remote server console.
2.170 - *
2.171 - * Note: Newlines are not added automatically.
2.172 - *
2.173 - * @param str Message string.
2.174 - */
2.175 - virtual void ConPrint(const char *str) =0;
2.176 + /**
2.177 + * @brief Prints an unformatted string to the remote server console.
2.178 + *
2.179 + * Note: Newlines are not added automatically.
2.180 + *
2.181 + * @param str Message string.
2.182 + */
2.183 + virtual void ConPrint(const char *str) =0;
2.184
2.185 - /**
2.186 - * @brief Prints a formatted message to the remote server console.
2.187 - *
2.188 - * Note: Newlines are not added automatically.
2.189 - *
2.190 - * @param fmt Formatted message.
2.191 - */
2.192 - virtual void ConPrintf(const char *fmt, ...) =0;
2.193 + /**
2.194 + * @brief Prints a formatted message to the remote server console.
2.195 + *
2.196 + * Note: Newlines are not added automatically.
2.197 + *
2.198 + * @param fmt Formatted message.
2.199 + */
2.200 + virtual void ConPrintf(const char *fmt, ...) =0;
2.201
2.202 - /**
2.203 - * @brief Returns the Metamod Version numbers as major version and minor (API) version.
2.204 - * Changes to minor version are guaranteed to be backwards compatible.
2.205 - * Changes to major version are not.
2.206 - *
2.207 - * @param major Filled with the major API version number.
2.208 - * @param minor Filled with the minor API version number.
2.209 - * @param plvers Filled with the current plugin API version number.
2.210 - * @param plmin Filled with the minimum plugin API version number supported.
2.211 - */
2.212 - virtual void GetApiVersions(int &major, int &minor, int &plvers, int &plmin) =0;
2.213 + /**
2.214 + * @brief Returns the Metamod Version numbers as major version and
2.215 + * minor (API) version. Changes to minor version are guaranteed to be
2.216 + * backwards compatible. Changes to major version are not.
2.217 + *
2.218 + * @param major Filled with the major API version number.
2.219 + * @param minor Filled with the minor API version number.
2.220 + * @param plvers Filled with the current plugin API version number.
2.221 + * @param plmin Filled with the minimum plugin API version number
2.222 + * supported.
2.223 + */
2.224 + virtual void GetApiVersions(int &major, int &minor, int &plvers, int &plmin) =0;
2.225
2.226 - /**
2.227 - * @brief Returns sourcehook API version and implementation version.
2.228 - *
2.229 - * @param shvers Filled with the SourceHook API version number.
2.230 - * @param shimpl Filled with the SourceHook implementation number.
2.231 - */
2.232 - virtual void GetShVersions(int &shvers, int &shimpl) =0;
2.233 + /**
2.234 + * @brief Returns sourcehook API version and implementation version.
2.235 + *
2.236 + * @param shvers Filled with the SourceHook API version number.
2.237 + * @param shimpl Filled with the SourceHook implementation number.
2.238 + */
2.239 + virtual void GetShVersions(int &shvers, int &shimpl) =0;
2.240
2.241 - /**
2.242 - * @brief Adds a Metamod listener.
2.243 - *
2.244 - * @param plugin Plugin interface pointer.
2.245 - * @param pListener Listener interface pointer to add.
2.246 - */
2.247 - virtual void AddListener(ISmmPlugin *plugin, IMetamodListener *pListener) =0;
2.248 + /**
2.249 + * @brief Adds a Metamod listener.
2.250 + *
2.251 + * @param plugin Plugin interface pointer.
2.252 + * @param pListener Listener interface pointer to add.
2.253 + */
2.254 + virtual void AddListener(ISmmPlugin *plugin, IMetamodListener *pListener) =0;
2.255
2.256 - /**
2.257 - * @brief Queries the metamod factory
2.258 - *
2.259 - * @param iface String containing interface name
2.260 - * @param ret Optional pointer to store return status
2.261 - * @param id Optional pointer to store id of plugin that overrode interface, 0 if none
2.262 - * @return Returned pointer
2.263 - */
2.264 - virtual void *MetaFactory(const char *iface, int *ret, PluginId *id) =0;
2.265 + /**
2.266 + * @brief Queries the metamod factory
2.267 + *
2.268 + * @param iface String containing interface name
2.269 + * @param ret Optional pointer to store return status
2.270 + * @param id Optional pointer to store id of plugin that
2.271 + * overrode interface, 0 if none
2.272 + * @return Returned pointer
2.273 + */
2.274 + virtual void *MetaFactory(const char *iface, int *ret, PluginId *id) =0;
2.275
2.276 - /**
2.277 - * @brief Given a base interface name, such as ServerGameDLL or ServerGameDLL003,
2.278 - * reformats the string to increase the number, then returns the new number.
2.279 - * This is the base function to InterfaceSearch() and VInterfaceMatch().
2.280 - *
2.281 - * @param iface Input/output interface name. Must be writable.
2.282 - * @param maxlength Maximum length of iface buffer. Must be at least strlen(iface)+4 chars.
2.283 - * @return The newly incremented iface version number.
2.284 - */
2.285 - virtual int FormatIface(char iface[], unsigned int maxlength) =0;
2.286 + /**
2.287 + * @brief Given a base interface name, such as ServerGameDLL or
2.288 + * ServerGameDLL003, reformats the string to increase the number, then
2.289 + * returns the new number. This is the base function to InterfaceSearch()
2.290 + * and VInterfaceMatch().
2.291 + *
2.292 + * @param iface Input/output interface name. Must be writable.
2.293 + * @param maxlength Maximum length of iface buffer. Must be at least
2.294 + * strlen(iface)+4 chars.
2.295 + * @return The newly incremented iface version number.
2.296 + */
2.297 + virtual int FormatIface(char iface[], unsigned int maxlength) =0;
2.298
2.299 - /**
2.300 - * @brief Searches for an interface, eliminating the need to loop through FormatIface().
2.301 - *
2.302 - * @param fn InterfaceFactory function.
2.303 - * @param iface Interface string name.
2.304 - * @param max Maximum version to look up.
2.305 - * @param ret Last return code from interface factory function.
2.306 - * @return Interface pointer, or NULL if not found.
2.307 - */
2.308 - virtual void *InterfaceSearch(CreateInterfaceFn fn, const char *iface, int max, int *ret) =0;
2.309 + /**
2.310 + * @brief Searches for an interface, eliminating the need to loop
2.311 + * through FormatIface().
2.312 + *
2.313 + * @param fn InterfaceFactory function.
2.314 + * @param iface Interface string name.
2.315 + * @param max Maximum version to look up.
2.316 + * @param ret Last return code from interface factory function.
2.317 + * @return Interface pointer, or NULL if not found.
2.318 + */
2.319 + virtual void *InterfaceSearch(CreateInterfaceFn fn,
2.320 + const char *iface,
2.321 + int max,
2.322 + int *ret) =0;
2.323
2.324 - /**
2.325 - * @brief Returns the base directory of the game/server, equivalent to
2.326 - * IVEngineServer::GetGameDir(), except the path is absolute.
2.327 - *
2.328 - * @return Static pointer to game's absolute basedir.
2.329 - */
2.330 - virtual const char *GetBaseDir() =0;
2.331 + /**
2.332 + * @brief Returns the base directory of the game/server, equivalent to
2.333 + * IVEngineServer::GetGameDir(), except the path is absolute.
2.334 + *
2.335 + * @return Static pointer to game's absolute basedir.
2.336 + */
2.337 + virtual const char *GetBaseDir() =0;
2.338
2.339 - /**
2.340 - * @brief Formats a file path to the local OS.
2.341 - *
2.342 - * Does not include any base directories. Note that all slashes and black
2.343 - * slashes are reverted to the local OS's expectancy.
2.344 - *
2.345 - * @param buffer Destination buffer to store path.
2.346 - * @param len Maximum length of buffer, including null terminator.
2.347 - * @param fmt Formatted string.
2.348 - */
2.349 - virtual void PathFormat(char *buffer, size_t len, const char *fmt, ...) =0;
2.350 + /**
2.351 + * @brief Formats a file path to the local OS.
2.352 + *
2.353 + * Does not include any base directories. Note that all slashes and
2.354 + * black slashes are reverted to the local OS's expectancy.
2.355 + *
2.356 + * @param buffer Destination buffer to store path.
2.357 + * @param len Maximum length of buffer, including null
2.358 + * terminator.
2.359 + * @param fmt Formatted string.
2.360 + */
2.361 + virtual void PathFormat(char *buffer, size_t len, const char *fmt, ...) =0;
2.362
2.363 - /**
2.364 - * @brief Prints text in the specified client's console. Same as
2.365 - * IVEngineServer::ClientPrintf except that it allows for string formatting.
2.366 - *
2.367 - * @param client Client edict pointer.
2.368 - * @param fmt Formatted string to print to the client.
2.369 - */
2.370 - virtual void ClientConPrintf(edict_t *client, const char *fmt, ...) =0;
2.371 + /**
2.372 + * @brief Prints text in the specified client's console. Same as
2.373 + * IVEngineServer::ClientPrintf except that it allows for string
2.374 + * formatting.
2.375 + *
2.376 + * @param client Client edict pointer.
2.377 + * @param fmt Formatted string to print to the client.
2.378 + */
2.379 + virtual void ClientConPrintf(edict_t *client, const char *fmt, ...) =0;
2.380
2.381 - /**
2.382 - * @brief Wrapper around InterfaceSearch(). Assumes no maximum.
2.383 - * This is designed to replace the fact that searches only went upwards.
2.384 - * The "V" is intended to convey that this is for Valve formatted interface strings.
2.385 - *
2.386 - * @param fn Interface factory function.
2.387 - * @param iface Interface string.
2.388 - * @param min Minimum value to search from. If zero, searching
2.389 - * begins from the first available version regardless
2.390 - * of the interface. Note that this can return
2.391 - * interfaces EARLIER than the version specified. A
2.392 - * value of -1 (default) specifies the string version
2.393 - * as the minimum. Any other value specifices the
2.394 - * minimum value to search from.
2.395 - * @return Interface pointer, or NULL if not found.
2.396 - */
2.397 - virtual void *VInterfaceMatch(CreateInterfaceFn fn, const char *iface, int min=-1) =0;
2.398 + /**
2.399 + * @brief Wrapper around InterfaceSearch(). Assumes no maximum.
2.400 + * This is designed to replace the fact that searches only went upwards.
2.401 + * The "V" is intended to convey that this is for Valve formatted
2.402 + * interface strings.
2.403 + *
2.404 + * @param fn Interface factory function.
2.405 + * @param iface Interface string.
2.406 + * @param min Minimum value to search from. If zero, searching
2.407 + * begins from the first available version regardless
2.408 + * of the interface. Note that this can return
2.409 + * interfaces EARLIER than the version specified. A
2.410 + * value of -1 (default) specifies the string version
2.411 + * as the minimum. Any other value specifices the
2.412 + * minimum value to search from.
2.413 + * @return Interface pointer, or NULL if not found.
2.414 + */
2.415 + virtual void *VInterfaceMatch(CreateInterfaceFn fn,
2.416 + const char *iface,
2.417 + int min=-1) =0;
2.418
2.419 - /**
2.420 - * @brief Tells SourceMM to add VSP hooking capability to plugins.
2.421 - *
2.422 - * Since this potentially uses more resources than it would otherwise,
2.423 - * plugins have to explicitly enable the feature. Whether requested or
2.424 - * not, if it is enabled, all plugins will get a pointer to the VSP
2.425 - * listener through IMetamodListener. This will not be called more than
2.426 - * once for a given plugin; if it is requested more than once, each
2.427 - * successive call will only give the pointer to plugins which have not
2.428 - * yet received it.
2.429 - */
2.430 - virtual void EnableVSPListener() =0;
2.431 + /**
2.432 + * @brief Tells SourceMM to add VSP hooking capability to plugins.
2.433 + *
2.434 + * Since this potentially uses more resources than it would otherwise,
2.435 + * plugins have to explicitly enable the feature. Whether requested or
2.436 + * not, if it is enabled, all plugins will get a pointer to the VSP
2.437 + * listener through IMetamodListener. This will not be called more than
2.438 + * once for a given plugin; if it is requested more than once, each
2.439 + * successive call will only give the pointer to plugins which have not
2.440 + * yet received it.
2.441 + */
2.442 + virtual void EnableVSPListener() =0;
2.443
2.444 - /**
2.445 - * @brief Returns the interface version of the GameDLL's IServerGameDLL
2.446 - * implementation.
2.447 - *
2.448 - * @return Interface version of the loaded IServerGameDLL.
2.449 - */
2.450 - virtual int GetGameDLLVersion() =0;
2.451 + /**
2.452 + * @brief Returns the interface version of the GameDLL's IServerGameDLL
2.453 + * implementation.
2.454 + *
2.455 + * @return Interface version of the loaded IServerGameDLL.
2.456 + */
2.457 + virtual int GetGameDLLVersion() =0;
2.458
2.459 - /**
2.460 - * @brief Returns the number of user messages in the GameDLL.
2.461 - *
2.462 - * @return Number of user messages, or -1 if SourceMM has
2.463 - * failed to get user message list.
2.464 - */
2.465 - virtual int GetUserMessageCount() =0;
2.466 + /**
2.467 + * @brief Returns the number of user messages in the GameDLL.
2.468 + *
2.469 + * @return Number of user messages, or -1 if SourceMM has
2.470 + * failed to get user message list.
2.471 + */
2.472 + virtual int GetUserMessageCount() =0;
2.473
2.474 - /**
2.475 - * @brief Returns the index of the specified user message.
2.476 - *
2.477 - * @param name User message name.
2.478 - * @param size Optional pointer to store size of user message.
2.479 - * @return Message index, or -1 on failure.
2.480 - */
2.481 - virtual int FindUserMessage(const char *name, int *size=NULL) =0;
2.482 + /**
2.483 + * @brief Returns the index of the specified user message.
2.484 + *
2.485 + * @param name User message name.
2.486 + * @param size Optional pointer to store size of user message.
2.487 + * @return Message index, or -1 on failure.
2.488 + */
2.489 + virtual int FindUserMessage(const char *name, int *size=NULL) =0;
2.490
2.491 - /**
2.492 - * @brief Returns the name of the specified user message.
2.493 - *
2.494 - * @param index User message index.
2.495 - * @param size Optional pointer to store size of user message.
2.496 - * @return Message name, or NULL on failure.
2.497 - */
2.498 - virtual const char *GetUserMessage(int index, int *size=NULL) =0;
2.499 + /**
2.500 + * @brief Returns the name of the specified user message.
2.501 + *
2.502 + * @param index User message index.
2.503 + * @param size Optional pointer to store size of user message.
2.504 + * @return Message name, or NULL on failure.
2.505 + */
2.506 + virtual const char *GetUserMessage(int index, int *size=NULL) =0;
2.507
2.508 - /**
2.509 - * @brief Returns the highest interface version of IServerPluginCallbacks
2.510 - * that the engine supports. This is useful for games that run on older
2.511 - * versions of the Source engine, such as The Ship.
2.512 - *
2.513 - * @return Highest interface version of IServerPluginCallbacks.
2.514 - * Returns 0 if SourceMM's VSP listener isn't currently
2.515 - * enabled.
2.516 - */
2.517 - virtual int GetVSPVersion() =0;
2.518 + /**
2.519 + * @brief Returns the highest interface version of IServerPluginCallbacks
2.520 + * that the engine supports. This is useful for games that run on older
2.521 + * versions of the Source engine, such as The Ship.
2.522 + *
2.523 + * @return Highest interface version of IServerPluginCallbacks.
2.524 + * Returns 0 if SourceMM's VSP listener isn't
2.525 + * currently enabled.
2.526 + */
2.527 + virtual int GetVSPVersion() =0;
2.528
2.529 - /**
2.530 - * @brief Returns the engine interface that MM:S is using as a backend.
2.531 - *
2.532 - * The values will be one of the SOURCE_ENGINE_* constants from the top
2.533 - * of this file.
2.534 - *
2.535 - * @return A SOURCE_ENGINE_* constant value.
2.536 - */
2.537 - virtual int GetSourceEngineBuild() =0;
2.538 + /**
2.539 + * @brief Returns the engine interface that MM:S is using as a backend.
2.540 + *
2.541 + * The values will be one of the SOURCE_ENGINE_* constants from the top
2.542 + * of this file.
2.543 + *
2.544 + * @return A SOURCE_ENGINE_* constant value.
2.545 + */
2.546 + virtual int GetSourceEngineBuild() =0;
2.547
2.548 - /**
2.549 - * @brief Returns the VSP listener loaded.
2.550 - *
2.551 - * This is useful for late-loading plugins which need to decide whether
2.552 - * to add a listener or not (or need to get the pointer at all).
2.553 - *
2.554 - * @param Optional pointer to store the VSP version.
2.555 - * @return IServerPluginCallbacks pointer, or NULL if an
2.556 - * IMetamodListener event has yet to occur for
2.557 - * EnableVSPListener().
2.558 - */
2.559 - virtual IServerPluginCallbacks *GetVSPInfo(int *pVersion) =0;
2.560 + /**
2.561 + * @brief Returns the VSP listener loaded.
2.562 + *
2.563 + * This is useful for late-loading plugins which need to decide whether
2.564 + * to add a listener or not (or need to get the pointer at all).
2.565 + *
2.566 + * @param Optional pointer to store the VSP version.
2.567 + * @return IServerPluginCallbacks pointer, or NULL if an
2.568 + * IMetamodListener event has yet to occur for
2.569 + * EnableVSPListener().
2.570 + */
2.571 + virtual IServerPluginCallbacks *GetVSPInfo(int *pVersion) =0;
2.572
2.573 - /**
2.574 - * @brief Formats a string. This is a platform safe wrapper around
2.575 - * snprintf/_snprintf.
2.576 - *
2.577 - * @param buffer Buffer to write to.
2.578 - * @param maxlength Maximum length of the buffer.
2.579 - * @param format Format specifiers.
2.580 - * @param ... Format arguments.
2.581 - * @return Number of bytes actually written, not including the
2.582 - * null terminator.
2.583 - */
2.584 + /**
2.585 + * @brief Formats a string. This is a platform safe wrapper around
2.586 + * snprintf/_snprintf.
2.587 + *
2.588 + * @param buffer Buffer to write to.
2.589 + * @param maxlength Maximum length of the buffer.
2.590 + * @param format Format specifiers.
2.591 + * @param ... Format arguments.
2.592 + * @return Number of bytes actually written, not including
2.593 + * the null terminator.
2.594 + */
2.595 virtual size_t Format(char *buffer,
2.596 - size_t maxlength,
2.597 - const char *format,
2.598 - ...) =0;
2.599 + size_t maxlength,
2.600 + const char *format,
2.601 + ...) =0;
2.602
2.603 /**
2.604 * @brief Formats a string. This is a platform safe wrapper around
2.605 @@ -364,11 +378,15 @@
2.606 * null terminator.
2.607 */
2.608 virtual size_t FormatArgs(char *buffer,
2.609 - size_t maxlength,
2.610 - const char *format,
2.611 - va_list ap) =0;
2.612 -};
2.613 + size_t maxlength,
2.614 + const char *format,
2.615 + va_list ap) =0;
2.616 + };
2.617 +}
2.618
2.619 +#if !defined METAMOD_NO_AUTO_NAMESPACE
2.620 +using namespace SourceMM;
2.621 +#endif
2.622
2.623 /**
2.624 * Version History
3.1 --- a/sourcemm/ISmmPlugin.h Mon Oct 08 17:32:28 2007 +0000
3.2 +++ b/sourcemm/ISmmPlugin.h Mon Oct 08 18:47:31 2007 +0000
3.3 @@ -35,331 +35,386 @@
3.4
3.5 #include <interface.h>
3.6 #include <sourcehook.h>
3.7 -#include "ISmmAPI.h"
3.8 +#include <IPluginManager.h>
3.9 +#include <ISmmAPI.h>
3.10
3.11 -#define PLAPI_VERSION 13
3.12 -#define PLAPI_NAME "ISmmPlugin"
3.13 +#define METAMOD_PLAPI_VERSION 13 /**< Version of this header file */
3.14 +#define METAMOD_PLAPI_NAME "ISmmPlugin" /**< Name of the plugin interface */
3.15
3.16 -class ISmmAPI;
3.17 -
3.18 -class ISmmPlugin
3.19 +namespace SourceMM
3.20 {
3.21 -public:
3.22 - virtual int GetApiVersion() { return PLAPI_VERSION; }
3.23 - virtual ~ISmmPlugin() { }
3.24 -public:
3.25 - /**
3.26 - * @brief Called on plugin load.
3.27 - *
3.28 - * NOTE - As of API 7, this is called as DLLInit() executes - after the parameters are known, but before
3.29 - * the original GameDLL function is called. Therefore, you cannot hook it, but you don't need to -
3.30 - * Load() is basically your hook.
3.31 - * NOTE - As of API 7, you can override factories before the engine and gamedll exchange them.
3.32 - * However, take care to note that if your plugin is unloaded, and the gamedll/engine have cached
3.33 - * an interface you've passed, something will definitely crash. Be careful.
3.34 - *
3.35 - * @param id Internal id of plugin. Saved globally by PLUGIN_SAVEVARS()
3.36 - * @param ismm External API for SourceMM. Saved globally by PLUGIN_SAVEVARS()
3.37 - * @param list Contains a list of factories. Hook a factory call by setting one equal to your own function.
3.38 - * @param late Set to true if your plugin was loaded late (not at server load).
3.39 - * @param error Error message buffer
3.40 - * @param maxlen Size of error message buffer
3.41 - * @return True if successful, return false to reject the load.
3.42 - */
3.43 - virtual bool Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlength, bool late) =0;
3.44 + class ISmmAPI;
3.45
3.46 /**
3.47 - * @brief Called when your plugin is "queried".
3.48 - *
3.49 - * This is useful for rejecting a loaded state. For example, if your plugin wants
3.50 - * to stop operating, it can simply return false and copy an error message. This
3.51 - * will notify other plugins or MM:S of something bad that happened. NOTE - MM:S
3.52 - * will not cache the return state, so if you return false, your plugin will not
3.53 - * actually be paused or unloaded. This callback will be called when:
3.54 - * - Another plugin requests it
3.55 - * - Someone types "meta list", it will show up as "REFUSED"
3.56 - * - When Metamod need to re-check the plugin's status
3.57 - * - If the plugin does something like overload a factory, Metamod will make sure the Query() returns true
3.58 - * before calling it.
3.59 - * Also note that this query will only override Metamod when the plugin is running and not paused.
3.60 - *
3.61 - * @param error Buffer for error message. This can be NULL!
3.62 - * @param maxlen Maximum length of error buffer.
3.63 - * @return Status code - true for okay, false for badness.
3.64 + * @brief Callbacks that a plugin must expose.
3.65 */
3.66 - virtual bool QueryRunning(char *error, size_t maxlen)
3.67 + class ISmmPlugin
3.68 {
3.69 - return true;
3.70 - }
3.71 + public:
3.72 + /**
3.73 + * @brief Called to request the plugin's API version.
3.74 + *
3.75 + * This is the first callback invoked, and always remains at the top
3.76 + * of the virtual table.
3.77 + *
3.78 + * @return Plugin API version.
3.79 + */
3.80 + virtual int GetApiVersion()
3.81 + {
3.82 + return METAMOD_PLAPI_VERSION;
3.83 + }
3.84 +
3.85 + /**
3.86 + * @brief Virtual destructor so GCC doesn't complain.
3.87 + */
3.88 + virtual ~ISmmPlugin()
3.89 + {
3.90 + }
3.91
3.92 - /**
3.93 - * @brief Called on plugin unload. You can return false if you know your plugin
3.94 - * is not capable of restoring critical states it modifies.
3.95 - *
3.96 - * @param error Error message buffer
3.97 - * @param maxlen Size of error message buffer
3.98 - * @return True on success, return false to request no unload.
3.99 - */
3.100 - virtual bool Unload(char *error, size_t maxlen)
3.101 - {
3.102 - return true;
3.103 - }
3.104 + public:
3.105 + /**
3.106 + * @brief Called on plugin load.
3.107 + *
3.108 + * This is called as DLLInit() executes - after the parameters are
3.109 + * known, but before the original GameDLL function is called.
3.110 + * Therefore, you cannot hook it, but you don't need to - Load() is
3.111 + * basically your hook. You can override factories before the engine
3.112 + * and gamedll exchange them. However, take care to note that if your
3.113 + * plugin is unloaded, and the gamedll/engine have cached an interface
3.114 + * you've passed, something will definitely crash. Be careful.
3.115 + *
3.116 + * @param id Internal id of plugin. Saved globally by PLUGIN_SAVEVARS()
3.117 + * @param ismm External API for SourceMM. Saved globally by PLUGIN_SAVEVARS()
3.118 + * @param error Error message buffer
3.119 + * @param maxlength Size of error message buffer
3.120 + * @param late Set to true if your plugin was loaded late (not at server load).
3.121 + * @return True if successful, return false to reject the load.
3.122 + */
3.123 + virtual bool Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlength, bool late) =0;
3.124
3.125 - /** @brief Called on plugin pause.
3.126 - *
3.127 - * @param error Error message buffer
3.128 - * @param maxlen Size of error message buffer
3.129 - * @return True on success, return false to request no pause.
3.130 - */
3.131 - virtual bool Pause(char *error, size_t maxlen)
3.132 - {
3.133 - return true;
3.134 - }
3.135 -
3.136 - /** @brief Called on plugin unpause.
3.137 - *
3.138 - * @param error Error message buffer
3.139 - * @param maxlen Size of error message buffer
3.140 - * @return True on success, return false to request no unpause.
3.141 - */
3.142 - virtual bool Unpause(char *error, size_t maxlen)
3.143 - {
3.144 - return true;
3.145 - }
3.146 -public:
3.147 - /** @brief Return author as string */
3.148 - virtual const char *GetAuthor() =0;
3.149 + /**
3.150 + * @brief Called when all plugins have been loaded.
3.151 + *
3.152 + * This is called after DLLInit(), and thus the mod has been mostly initialized.
3.153 + * It is also safe to assume that all other (automatically loaded) plugins are now
3.154 + * ready to start interacting, because they are all loaded.
3.155 + */
3.156 + virtual void AllPluginsLoaded()
3.157 + {
3.158 + }
3.159
3.160 - /** @brief Return plugin name as string */
3.161 - virtual const char *GetName() =0;
3.162 -
3.163 - /** @brief Return a description as string */
3.164 - virtual const char *GetDescription() =0;
3.165 -
3.166 - /** @brief Return a URL as string */
3.167 - virtual const char *GetURL() =0;
3.168 + /**
3.169 + * @brief Called when your plugin is "queried".
3.170 + *
3.171 + * This is useful for rejecting a loaded state. For example, if your
3.172 + * plugin wants to stop operating, it can simply return false and copy
3.173 + * an error message. This will notify other plugins or MM:S of
3.174 + * something bad that happened. MM:S will not cache the return state,
3.175 + * so if you return false, your plugin will not actually be paused or
3.176 + * unloaded. This callback will be called when:
3.177 + * - Another plugin requests it
3.178 + * - Someone types "meta list", it will show up as "REFUSED"
3.179 + * - When Metamod need to re-check the plugin's status
3.180 + * - If the plugin does something like overload a factory, Metamod
3.181 + * will make sure the Query() returns true before calling it.
3.182 + * Also note that this query will only override Metamod when the
3.183 + * plugin is running and not paused.
3.184 + *
3.185 + * @param error Buffer for error message, or NULL if none.
3.186 + * @param maxlen Maximum length of error buffer.
3.187 + * @return Status code - true for okay, false for badness.
3.188 + */
3.189 + virtual bool QueryRunning(char *error, size_t maxlen)
3.190 + {
3.191 + return true;
3.192 + }
3.193
3.194 - /** @brief Return quick license code as string */
3.195 - virtual const char *GetLicense() =0;
3.196 -
3.197 - /** @brief Return version as string */
3.198 - virtual const char *GetVersion() =0;
3.199 -
3.200 - /** @brief Return author as string */
3.201 - virtual const char *GetDate() =0;
3.202 + /**
3.203 + * @brief Called on plugin unload. You can return false if you know
3.204 + * your plugin is not capable of restoring critical states it modifies.
3.205 + *
3.206 + * @param error Error message buffer
3.207 + * @param maxlen Size of error message buffer
3.208 + * @return True on success, return false to request no unload.
3.209 + */
3.210 + virtual bool Unload(char *error, size_t maxlen)
3.211 + {
3.212 + return true;
3.213 + }
3.214
3.215 - /** @brief Return author as string */
3.216 - virtual const char *GetLogTag() =0;
3.217 -public:
3.218 - /**
3.219 - * @brief Called when all plugins have been loaded.
3.220 - *
3.221 - * This is called after DLLInit(), and thus the mod has been mostly initialized.
3.222 - * It is also safe to assume that all other (automatically loaded) plugins are now
3.223 - * ready to start interacting, because they are all loaded.
3.224 - */
3.225 - virtual void AllPluginsLoaded()
3.226 - {
3.227 - }
3.228 -};
3.229 + /**
3.230 + * @brief Called on plugin pause.
3.231 + *
3.232 + * @param error Error message buffer
3.233 + * @param maxlen Size of error message buffer
3.234 + * @return True on success, return false to request no pause.
3.235 + */
3.236 + virtual bool Pause(char *error, size_t maxlen)
3.237 + {
3.238 + return true;
3.239 + }
3.240
3.241 -/**
3.242 - * @brief Added in 1.1 so plugins could listen to specific events
3.243 - */
3.244 -class IMetamodListener
3.245 -{
3.246 -public:
3.247 - virtual ~IMetamodListener()
3.248 - {
3.249 - }
3.250 -public:
3.251 - /**
3.252 - * @brief Called when a plugin is loaded.
3.253 - *
3.254 - * @param id Id of the plugin.
3.255 - */
3.256 - virtual void OnPluginLoad(PluginId id)
3.257 - {
3.258 - }
3.259 -
3.260 - /**
3.261 - * @brief Called when a plugin is unloaded.
3.262 - *
3.263 - * @param id Id of the plugin.
3.264 - */
3.265 - virtual void OnPluginUnload(PluginId id)
3.266 - {
3.267 - }
3.268 + /**
3.269 + * @brief Called on plugin unpause.
3.270 + *
3.271 + * @param error Error message buffer
3.272 + * @param maxlen Size of error message buffer
3.273 + * @return True on success, return false to request no unpause.
3.274 + */
3.275 + virtual bool Unpause(char *error, size_t maxlen)
3.276 + {
3.277 + return true;
3.278 + }
3.279 + public:
3.280 + /** @brief Return author as string */
3.281 + virtual const char *GetAuthor() =0;
3.282 +
3.283 + /** @brief Return plugin name as string */
3.284 + virtual const char *GetName() =0;
3.285 +
3.286 + /** @brief Return a description as string */
3.287 + virtual const char *GetDescription() =0;
3.288 +
3.289 + /** @brief Return a URL as string */
3.290 + virtual const char *GetURL() =0;
3.291 +
3.292 + /** @brief Return quick license code as string */
3.293 + virtual const char *GetLicense() =0;
3.294 +
3.295 + /** @brief Return version as string */
3.296 + virtual const char *GetVersion() =0;
3.297 +
3.298 + /** @brief Return author as string */
3.299 + virtual const char *GetDate() =0;
3.300 +
3.301 + /** @brief Return author as string */
3.302 + virtual const char *GetLogTag() =0;
3.303 + };
3.304
3.305 /**
3.306 - * @brief Called when a plugin is paused.
3.307 - *
3.308 - * @param id Id of the plugin.
3.309 + * @brief Various events that Metamod can fire.
3.310 */
3.311 - virtual void OnPluginPause(PluginId id)
3.312 - {
3.313 - }
3.314 -
3.315 - /**
3.316 - * @brief Called when a plugin is unpaused.
3.317 - *
3.318 - * @param id Id of the plugin.
3.319 - */
3.320 - virtual void OnPluginUnpause(PluginId id)
3.321 + class IMetamodListener
3.322 {
3.323 - }
3.324 -
3.325 - /**
3.326 - * @brief Called when the level is loaded (after GameInit, before ServerActivate).
3.327 - *
3.328 - * To override this, hook IServerGameDLL::LevelInit().
3.329 - *
3.330 - * @param pMapName Name of the map.
3.331 - * @param pMapEntities Lump string of the map entities, in KeyValue format.
3.332 - * @param pOldLevel Unknown.
3.333 - * @param pLandmarkName Unknown.
3.334 - * @param loadGame Unknown.
3.335 - * @param background Unknown.
3.336 - */
3.337 - virtual void OnLevelInit(char const *pMapName, char const *pMapEntities, char const *pOldLevel, char const *pLandmarkName, bool loadGame, bool background) { }
3.338 -
3.339 - /**
3.340 - * @brief Called when the level is shut down. May be called more than once.
3.341 - */
3.342 - virtual void OnLevelShutdown()
3.343 - {
3.344 - }
3.345 -
3.346 - /**
3.347 - * @brief Called when engineFactory() is used through Metamod:Source's wrapper.
3.348 - * This can be used to provide interfaces to other plugins or the GameDLL.
3.349 - *
3.350 - * If ret is passed, you should fill it with IFACE_OK or IFACE_FAILED.
3.351 - *
3.352 - * @param iface Interface string.
3.353 - * @param ret Optional pointer to store return code.
3.354 - * @return Generic pointer to the interface, or NULL if not found.
3.355 - */
3.356 - virtual void *OnEngineQuery(const char *iface, int *ret)
3.357 - {
3.358 - if (ret)
3.359 + public:
3.360 + /**
3.361 + * @brief Called when a plugin is loaded.
3.362 + *
3.363 + * @param id Id of the plugin.
3.364 + */
3.365 + virtual void OnPluginLoad(PluginId id)
3.366 {
3.367 - *ret = IFACE_FAILED;
3.368 }
3.369
3.370 - return NULL;
3.371 - }
3.372 + /**
3.373 + * @brief Called when a plugin is unloaded.
3.374 + *
3.375 + * @param id Id of the plugin.
3.376 + */
3.377 + virtual void OnPluginUnload(PluginId id)
3.378 + {
3.379 + }
3.380 +
3.381 + /**
3.382 + * @brief Called when a plugin is paused.
3.383 + *
3.384 + * @param id Id of the plugin.
3.385 + */
3.386 + virtual void OnPluginPause(PluginId id)
3.387 + {
3.388 + }
3.389 +
3.390 + /**
3.391 + * @brief Called when a plugin is unpaused.
3.392 + *
3.393 + * @param id Id of the plugin.
3.394 + */
3.395 + virtual void OnPluginUnpause(PluginId id)
3.396 + {
3.397 + }
3.398 +
3.399 + /**
3.400 + * @brief Called when the level is loaded (after GameInit, before
3.401 + * ServerActivate).
3.402 + *
3.403 + * To override this, hook IServerGameDLL::LevelInit().
3.404 + *
3.405 + * @param pMapName Name of the map.
3.406 + * @param pMapEntities Lump string of the map entities, in KeyValues
3.407 + * format.
3.408 + * @param pOldLevel Unknown.
3.409 + * @param pLandmarkName Unknown.
3.410 + * @param loadGame Unknown.
3.411 + * @param background Unknown.
3.412 + */
3.413 + virtual void OnLevelInit(char const *pMapName,
3.414 + char const *pMapEntities,
3.415 + char const *pOldLevel,
3.416 + char const *pLandmarkName,
3.417 + bool loadGame,
3.418 + bool background)
3.419 + {
3.420 + }
3.421
3.422 - /**
3.423 - * @brief Called when the physics factory is used through Metamod:Source's wrapper.
3.424 - * This can be used to provide interfaces to other plugins.
3.425 - *
3.426 - * If ret is passed, you should fill it with IFACE_OK or IFACE_FAILED.
3.427 - *
3.428 - * @param iface Interface string.
3.429 - * @param ret Optional pointer to store return code.
3.430 - * @return Generic pointer to the interface, or NULL if not found.
3.431 - */
3.432 - virtual void *OnPhysicsQuery(const char *iface, int *ret)
3.433 - {
3.434 - if (ret)
3.435 + /**
3.436 + * @brief Called when the level is shut down. May be called more than
3.437 + * once.
3.438 + */
3.439 + virtual void OnLevelShutdown()
3.440 {
3.441 - *ret = IFACE_FAILED;
3.442 + }
3.443 +
3.444 + /**
3.445 + * @brief Called when engineFactory() is used through Metamod:Source's
3.446 + * wrapper. This can be used to provide interfaces to other plugins or
3.447 + * the GameDLL.
3.448 + *
3.449 + * If ret is passed, you should fill it with IFACE_OK or IFACE_FAILED.
3.450 + *
3.451 + * @param iface Interface string.
3.452 + * @param ret Optional pointer to store return code.
3.453 + * @return Generic pointer to the interface, or NULL if
3.454 + * not found.
3.455 + */
3.456 + virtual void *OnEngineQuery(const char *iface, int *ret)
3.457 + {
3.458 + if (ret)
3.459 + {
3.460 + *ret = IFACE_FAILED;
3.461 + }
3.462 +
3.463 + return NULL;
3.464 }
3.465
3.466 - return NULL;
3.467 - }
3.468 -
3.469 - /**
3.470 - * @brief Called when the filesystem factory is used through Metamod:Source's wrapper.
3.471 - * This can be used to provide interfaces to other plugins.
3.472 - *
3.473 - * If ret is passed, you should fill it with IFACE_OK or IFACE_FAILED.
3.474 - *
3.475 - * @param iface Interface string.
3.476 - * @param ret Optional pointer to store return code.
3.477 - * @return Generic pointer to the interface, or NULL if not found.
3.478 - */
3.479 - virtual void *OnFileSystemQuery(const char *iface, int *ret)
3.480 - {
3.481 - if (ret)
3.482 + /**
3.483 + * @brief Called when the physics factory is used through
3.484 + * Metamod:Source's wrapper. This can be used to provide interfaces to
3.485 + * other plugins.
3.486 + *
3.487 + * If ret is passed, you should fill it with IFACE_OK or IFACE_FAILED.
3.488 + *
3.489 + * @param iface Interface string.
3.490 + * @param ret Optional pointer to store return code.
3.491 + * @return Generic pointer to the interface, or NULL if
3.492 + * not found.
3.493 + */
3.494 + virtual void *OnPhysicsQuery(const char *iface, int *ret)
3.495 {
3.496 - *ret = IFACE_FAILED;
3.497 + if (ret)
3.498 + {
3.499 + *ret = IFACE_FAILED;
3.500 + }
3.501 +
3.502 + return NULL;
3.503 }
3.504 -
3.505 - return NULL;
3.506 - }
3.507
3.508 - /**
3.509 - * @brief Called when the server DLL's factory is used through Metamod:Source's wrapper.
3.510 - * This can be used to provide interfaces to other plugins.
3.511 - *
3.512 - * If ret is passed, you should fill it with IFACE_OK or IFACE_FAILED.
3.513 - *
3.514 - * @param iface Interface string.
3.515 - * @param ret Optional pointer to store return code.
3.516 - * @return Generic pointer to the interface, or NULL if not found.
3.517 - */
3.518 - virtual void *OnGameDLLQuery(const char *iface, int *ret)
3.519 - {
3.520 - if (ret)
3.521 + /**
3.522 + * @brief Called when the filesystem factory is used through
3.523 + * Metamod:Source's wrapper. This can be used to provide interfaces to
3.524 + * other plugins.
3.525 + *
3.526 + * If ret is passed, you should fill it with IFACE_OK or IFACE_FAILED.
3.527 + *
3.528 + * @param iface Interface string.
3.529 + * @param ret Optional pointer to store return code.
3.530 + * @return Generic pointer to the interface, or NULL if not
3.531 + * found.
3.532 + */
3.533 + virtual void *OnFileSystemQuery(const char *iface, int *ret)
3.534 {
3.535 - *ret = IFACE_FAILED;
3.536 + if (ret)
3.537 + {
3.538 + *ret = IFACE_FAILED;
3.539 + }
3.540 +
3.541 + return NULL;
3.542 }
3.543
3.544 - return NULL;
3.545 - }
3.546 + /**
3.547 + * @brief Called when the server DLL's factory is used through
3.548 + * Metamod:Source's wrapper. This can be used to provide interfaces to
3.549 + * other plugins.
3.550 + *
3.551 + * If ret is passed, you should fill it with IFACE_OK or IFACE_FAILED.
3.552 + *
3.553 + * @param iface Interface string.
3.554 + * @param ret Optional pointer to store return code.
3.555 + * @return Generic pointer to the interface, or NULL if not
3.556 + * found.
3.557 + */
3.558 + virtual void *OnGameDLLQuery(const char *iface, int *ret)
3.559 + {
3.560 + if (ret)
3.561 + {
3.562 + *ret = IFACE_FAILED;
3.563 + }
3.564 +
3.565 + return NULL;
3.566 + }
3.567
3.568 - /**
3.569 - * @brief Called when Metamod's own factory is invoked.
3.570 - * This can be used to provide interfaces to other plugins.
3.571 - *
3.572 - * If ret is passed, you should fill it with IFACE_OK or IFACE_FAILED.
3.573 - *
3.574 - * @param iface Interface string.
3.575 - * @param ret Optional pointer to store return code.
3.576 - * @return Generic pointer to the interface, or NULL if not found.
3.577 - */
3.578 - virtual void *OnMetamodQuery(const char *iface, int *ret)
3.579 - {
3.580 - if (ret)
3.581 + /**
3.582 + * @brief Called when Metamod's own factory is invoked.
3.583 + * This can be used to provide interfaces to other plugins.
3.584 + *
3.585 + * If ret is passed, you should fill it with IFACE_OK or IFACE_FAILED.
3.586 + *
3.587 + * @param iface Interface string.
3.588 + * @param ret Optional pointer to store return code.
3.589 + * @return Generic pointer to the interface, or NULL if not
3.590 + * found.
3.591 + */
3.592 + virtual void *OnMetamodQuery(const char *iface, int *ret)
3.593 {
3.594 - *ret = IFACE_FAILED;
3.595 + if (ret)
3.596 + {
3.597 + *ret = IFACE_FAILED;
3.598 + }
3.599 +
3.600 + return NULL;
3.601 }
3.602
3.603 - return NULL;
3.604 - }
3.605 + /**
3.606 + * @brief Called when Metamod:Source acquires a valid
3.607 + * IServerPluginCallbacks pointer to be used for hooking by plugins.
3.608 + *
3.609 + * This will only be called after a call to ISmmAPI::EnableVSPListener().
3.610 + * If called before GameInit, this callback will occur before LevelInit.
3.611 + * Otherwise, it will be called on the first call after that.
3.612 + *
3.613 + * This callback is provided to all plugins regardless of which (or how
3.614 + * many) called EnableVSPListener(), but only if at least one did in
3.615 + * fact enable it, and only once for all plugins. That is, a late
3.616 + * loading plugin should use ISmmAPI::GetVSPInfo() before relying on
3.617 + * this callback.
3.618 + *
3.619 + * @param iface Interface pointer. If NULL, then the VSP
3.620 + * listening construct failed to initialize and
3.621 + * is not available.
3.622 + */
3.623 + virtual void OnVSPListening(IServerPluginCallbacks *iface)
3.624 + {
3.625 + }
3.626
3.627 - /**
3.628 - * @brief Called when Metamod:Source acquires a valid IServerPluginCallbacks
3.629 - * pointer to be used for hooking by plugins.
3.630 - *
3.631 - * This will only be called after a call to ISmmAPI::EnableVSPListener().
3.632 - * If called before GameInit, this callback will occur before LevelInit.
3.633 - * Otherwise, it will be called on the first call after that.
3.634 - *
3.635 - * This callback is provided to all plugins regardless of which (or how many)
3.636 - * called EnableVSPListener(), but only if at least one did in fact enable it.
3.637 - *
3.638 - * This callback is only available for plugins using API v1:5 (Metamod:Source 1.4+).
3.639 - * If a plugin loads lately, it may still call EnableVSPListener().
3.640 - *
3.641 - * @param iface Interface pointer. If NULL, then the VSP listening construct
3.642 - * failed to initialize and is not available.
3.643 - */
3.644 - virtual void OnVSPListening(IServerPluginCallbacks *iface) { }
3.645 + /**
3.646 + * @brief Called when Metamod:Source is about to remove a concommand or
3.647 + * convar. This can also be called if ISmmAPI::UnregisterConCmdBase is
3.648 + * used by a plugin.
3.649 + *
3.650 + * @param id Id of the plugin that created the concommand or
3.651 + * convar.
3.652 + * @param pCommand Pointer to concommand or convar that is being
3.653 + * removed.
3.654 + */
3.655 + virtual void OnUnlinkConCommandBase(PluginId id, ConCommandBase *pCommand)
3.656 + {
3.657 + }
3.658 + };
3.659 +}
3.660
3.661 - /**
3.662 - * @brief Called when Metamod:Source is about to remove a concommand or convar.
3.663 - * This can also be called if ISmmAPI::UnregisterConCmdBase is used by a plugin.
3.664 - *
3.665 - * @param id Id of the plugin that created the concommand or convar.
3.666 - * @param pCommand Pointer to concommand or convar that is being removed.
3.667 - */
3.668 - virtual void OnUnlinkConCommandBase(PluginId id, ConCommandBase *pCommand)
3.669 - {
3.670 - }
3.671 -};
3.672 +#if !defined METAMOD_NO_AUTO_NAMESPACE
3.673 +using namespace SourceMM;
3.674 +#endif
3.675 +
3.676
3.677 #define PL_EXPOSURE CreateInterface
3.678 #define PL_EXPOSURE_C "CreateInterface"
3.679 @@ -370,7 +425,7 @@
3.680 PluginId g_PLID = (PluginId)0; \
3.681 SourceHook::ISourceHook *g_SHPtr = NULL; \
3.682 SMM_API void *PL_EXPOSURE(const char *name, int *code) { \
3.683 - if (name && !strcmp(name, PLAPI_NAME)) { \
3.684 + if (name && !strcmp(name, METAMOD_PLAPI_NAME)) { \
3.685 return static_cast<void *>(&var); \
3.686 } \
3.687 return NULL; \
4.1 --- a/sourcemm/metamod.cpp Mon Oct 08 17:32:28 2007 +0000
4.2 +++ b/sourcemm/metamod.cpp Mon Oct 08 18:47:31 2007 +0000
4.3 @@ -191,7 +191,7 @@
4.4 SMM_API void *CreateInterface(const char *iface, int *ret)
4.5 {
4.6 /* Prevent loading of self as a SourceMM plugin or Valve server plugin :x */
4.7 - if (strcmp(iface, PLAPI_NAME) == 0)
4.8 + if (strcmp(iface, METAMOD_PLAPI_NAME) == 0)
4.9 {
4.10 provider->DisplayWarning("Do not try loading Metamod:Source as a plugin.\n");
4.11
4.12 @@ -878,7 +878,7 @@
4.13 {
4.14 major = SM_VERS_API_MAJOR;
4.15 minor = SM_VERS_API_MINOR;
4.16 - plvers = PLAPI_VERSION;
4.17 + plvers = METAMOD_PLAPI_VERSION;
4.18 plmin = PLAPI_MIN_VERSION;
4.19 }
4.20
5.1 --- a/sourcemm/metamod.h Mon Oct 08 17:32:28 2007 +0000
5.2 +++ b/sourcemm/metamod.h Mon Oct 08 18:47:31 2007 +0000
5.3 @@ -38,7 +38,7 @@
5.4 #include <eiface.h>
5.5 #include <sourcehook/sourcehook_impl.h>
5.6 #include <sourcehook/sourcehook.h>
5.7 -#include "ISmmAPI.h"
5.8 +#include <ISmmPlugin.h>
5.9 #include "metamod_provider.h"
5.10 #include "svn_version.h"
5.11
6.1 --- a/sourcemm/metamod_console.cpp Mon Oct 08 17:32:28 2007 +0000
6.2 +++ b/sourcemm/metamod_console.cpp Mon Oct 08 18:47:31 2007 +0000
6.3 @@ -72,7 +72,7 @@
6.4 {
6.5 CONMSG("Metamod:Source version %s\n", SOURCEMM_VERSION);
6.6 CONMSG("Compiled on: %s\n", SOURCEMM_DATE);
6.7 - CONMSG("Plugin interface version: %d:%d\n", PLAPI_VERSION, PLAPI_MIN_VERSION);
6.8 + CONMSG("Plugin interface version: %d:%d\n", METAMOD_PLAPI_VERSION, PLAPI_MIN_VERSION);
6.9 CONMSG("SourceHook version: %d:%d\n", g_SHPtr->GetIfaceVersion(), g_SHPtr->GetImplVersion());
6.10 CONMSG("http://www.sourcemm.net/\n");
6.11
6.12 @@ -679,7 +679,7 @@
6.13 {
6.14 CLIENT_CONMSG(client, "Metamod:Source version %s\n", SOURCEMM_VERSION);
6.15 CLIENT_CONMSG(client, "Compiled on: %s\n", SOURCEMM_DATE);
6.16 - CLIENT_CONMSG(client, "Plugin interface version: %d:%d\n", PLAPI_VERSION, PLAPI_MIN_VERSION);
6.17 + CLIENT_CONMSG(client, "Plugin interface version: %d:%d\n", METAMOD_PLAPI_VERSION, PLAPI_MIN_VERSION);
6.18 CLIENT_CONMSG(client, "SourceHook version: %d:%d\n", g_SHPtr->GetIfaceVersion(), g_SHPtr->GetImplVersion());
6.19 CLIENT_CONMSG(client, "http://www.sourcemm.net/\n");
6.20
7.1 --- a/sourcemm/metamod_plugins.cpp Mon Oct 08 17:32:28 2007 +0000
7.2 +++ b/sourcemm/metamod_plugins.cpp Mon Oct 08 18:47:31 2007 +0000
7.3 @@ -95,12 +95,12 @@
7.4 return NULL;
7.5 }
7.6
7.7 -SourceHook::List<SourceMM::CNameAlias *>::iterator CPluginManager::_alias_begin()
7.8 +SourceHook::List<CNameAlias *>::iterator CPluginManager::_alias_begin()
7.9 {
7.10 return m_Aliases.begin();
7.11 }
7.12
7.13 -SourceHook::List<SourceMM::CNameAlias *>::iterator CPluginManager::_alias_end()
7.14 +SourceHook::List<CNameAlias *>::iterator CPluginManager::_alias_end()
7.15 {
7.16 return m_Aliases.end();
7.17 }
7.18 @@ -426,7 +426,7 @@
7.19 }
7.20 else
7.21 {
7.22 - pl->m_API = static_cast<ISmmPlugin *>((pfn)(PLAPI_NAME, NULL));
7.23 + pl->m_API = static_cast<ISmmPlugin *>((pfn)(METAMOD_PLAPI_NAME, NULL));
7.24 if (!pl->m_API)
7.25 {
7.26 if (error)
7.27 @@ -446,11 +446,11 @@
7.28 }
7.29 pl->m_Status = Pl_Error;
7.30 }
7.31 - else if (api > PLAPI_VERSION)
7.32 + else if (api > METAMOD_PLAPI_VERSION)
7.33 {
7.34 if (error)
7.35 {
7.36 - UTIL_Format(error, maxlen, "Plugin API %d is newer than internal version (%d)", api, PLAPI_VERSION);
7.37 + UTIL_Format(error, maxlen, "Plugin API %d is newer than internal version (%d)", api, METAMOD_PLAPI_VERSION);
7.38 }
7.39 pl->m_Status = Pl_Error;
7.40 }
8.1 --- a/sourcemm/metamod_plugins.h Mon Oct 08 17:32:28 2007 +0000
8.2 +++ b/sourcemm/metamod_plugins.h Mon Oct 08 18:47:31 2007 +0000
8.3 @@ -35,6 +35,7 @@
8.4
8.5 #include <interface.h>
8.6 #include <eiface.h>
8.7 +#include <convar.h>
8.8 #include <sh_list.h>
8.9 #include <sh_string.h>
8.10 #include "IPluginManager.h"
8.11 @@ -62,108 +63,105 @@
8.12
8.13 #define PLAPI_MIN_VERSION 13
8.14
8.15 -namespace SourceMM
8.16 +struct CNameAlias
8.17 {
8.18 - struct CNameAlias
8.19 + SourceHook::String alias;
8.20 + SourceHook::String value;
8.21 +};
8.22 +/**
8.23 + * @brief Implements Plugin Manager API
8.24 + */
8.25 +class CPluginManager : public ISmmPluginManager
8.26 +{
8.27 +public:
8.28 + /**
8.29 + * @brief Internal structure for holding plugin data
8.30 + */
8.31 + class CPlugin
8.32 {
8.33 - SourceHook::String alias;
8.34 - SourceHook::String value;
8.35 - };
8.36 - /**
8.37 - * @brief Implements Plugin Manager API
8.38 - */
8.39 - class CPluginManager : public ISmmPluginManager
8.40 - {
8.41 + public:
8.42 + CPlugin();
8.43 public:
8.44 - /**
8.45 - * @brief Internal structure for holding plugin data
8.46 - */
8.47 - class CPlugin
8.48 - {
8.49 - public:
8.50 - CPlugin();
8.51 - public:
8.52 - PluginId m_Id;
8.53 - SourceHook::String m_File;
8.54 - Pl_Status m_Status;
8.55 - PluginId m_Source;
8.56 - ISmmPlugin *m_API;
8.57 - HINSTANCE m_Lib;
8.58 - SourceHook::List<ConCommandBase *> m_Cvars;
8.59 - SourceHook::List<ConCommandBase *> m_Cmds;
8.60 - SourceHook::List<IMetamodListener *> m_Events;
8.61 - };
8.62 - public:
8.63 - CPluginManager();
8.64 - ~CPluginManager();
8.65 - void SetAllLoaded();
8.66 - public:
8.67 - PluginId Load(const char *file, PluginId source, bool &already, char *error, size_t maxlen);
8.68 - bool Unload(PluginId id, bool force, char *error, size_t maxlen);
8.69 - bool Pause(PluginId id, char *error, size_t maxlen);
8.70 - bool Unpause(PluginId id, char *error, size_t maxlen);
8.71 - bool UnloadAll();
8.72 - void SetAlias(const char *alias, const char *value);
8.73 - public:
8.74 - bool Query(PluginId id, const char *&file, Pl_Status &status, PluginId &source);
8.75 - bool QueryRunning(PluginId id, char *error, size_t maxlength);
8.76 - bool QueryHandle(PluginId id, void *&handle);
8.77 + PluginId m_Id;
8.78 + SourceHook::String m_File;
8.79 + Pl_Status m_Status;
8.80 + PluginId m_Source;
8.81 + ISmmPlugin *m_API;
8.82 + HINSTANCE m_Lib;
8.83 + SourceHook::List<ConCommandBase *> m_Cvars;
8.84 + SourceHook::List<ConCommandBase *> m_Cmds;
8.85 + SourceHook::List<IMetamodListener *> m_Events;
8.86 + };
8.87 +public:
8.88 + CPluginManager();
8.89 + ~CPluginManager();
8.90 + void SetAllLoaded();
8.91 +public:
8.92 + PluginId Load(const char *file, PluginId source, bool &already, char *error, size_t maxlen);
8.93 + bool Unload(PluginId id, bool force, char *error, size_t maxlen);
8.94 + bool Pause(PluginId id, char *error, size_t maxlen);
8.95 + bool Unpause(PluginId id, char *error, size_t maxlen);
8.96 + bool UnloadAll();
8.97 + void SetAlias(const char *alias, const char *value);
8.98 +public:
8.99 + bool Query(PluginId id, const char *&file, Pl_Status &status, PluginId &source);
8.100 + bool QueryRunning(PluginId id, char *error, size_t maxlength);
8.101 + bool QueryHandle(PluginId id, void *&handle);
8.102
8.103 - void AddPluginCvar(ISmmPlugin *api, ConCommandBase *pCvar);
8.104 - void AddPluginCmd(ISmmPlugin *api, ConCommandBase *pCmd);
8.105 - void RemovePluginCvar(ISmmPlugin *api, ConCommandBase *pCvar);
8.106 - void RemovePluginCmd(ISmmPlugin *api, ConCommandBase *pCmd);
8.107 + void AddPluginCvar(ISmmPlugin *api, ConCommandBase *pCvar);
8.108 + void AddPluginCmd(ISmmPlugin *api, ConCommandBase *pCmd);
8.109 + void RemovePluginCvar(ISmmPlugin *api, ConCommandBase *pCvar);
8.110 + void RemovePluginCmd(ISmmPlugin *api, ConCommandBase *pCmd);
8.111
8.112 - /**
8.113 - * @brief Finds a plugin by Id
8.114 - *
8.115 - * @param id Id of plugin
8.116 - * @return CPlugin on success, NULL otherwise
8.117 - */
8.118 - CPlugin *FindById(PluginId id);
8.119 -
8.120 - CPlugin *FindByAPI(ISmmPlugin *api);
8.121 + /**
8.122 + * @brief Finds a plugin by Id
8.123 + *
8.124 + * @param id Id of plugin
8.125 + * @return CPlugin on success, NULL otherwise
8.126 + */
8.127 + CPlugin *FindById(PluginId id);
8.128
8.129 - /**
8.130 - * @brief Attempts to reload a failed plugin
8.131 - *
8.132 - * @param id Id of plugin
8.133 - * @param error Error message buffer
8.134 - * @param len Maximum length of buffer
8.135 - * @return True on success, false otherwise
8.136 - */
8.137 - bool Retry(PluginId id, char *error, size_t len);
8.138 + CPlugin *FindByAPI(ISmmPlugin *api);
8.139
8.140 - int GetPluginCount();
8.141 - const char *GetStatusText(CPlugin *pl);
8.142 + /**
8.143 + * @brief Attempts to reload a failed plugin
8.144 + *
8.145 + * @param id Id of plugin
8.146 + * @param error Error message buffer
8.147 + * @param len Maximum length of buffer
8.148 + * @return True on success, false otherwise
8.149 + */
8.150 + bool Retry(PluginId id, char *error, size_t len);
8.151
8.152 - //get alias info
8.153 - const char *LookupAlias(const char *alias);
8.154 - SourceHook::List<SourceMM::CNameAlias *>::iterator _alias_begin();
8.155 - SourceHook::List<SourceMM::CNameAlias *>::iterator _alias_end();
8.156 + int GetPluginCount();
8.157 + const char *GetStatusText(CPlugin *pl);
8.158
8.159 - //Internal iterators
8.160 - SourceHook::List<SourceMM::CPluginManager::CPlugin *>::iterator _begin();
8.161 - SourceHook::List<SourceMM::CPluginManager::CPlugin *>::iterator _end();
8.162 - private:
8.163 - //These are identical internal functions for the wrappers above.
8.164 - CPlugin *_Load(const char *file, PluginId source, char *error, size_t maxlen);
8.165 - bool _Unload(CPlugin *pl, bool force, char *error, size_t maxlen);
8.166 - bool _Pause(CPlugin *pl, char *error, size_t maxlen);
8.167 - bool _Unpause(CPlugin *pl, char *error, size_t maxlen);
8.168 - void UnregAllConCmds(CPlugin *pl);
8.169 - private:
8.170 - PluginId m_LastId;
8.171 - SourceHook::List<CPlugin *> m_Plugins;
8.172 - SourceHook::List<CNameAlias *> m_Aliases;
8.173 - bool m_AllLoaded;
8.174 - };
8.175 + //get alias info
8.176 + const char *LookupAlias(const char *alias);
8.177 + SourceHook::List<CNameAlias *>::iterator _alias_begin();
8.178 + SourceHook::List<CNameAlias *>::iterator _alias_end();
8.179 +
8.180 + //Internal iterators
8.181 + SourceHook::List<CPluginManager::CPlugin *>::iterator _begin();
8.182 + SourceHook::List<CPluginManager::CPlugin *>::iterator _end();
8.183 +private:
8.184 + //These are identical internal functions for the wrappers above.
8.185 + CPlugin *_Load(const char *file, PluginId source, char *error, size_t maxlen);
8.186 + bool _Unload(CPlugin *pl, bool force, char *error, size_t maxlen);
8.187 + bool _Pause(CPlugin *pl, char *error, size_t maxlen);
8.188 + bool _Unpause(CPlugin *pl, char *error, size_t maxlen);
8.189 + void UnregAllConCmds(CPlugin *pl);
8.190 +private:
8.191 + PluginId m_LastId;
8.192 + SourceHook::List<CPlugin *> m_Plugins;
8.193 + SourceHook::List<CNameAlias *> m_Aliases;
8.194 + bool m_AllLoaded;
8.195 };
8.196
8.197 -typedef SourceHook::List<SourceMM::CPluginManager::CPlugin *>::iterator PluginIter;
8.198 +typedef SourceHook::List<CPluginManager::CPlugin *>::iterator PluginIter;
8.199
8.200 /** @brief Singleton for plugin manager */
8.201 -extern SourceMM::CPluginManager g_PluginMngr;
8.202 +extern CPluginManager g_PluginMngr;
8.203
8.204 #endif //_INCLUDE_CPLUGIN_H
8.205