diff options
Diffstat (limited to 'source/PluginManager.cpp')
-rw-r--r-- | source/PluginManager.cpp | 60 |
1 files changed, 33 insertions, 27 deletions
diff --git a/source/PluginManager.cpp b/source/PluginManager.cpp index 1123f3615..162aaf2e3 100644 --- a/source/PluginManager.cpp +++ b/source/PluginManager.cpp @@ -253,21 +253,6 @@ bool cPluginManager::CallHook(PluginHook a_Hook, unsigned int a_NumArgs, ...) break; } - case HOOK_TAKE_DAMAGE: - { - if( a_NumArgs != 2 ) break; - va_list argptr; - va_start( argptr, a_NumArgs); - cPawn* Pawn = va_arg(argptr, cPawn* ); - TakeDamageInfo* TDI = va_arg(argptr, TakeDamageInfo* ); - va_end (argptr); - for( PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr ) - { - (*itr)->OnTakeDamage( Pawn, TDI ); - } - break; - } - case HOOK_KILLED: { if( a_NumArgs != 2 ) break; @@ -482,16 +467,16 @@ bool cPluginManager::CallHookCollectPickup(cPlayer * a_Player, cPickup & a_Picku -bool cPluginManager::CallHookPreCrafting(const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) +bool cPluginManager::CallHookCraftingNoRecipe(const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) { - HookMap::iterator Plugins = m_Hooks.find(HOOK_PRE_CRAFTING); + HookMap::iterator Plugins = m_Hooks.find(HOOK_CRAFTING_NO_RECIPE); if (Plugins == m_Hooks.end()) { return false; } for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) { - if ((*itr)->OnPreCrafting(a_Player, a_Grid, a_Recipe)) + if ((*itr)->OnCraftingNoRecipe(a_Player, a_Grid, a_Recipe)) { return true; } @@ -503,16 +488,16 @@ bool cPluginManager::CallHookPreCrafting(const cPlayer * a_Player, const cCrafti -bool cPluginManager::CallHookCraftingNoRecipe(const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) +bool cPluginManager::CallHookDisconnect(cPlayer * a_Player, const AString & a_Reason) { - HookMap::iterator Plugins = m_Hooks.find(HOOK_CRAFTING_NO_RECIPE); + HookMap::iterator Plugins = m_Hooks.find(HOOK_DISCONNECT); if (Plugins == m_Hooks.end()) { return false; } for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) { - if ((*itr)->OnCraftingNoRecipe(a_Player, a_Grid, a_Recipe)) + if ((*itr)->OnDisconnect(a_Player, a_Reason)) { return true; } @@ -524,16 +509,16 @@ bool cPluginManager::CallHookCraftingNoRecipe(const cPlayer * a_Player, const cC -bool cPluginManager::CallHookDisconnect(cPlayer * a_Player, const AString & a_Reason) +bool cPluginManager::CallHookPostCrafting(const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) { - HookMap::iterator Plugins = m_Hooks.find(HOOK_DISCONNECT); + HookMap::iterator Plugins = m_Hooks.find(HOOK_POST_CRAFTING); if (Plugins == m_Hooks.end()) { return false; } for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) { - if ((*itr)->OnDisconnect(a_Player, a_Reason)) + if ((*itr)->OnPostCrafting(a_Player, a_Grid, a_Recipe)) { return true; } @@ -545,16 +530,37 @@ bool cPluginManager::CallHookDisconnect(cPlayer * a_Player, const AString & a_Re -bool cPluginManager::CallHookPostCrafting(const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) +bool cPluginManager::CallHookPreCrafting(const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) { - HookMap::iterator Plugins = m_Hooks.find(HOOK_POST_CRAFTING); + HookMap::iterator Plugins = m_Hooks.find(HOOK_PRE_CRAFTING); if (Plugins == m_Hooks.end()) { return false; } for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) { - if ((*itr)->OnPostCrafting(a_Player, a_Grid, a_Recipe)) + if ((*itr)->OnPreCrafting(a_Player, a_Grid, a_Recipe)) + { + return true; + } + } + return false; +} + + + + + +bool cPluginManager::CallHookTakeDamage(cPawn & a_Receiver, TakeDamageInfo & a_TDI) +{ + HookMap::iterator Plugins = m_Hooks.find(HOOK_TAKE_DAMAGE); + if (Plugins == m_Hooks.end()) + { + return false; + } + for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) + { + if ((*itr)->OnTakeDamage(a_Receiver, a_TDI)) { return true; } |