diff -r 158b860440c0 -r 7c36121e2dfe sourcemm/ISmmPlugin.h --- a/sourcemm/ISmmPlugin.h Wed Oct 05 21:51:02 2005 +0000 +++ b/sourcemm/ISmmPlugin.h Thu Oct 06 00:59:01 2005 +0000 @@ -38,42 +38,83 @@ { public: virtual int GetApiVersion() { return PLAPI_VERSION; } + virtual ~ISmmPlugin() { } 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. + * NOTE - As of API 7, you can override factories before the engine and gamedll exchange them. + * 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 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 on success, return false to request no load. + * @return True if successful, return false to reject the load. */ - virtual bool Load(PluginId id, ISmmAPI *ismm, factories *list, char *error, size_t maxlen) =0; + virtual bool Load(PluginId id, ISmmAPI *ismm, factories *list, char *error, size_t maxlength, bool late) =0; - /** @brief Called on plugin unload. + /** + * @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 + * - If the plugin does something like overload a factory, Metamod will make sure the Query() returns true + * before calling it. + * Also note that this query will only override Metamod when the plugin is running and not paused. * - * @param error Error message buffer - * @param maxlen Size of error message buffer - * @return True on success, return false to request no unload. + * @param error Buffer for error message. This can be NULL! + * @param maxlen Maximum length of error buffer. + * @return Status code - true for okay, false for badness. */ - virtual bool Unload(char *error, size_t maxlen) =0; + virtual bool QueryRunning(char *error, size_t maxlen) + { + return true; + } + + /** + * @brief Called on plugin unload. You can return false if you know your plugin + * is not capable of restoring critical states it modifies. + * + * @param error Error message buffer + * @param maxlen Size of error message buffer + * @return True on success, return false to request no unload. + */ + virtual bool Unload(char *error, size_t maxlen) + { + return true; + } /** @brief Called on plugin pause. * - * @param error Error message buffer - * @param maxlen Size of error message buffer - * @return True on success, return false to request no pause. + * @param error Error message buffer + * @param maxlen Size of error message buffer + * @return True on success, return false to request no pause. */ - virtual bool Pause(char *error, size_t maxlen) =0; + virtual bool Pause(char *error, size_t maxlen) + { + return true; + } /** @brief Called on plugin unpause. * - * @param error Error message buffer - * @param maxlen Size of error message buffer - * @return True on success, return false to request no unpause. + * @param error Error message buffer + * @param maxlen Size of error message buffer + * @return True on success, return false to request no unpause. */ - virtual bool Unpause(char *error, size_t maxlen) =0; + virtual bool Unpause(char *error, size_t maxlen) + { + return true; + } public: /** @brief Return author as string */ virtual const char *GetAuthor() =0; @@ -101,13 +142,16 @@ public: /** * @brief Called when all plugins have been loaded - API version 4 - * - * Ths is useful for knowing when it's safe to request things another plugin might have. + * + * 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(). */ - virtual void AllPluginsLoaded() =0; + virtual void AllPluginsLoaded() + { + } }; -#define PL_EXPOSURE CreateInterface +#define PL_EXPOSURE CreateInterface #define PL_EXPOSURE_C "CreateInterface" #define PLUGIN_EXPOSE(name, var) \ @@ -138,13 +182,13 @@ g_SMAPI->SetLastMetaReturn(mres); \ return value; -#define META_LOG g_SMAPI->LogMsg +#define META_LOG g_SMAPI->LogMsg #define META_REGCMD(name) g_SMAPI->RegisterConCmdBase(g_PLAPI, name##_command) #define META_REGCVAR(var) g_SMAPI->RegisterConCmdBase(g_PLAPI, var) #define META_UNREGCMD(name) g_SMAPI->UnregisterConCmdBase(g_PLAPI, name##_command) #define META_UNREGCVAR(var) g_SMAPI->UnregisterConCmdBase(g_PLAPI, var) -#define META_CONPRINT g_SMAPI->ConPrint -#define META_CONPRINTF g_SMAPI->ConPrintf +#define META_CONPRINT g_SMAPI->ConPrint +#define META_CONPRINTF g_SMAPI->ConPrintf //probably should use this up above someday #define CONCMD_VARNAME(name) name##_command