Fixed another daylight sensor bug
Additionally fixed unpowering across chunks.
This commit is contained in:
parent
b2bf466122
commit
3ec8b33b76
@ -59,21 +59,20 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY,
|
||||
int RelZ = 0;
|
||||
BLOCKTYPE Block;
|
||||
NIBBLETYPE Meta;
|
||||
cChunk * Chunk;
|
||||
cChunk * OtherChunk = a_Chunk;
|
||||
|
||||
if (a_OtherChunk != NULL)
|
||||
{
|
||||
RelX = a_BlockX - a_OtherChunk->GetPosX() * cChunkDef::Width;
|
||||
RelZ = a_BlockZ - a_OtherChunk->GetPosZ() * cChunkDef::Width;
|
||||
a_OtherChunk->GetBlockTypeMeta(RelX, a_BlockY, RelZ, Block, Meta);
|
||||
Chunk = a_OtherChunk;
|
||||
OtherChunk = a_OtherChunk;
|
||||
}
|
||||
else
|
||||
{
|
||||
RelX = a_BlockX - a_Chunk->GetPosX() * cChunkDef::Width;
|
||||
RelZ = a_BlockZ - a_Chunk->GetPosZ() * cChunkDef::Width;
|
||||
a_Chunk->GetBlockTypeMeta(RelX, a_BlockY, RelZ, Block, Meta);
|
||||
Chunk = a_Chunk;
|
||||
}
|
||||
|
||||
// Every time a block is changed (AddBlock called), we want to go through all lists and check to see if the coordiantes stored within are still valid
|
||||
@ -92,7 +91,8 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY,
|
||||
{
|
||||
LOGD("cIncrementalRedstoneSimulator: Erased block @ {%i, %i, %i} from powered blocks list as it no longer connected to a source", itr->a_BlockPos.x, itr->a_BlockPos.y, itr->a_BlockPos.z);
|
||||
itr = PoweredBlocks->erase(itr);
|
||||
Chunk->SetIsRedstoneDirty(true);
|
||||
a_Chunk->SetIsRedstoneDirty(true);
|
||||
OtherChunk->SetIsRedstoneDirty(true);
|
||||
continue;
|
||||
}
|
||||
else if (
|
||||
@ -107,21 +107,23 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY,
|
||||
{
|
||||
LOGD("cIncrementalRedstoneSimulator: Erased block @ {%i, %i, %i} from powered blocks list due to present/past metadata mismatch", itr->a_BlockPos.x, itr->a_BlockPos.y, itr->a_BlockPos.z);
|
||||
itr = PoweredBlocks->erase(itr);
|
||||
Chunk->SetIsRedstoneDirty(true);
|
||||
a_Chunk->SetIsRedstoneDirty(true);
|
||||
OtherChunk->SetIsRedstoneDirty(true);
|
||||
continue;
|
||||
}
|
||||
else if (Block == E_BLOCK_DAYLIGHT_SENSOR)
|
||||
{
|
||||
if (!m_World.IsChunkLighted(Chunk->GetPosX(), Chunk->GetPosZ()))
|
||||
if (!m_World.IsChunkLighted(OtherChunk->GetPosX(), OtherChunk->GetPosZ()))
|
||||
{
|
||||
m_World.QueueLightChunk(Chunk->GetPosX(), Chunk->GetPosZ());
|
||||
m_World.QueueLightChunk(OtherChunk->GetPosX(), OtherChunk->GetPosZ());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Chunk->GetTimeAlteredLight(Chunk->GetSkyLight(RelX, a_BlockY + 1, RelZ)) <= 7)
|
||||
if (OtherChunk->GetTimeAlteredLight(OtherChunk->GetSkyLight(RelX, a_BlockY + 1, RelZ)) <= 7)
|
||||
{
|
||||
itr = PoweredBlocks->erase(itr);
|
||||
Chunk->SetIsRedstoneDirty(true);
|
||||
a_Chunk->SetIsRedstoneDirty(true);
|
||||
OtherChunk->SetIsRedstoneDirty(true);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@ -139,7 +141,8 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY,
|
||||
{
|
||||
LOGD("cIncrementalRedstoneSimulator: Erased block @ {%i, %i, %i} from linked powered blocks list as it is no longer connected to a source", itr->a_BlockPos.x, itr->a_BlockPos.y, itr->a_BlockPos.z);
|
||||
itr = LinkedPoweredBlocks->erase(itr);
|
||||
Chunk->SetIsRedstoneDirty(true);
|
||||
a_Chunk->SetIsRedstoneDirty(true);
|
||||
OtherChunk->SetIsRedstoneDirty(true);
|
||||
continue;
|
||||
}
|
||||
else if (
|
||||
@ -153,7 +156,8 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY,
|
||||
{
|
||||
LOGD("cIncrementalRedstoneSimulator: Erased block @ {%i, %i, %i} from linked powered blocks list due to present/past metadata mismatch", itr->a_BlockPos.x, itr->a_BlockPos.y, itr->a_BlockPos.z);
|
||||
itr = LinkedPoweredBlocks->erase(itr);
|
||||
Chunk->SetIsRedstoneDirty(true);
|
||||
a_Chunk->SetIsRedstoneDirty(true);
|
||||
OtherChunk->SetIsRedstoneDirty(true);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@ -163,7 +167,8 @@ void cIncrementalRedstoneSimulator::RedstoneAddBlock(int a_BlockX, int a_BlockY,
|
||||
{
|
||||
LOGD("cIncrementalRedstoneSimulator: Erased block @ {%i, %i, %i} from linked powered blocks list as it is no longer powered through a valid middle block", itr->a_BlockPos.x, itr->a_BlockPos.y, itr->a_BlockPos.z);
|
||||
itr = LinkedPoweredBlocks->erase(itr);
|
||||
Chunk->SetIsRedstoneDirty(true);
|
||||
a_Chunk->SetIsRedstoneDirty(true);
|
||||
OtherChunk->SetIsRedstoneDirty(true);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@ -1072,19 +1077,17 @@ void cIncrementalRedstoneSimulator::HandleNoteBlock(int a_RelBlockX, int a_RelBl
|
||||
|
||||
void cIncrementalRedstoneSimulator::HandleDaylightSensor(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ)
|
||||
{
|
||||
int a_ChunkX, a_ChunkZ;
|
||||
cChunkDef::BlockToChunk(a_RelBlockX, a_RelBlockZ, a_ChunkX, a_ChunkZ);
|
||||
int BlockX = (m_Chunk->GetPosX() * cChunkDef::Width) + a_RelBlockX, BlockZ = (m_Chunk->GetPosZ() * cChunkDef::Width) + a_RelBlockZ;
|
||||
int ChunkX, ChunkZ;
|
||||
cChunkDef::BlockToChunk(BlockX, BlockZ, ChunkX, ChunkZ);
|
||||
|
||||
if (!m_World.IsChunkLighted(a_ChunkX, a_ChunkZ))
|
||||
if (!m_World.IsChunkLighted(ChunkX, ChunkZ))
|
||||
{
|
||||
m_World.QueueLightChunk(a_ChunkX, a_ChunkZ);
|
||||
m_World.QueueLightChunk(ChunkX, ChunkZ);
|
||||
}
|
||||
else
|
||||
{
|
||||
int BlockX = (m_Chunk->GetPosX() * cChunkDef::Width) + a_RelBlockX;
|
||||
int BlockZ = (m_Chunk->GetPosZ() * cChunkDef::Width) + a_RelBlockZ;
|
||||
NIBBLETYPE SkyLight = m_Chunk->GetTimeAlteredLight(m_World.GetBlockSkyLight(BlockX, a_RelBlockY + 1, BlockZ));
|
||||
if (SkyLight > 8)
|
||||
if (m_Chunk->GetTimeAlteredLight(m_World.GetBlockSkyLight(BlockX, a_RelBlockY + 1, BlockZ)) > 8)
|
||||
{
|
||||
SetAllDirsAsPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user