diff -r d0868271663a -r 751179604513 sourcemm/ISmmPlugin.h --- a/sourcemm/ISmmPlugin.h Fri Aug 10 23:43:16 2007 +0000 +++ b/sourcemm/ISmmPlugin.h Thu Oct 04 20:15:25 2007 +0000 @@ -1,12 +1,29 @@ -/* ======== SourceMM ======== -* Copyright (C) 2004-2007 Metamod:Source Development Team -* No warranties of any kind -* -* License: zlib/libpng -* -* Author(s): David "BAILOPAN" Anderson -* ============================ -*/ +/** + * vim: set ts=4 : + * ====================================================== + * Metamod:Source + * Copyright (C) 2004-2007 AlliedModders LLC and authors. + * All rights reserved. + * ====================================================== + * + * This software is provided 'as-is', without any express or implied warranty. + * In no event will the authors be held liable for any damages arising from + * the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software in a + * product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + * Version: $Id$ + */ #ifndef _INCLUDE_ISMM_PLUGIN_H #define _INCLUDE_ISMM_PLUGIN_H @@ -17,7 +34,7 @@ */ #include -#include +#include #include "ISmmAPI.h" #define PLAPI_VERSION 12 @@ -33,6 +50,7 @@ public: /** * @brief Called on plugin load. + * * NOTE - As of API 7, this is called as DLLInit() executes - after the parameters are known, but before * the original GameDLL function is called. Therefore, you cannot hook it, but you don't need to - * Load() is basically your hook. @@ -40,22 +58,24 @@ * However, take care to note that if your plugin is unloaded, and the gamedll/engine have cached * an interface you've passed, something will definitely crash. Be careful. * - * @param id Internal id of plugin. Saved globally by PLUGIN_SAVEVARS() - * @param ismm External API for SourceMM. Saved globally by PLUGIN_SAVEVARS() - * @param list Contains a list of factories. Hook a factory call by setting one equal to your own function. - * @param late Set to true if your plugin was loaded late (not at server load). - * @param error Error message buffer - * @param maxlen Size of error message buffer - * @return True if successful, return false to reject the load. + * @param id Internal id of plugin. Saved globally by PLUGIN_SAVEVARS() + * @param ismm External API for SourceMM. Saved globally by PLUGIN_SAVEVARS() + * @param list Contains a list of factories. Hook a factory call by setting one equal to your own function. + * @param late Set to true if your plugin was loaded late (not at server load). + * @param error Error message buffer + * @param maxlen Size of error message buffer + * @return True if successful, return false to reject the load. */ virtual bool Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlength, bool late) =0; /** - * @brief Called when your plugin is "queried". This is useful for rejecting a loaded - * state. For example, if your plugin wants to stop operating, it can simply return - * false and copy an error message. This will notify other plugins or MM:S of something - * bad that happened. NOTE - MM:S will not cache the return state, so if you return false, - * your plugin will not actually be paused or unloaded. This callback will be called when: + * @brief Called when your plugin is "queried". + * + * This is useful for rejecting a loaded state. For example, if your plugin wants + * to stop operating, it can simply return false and copy an error message. This + * will notify other plugins or MM:S of something bad that happened. NOTE - MM:S + * will not cache the return state, so if you return false, your plugin will not + * actually be paused or unloaded. This callback will be called when: * - Another plugin requests it * - Someone types "meta list", it will show up as "REFUSED" * - When Metamod need to re-check the plugin's status @@ -132,10 +152,11 @@ virtual const char *GetLogTag() =0; public: /** - * @brief Called when all plugins have been loaded - API version 4 + * @brief Called when all plugins have been loaded. * - * This is useful for knowing when it's safe to request things another plugin might have. - * NOTE for API 7 - This is called after DLLInit(). + * This is called after DLLInit(), and thus the mod has been mostly initialized. + * It is also safe to assume that all other (automatically loaded) plugins are now + * ready to start interacting, because they are all loaded. */ virtual void AllPluginsLoaded() { @@ -148,35 +169,45 @@ class IMetamodListener { public: - virtual ~IMetamodListener() { } + virtual ~IMetamodListener() + { + } public: /** * @brief Called when a plugin is loaded. * * @param id Id of the plugin. */ - virtual void OnPluginLoad(PluginId id) { } + virtual void OnPluginLoad(PluginId id) + { + } /** * @brief Called when a plugin is unloaded. * * @param id Id of the plugin. */ - virtual void OnPluginUnload(PluginId id) { } + virtual void OnPluginUnload(PluginId id) + { + } /** * @brief Called when a plugin is paused. * * @param id Id of the plugin. */ - virtual void OnPluginPause(PluginId id) { } + virtual void OnPluginPause(PluginId id) + { + } /** * @brief Called when a plugin is unpaused. * * @param id Id of the plugin. */ - virtual void OnPluginUnpause(PluginId id) { } + virtual void OnPluginUnpause(PluginId id) + { + } /** * @brief Called when the level is loaded (after GameInit, before ServerActivate). @@ -195,7 +226,9 @@ /** * @brief Called when the level is shut down. May be called more than once. */ - virtual void OnLevelShutdown() { } + virtual void OnLevelShutdown() + { + } /** * @brief Called when engineFactory() is used through Metamod:Source's wrapper. @@ -308,7 +341,8 @@ * This callback is provided to all plugins regardless of which (or how many) * called EnableVSPListener(), but only if at least one did in fact enable it. * - * This callback is only available for plugins using API v1:5 (SourceMM 1.4+). + * This callback is only available for plugins using API v1:5 (Metamod:Source 1.4+). + * If a plugin loads lately, it may still call EnableVSPListener(). * * @param iface Interface pointer. If NULL, then the VSP listening construct * failed to initialize and is not available. @@ -322,6 +356,17 @@ * @param pCommand Pointer to concommand or convar that is being removed. */ virtual void OnUnlinkConCommandBase(PluginId id, ConCommandBase *pCommand) { } + + /** + * @brief Called when Metamod:Source is about to remove a concommand or convar. + * This can also be called if ISmmAPI::UnregisterConCmdBase is used by a plugin. + * + * @param id Id of the plugin that created the concommand or convar. + * @param pCommand Pointer to concommand or convar that is being removed. + */ + virtual void OnUnlinkConCommandBase(PluginId id, ConCommandBase *pCommand) + { + } }; #define PL_EXPOSURE CreateInterface @@ -413,3 +458,4 @@ } #endif //_INCLUDE_ISMM_PLUGIN_H +