1.1 --- a/sourcemm/ISmmPlugin.h Fri Aug 10 23:43:16 2007 +0000
1.2 +++ b/sourcemm/ISmmPlugin.h Thu Oct 04 20:15:25 2007 +0000
1.3 @@ -1,12 +1,29 @@
1.4 -/* ======== SourceMM ========
1.5 -* Copyright (C) 2004-2007 Metamod:Source Development Team
1.6 -* No warranties of any kind
1.7 -*
1.8 -* License: zlib/libpng
1.9 -*
1.10 -* Author(s): David "BAILOPAN" Anderson
1.11 -* ============================
1.12 -*/
1.13 +/**
1.14 + * vim: set ts=4 :
1.15 + * ======================================================
1.16 + * Metamod:Source
1.17 + * Copyright (C) 2004-2007 AlliedModders LLC and authors.
1.18 + * All rights reserved.
1.19 + * ======================================================
1.20 + *
1.21 + * This software is provided 'as-is', without any express or implied warranty.
1.22 + * In no event will the authors be held liable for any damages arising from
1.23 + * the use of this software.
1.24 + *
1.25 + * Permission is granted to anyone to use this software for any purpose,
1.26 + * including commercial applications, and to alter it and redistribute it
1.27 + * freely, subject to the following restrictions:
1.28 + *
1.29 + * 1. The origin of this software must not be misrepresented; you must not
1.30 + * claim that you wrote the original software. If you use this software in a
1.31 + * product, an acknowledgment in the product documentation would be
1.32 + * appreciated but is not required.
1.33 + * 2. Altered source versions must be plainly marked as such, and must not be
1.34 + * misrepresented as being the original software.
1.35 + * 3. This notice may not be removed or altered from any source distribution.
1.36 + *
1.37 + * Version: $Id$
1.38 + */
1.39
1.40 #ifndef _INCLUDE_ISMM_PLUGIN_H
1.41 #define _INCLUDE_ISMM_PLUGIN_H
1.42 @@ -17,7 +34,7 @@
1.43 */
1.44
1.45 #include <interface.h>
1.46 -#include <sourcehook/sourcehook.h>
1.47 +#include <sourcehook.h>
1.48 #include "ISmmAPI.h"
1.49
1.50 #define PLAPI_VERSION 12
1.51 @@ -33,6 +50,7 @@
1.52 public:
1.53 /**
1.54 * @brief Called on plugin load.
1.55 + *
1.56 * NOTE - As of API 7, this is called as DLLInit() executes - after the parameters are known, but before
1.57 * the original GameDLL function is called. Therefore, you cannot hook it, but you don't need to -
1.58 * Load() is basically your hook.
1.59 @@ -40,22 +58,24 @@
1.60 * However, take care to note that if your plugin is unloaded, and the gamedll/engine have cached
1.61 * an interface you've passed, something will definitely crash. Be careful.
1.62 *
1.63 - * @param id Internal id of plugin. Saved globally by PLUGIN_SAVEVARS()
1.64 - * @param ismm External API for SourceMM. Saved globally by PLUGIN_SAVEVARS()
1.65 - * @param list Contains a list of factories. Hook a factory call by setting one equal to your own function.
1.66 - * @param late Set to true if your plugin was loaded late (not at server load).
1.67 - * @param error Error message buffer
1.68 - * @param maxlen Size of error message buffer
1.69 - * @return True if successful, return false to reject the load.
1.70 + * @param id Internal id of plugin. Saved globally by PLUGIN_SAVEVARS()
1.71 + * @param ismm External API for SourceMM. Saved globally by PLUGIN_SAVEVARS()
1.72 + * @param list Contains a list of factories. Hook a factory call by setting one equal to your own function.
1.73 + * @param late Set to true if your plugin was loaded late (not at server load).
1.74 + * @param error Error message buffer
1.75 + * @param maxlen Size of error message buffer
1.76 + * @return True if successful, return false to reject the load.
1.77 */
1.78 virtual bool Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlength, bool late) =0;
1.79
1.80 /**
1.81 - * @brief Called when your plugin is "queried". This is useful for rejecting a loaded
1.82 - * state. For example, if your plugin wants to stop operating, it can simply return
1.83 - * false and copy an error message. This will notify other plugins or MM:S of something
1.84 - * bad that happened. NOTE - MM:S will not cache the return state, so if you return false,
1.85 - * your plugin will not actually be paused or unloaded. This callback will be called when:
1.86 + * @brief Called when your plugin is "queried".
1.87 + *
1.88 + * This is useful for rejecting a loaded state. For example, if your plugin wants
1.89 + * to stop operating, it can simply return false and copy an error message. This
1.90 + * will notify other plugins or MM:S of something bad that happened. NOTE - MM:S
1.91 + * will not cache the return state, so if you return false, your plugin will not
1.92 + * actually be paused or unloaded. This callback will be called when:
1.93 * - Another plugin requests it
1.94 * - Someone types "meta list", it will show up as "REFUSED"
1.95 * - When Metamod need to re-check the plugin's status
1.96 @@ -132,10 +152,11 @@
1.97 virtual const char *GetLogTag() =0;
1.98 public:
1.99 /**
1.100 - * @brief Called when all plugins have been loaded - API version 4
1.101 + * @brief Called when all plugins have been loaded.
1.102 *
1.103 - * This is useful for knowing when it's safe to request things another plugin might have.
1.104 - * NOTE for API 7 - This is called after DLLInit().
1.105 + * This is called after DLLInit(), and thus the mod has been mostly initialized.
1.106 + * It is also safe to assume that all other (automatically loaded) plugins are now
1.107 + * ready to start interacting, because they are all loaded.
1.108 */
1.109 virtual void AllPluginsLoaded()
1.110 {
1.111 @@ -148,35 +169,45 @@
1.112 class IMetamodListener
1.113 {
1.114 public:
1.115 - virtual ~IMetamodListener() { }
1.116 + virtual ~IMetamodListener()
1.117 + {
1.118 + }
1.119 public:
1.120 /**
1.121 * @brief Called when a plugin is loaded.
1.122 *
1.123 * @param id Id of the plugin.
1.124 */
1.125 - virtual void OnPluginLoad(PluginId id) { }
1.126 + virtual void OnPluginLoad(PluginId id)
1.127 + {
1.128 + }
1.129
1.130 /**
1.131 * @brief Called when a plugin is unloaded.
1.132 *
1.133 * @param id Id of the plugin.
1.134 */
1.135 - virtual void OnPluginUnload(PluginId id) { }
1.136 + virtual void OnPluginUnload(PluginId id)
1.137 + {
1.138 + }
1.139
1.140 /**
1.141 * @brief Called when a plugin is paused.
1.142 *
1.143 * @param id Id of the plugin.
1.144 */
1.145 - virtual void OnPluginPause(PluginId id) { }
1.146 + virtual void OnPluginPause(PluginId id)
1.147 + {
1.148 + }
1.149
1.150 /**
1.151 * @brief Called when a plugin is unpaused.
1.152 *
1.153 * @param id Id of the plugin.
1.154 */
1.155 - virtual void OnPluginUnpause(PluginId id) { }
1.156 + virtual void OnPluginUnpause(PluginId id)
1.157 + {
1.158 + }
1.159
1.160 /**
1.161 * @brief Called when the level is loaded (after GameInit, before ServerActivate).
1.162 @@ -195,7 +226,9 @@
1.163 /**
1.164 * @brief Called when the level is shut down. May be called more than once.
1.165 */
1.166 - virtual void OnLevelShutdown() { }
1.167 + virtual void OnLevelShutdown()
1.168 + {
1.169 + }
1.170
1.171 /**
1.172 * @brief Called when engineFactory() is used through Metamod:Source's wrapper.
1.173 @@ -308,7 +341,8 @@
1.174 * This callback is provided to all plugins regardless of which (or how many)
1.175 * called EnableVSPListener(), but only if at least one did in fact enable it.
1.176 *
1.177 - * This callback is only available for plugins using API v1:5 (SourceMM 1.4+).
1.178 + * This callback is only available for plugins using API v1:5 (Metamod:Source 1.4+).
1.179 + * If a plugin loads lately, it may still call EnableVSPListener().
1.180 *
1.181 * @param iface Interface pointer. If NULL, then the VSP listening construct
1.182 * failed to initialize and is not available.
1.183 @@ -322,6 +356,17 @@
1.184 * @param pCommand Pointer to concommand or convar that is being removed.
1.185 */
1.186 virtual void OnUnlinkConCommandBase(PluginId id, ConCommandBase *pCommand) { }
1.187 +
1.188 + /**
1.189 + * @brief Called when Metamod:Source is about to remove a concommand or convar.
1.190 + * This can also be called if ISmmAPI::UnregisterConCmdBase is used by a plugin.
1.191 + *
1.192 + * @param id Id of the plugin that created the concommand or convar.
1.193 + * @param pCommand Pointer to concommand or convar that is being removed.
1.194 + */
1.195 + virtual void OnUnlinkConCommandBase(PluginId id, ConCommandBase *pCommand)
1.196 + {
1.197 + }
1.198 };
1.199
1.200 #define PL_EXPOSURE CreateInterface
1.201 @@ -413,3 +458,4 @@
1.202 }
1.203
1.204 #endif //_INCLUDE_ISMM_PLUGIN_H
1.205 +