summaryrefslogtreecommitdiffstats
path: root/src/Simulator/IncrementalRedstoneSimulator.cpp
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@hotmail.co.uk>2014-06-04 14:14:38 +0200
committerTiger Wang <ziwei.tiger@hotmail.co.uk>2014-06-04 14:14:38 +0200
commit86e5273cd17be8b8f1ae8a9b0dc2d212cb9b2791 (patch)
tree1b5c702a9e9da9115e64c317bdad5aba3544d4a1 /src/Simulator/IncrementalRedstoneSimulator.cpp
parentImplemented bed homes (diff)
parentMerge pull request #1059 from mc-server/coverity_fixes (diff)
downloadcuberite-86e5273cd17be8b8f1ae8a9b0dc2d212cb9b2791.tar
cuberite-86e5273cd17be8b8f1ae8a9b0dc2d212cb9b2791.tar.gz
cuberite-86e5273cd17be8b8f1ae8a9b0dc2d212cb9b2791.tar.bz2
cuberite-86e5273cd17be8b8f1ae8a9b0dc2d212cb9b2791.tar.lz
cuberite-86e5273cd17be8b8f1ae8a9b0dc2d212cb9b2791.tar.xz
cuberite-86e5273cd17be8b8f1ae8a9b0dc2d212cb9b2791.tar.zst
cuberite-86e5273cd17be8b8f1ae8a9b0dc2d212cb9b2791.zip
Diffstat (limited to '')
-rw-r--r--src/Simulator/IncrementalRedstoneSimulator.cpp26
1 files changed, 10 insertions, 16 deletions
diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp
index 074063add..51a7c2886 100644
--- a/src/Simulator/IncrementalRedstoneSimulator.cpp
+++ b/src/Simulator/IncrementalRedstoneSimulator.cpp
@@ -11,7 +11,7 @@
#include "../Blocks/BlockDoor.h"
#include "../Blocks/BlockButton.h"
#include "../Blocks/BlockLever.h"
-#include "../Piston.h"
+#include "../Blocks/BlockPiston.h"
@@ -814,17 +814,16 @@ void cIncrementalRedstoneSimulator::HandleRedstoneRepeater(int a_RelBlockX, int
void cIncrementalRedstoneSimulator::HandlePiston(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ)
{
- cPiston Piston(&m_World);
int BlockX = (m_Chunk->GetPosX() * cChunkDef::Width) + a_RelBlockX;
int BlockZ = (m_Chunk->GetPosZ() * cChunkDef::Width) + a_RelBlockZ;
if (IsPistonPowered(a_RelBlockX, a_RelBlockY, a_RelBlockZ, m_Chunk->GetMeta(a_RelBlockX, a_RelBlockY, a_RelBlockZ) & 0x7)) // We only want the bottom three bits (4th controls extended-ness)
{
- Piston.ExtendPiston(BlockX, a_RelBlockY, BlockZ);
+ cBlockPistonHandler::ExtendPiston(BlockX, a_RelBlockY, BlockZ, &m_World);
}
else
{
- Piston.RetractPiston(BlockX, a_RelBlockY, BlockZ);
+ cBlockPistonHandler::RetractPiston(BlockX, a_RelBlockY, BlockZ, &m_World);
}
}
@@ -1490,41 +1489,36 @@ bool cIncrementalRedstoneSimulator::IsPistonPowered(int a_RelBlockX, int a_RelBl
{
// Pistons cannot be powered through their front face; this function verifies that a source meets this requirement
- int OldX = a_RelBlockX, OldY = a_RelBlockY, OldZ = a_RelBlockZ;
- eBlockFace Face = cPiston::MetaDataToDirection(a_Meta);
- int BlockX = (m_Chunk->GetPosX() * cChunkDef::Width) + a_RelBlockX;
- int BlockZ = (m_Chunk->GetPosZ() * cChunkDef::Width) + a_RelBlockZ;
+ eBlockFace Face = cBlockPistonHandler::MetaDataToDirection(a_Meta);
+ int BlockX = m_Chunk->GetPosX() * cChunkDef::Width + a_RelBlockX;
+ int BlockZ = m_Chunk->GetPosZ() * cChunkDef::Width + a_RelBlockZ;
for (PoweredBlocksList::const_iterator itr = m_PoweredBlocks->begin(); itr != m_PoweredBlocks->end(); ++itr)
{
if (!itr->a_BlockPos.Equals(Vector3i(BlockX, a_RelBlockY, BlockZ))) { continue; }
- AddFaceDirection(a_RelBlockX, a_RelBlockY, a_RelBlockZ, Face);
+ AddFaceDirection(BlockX, a_RelBlockY, BlockZ, Face);
if (!itr->a_SourcePos.Equals(Vector3i(BlockX, a_RelBlockY, BlockZ)))
{
return true;
}
- a_RelBlockX = OldX;
- a_RelBlockY = OldY;
- a_RelBlockZ = OldZ;
+ AddFaceDirection(BlockX, a_RelBlockY, BlockZ, Face, true);
}
for (LinkedBlocksList::const_iterator itr = m_LinkedPoweredBlocks->begin(); itr != m_LinkedPoweredBlocks->end(); ++itr)
{
if (!itr->a_BlockPos.Equals(Vector3i(BlockX, a_RelBlockY, BlockZ))) { continue; }
- AddFaceDirection(a_RelBlockX, a_RelBlockY, a_RelBlockZ, Face);
+ AddFaceDirection(BlockX, a_RelBlockY, BlockZ, Face);
if (!itr->a_MiddlePos.Equals(Vector3i(BlockX, a_RelBlockY, BlockZ)))
{
return true;
}
- a_RelBlockX = OldX;
- a_RelBlockY = OldY;
- a_RelBlockZ = OldZ;
+ AddFaceDirection(BlockX, a_RelBlockY, BlockZ, Face, true);
}
return false; // Source was in front of the piston's front face
}