sourcemm/ISmmPlugin.h
changeset 122 7c36121e2dfe
parent 97 7d3a2a8d5bf5
child 138 dfa3b31cc042
     1.1 --- a/sourcemm/ISmmPlugin.h	Wed Oct 05 21:51:02 2005 +0000
     1.2 +++ b/sourcemm/ISmmPlugin.h	Thu Oct 06 00:59:01 2005 +0000
     1.3 @@ -38,42 +38,83 @@
     1.4  {
     1.5  public:
     1.6  	virtual int GetApiVersion() { return PLAPI_VERSION; }
     1.7 +	virtual ~ISmmPlugin() { }
     1.8  public:
     1.9  	/**
    1.10  	 * @brief Called on plugin load.
    1.11 +	 * NOTE - As of API 7, this is called as DLLInit() executes - after the parameters are known, but before 
    1.12 +	 *  the original GameDLL function is called.  Therefore, you cannot hook it, but you don't need to - 
    1.13 +	 *  Load() is basically your hook.
    1.14 +	 * NOTE - As of API 7, you can override factories before the engine and gamedll exchange them.
    1.15 +	 *  However, take care to note that if your plugin is unloaded, and the gamedll/engine have cached
    1.16 +	 *  an interface you've passed, something will definitely crash.  Be careful.
    1.17  	 *
    1.18 -	 * @param id Internal id of plugin.  Saved globally by PLUGIN_SAVEVARS()
    1.19 -	 * @param ismm External API for SourceMM.  Saved globally by PLUGIN_SAVEVARS()
    1.20 -	 * @param list Contains a list of factories.  Hook a factory call by setting one equal to your own function.
    1.21 +	 * @param id	Internal id of plugin.  Saved globally by PLUGIN_SAVEVARS()
    1.22 +	 * @param ismm	External API for SourceMM.  Saved globally by PLUGIN_SAVEVARS()
    1.23 +	 * @param list	Contains a list of factories.  Hook a factory call by setting one equal to your own function.
    1.24 +	 * @param late	Set to true if your plugin was loaded late (not at server load).
    1.25  	 * @param error Error message buffer
    1.26  	 * @param maxlen Size of error message buffer
    1.27 -	 * @return True on success, return false to request no load.
    1.28 +	 * @return		True if successful, return false to reject the load.
    1.29  	 */
    1.30 -	virtual bool Load(PluginId id, ISmmAPI *ismm, factories *list, char *error, size_t maxlen) =0;
    1.31 +	virtual bool Load(PluginId id, ISmmAPI *ismm, factories *list, char *error, size_t maxlength, bool late) =0;
    1.32  
    1.33 -	/** @brief Called on plugin unload.
    1.34 +	/**
    1.35 +	 * @brief Called when your plugin is "queried".  This is useful for rejecting a loaded
    1.36 +	 *  state.  For example, if your plugin wants to stop operating, it can simply return
    1.37 +	 *  false and copy an error message.  This will notify other plugins or MM:S of something
    1.38 +	 *  bad that happened.  NOTE - MM:S will not cache the return state, so if you return false,
    1.39 +	 *  your plugin will not actually be paused or unloaded.  This callback will be called when:
    1.40 +	 *  - Another plugin requests it
    1.41 +	 *  - Someone types "meta list", it will show up as "REFUSED"
    1.42 +	 *  - When Metamod need to re-check the plugin's status
    1.43 +	 *  - If the plugin does something like overload a factory, Metamod will make sure the Query() returns true
    1.44 +	 *    before calling it.
    1.45 +	 *  Also note that this query will only override Metamod when the plugin is running and not paused.
    1.46  	 *
    1.47 -	 * @param error Error message buffer
    1.48 -	 * @param maxlen Size of error message buffer
    1.49 -	 * @return True on success, return false to request no unload.
    1.50 +	 * @param error		Buffer for error message.  This can be NULL!
    1.51 +	 * @param maxlen	Maximum length of error buffer.
    1.52 +	 * @return			Status code - true for okay, false for badness.
    1.53  	 */
    1.54 -	virtual bool Unload(char *error, size_t maxlen) =0;
    1.55 +	virtual bool QueryRunning(char *error, size_t maxlen)
    1.56 +	{
    1.57 +		return true;
    1.58 +	}
    1.59 +
    1.60 +	/** 
    1.61 +	 * @brief Called on plugin unload.  You can return false if you know your plugin
    1.62 +	 *  is not capable of restoring critical states it modifies.
    1.63 +	 *
    1.64 +	 * @param	error Error message buffer
    1.65 +	 * @param	maxlen Size of error message buffer
    1.66 +	 * @return	True on success, return false to request no unload.
    1.67 +	 */
    1.68 +	virtual bool Unload(char *error, size_t maxlen)
    1.69 +	{
    1.70 +		return true;
    1.71 +	}
    1.72  
    1.73  	/** @brief Called on plugin pause.
    1.74  	 *
    1.75 -	 * @param error Error message buffer
    1.76 -	 * @param maxlen Size of error message buffer
    1.77 -	 * @return True on success, return false to request no pause.
    1.78 +	 * @param	error Error message buffer
    1.79 +	 * @param	maxlen Size of error message buffer
    1.80 +	 * @return	True on success, return false to request no pause.
    1.81  	 */
    1.82 -	virtual bool Pause(char *error, size_t maxlen) =0;
    1.83 +	virtual bool Pause(char *error, size_t maxlen)
    1.84 +	{
    1.85 +		return true;
    1.86 +	}
    1.87  
    1.88  	/** @brief Called on plugin unpause.
    1.89  	 *
    1.90 -	 * @param error Error message buffer
    1.91 -	 * @param maxlen Size of error message buffer
    1.92 -	 * @return True on success, return false to request no unpause.
    1.93 +	 * @param	error Error message buffer
    1.94 +	 * @param	maxlen Size of error message buffer
    1.95 +	 * @return	True on success, return false to request no unpause.
    1.96  	 */
    1.97 -	virtual bool Unpause(char *error, size_t maxlen) =0;
    1.98 +	virtual bool Unpause(char *error, size_t maxlen)
    1.99 +	{
   1.100 +		return true;
   1.101 +	}
   1.102  public:
   1.103  	/** @brief Return author as string */
   1.104  	virtual const char *GetAuthor() =0;
   1.105 @@ -101,13 +142,16 @@
   1.106  public:
   1.107  	/**
   1.108  	 * @brief Called when all plugins have been loaded - API version 4
   1.109 -         *
   1.110 -         * Ths is useful for knowing when it's safe to request things another plugin might have.
   1.111 +	 *
   1.112 +	 * This is useful for knowing when it's safe to request things another plugin might have.
   1.113 +	 * NOTE for API 7 - This is called after DLLInit(). 
   1.114  	 */
   1.115 -	virtual void AllPluginsLoaded() =0;
   1.116 +	virtual void AllPluginsLoaded()
   1.117 +	{
   1.118 +	}
   1.119  };
   1.120  
   1.121 -#define PL_EXPOSURE	CreateInterface
   1.122 +#define PL_EXPOSURE		CreateInterface
   1.123  #define PL_EXPOSURE_C	"CreateInterface"
   1.124  
   1.125  #define PLUGIN_EXPOSE(name, var) \
   1.126 @@ -138,13 +182,13 @@
   1.127  	g_SMAPI->SetLastMetaReturn(mres); \
   1.128  	return value;
   1.129  
   1.130 -#define META_LOG		g_SMAPI->LogMsg
   1.131 +#define META_LOG				g_SMAPI->LogMsg
   1.132  #define META_REGCMD(name)		g_SMAPI->RegisterConCmdBase(g_PLAPI, name##_command)
   1.133  #define META_REGCVAR(var)		g_SMAPI->RegisterConCmdBase(g_PLAPI, var)
   1.134  #define META_UNREGCMD(name)		g_SMAPI->UnregisterConCmdBase(g_PLAPI, name##_command)
   1.135  #define META_UNREGCVAR(var)		g_SMAPI->UnregisterConCmdBase(g_PLAPI, var)
   1.136 -#define	META_CONPRINT	g_SMAPI->ConPrint
   1.137 -#define META_CONPRINTF	g_SMAPI->ConPrintf
   1.138 +#define	META_CONPRINT			g_SMAPI->ConPrint
   1.139 +#define META_CONPRINTF			g_SMAPI->ConPrintf
   1.140  
   1.141  //probably should use this up above someday
   1.142  #define CONCMD_VARNAME(name) name##_command