summaryrefslogtreecommitdiffstats
path: root/src/Simulator
diff options
context:
space:
mode:
authorHowaner <franzi.moos@googlemail.com>2014-09-25 19:22:46 +0200
committerHowaner <franzi.moos@googlemail.com>2014-09-25 19:22:46 +0200
commitdd423a2467f39550d7f54ef8e22a1089793ea7d4 (patch)
treea13a8d59404456a9c28b4c6d93f68851d03ffbcb /src/Simulator
parentFixed wrong Surrounding size (diff)
parentRedstone: Fixed a crash with repeaters on a chunk border. (diff)
downloadcuberite-dd423a2467f39550d7f54ef8e22a1089793ea7d4.tar
cuberite-dd423a2467f39550d7f54ef8e22a1089793ea7d4.tar.gz
cuberite-dd423a2467f39550d7f54ef8e22a1089793ea7d4.tar.bz2
cuberite-dd423a2467f39550d7f54ef8e22a1089793ea7d4.tar.lz
cuberite-dd423a2467f39550d7f54ef8e22a1089793ea7d4.tar.xz
cuberite-dd423a2467f39550d7f54ef8e22a1089793ea7d4.tar.zst
cuberite-dd423a2467f39550d7f54ef8e22a1089793ea7d4.zip
Diffstat (limited to 'src/Simulator')
-rw-r--r--src/Simulator/IncrementalRedstoneSimulator.cpp35
1 files changed, 22 insertions, 13 deletions
diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp
index 7b3a2c2fa..8649a1841 100644
--- a/src/Simulator/IncrementalRedstoneSimulator.cpp
+++ b/src/Simulator/IncrementalRedstoneSimulator.cpp
@@ -1619,17 +1619,22 @@ bool cIncrementalRedstoneSimulator::IsRepeaterLocked(int a_RelBlockX, int a_RelB
{
// Check if eastern(right) neighbor is a powered on repeater who is facing us
BLOCKTYPE Block = 0;
- if (m_Chunk->UnboundedRelGetBlockType(a_RelBlockX + 1, a_RelBlockY, a_RelBlockZ, Block) && (Block == E_BLOCK_REDSTONE_REPEATER_ON)) // Is right neighbor a powered repeater?
+ NIBBLETYPE OtherRepeaterDir = 0;
+ if (m_Chunk->UnboundedRelGetBlock(a_RelBlockX + 1, a_RelBlockY, a_RelBlockZ, Block, OtherRepeaterDir) && (Block == E_BLOCK_REDSTONE_REPEATER_ON)) // Is right neighbor a powered repeater?
{
- NIBBLETYPE OtherRepeaterDir = m_Chunk->GetMeta(a_RelBlockX + 1, a_RelBlockY, a_RelBlockZ) & 0x3;
- if (OtherRepeaterDir == 0x3) { return true; } // If so, I am latched/locked
+ if ((OtherRepeaterDir & 0x03) == 0x03)
+ {
+ return true;
+ } // If so, I am latched/locked
}
// Check if western(left) neighbor is a powered on repeater who is facing us
- if (m_Chunk->UnboundedRelGetBlockType(a_RelBlockX - 1, a_RelBlockY, a_RelBlockZ, Block) && (Block == E_BLOCK_REDSTONE_REPEATER_ON))
+ if (m_Chunk->UnboundedRelGetBlock(a_RelBlockX - 1, a_RelBlockY, a_RelBlockZ, Block, OtherRepeaterDir) && (Block == E_BLOCK_REDSTONE_REPEATER_ON))
{
- NIBBLETYPE OtherRepeaterDir = m_Chunk->GetMeta(a_RelBlockX -1, a_RelBlockY, a_RelBlockZ) & 0x3;
- if (OtherRepeaterDir == 0x1) { return true; } // If so, I am latched/locked
+ if ((OtherRepeaterDir & 0x03) == 0x01)
+ {
+ return true;
+ } // If so, I am latched/locked
}
break;
@@ -1641,19 +1646,23 @@ bool cIncrementalRedstoneSimulator::IsRepeaterLocked(int a_RelBlockX, int a_RelB
{
// Check if southern(down) neighbor is a powered on repeater who is facing us
BLOCKTYPE Block = 0;
- if (m_Chunk->UnboundedRelGetBlockType(a_RelBlockX, a_RelBlockY, a_RelBlockZ + 1, Block) && (Block == E_BLOCK_REDSTONE_REPEATER_ON))
+ NIBBLETYPE OtherRepeaterDir = 0;
+ if (m_Chunk->UnboundedRelGetBlock(a_RelBlockX, a_RelBlockY, a_RelBlockZ + 1, Block, OtherRepeaterDir) && (Block == E_BLOCK_REDSTONE_REPEATER_ON))
{
- NIBBLETYPE OtherRepeaterDir = m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ + 1) & 0x3;
- if (OtherRepeaterDir == 0x0) { return true; } // If so, am latched/locked
+ if ((OtherRepeaterDir & 0x03) == 0x00)
+ {
+ return true;
+ } // If so, am latched/locked
}
// Check if northern(up) neighbor is a powered on repeater who is facing us
- if (m_Chunk->UnboundedRelGetBlockType(a_RelBlockX, a_RelBlockY, a_RelBlockZ - 1, Block) && (Block == E_BLOCK_REDSTONE_REPEATER_ON))
+ if (m_Chunk->UnboundedRelGetBlock(a_RelBlockX, a_RelBlockY, a_RelBlockZ - 1, Block, OtherRepeaterDir) && (Block == E_BLOCK_REDSTONE_REPEATER_ON))
{
- NIBBLETYPE OtherRepeaterDir = m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ - 1) & 0x3;
- if (OtherRepeaterDir == 0x2) { return true; } // If so, I am latched/locked
+ if ((OtherRepeaterDir & 0x03) == 0x02)
+ {
+ return true;
+ } // If so, I am latched/locked
}
-
break;
}
}