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/ChunkMap.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'source/ChunkMap.cpp') diff --git a/source/ChunkMap.cpp b/source/ChunkMap.cpp index ede16ffa6..142a009f5 100644 --- a/source/ChunkMap.cpp +++ b/source/ChunkMap.cpp @@ -11,6 +11,7 @@ #include "Chunk.h" #include "Generating/Trees.h" // used in cChunkMap::ReplaceTreeBlocks() for tree block discrimination #include "BlockArea.h" +#include "PluginManager.h" #ifndef _WIN32 #include // abs @@ -711,6 +712,9 @@ void cChunkMap::SetChunkData( { Chunk->MarkDirty(); } + + // Notify plugins of the chunk becoming available + cPluginManager::Get()->CallHookChunkAvailable(m_World, a_ChunkX, a_ChunkZ); } @@ -1992,7 +1996,11 @@ void cChunkMap::cChunkLayer::UnloadUnusedChunks(void) { for (int i = 0; i < ARRAYCOUNT(m_Chunks); i++) { - if ((m_Chunks[i] != NULL) && (m_Chunks[i]->CanUnload())) + if ( + (m_Chunks[i] != NULL) && // Is valid + (m_Chunks[i]->CanUnload()) && // Can unload + !cPluginManager::Get()->CallHookChunkUnloading(m_Parent->GetWorld(), m_Chunks[i]->GetPosX(), m_Chunks[i]->GetPosZ()) // Plugins agree + ) { // The cChunk destructor calls our GetChunk() while removing its entities // so we still need to be able to return the chunk. Therefore we first delete, then NULLify -- cgit v1.2.3