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.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'source/PluginManager.cpp') diff --git a/source/PluginManager.cpp b/source/PluginManager.cpp index e6ff3e6e2..a2726bd58 100644 --- a/source/PluginManager.cpp +++ b/source/PluginManager.cpp @@ -61,7 +61,7 @@ void cPluginManager::FindPlugins(void) // First get a clean list of only the currently running plugins, we don't want to mess those up for (PluginMap::iterator itr = m_Plugins.begin(); itr != m_Plugins.end();) { - if( itr->second == NULL ) + if (itr->second == NULL) { PluginMap::iterator thiz = itr; ++thiz; @@ -1585,6 +1585,15 @@ void cPluginManager::TabCompleteCommand(const AString & a_Text, AStringVector & +bool cPluginManager::IsValidHookType(int a_HookType) +{ + return ((a_HookType >= 0) && (a_HookType <= HOOK_MAX)); +} + + + + + bool cPluginManager::AddPlugin(cPlugin * a_Plugin) { m_Plugins[a_Plugin->GetDirectory()] = a_Plugin; @@ -1603,7 +1612,7 @@ bool cPluginManager::AddPlugin(cPlugin * a_Plugin) -void cPluginManager::AddHook(cPlugin * a_Plugin, PluginHook a_Hook) +void cPluginManager::AddHook(cPlugin * a_Plugin, int a_Hook) { if (!a_Plugin) { -- cgit v1.2.3 From 7eae58281a1c912f298ac8d5f463a2c60cdc2440 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 22 Aug 2013 21:03:20 +0200 Subject: Fixed AddHook() wanting old-style function names. Error reported by STR_Warrior in the forum http://forum.mc-server.org/showthread.php?tid=1227&pid=9620#pid9620 --- source/PluginManager.cpp | 4 ---- 1 file changed, 4 deletions(-) (limited to 'source/PluginManager.cpp') diff --git a/source/PluginManager.cpp b/source/PluginManager.cpp index a2726bd58..93ee71926 100644 --- a/source/PluginManager.cpp +++ b/source/PluginManager.cpp @@ -1619,10 +1619,6 @@ void cPluginManager::AddHook(cPlugin * a_Plugin, int a_Hook) LOGWARN("Called cPluginManager::AddHook() with a_Plugin == NULL"); return; } - if (!a_Plugin->CanAddHook(a_Hook)) - { - return; - } PluginList & Plugins = m_Hooks[a_Hook]; Plugins.remove(a_Plugin); Plugins.push_back(a_Plugin); -- cgit v1.2.3