fixed a very serious flaw where Vectors being passed as pointers would corrupt the vector object values. this caused TeleportEntity() to have very weird effects
3 * ===============================================================
4 * SourceMod, Copyright (C) 2004-2007 AlliedModders LLC.
6 * ===============================================================
8 * This file is part of the SourceMod/SourcePawn SDK. This file may only be
9 * used or modified under the Terms and Conditions of its License Agreement,
10 * which is found in public/licenses/LICENSE.txt. As of this notice, derivative
11 * works must be licensed under the GNU General Public License (version 2 or
12 * greater). A copy of the GPL is included under public/licenses/GPL.txt.
14 * To view the latest information, see: http://www.sourcemod.net/license.php
19 #ifndef _INCLUDE_SOURCEMOD_PLUGINMNGR_INTERFACE_H_
20 #define _INCLUDE_SOURCEMOD_PLUGINMNGR_INTERFACE_H_
24 * @brief Defines the interface for the Plugin System, which manages loaded plugins.
27 #include <IShareSys.h>
28 #include <sp_vm_api.h>
30 #define SMINTERFACE_PLUGINSYSTEM_NAME "IPluginManager"
31 #define SMINTERFACE_PLUGINSYSTEM_VERSION 2
33 /** Context user slot 3 is used Core for holding an IPluginContext pointer. */
34 #define SM_CONTEXTVAR_USER 3
41 * @brief Encapsulates plugin public information exposed through "myinfo."
43 typedef struct sm_plugininfo_s
45 const char *name; /**< Plugin name */
46 const char *author; /**< Plugin author */
47 const char *description; /**< Plugin description */
48 const char *version; /**< Plugin version string */
49 const char *url; /**< Plugin URL */
54 * @brief Describes the usability status of a plugin.
58 Plugin_Running=0, /**< Plugin is running */
59 /* All states below are unexecutable */
60 Plugin_Paused, /**< Plugin is loaded but paused */
61 Plugin_Error, /**< Plugin is loaded but errored/locked */
62 /* All states below do not have all natives */
63 Plugin_Loaded, /**< Plugin has passed loading and can be finalized */
64 Plugin_Failed, /**< Plugin has a fatal failure */
65 Plugin_Created, /**< Plugin is created but not initialized */
66 Plugin_Uncompiled, /**< Plugin is not yet compiled by the JIT */
67 Plugin_BadLoad, /**< Plugin failed to load */
72 * @brief Describes the object lifetime of a plugin.
76 PluginType_Private, /**< Plugin is privately managed and receives no forwards */
77 PluginType_MapUpdated, /**< Plugin will never be unloaded unless for updates on mapchange */
78 PluginType_MapOnly, /**< Plugin will be removed at mapchange */
79 PluginType_Global, /**< Plugin will never be unloaded or updated */
83 * @brief Encapsulates a run-time plugin as maintained by SourceMod.
88 /** Virtual destructor */
94 * @brief Returns the lifetime of a plugin.
96 virtual PluginType GetType() =0;
99 * @brief Returns the current API context being used in the plugin.
101 * @return Pointer to an IPluginContext, or NULL if not loaded.
103 virtual SourcePawn::IPluginContext *GetBaseContext() =0;
106 * @brief Returns the context structure being used in the plugin.
108 * @return Pointer to an sp_context_t, or NULL if not loaded.
110 virtual sp_context_t *GetContext() =0;
113 * @brief Returns the plugin file structure.
115 * @return Pointer to an sp_plugin_t, or NULL if not loaded.
117 virtual const sp_plugin_t *GetPluginStructure() =0;
120 * @brief Returns information about the plugin by reference.
122 * @return Pointer to a sm_plugininfo_t object, NULL if plugin is not loaded.
124 virtual const sm_plugininfo_t *GetPublicInfo() =0;
127 * @brief Returns the plugin filename (relative to plugins dir).
129 virtual const char *GetFilename() =0;
132 * @brief Returns true if a plugin is in debug mode, false otherwise.
134 virtual bool IsDebugging() =0;
137 * @brief Returns the plugin status.
139 virtual PluginStatus GetStatus() =0;
142 * @brief Sets whether the plugin is paused or not.
144 * @return True on successful state change, false otherwise.
146 virtual bool SetPauseState(bool paused) =0;
149 * @brief Returns the unique serial number of a plugin.
151 virtual unsigned int GetSerial() =0;
154 * @brief Returns a plugin's identity token.
156 virtual IdentityToken_t *GetIdentity() =0;
159 * @brief Sets a property on this plugin. This is used for per-plugin
160 * data from extensions or other parts of core. The property's value must
161 * be manually destructed when the plugin is destroyed.
163 * @param prop String containing name of the property.
164 * @param ptr Generic pointer to set.
165 * @return True on success, false if the property is already set.
167 virtual bool SetProperty(const char *prop, void *ptr) =0;
170 * @brief Gets a property from a plugin.
172 * @param prop String containing the property's name.
173 * @param ptr Optional pointer to the generic pointer.
174 * @param remove Optional boolean value; if true, property is removed
175 * (so it can be set again).
176 * @return True if the property existed, false otherwise.
178 virtual bool GetProperty(const char *prop, void **ptr, bool remove=false) =0;
183 * @brief Iterates over a list of plugins.
185 class IPluginIterator
188 /** Virtual destructor */
189 virtual ~IPluginIterator()
194 * @brief Returns true if there are more plugins in the iterator.
196 virtual bool MorePlugins() =0;
199 * @brief Returns the plugin at the current iterator position.
201 virtual IPlugin *GetPlugin() =0;
204 * @brief Advances to the next plugin in the iterator.
206 virtual void NextPlugin() =0;
209 * @brief Destroys the iterator object.
210 * Note: You may use 'delete' in lieu of this function.
212 virtual void Release() =0;
216 * @brief Listens for plugin-oriented events.
218 class IPluginsListener
222 * @brief Called when a plugin is created/mapped into memory.
224 virtual void OnPluginCreated(IPlugin *plugin)
229 * @brief Called when a plugin is fully loaded successfully.
231 virtual void OnPluginLoaded(IPlugin *plugin)
236 * @brief Called when a plugin is paused or unpaused.
238 virtual void OnPluginPauseChange(IPlugin *plugin, bool paused)
243 * @brief Called when a plugin is unloaded (only if fully loaded).
245 virtual void OnPluginUnloaded(IPlugin *plugin)
250 * @brief Called when a plugin is destroyed.
251 * NOTE: Always called if Created, even if load failed.
253 virtual void OnPluginDestroyed(IPlugin *plugin)
260 * @brief Manages the runtime loading and unloading of plugins.
262 class IPluginManager : public SMInterface
265 virtual const char *GetInterfaceName()
267 return SMINTERFACE_PLUGINSYSTEM_NAME;
270 virtual unsigned int GetInterfaceVersion()
272 return SMINTERFACE_PLUGINSYSTEM_VERSION;
276 * @brief Attempts to load a plugin.
278 * @param path Path and filename of plugin, relative to plugins folder.
279 * @param debug Whether or not to default the plugin into debug mode.
280 * @param type Lifetime of the plugin.
281 * @param error Buffer to hold any error message.
282 * @param maxlength Maximum length of error message buffer.
283 * @param wasloaded Stores if the plugin is already loaded.
284 * @return A new plugin pointer on success, false otherwise.
286 virtual IPlugin *LoadPlugin(const char *path,
294 * @brief Attempts to unload a plugin.
296 * @param plugin Pointer to the plugin handle.
297 * @return True on success, false otherwise.
299 virtual bool UnloadPlugin(IPlugin *plugin) =0;
302 * @brief Finds a plugin by its context.
303 * Note: This function should be considered O(1).
305 * @param ctx Pointer to an sp_context_t.
306 * @return Pointer to a matching IPlugin, or NULL if none found.
308 virtual IPlugin *FindPluginByContext(const sp_context_t *ctx) =0;
311 * @brief Returns the number of plugins (both failed and loaded).
313 * @return The number of internally cached plugins.
315 virtual unsigned int GetPluginCount() =0;
318 * @brief Returns a pointer that can be used to iterate through plugins.
319 * Note: This pointer must be freed using EITHER delete OR IPluginIterator::Release().
321 virtual IPluginIterator *GetPluginIterator() =0;
324 * @brief Adds a plugin manager listener.
326 * @param listener Pointer to a listener.
328 virtual void AddPluginsListener(IPluginsListener *listener) =0;
331 * @brief Removes a plugin listener.
333 * @param listener Pointer to a listener.
335 virtual void RemovePluginsListener(IPluginsListener *listener) =0;
339 #endif //_INCLUDE_SOURCEMOD_PLUGINMNGR_INTERFACE_H_