From dedb414a50328bf00462409d14d8917ff24844be Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Tue, 5 Feb 2013 19:57:22 +0000 Subject: Added new hooks: OnChunkAvailable(), OnChunkUnloaded() and OnChunkUnloading(). Modified OnChunkGenerated() signature. http://forum.mc-server.org/showthread.php?tid=464&pid=6312#pid6312 git-svn-id: http://mc-server.googlecode.com/svn/trunk@1193 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/PluginManager.cpp | 71 +++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 67 insertions(+), 4 deletions(-) (limited to 'source/PluginManager.cpp') diff --git a/source/PluginManager.cpp b/source/PluginManager.cpp index f25b8ec73..8ff4f4e8f 100644 --- a/source/PluginManager.cpp +++ b/source/PluginManager.cpp @@ -233,7 +233,28 @@ bool cPluginManager::CallHookChat(cPlayer * a_Player, const AString & a_Message) -bool cPluginManager::CallHookChunkGenerated(cWorld * a_World, int a_ChunkX, int a_ChunkZ) +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; + } + for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) + { + if ((*itr)->OnChunkAvailable(a_World, a_ChunkX, a_ChunkZ)) + { + return true; + } + } + return false; +} + + + + + +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()) @@ -242,7 +263,7 @@ bool cPluginManager::CallHookChunkGenerated(cWorld * a_World, int a_ChunkX, int } for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) { - if ((*itr)->OnChunkGenerated(a_World, a_ChunkX, a_ChunkZ)) + if ((*itr)->OnChunkGenerated(a_World, a_ChunkX, a_ChunkZ, a_ChunkDesc)) { return true; } @@ -254,7 +275,7 @@ bool cPluginManager::CallHookChunkGenerated(cWorld * a_World, int a_ChunkX, int -bool cPluginManager::CallHookChunkGenerating(cWorld * a_World, int a_ChunkX, int a_ChunkZ, cChunkDesc * a_LuaChunk) +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()) @@ -263,7 +284,49 @@ bool cPluginManager::CallHookChunkGenerating(cWorld * a_World, int a_ChunkX, int } for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) { - if ((*itr)->OnChunkGenerating(a_World, a_ChunkX, a_ChunkZ, a_LuaChunk)) + if ((*itr)->OnChunkGenerating(a_World, a_ChunkX, a_ChunkZ, a_ChunkDesc)) + { + return true; + } + } + return false; +} + + + + + +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; + } + for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) + { + if ((*itr)->OnChunkUnloaded(a_World, a_ChunkX, a_ChunkZ)) + { + return true; + } + } + return false; +} + + + + + +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; + } + for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr) + { + if ((*itr)->OnChunkUnloading(a_World, a_ChunkX, a_ChunkZ)) { return true; } -- cgit v1.2.3