From 25ec7750aac9800bec83a844020a6eeda5cd4d74 Mon Sep 17 00:00:00 2001 From: Tycho Date: Fri, 31 Jan 2014 15:17:41 -0800 Subject: Changed signitures of Several BLockHandler Methods Changed the signitures of the following to use interfaces: GetPlacementBlockTypeMeta OnPlaced OnPlacedByPlayer OnDestroyed OnNeighbourChanged NeighbourChanged OnUse CanBeAt Check --- src/Chunk.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/Chunk.cpp') diff --git a/src/Chunk.cpp b/src/Chunk.cpp index a72464ec3..4fdaf4b69 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -753,7 +753,7 @@ void cChunk::BroadcastPendingBlockChanges(void) -void cChunk::CheckBlocks(void) +void cChunk::CheckBlocks() { if (m_ToTickBlocks.size() == 0) { @@ -762,13 +762,15 @@ void cChunk::CheckBlocks(void) std::vector ToTickBlocks; std::swap(m_ToTickBlocks, ToTickBlocks); + cChunkInterface ChunkInterface(m_World->GetChunkMap()); + for (std::vector::const_iterator itr = ToTickBlocks.begin(), end = ToTickBlocks.end(); itr != end; ++itr) { unsigned int index = (*itr); Vector3i BlockPos = IndexToCoordinate(index); cBlockHandler * Handler = BlockHandler(GetBlock(index)); - Handler->Check(BlockPos.x, BlockPos.y, BlockPos.z, *this); + Handler->Check(&ChunkInterface, BlockPos.x, BlockPos.y, BlockPos.z, *this); } // for itr - ToTickBlocks[] } -- cgit v1.2.3 From c6304b2b4faf31c2e4a91a07bcac298467898dba Mon Sep 17 00:00:00 2001 From: Tycho Date: Sat, 1 Feb 2014 05:06:32 -0800 Subject: Changed pointers to references --- src/Chunk.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Chunk.cpp') diff --git a/src/Chunk.cpp b/src/Chunk.cpp index 4fdaf4b69..b29c97084 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -770,7 +770,7 @@ void cChunk::CheckBlocks() Vector3i BlockPos = IndexToCoordinate(index); cBlockHandler * Handler = BlockHandler(GetBlock(index)); - Handler->Check(&ChunkInterface, BlockPos.x, BlockPos.y, BlockPos.z, *this); + Handler->Check(ChunkInterface, BlockPos.x, BlockPos.y, BlockPos.z, *this); } // for itr - ToTickBlocks[] } -- cgit v1.2.3 From b82fc394dd2a40e12e3c13709fea26c2435792c9 Mon Sep 17 00:00:00 2001 From: Tycho Date: Sun, 2 Feb 2014 06:49:37 -0800 Subject: Changed Signiture of OnUpdate --- src/Chunk.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/Chunk.cpp') diff --git a/src/Chunk.cpp b/src/Chunk.cpp index b29c97084..b48bfe65e 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -31,7 +31,7 @@ #include "Simulator/FluidSimulator.h" #include "MobCensus.h" #include "MobSpawner.h" - +#include "BlockInServerPluginInterface.h" #include "json/json.h" @@ -638,7 +638,9 @@ void cChunk::TickBlock(int a_RelX, int a_RelY, int a_RelZ) unsigned Index = MakeIndex(a_RelX, a_RelY, a_RelZ); cBlockHandler * Handler = BlockHandler(m_BlockTypes[Index]); ASSERT(Handler != NULL); // Happenned on server restart, FS #243 - Handler->OnUpdate(*this, a_RelX, a_RelY, a_RelZ); + cChunkInterface ChunkInterface(this->GetWorld()->GetChunkMap()); + cBlockInServerPluginInterface PluginInterface(*this->GetWorld()); + Handler->OnUpdate(ChunkInterface, *this->GetWorld(), PluginInterface,*this, a_RelX, a_RelY, a_RelZ); } @@ -763,6 +765,7 @@ void cChunk::CheckBlocks() std::swap(m_ToTickBlocks, ToTickBlocks); cChunkInterface ChunkInterface(m_World->GetChunkMap()); + cBlockInServerPluginInterface PluginInterface(*m_World); for (std::vector::const_iterator itr = ToTickBlocks.begin(), end = ToTickBlocks.end(); itr != end; ++itr) { @@ -770,7 +773,7 @@ void cChunk::CheckBlocks() Vector3i BlockPos = IndexToCoordinate(index); cBlockHandler * Handler = BlockHandler(GetBlock(index)); - Handler->Check(ChunkInterface, BlockPos.x, BlockPos.y, BlockPos.z, *this); + Handler->Check(ChunkInterface, PluginInterface, BlockPos.x, BlockPos.y, BlockPos.z, *this); } // for itr - ToTickBlocks[] } @@ -788,6 +791,9 @@ void cChunk::TickBlocks(void) int TickX = m_BlockTickX; int TickY = m_BlockTickY; int TickZ = m_BlockTickZ; + + cChunkInterface ChunkInterface(this->GetWorld()->GetChunkMap()); + cBlockInServerPluginInterface PluginInterface(*this->GetWorld()); // This for loop looks disgusting, but it actually does a simple thing - first processes m_BlockTick, then adds random to it // This is so that SetNextBlockTick() works @@ -813,7 +819,7 @@ void cChunk::TickBlocks(void) unsigned int Index = MakeIndexNoCheck(m_BlockTickX, m_BlockTickY, m_BlockTickZ); cBlockHandler * Handler = BlockHandler(m_BlockTypes[Index]); ASSERT(Handler != NULL); // Happenned on server restart, FS #243 - Handler->OnUpdate(*this, m_BlockTickX, m_BlockTickY, m_BlockTickZ); + Handler->OnUpdate(ChunkInterface, *this->GetWorld(), PluginInterface, *this, m_BlockTickX, m_BlockTickY, m_BlockTickZ); } // for i - tickblocks } -- cgit v1.2.3