From f3a0fed72427e747d2c8c9599dd8279ff598dc28 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Wed, 21 Aug 2013 21:29:30 +0200 Subject: Hook adding uses the new API. Multiple hooks per plugin can be added. The cPluginManager.AddHook() has four available signatures, the recommended one is cPluginManager.AddHook(HOOK_TYPE, CallbackFunction) --- source/PluginManager.h | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'source/PluginManager.h') diff --git a/source/PluginManager.h b/source/PluginManager.h index 0933d389f..816e4a40c 100644 --- a/source/PluginManager.h +++ b/source/PluginManager.h @@ -110,6 +110,10 @@ public: // tolua_export // Note that if a hook type is added, it may need processing in cPlugin::CanAddHook() descendants, // and it definitely needs adding in cPluginLua::GetHookFnName() ! + + // Keep these two as the last items, they are used for validity checking and get their values automagically + HOOK_NUM_HOOKS, + HOOK_MAX = HOOK_NUM_HOOKS - 1, } ; // tolua_end @@ -133,7 +137,9 @@ public: // tolua_export void FindPlugins(); // tolua_export void ReloadPlugins(); // tolua_export - void AddHook( cPlugin* a_Plugin, PluginHook a_Hook ); // tolua_export + + /// Adds the plugin to the list of plugins called for the specified hook type. Handles multiple adds as a single add + void AddHook(cPlugin * a_Plugin, int a_HookType); unsigned int GetNumPlugins() const; // tolua_export @@ -237,6 +243,9 @@ public: // tolua_export */ void TabCompleteCommand(const AString & a_Text, AStringVector & a_Results, cPlayer * a_Player); + /// Returns true if the specified hook type is within the allowed range + static bool IsValidHookType(int a_HookType); + private: friend class cRoot; @@ -248,7 +257,7 @@ private: AString m_HelpString; } ; - typedef std::map< cPluginManager::PluginHook, cPluginManager::PluginList > HookMap; + typedef std::map HookMap; typedef std::map CommandMap; PluginList m_DisablePluginList; -- cgit v1.2.3