From 76444470a482a9d05c7c3eb95d0f9ac118dda53e Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Mon, 23 Dec 2013 15:22:05 +0000 Subject: [PATCH] Provides an enhancement to daylight sensors --- src/Simulator/RedstoneSimulator.cpp | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/src/Simulator/RedstoneSimulator.cpp b/src/Simulator/RedstoneSimulator.cpp index 3e267525f..638b977d4 100644 --- a/src/Simulator/RedstoneSimulator.cpp +++ b/src/Simulator/RedstoneSimulator.cpp @@ -112,10 +112,35 @@ void cRedstoneSimulator::SimulateChunk(float a_Dt, int a_ChunkX, int a_ChunkZ, c LOGD("cRedstoneSimulator: Erased block %s from powered blocks list due to present/past metadata mismatch", ItemToFullString(itr->a_SourceBlock).c_str()); itr = m_PoweredBlocks.erase(itr); } + else if (SourceBlockType == E_BLOCK_DAYLIGHT_SENSOR) + { + if (!a_Chunk->IsLightValid()) + { + m_World.QueueLightChunk(a_ChunkX, a_ChunkZ); + itr++; + continue; + } + else + { + NIBBLETYPE SkyLight; + a_Chunk->UnboundedRelGetBlockSkyLight(RelX, itr->a_SourcePos.y + 1, RelZ, SkyLight); + + if (a_Chunk->GetTimeAlteredLight(SkyLight) <= 8) // Could use SkyLight - m_World.GetSkyDarkness(); + { + LOGD("cRedstoneSimulator: Erased daylight sensor from powered blocks list due to insufficient light level"); + itr = m_PoweredBlocks.erase(itr); + } + else + { + itr++; + continue; + } + } + } else if ((SourceBlockType == E_BLOCK_REDSTONE_WIRE) && (DestBlockType == E_BLOCK_REDSTONE_WIRE)) { // It is simply not allowed that a wire powers another wire, presuming that data here is sane and a dest and source are beside each other - LOGD("cRedstoneSimulator: Erased redstone wire from powered blocks list because it's source was also wire"); + LOGD("cRedstoneSimulator: Erased redstone wire from powered blocks list because its source was also wire"); itr = m_PoweredBlocks.erase(itr); } else @@ -283,7 +308,7 @@ void cRedstoneSimulator::SimulateChunk(float a_Dt, int a_ChunkX, int a_ChunkZ, c } } - ++dataitr; + dataitr++; } }