summaryrefslogtreecommitdiffstats
path: root/src/Bindings/PluginManager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Bindings/PluginManager.cpp')
-rw-r--r--src/Bindings/PluginManager.cpp468
1 files changed, 180 insertions, 288 deletions
diff --git a/src/Bindings/PluginManager.cpp b/src/Bindings/PluginManager.cpp
index fc690d4de..9bcd8e3b7 100644
--- a/src/Bindings/PluginManager.cpp
+++ b/src/Bindings/PluginManager.cpp
@@ -14,6 +14,13 @@
#include "inifile/iniFile.h"
#include "../Entities/Player.h"
+#define FIND_HOOK(a_HookName) HookMap::iterator Plugins = m_Hooks.find(a_HookName);
+#define VERIFY_HOOK \
+ if (Plugins == m_Hooks.end()) \
+ { \
+ return false; \
+ }
+
@@ -192,7 +199,7 @@ void cPluginManager::Tick(float a_Dt)
ReloadPluginsNow();
}
- HookMap::iterator Plugins = m_Hooks.find(HOOK_TICK);
+ FIND_HOOK(HOOK_TICK);
if (Plugins != m_Hooks.end())
{
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
@@ -208,11 +215,9 @@ void cPluginManager::Tick(float a_Dt)
bool cPluginManager::CallHookBlockSpread(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, eSpreadSource a_Source)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_BLOCK_SPREAD);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_BLOCK_SPREAD);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnBlockSpread(a_World, a_BlockX, a_BlockY, a_BlockZ, a_Source))
@@ -233,11 +238,9 @@ bool cPluginManager::CallHookBlockToPickups(
cItems & a_Pickups
)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_BLOCK_TO_PICKUPS);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_BLOCK_TO_PICKUPS);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnBlockToPickups(a_World, a_Digger, a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta, a_Pickups))
@@ -275,11 +278,8 @@ bool cPluginManager::CallHookChat(cPlayer * a_Player, AString & a_Message)
return true; // Cancel sending
}
- HookMap::iterator Plugins = m_Hooks.find(HOOK_CHAT);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_CHAT);
+ VERIFY_HOOK;
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
@@ -298,11 +298,9 @@ bool cPluginManager::CallHookChat(cPlayer * a_Player, AString & a_Message)
bool cPluginManager::CallHookChunkAvailable(cWorld * a_World, int a_ChunkX, int a_ChunkZ)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_CHUNK_AVAILABLE);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_CHUNK_AVAILABLE);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnChunkAvailable(a_World, a_ChunkX, a_ChunkZ))
@@ -319,11 +317,9 @@ bool cPluginManager::CallHookChunkAvailable(cWorld * a_World, int a_ChunkX, int
bool cPluginManager::CallHookChunkGenerated(cWorld * a_World, int a_ChunkX, int a_ChunkZ, cChunkDesc * a_ChunkDesc)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_CHUNK_GENERATED);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_CHUNK_GENERATED);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnChunkGenerated(a_World, a_ChunkX, a_ChunkZ, a_ChunkDesc))
@@ -340,11 +336,9 @@ bool cPluginManager::CallHookChunkGenerated(cWorld * a_World, int a_ChunkX, int
bool cPluginManager::CallHookChunkGenerating(cWorld * a_World, int a_ChunkX, int a_ChunkZ, cChunkDesc * a_ChunkDesc)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_CHUNK_GENERATING);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_CHUNK_GENERATING);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnChunkGenerating(a_World, a_ChunkX, a_ChunkZ, a_ChunkDesc))
@@ -361,11 +355,9 @@ bool cPluginManager::CallHookChunkGenerating(cWorld * a_World, int a_ChunkX, int
bool cPluginManager::CallHookChunkUnloaded(cWorld * a_World, int a_ChunkX, int a_ChunkZ)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_CHUNK_UNLOADED);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_CHUNK_UNLOADED);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnChunkUnloaded(a_World, a_ChunkX, a_ChunkZ))
@@ -382,11 +374,9 @@ bool cPluginManager::CallHookChunkUnloaded(cWorld * a_World, int a_ChunkX, int a
bool cPluginManager::CallHookChunkUnloading(cWorld * a_World, int a_ChunkX, int a_ChunkZ)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_CHUNK_UNLOADING);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_CHUNK_UNLOADING);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnChunkUnloading(a_World, a_ChunkX, a_ChunkZ))
@@ -403,11 +393,9 @@ bool cPluginManager::CallHookChunkUnloading(cWorld * a_World, int a_ChunkX, int
bool cPluginManager::CallHookCollectingPickup(cPlayer * a_Player, cPickup & a_Pickup)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_COLLECTING_PICKUP);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_COLLECTING_PICKUP);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnCollectingPickup(a_Player, &a_Pickup))
@@ -424,11 +412,9 @@ bool cPluginManager::CallHookCollectingPickup(cPlayer * a_Player, cPickup & a_Pi
bool cPluginManager::CallHookCraftingNoRecipe(const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_CRAFTING_NO_RECIPE);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_CRAFTING_NO_RECIPE);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnCraftingNoRecipe(a_Player, a_Grid, a_Recipe))
@@ -445,11 +431,9 @@ bool cPluginManager::CallHookCraftingNoRecipe(const cPlayer * a_Player, const cC
bool cPluginManager::CallHookDisconnect(cClientHandle & a_Client, const AString & a_Reason)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_DISCONNECT);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_DISCONNECT);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnDisconnect(a_Client, a_Reason))
@@ -466,11 +450,9 @@ bool cPluginManager::CallHookDisconnect(cClientHandle & a_Client, const AString
bool cPluginManager::CallHookExecuteCommand(cPlayer * a_Player, const AStringVector & a_Split)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_EXECUTE_COMMAND);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_EXECUTE_COMMAND);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnExecuteCommand(a_Player, a_Split))
@@ -487,11 +469,9 @@ bool cPluginManager::CallHookExecuteCommand(cPlayer * a_Player, const AStringVec
bool cPluginManager::CallHookExploded(cWorld & a_World, double a_ExplosionSize, bool a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void * a_SourceData)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_EXPLODED);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_EXPLODED);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnExploded(a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, a_SourceData))
@@ -508,11 +488,9 @@ bool cPluginManager::CallHookExploded(cWorld & a_World, double a_ExplosionSize,
bool cPluginManager::CallHookExploding(cWorld & a_World, double & a_ExplosionSize, bool & a_CanCauseFire, double a_X, double a_Y, double a_Z, eExplosionSource a_Source, void * a_SourceData)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_EXPLODING);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_EXPLODING);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnExploding(a_World, a_ExplosionSize, a_CanCauseFire, a_X, a_Y, a_Z, a_Source, a_SourceData))
@@ -529,11 +507,9 @@ bool cPluginManager::CallHookExploding(cWorld & a_World, double & a_ExplosionSiz
bool cPluginManager::CallHookHandshake(cClientHandle * a_ClientHandle, const AString & a_Username)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_HANDSHAKE);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_HANDSHAKE);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnHandshake(a_ClientHandle, a_Username))
@@ -550,11 +526,9 @@ bool cPluginManager::CallHookHandshake(cClientHandle * a_ClientHandle, const ASt
bool cPluginManager::CallHookHopperPullingItem(cWorld & a_World, cHopperEntity & a_Hopper, int a_DstSlotNum, cBlockEntityWithItems & a_SrcEntity, int a_SrcSlotNum)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_HOPPER_PULLING_ITEM);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_HOPPER_PULLING_ITEM);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnHopperPullingItem(a_World, a_Hopper, a_DstSlotNum, a_SrcEntity, a_SrcSlotNum))
@@ -571,11 +545,9 @@ bool cPluginManager::CallHookHopperPullingItem(cWorld & a_World, cHopperEntity &
bool cPluginManager::CallHookHopperPushingItem(cWorld & a_World, cHopperEntity & a_Hopper, int a_SrcSlotNum, cBlockEntityWithItems & a_DstEntity, int a_DstSlotNum)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_HOPPER_PUSHING_ITEM);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_HOPPER_PUSHING_ITEM);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnHopperPushingItem(a_World, a_Hopper, a_SrcSlotNum, a_DstEntity, a_DstSlotNum))
@@ -592,11 +564,9 @@ bool cPluginManager::CallHookHopperPushingItem(cWorld & a_World, cHopperEntity &
bool cPluginManager::CallHookKilling(cEntity & a_Victim, cEntity * a_Killer)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_KILLING);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_KILLING);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnKilling(a_Victim, a_Killer))
@@ -613,11 +583,9 @@ bool cPluginManager::CallHookKilling(cEntity & a_Victim, cEntity * a_Killer)
bool cPluginManager::CallHookLogin(cClientHandle * a_Client, int a_ProtocolVersion, const AString & a_Username)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_LOGIN);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_LOGIN);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnLogin(a_Client, a_ProtocolVersion, a_Username))
@@ -634,11 +602,9 @@ bool cPluginManager::CallHookLogin(cClientHandle * a_Client, int a_ProtocolVersi
bool cPluginManager::CallHookPlayerAnimation(cPlayer & a_Player, int a_Animation)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_ANIMATION);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_PLAYER_ANIMATION);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnPlayerAnimation(a_Player, a_Animation))
@@ -655,11 +621,9 @@ bool cPluginManager::CallHookPlayerAnimation(cPlayer & a_Player, int a_Animation
bool cPluginManager::CallHookPlayerBreakingBlock(cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_BREAKING_BLOCK);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_PLAYER_BREAKING_BLOCK);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnPlayerBreakingBlock(a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_BlockType, a_BlockMeta))
@@ -676,11 +640,9 @@ bool cPluginManager::CallHookPlayerBreakingBlock(cPlayer & a_Player, int a_Block
bool cPluginManager::CallHookPlayerBrokenBlock(cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_BROKEN_BLOCK);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_PLAYER_BROKEN_BLOCK);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnPlayerBrokenBlock(a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_BlockType, a_BlockMeta))
@@ -697,11 +659,9 @@ bool cPluginManager::CallHookPlayerBrokenBlock(cPlayer & a_Player, int a_BlockX,
bool cPluginManager::CallHookPlayerDestroyed(cPlayer & a_Player)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_DESTROYED);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_PLAYER_DESTROYED);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnPlayerDestroyed(a_Player))
@@ -718,11 +678,9 @@ bool cPluginManager::CallHookPlayerDestroyed(cPlayer & a_Player)
bool cPluginManager::CallHookPlayerEating(cPlayer & a_Player)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_EATING);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_PLAYER_EATING);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnPlayerEating(a_Player))
@@ -739,11 +697,9 @@ bool cPluginManager::CallHookPlayerEating(cPlayer & a_Player)
bool cPluginManager::CallHookPlayerFished(cPlayer & a_Player, const cItems a_Reward)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_FISHED);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_PLAYER_FISHED);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnPlayerFished(a_Player, a_Reward))
@@ -760,11 +716,9 @@ bool cPluginManager::CallHookPlayerFished(cPlayer & a_Player, const cItems a_Rew
bool cPluginManager::CallHookPlayerFishing(cPlayer & a_Player, cItems a_Reward)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_FISHING);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_PLAYER_FISHING);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnPlayerFishing(a_Player, a_Reward))
@@ -781,11 +735,9 @@ bool cPluginManager::CallHookPlayerFishing(cPlayer & a_Player, cItems a_Reward)
bool cPluginManager::CallHookPlayerJoined(cPlayer & a_Player)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_JOINED);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_PLAYER_JOINED);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnPlayerJoined(a_Player))
@@ -802,11 +754,9 @@ bool cPluginManager::CallHookPlayerJoined(cPlayer & a_Player)
bool cPluginManager::CallHookPlayerLeftClick(cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, char a_Status)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_LEFT_CLICK);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_PLAYER_LEFT_CLICK);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnPlayerLeftClick(a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_Status))
@@ -823,11 +773,9 @@ bool cPluginManager::CallHookPlayerLeftClick(cPlayer & a_Player, int a_BlockX, i
bool cPluginManager::CallHookPlayerMoving(cPlayer & a_Player)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_MOVING);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_PLAYER_MOVING);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnPlayerMoved(a_Player))
@@ -844,11 +792,9 @@ bool cPluginManager::CallHookPlayerMoving(cPlayer & a_Player)
bool cPluginManager::CallHookPlayerPlacedBlock(cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_PLACED_BLOCK);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_PLAYER_PLACED_BLOCK);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnPlayerPlacedBlock(a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, a_BlockType, a_BlockMeta))
@@ -865,11 +811,9 @@ bool cPluginManager::CallHookPlayerPlacedBlock(cPlayer & a_Player, int a_BlockX,
bool cPluginManager::CallHookPlayerPlacingBlock(cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_PLACING_BLOCK);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_PLAYER_PLACING_BLOCK);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnPlayerPlacingBlock(a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, a_BlockType, a_BlockMeta))
@@ -886,11 +830,9 @@ bool cPluginManager::CallHookPlayerPlacingBlock(cPlayer & a_Player, int a_BlockX
bool cPluginManager::CallHookPlayerRightClick(cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_RIGHT_CLICK);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_PLAYER_RIGHT_CLICK);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnPlayerRightClick(a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ))
@@ -907,11 +849,9 @@ bool cPluginManager::CallHookPlayerRightClick(cPlayer & a_Player, int a_BlockX,
bool cPluginManager::CallHookPlayerRightClickingEntity(cPlayer & a_Player, cEntity & a_Entity)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_RIGHT_CLICKING_ENTITY);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_PLAYER_RIGHT_CLICKING_ENTITY);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnPlayerRightClickingEntity(a_Player, a_Entity))
@@ -928,11 +868,9 @@ bool cPluginManager::CallHookPlayerRightClickingEntity(cPlayer & a_Player, cEnti
bool cPluginManager::CallHookPlayerShooting(cPlayer & a_Player)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_SHOOTING);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_PLAYER_SHOOTING);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnPlayerShooting(a_Player))
@@ -949,11 +887,9 @@ bool cPluginManager::CallHookPlayerShooting(cPlayer & a_Player)
bool cPluginManager::CallHookPlayerSpawned(cPlayer & a_Player)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_SPAWNED);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_PLAYER_SPAWNED);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnPlayerSpawned(a_Player))
@@ -970,11 +906,9 @@ bool cPluginManager::CallHookPlayerSpawned(cPlayer & a_Player)
bool cPluginManager::CallHookPlayerTossingItem(cPlayer & a_Player)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_TOSSING_ITEM);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_PLAYER_TOSSING_ITEM);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnPlayerTossingItem(a_Player))
@@ -991,11 +925,9 @@ bool cPluginManager::CallHookPlayerTossingItem(cPlayer & a_Player)
bool cPluginManager::CallHookPlayerUsedBlock(cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_USED_BLOCK);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_PLAYER_USED_BLOCK);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnPlayerUsedBlock(a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, a_BlockType, a_BlockMeta))
@@ -1012,11 +944,9 @@ bool cPluginManager::CallHookPlayerUsedBlock(cPlayer & a_Player, int a_BlockX, i
bool cPluginManager::CallHookPlayerUsedItem(cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_USED_ITEM);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_PLAYER_USED_ITEM);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnPlayerUsedItem(a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ))
@@ -1033,11 +963,9 @@ bool cPluginManager::CallHookPlayerUsedItem(cPlayer & a_Player, int a_BlockX, in
bool cPluginManager::CallHookPlayerUsingBlock(cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_USING_BLOCK);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_PLAYER_USING_BLOCK);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnPlayerUsingBlock(a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ, a_BlockType, a_BlockMeta))
@@ -1054,11 +982,9 @@ bool cPluginManager::CallHookPlayerUsingBlock(cPlayer & a_Player, int a_BlockX,
bool cPluginManager::CallHookPlayerUsingItem(cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_PLAYER_USING_ITEM);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_PLAYER_USING_ITEM);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnPlayerUsingItem(a_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ))
@@ -1075,11 +1001,9 @@ bool cPluginManager::CallHookPlayerUsingItem(cPlayer & a_Player, int a_BlockX, i
bool cPluginManager::CallHookPluginMessage(cClientHandle & a_Client, const AString & a_Channel, const AString & a_Message)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_PLUGIN_MESSAGE);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_PLUGIN_MESSAGE);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnPluginMessage(a_Client, a_Channel, a_Message))
@@ -1096,11 +1020,9 @@ bool cPluginManager::CallHookPluginMessage(cClientHandle & a_Client, const AStri
bool cPluginManager::CallHookPluginsLoaded(void)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_PLUGINS_LOADED);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_PLUGINS_LOADED);
+ VERIFY_HOOK;
+
bool res = false;
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
@@ -1115,11 +1037,9 @@ bool cPluginManager::CallHookPluginsLoaded(void)
bool cPluginManager::CallHookPostCrafting(const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_POST_CRAFTING);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_POST_CRAFTING);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnPostCrafting(a_Player, a_Grid, a_Recipe))
@@ -1136,11 +1056,9 @@ bool cPluginManager::CallHookPostCrafting(const cPlayer * a_Player, const cCraft
bool cPluginManager::CallHookPreCrafting(const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_PRE_CRAFTING);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_PRE_CRAFTING);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnPreCrafting(a_Player, a_Grid, a_Recipe))
@@ -1155,16 +1073,14 @@ bool cPluginManager::CallHookPreCrafting(const cPlayer * a_Player, const cCrafti
-bool cPluginManager::CallHookProjectileHitBlock(cProjectileEntity & a_Projectile)
+bool cPluginManager::CallHookProjectileHitBlock(cProjectileEntity & a_Projectile, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_Face, const Vector3d & a_BlockHitPos)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_PROJECTILE_HIT_BLOCK);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_PROJECTILE_HIT_BLOCK);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
- if ((*itr)->OnProjectileHitBlock(a_Projectile))
+ if ((*itr)->OnProjectileHitBlock(a_Projectile, a_BlockX, a_BlockY, a_BlockZ, a_Face, a_BlockHitPos))
{
return true;
}
@@ -1178,11 +1094,9 @@ bool cPluginManager::CallHookProjectileHitBlock(cProjectileEntity & a_Projectile
bool cPluginManager::CallHookProjectileHitEntity(cProjectileEntity & a_Projectile, cEntity & a_HitEntity)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_PROJECTILE_HIT_ENTITY);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_PROJECTILE_HIT_ENTITY);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnProjectileHitEntity(a_Projectile, a_HitEntity))
@@ -1199,11 +1113,9 @@ bool cPluginManager::CallHookProjectileHitEntity(cProjectileEntity & a_Projectil
bool cPluginManager::CallHookSpawnedEntity(cWorld & a_World, cEntity & a_Entity)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_SPAWNED_ENTITY);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_SPAWNED_ENTITY);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnSpawnedEntity(a_World, a_Entity))
@@ -1219,11 +1131,9 @@ bool cPluginManager::CallHookSpawnedEntity(cWorld & a_World, cEntity & a_Entity)
bool cPluginManager::CallHookSpawnedMonster(cWorld & a_World, cMonster & a_Monster)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_SPAWNED_MONSTER);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_SPAWNED_MONSTER);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnSpawnedMonster(a_World, a_Monster))
@@ -1239,11 +1149,9 @@ bool cPluginManager::CallHookSpawnedMonster(cWorld & a_World, cMonster & a_Monst
bool cPluginManager::CallHookSpawningEntity(cWorld & a_World, cEntity & a_Entity)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_SPAWNING_ENTITY);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_SPAWNING_ENTITY);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnSpawningEntity(a_World, a_Entity))
@@ -1260,11 +1168,9 @@ bool cPluginManager::CallHookSpawningEntity(cWorld & a_World, cEntity & a_Entity
bool cPluginManager::CallHookSpawningMonster(cWorld & a_World, cMonster & a_Monster)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_SPAWNING_MONSTER);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_SPAWNING_MONSTER);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnSpawningMonster(a_World, a_Monster))
@@ -1281,11 +1187,9 @@ bool cPluginManager::CallHookSpawningMonster(cWorld & a_World, cMonster & a_Mons
bool cPluginManager::CallHookTakeDamage(cEntity & a_Receiver, TakeDamageInfo & a_TDI)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_TAKE_DAMAGE);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_TAKE_DAMAGE);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnTakeDamage(a_Receiver, a_TDI))
@@ -1302,11 +1206,9 @@ bool cPluginManager::CallHookTakeDamage(cEntity & a_Receiver, TakeDamageInfo & a
bool cPluginManager::CallHookUpdatingSign(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, AString & a_Line1, AString & a_Line2, AString & a_Line3, AString & a_Line4, cPlayer * a_Player)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_UPDATING_SIGN);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_UPDATING_SIGN);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnUpdatingSign(a_World, a_BlockX, a_BlockY, a_BlockZ, a_Line1, a_Line2, a_Line3, a_Line4, a_Player))
@@ -1323,11 +1225,9 @@ bool cPluginManager::CallHookUpdatingSign(cWorld * a_World, int a_BlockX, int a_
bool cPluginManager::CallHookUpdatedSign(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ, const AString & a_Line1, const AString & a_Line2, const AString & a_Line3, const AString & a_Line4, cPlayer * a_Player)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_UPDATED_SIGN);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_UPDATED_SIGN);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnUpdatedSign(a_World, a_BlockX, a_BlockY, a_BlockZ, a_Line1, a_Line2, a_Line3, a_Line4, a_Player))
@@ -1344,11 +1244,9 @@ bool cPluginManager::CallHookUpdatedSign(cWorld * a_World, int a_BlockX, int a_B
bool cPluginManager::CallHookWeatherChanged(cWorld & a_World)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_WEATHER_CHANGED);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_WEATHER_CHANGED);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnWeatherChanged(a_World))
@@ -1365,11 +1263,9 @@ bool cPluginManager::CallHookWeatherChanged(cWorld & a_World)
bool cPluginManager::CallHookWeatherChanging(cWorld & a_World, eWeather & a_NewWeather)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_WEATHER_CHANGING);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_WEATHER_CHANGING);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnWeatherChanging(a_World, a_NewWeather))
@@ -1386,11 +1282,9 @@ bool cPluginManager::CallHookWeatherChanging(cWorld & a_World, eWeather & a_NewW
bool cPluginManager::CallHookWorldStarted(cWorld & a_World)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_WORLD_STARTED);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_WORLD_STARTED);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnWorldStarted(a_World))
@@ -1407,11 +1301,9 @@ bool cPluginManager::CallHookWorldStarted(cWorld & a_World)
bool cPluginManager::CallHookWorldTick(cWorld & a_World, float a_Dt, int a_LastTickDurationMSec)
{
- HookMap::iterator Plugins = m_Hooks.find(HOOK_WORLD_TICK);
- if (Plugins == m_Hooks.end())
- {
- return false;
- }
+ FIND_HOOK(HOOK_WORLD_TICK);
+ VERIFY_HOOK;
+
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
{
if ((*itr)->OnWorldTick(a_World, a_Dt, a_LastTickDurationMSec))