From d12106ee97dcc3d414792f695c0644724ac80f87 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sat, 30 Nov 2013 13:41:40 +0000 Subject: Improved piston direction checking Now uses AddFaceDirection, as suggested by xoft. --- src/Simulator/RedstoneSimulator.cpp | 70 +++++-------------------------------- 1 file changed, 8 insertions(+), 62 deletions(-) (limited to 'src/Simulator') diff --git a/src/Simulator/RedstoneSimulator.cpp b/src/Simulator/RedstoneSimulator.cpp index c4da2db3a..b6e1566ef 100644 --- a/src/Simulator/RedstoneSimulator.cpp +++ b/src/Simulator/RedstoneSimulator.cpp @@ -854,38 +854,11 @@ bool cRedstoneSimulator::IsPistonPowered(int a_BlockX, int a_BlockY, int a_Block if (!Change.a_BlockPos.Equals(Vector3i(a_BlockX, a_BlockY, a_BlockZ))) { continue; } - switch (a_Meta) // Pistons' metas are the directions they face; the source cannot be there + AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_Meta); // Piston meta is based on what direction they face, so we can do this + + if (!Change.a_SourcePos.Equals(Vector3i(a_BlockX, a_BlockY, a_BlockZ))) { - case BLOCK_FACE_YM: - { - if (!Change.a_SourcePos.Equals(Vector3i(a_BlockX, a_BlockY - 1, a_BlockZ))) { return true; } - break; - } - case BLOCK_FACE_YP: - { - if (!Change.a_SourcePos.Equals(Vector3i(a_BlockX, a_BlockY + 1, a_BlockZ))) { return true; } - break; - } - case BLOCK_FACE_ZM: - { - if (!Change.a_SourcePos.Equals(Vector3i(a_BlockX, a_BlockY, a_BlockZ - 1))) { return true; } - break; - } - case BLOCK_FACE_ZP: - { - if (!Change.a_SourcePos.Equals(Vector3i(a_BlockX, a_BlockY, a_BlockZ + 1))) { return true; } - break; - } - case BLOCK_FACE_XM: - { - if (!Change.a_SourcePos.Equals(Vector3i(a_BlockX - 1, a_BlockY, a_BlockZ))) { return true; } - break; - } - case BLOCK_FACE_XP: - { - if (!Change.a_SourcePos.Equals(Vector3i(a_BlockX + 1, a_BlockY, a_BlockZ))) { return true; } - break; - } + return true; } } @@ -895,38 +868,11 @@ bool cRedstoneSimulator::IsPistonPowered(int a_BlockX, int a_BlockY, int a_Block if (!Change.a_BlockPos.Equals(Vector3i(a_BlockX, a_BlockY, a_BlockZ))) { continue; } - switch (a_Meta) + AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_Meta); + + if (!Change.a_MiddlePos.Equals(Vector3i(a_BlockX, a_BlockY, a_BlockZ))) { - case BLOCK_FACE_YM: - { - if (!Change.a_MiddlePos.Equals(Vector3i(a_BlockX, a_BlockY - 1, a_BlockZ))) { return true; } - break; - } - case BLOCK_FACE_YP: - { - if (!Change.a_MiddlePos.Equals(Vector3i(a_BlockX, a_BlockY + 1, a_BlockZ))) { return true; } - break; - } - case BLOCK_FACE_ZM: - { - if (!Change.a_MiddlePos.Equals(Vector3i(a_BlockX, a_BlockY, a_BlockZ - 1))) { return true; } - break; - } - case BLOCK_FACE_ZP: - { - if (!Change.a_MiddlePos.Equals(Vector3i(a_BlockX, a_BlockY, a_BlockZ + 1))) { return true; } - break; - } - case BLOCK_FACE_XM: - { - if (!Change.a_MiddlePos.Equals(Vector3i(a_BlockX - 1, a_BlockY, a_BlockZ))) { return true; } - break; - } - case BLOCK_FACE_XP: - { - if (!Change.a_MiddlePos.Equals(Vector3i(a_BlockX + 1, a_BlockY, a_BlockZ))) { return true; } - break; - } + return true; } } return false; // Source was in front of the piston's front face -- cgit v1.2.3