From 6b6905fe1cbe3b07ff29e1df9259c0b7c3619421 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Thu, 12 Dec 2013 23:49:10 +0000 Subject: Redstone data is now loaded on chunk load --- src/Chunk.cpp | 6 ++++++ src/World.h | 1 + 2 files changed, 7 insertions(+) (limited to 'src') diff --git a/src/Chunk.cpp b/src/Chunk.cpp index 9c195fdf8..190521c0f 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -1335,6 +1335,7 @@ void cChunk::WakeUpSimulators(void) { cSimulator * WaterSimulator = m_World->GetWaterSimulator(); cSimulator * LavaSimulator = m_World->GetLavaSimulator(); + cSimulator * RedstoneSimulator = m_World->GetRedstoneSimulator(); int BaseX = m_PosX * cChunkDef::Width; int BaseZ = m_PosZ * cChunkDef::Width; for (int x = 0; x < Width; x++) @@ -1357,6 +1358,11 @@ void cChunk::WakeUpSimulators(void) LavaSimulator->AddBlock(BlockX, y, BlockZ, this); break; } + default: + { + RedstoneSimulator->AddBlock(BlockX, y, BlockZ, this); // Redstone simulator checks if valid redstone block already + break; + } } // switch (BlockType) } // for y } // for z diff --git a/src/World.h b/src/World.h index b6ab321fb..fc821a68a 100644 --- a/src/World.h +++ b/src/World.h @@ -392,6 +392,7 @@ public: inline cFluidSimulator * GetWaterSimulator(void) { return m_WaterSimulator; } inline cFluidSimulator * GetLavaSimulator (void) { return m_LavaSimulator; } + inline cRedstoneSimulator * GetRedstoneSimulator(void) { return m_RedstoneSimulator; } /// Calls the callback for each block entity in the specified chunk; returns true if all block entities processed, false if the callback aborted by returning true bool ForEachBlockEntityInChunk(int a_ChunkX, int a_ChunkZ, cBlockEntityCallback & a_Callback); // Exported in ManualBindings.cpp -- cgit v1.2.3 From 3757054d81b50bc1c625e7331b11cfc3e5b02bbb Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Fri, 13 Dec 2013 00:06:47 +0000 Subject: Fixed QueueSetBlock not sending to client changes --- src/Chunk.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/Chunk.cpp b/src/Chunk.cpp index 190521c0f..192c1242c 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -706,8 +706,7 @@ void cChunk::ProcessQueuedSetBlocks(void) { // Current world age is bigger than/equal to target world age - delay time reached AND // Previous block type was the same as current block type (to prevent duplication) - // Since blocktypes were the same, we just need to set the meta - SetMeta(itr->m_RelX, itr->m_RelY, itr->m_RelZ, itr->m_BlockMeta); + SetBlock(itr->m_RelX, itr->m_RelY, itr->m_RelZ, itr->m_BlockType, itr->m_BlockMeta); // SetMeta doesn't send to client itr = m_SetBlockQueue.erase(itr); LOGD("Successfully set queued block - previous and current types matched"); } -- cgit v1.2.3 From 99043091df952153ad4e941a30475dbd65f0c117 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Fri, 13 Dec 2013 19:01:15 +0000 Subject: Improved redstone loading performance --- src/Chunk.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Chunk.cpp b/src/Chunk.cpp index 192c1242c..42969bf6d 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -1345,7 +1345,16 @@ void cChunk::WakeUpSimulators(void) int BlockZ = z + BaseZ; for (int y = GetHeight(x, z); y >= 0; y--) { - switch (cChunkDef::GetBlock(m_BlockTypes, x, y, z)) + BLOCKTYPE Block = cChunkDef::GetBlock(m_BlockTypes, x, y, z); + + // The redstone sim takes multiple blocks, use the inbuilt checker + if (RedstoneSimulator->IsAllowedBlock(Block)) + { + RedstoneSimulator->AddBlock(BlockX, y, BlockZ, this); + continue; + } + + switch (Block) { case E_BLOCK_WATER: { @@ -1359,7 +1368,6 @@ void cChunk::WakeUpSimulators(void) } default: { - RedstoneSimulator->AddBlock(BlockX, y, BlockZ, this); // Redstone simulator checks if valid redstone block already break; } } // switch (BlockType) -- cgit v1.2.3