summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Harkness <bearbin@gmail.com>2014-04-07 18:12:06 +0200
committerAlexander Harkness <bearbin@gmail.com>2014-04-07 18:12:06 +0200
commit634c4d6770605323e2992e1b381682579d698f39 (patch)
tree96761d5c16c6d8f538395d97ff845dd6ec6cdb98
parentFix some of the comments in the PR tycho just did. (diff)
downloadcuberite-634c4d6770605323e2992e1b381682579d698f39.tar
cuberite-634c4d6770605323e2992e1b381682579d698f39.tar.gz
cuberite-634c4d6770605323e2992e1b381682579d698f39.tar.bz2
cuberite-634c4d6770605323e2992e1b381682579d698f39.tar.lz
cuberite-634c4d6770605323e2992e1b381682579d698f39.tar.xz
cuberite-634c4d6770605323e2992e1b381682579d698f39.tar.zst
cuberite-634c4d6770605323e2992e1b381682579d698f39.zip
-rw-r--r--src/Simulator/IncrementalRedstoneSimulator.cpp89
1 files changed, 40 insertions, 49 deletions
diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp
index 0c032eeab..cab3a714a 100644
--- a/src/Simulator/IncrementalRedstoneSimulator.cpp
+++ b/src/Simulator/IncrementalRedstoneSimulator.cpp
@@ -1223,57 +1223,48 @@ bool cIncrementalRedstoneSimulator::IsRepeaterPowered(int a_BlockX, int a_BlockY
bool cIncrementalRedstoneSimulator::IsRepeaterLocked(int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_Meta)
{
- // Repeaters can be locked by either of their sides
- for (PoweredBlocksList::const_iterator itr = m_PoweredBlocks->begin(); itr != m_PoweredBlocks->end(); ++itr)
- {
- if (!itr->a_BlockPos.Equals(Vector3i(a_BlockX, a_BlockY, a_BlockZ))) { continue; }
-
- switch (a_Meta)
- {
- // If N/S check E/W
- case 0x0:
- case 0x2:
- {
- if (itr->a_SourcePos.Equals(Vector3i(a_BlockX + 1, a_BlockY, a_BlockZ))) { return true; }
- if (itr->a_SourcePos.Equals(Vector3i(a_BlockX - 1, a_BlockY, a_BlockZ))) { return true; }
- break;
- }
- // If E/W check N/S
- case 0x1:
- case 0x3:
- {
- if (itr->a_SourcePos.Equals(Vector3i(a_BlockX, a_BlockY, a_BlockZ + 1))) { return true; }
- if (itr->a_SourcePos.Equals(Vector3i(a_BlockX, a_BlockY, a_BlockZ - 1))) { return true; }
- break;
- }
- }
+ // Change checking direction according to meta rotation.
+ switch (m_World.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ) & 0x3) //compare my direction to my neighbor's
+ {
+ // If N/S check E/W <<<<<
+
+ case 0x0:
+ case 0x2:
+ {
+ if (m_World.GetBlock(a_BlockX + 1, a_BlockY, a_BlockZ) == E_BLOCK_REDSTONE_REPEATER_ON) // Is right neighbor a
+ {
+ NIBBLETYPE otherRepeaterDir = m_World.GetBlockMeta(a_BlockX + 1, a_BlockY, a_BlockZ) & 0x3;
+ if (otherRepeaterDir == 0x1) { return true; }
+ }
+
+ if (m_World.GetBlock(a_BlockX - 1, a_BlockY, a_BlockZ) == E_BLOCK_REDSTONE_REPEATER_ON)
+ {
+ NIBBLETYPE otherRepeaterDir = m_World.GetBlockMeta(a_BlockX -1, a_BlockY, a_BlockZ) & 0x3;
+ if (otherRepeaterDir == 0x3) { return true; }
+ }
+
+ break;
+ }
+
+ // If E/W check N/S
+ case 0x1:
+ case 0x3:
+
+ if (m_World.GetBlock(a_BlockX, a_BlockY, a_BlockZ + 1) == E_BLOCK_REDSTONE_REPEATER_ON)
+ {
+ NIBBLETYPE otherRepeaterDir = m_World.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ + 1) & 0x3;
+ if (otherRepeaterDir == 0x0) { return true; }
+ }
+
+ if (m_World.GetBlock(a_BlockX, a_BlockY, a_BlockZ -1) == E_BLOCK_REDSTONE_REPEATER_ON)
+ {
+ NIBBLETYPE otherRepeaterDir = m_World.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ - 1) & 0x3;
+ if (otherRepeaterDir == 0x2) { return true; }
+ }
+ break;
}
- for (LinkedBlocksList::const_iterator itr = m_LinkedPoweredBlocks->begin(); itr != m_LinkedPoweredBlocks->end(); ++itr)
- {
- if (!itr->a_BlockPos.Equals(Vector3i(a_BlockX, a_BlockY, a_BlockZ))) { continue; }
-
- switch (a_Meta)
- {
- // If N/S check E/W
- case 0x0:
- case 0x2:
- {
- if (itr->a_MiddlePos.Equals(Vector3i(a_BlockX + 1, a_BlockY, a_BlockZ))) { return true; }
- if (itr->a_MiddlePos.Equals(Vector3i(a_BlockX - 1, a_BlockY, a_BlockZ))) { return true; }
- break;
- }
- // If E/W check N/S
- case 0x1:
- case 0x3:
- {
- if (itr->a_MiddlePos.Equals(Vector3i(a_BlockX, a_BlockY, a_BlockZ + 1))) { return true; }
- if (itr->a_MiddlePos.Equals(Vector3i(a_BlockX, a_BlockY, a_BlockZ - 1))) { return true; }
- break;
- }
- }
- }
- return false; // Repeater is not being powered from either side, therefore it is not locked.
+ return false;
}