summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@hotmail.co.uk>2013-12-14 03:40:54 +0100
committerTiger Wang <ziwei.tiger@hotmail.co.uk>2013-12-14 03:40:54 +0100
commit0aeece7fdaccc8f20e96f9560c4f4c1b5a6bc5cc (patch)
tree44d1bcade3ba52a46423d7e04c094e6ec8255ad5 /src
parentGroups.ini and Users.ini are now generated (diff)
downloadcuberite-0aeece7fdaccc8f20e96f9560c4f4c1b5a6bc5cc.tar
cuberite-0aeece7fdaccc8f20e96f9560c4f4c1b5a6bc5cc.tar.gz
cuberite-0aeece7fdaccc8f20e96f9560c4f4c1b5a6bc5cc.tar.bz2
cuberite-0aeece7fdaccc8f20e96f9560c4f4c1b5a6bc5cc.tar.lz
cuberite-0aeece7fdaccc8f20e96f9560c4f4c1b5a6bc5cc.tar.xz
cuberite-0aeece7fdaccc8f20e96f9560c4f4c1b5a6bc5cc.tar.zst
cuberite-0aeece7fdaccc8f20e96f9560c4f4c1b5a6bc5cc.zip
Diffstat (limited to 'src')
-rw-r--r--src/Entities/Player.cpp2
-rw-r--r--src/Simulator/RedstoneSimulator.cpp50
-rw-r--r--src/Simulator/RedstoneSimulator.h6
3 files changed, 37 insertions, 21 deletions
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index ff519f890..34caa340b 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -1415,7 +1415,7 @@ bool cPlayer::LoadFromDisk()
LOGINFO("Player %s has permissions:", m_PlayerName.c_str() );
for( PermissionMap::iterator itr = m_ResolvedPermissions.begin(); itr != m_ResolvedPermissions.end(); ++itr )
{
- if( itr->second ) LOGINFO("%s", itr->first.c_str() );
+ if( itr->second ) LOG(" %s", itr->first.c_str() );
}
AString SourceFile;
diff --git a/src/Simulator/RedstoneSimulator.cpp b/src/Simulator/RedstoneSimulator.cpp
index fb65a5af1..1eac48cf1 100644
--- a/src/Simulator/RedstoneSimulator.cpp
+++ b/src/Simulator/RedstoneSimulator.cpp
@@ -276,7 +276,7 @@ void cRedstoneSimulator::HandleRedstoneTorch(int a_BlockX, int a_BlockY, int a_B
int X = a_BlockX; int Y = a_BlockY; int Z = a_BlockZ;
AddFaceDirection(X, Y, Z, cBlockTorchHandler::MetaDataToDirection(m_World.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ)), true); // Inverse true to get the block torch is on
- if (AreCoordsPowered(X, Y, Z))
+ if (AreCoordsDirectlyPowered(X, Y, Z))
{
// There was a match, torch goes off
m_World.SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_REDSTONE_TORCH_OFF, m_World.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ));
@@ -323,7 +323,7 @@ void cRedstoneSimulator::HandleRedstoneTorch(int a_BlockX, int a_BlockY, int a_B
AddFaceDirection(X, Y, Z, cBlockTorchHandler::MetaDataToDirection(m_World.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ)), true); // Inverse true to get the block torch is on
// See if off state torch can be turned on again
- if (AreCoordsPowered(X, Y, Z))
+ if (AreCoordsDirectlyPowered(X, Y, Z))
{
return; // Something matches, torch still powered
}
@@ -410,7 +410,6 @@ void cRedstoneSimulator::HandleRedstoneWire(int a_BlockX, int a_BlockY, int a_Bl
if (AreCoordsPowered(a_BlockX, a_BlockY, a_BlockZ))
{
m_World.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, 15); // Maximum power
- SetBlockPowered(a_BlockX, a_BlockY - 1, a_BlockZ, a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_REDSTONE_WIRE); // Power block beneath
}
else
{
@@ -458,10 +457,12 @@ void cRedstoneSimulator::HandleRedstoneWire(int a_BlockX, int a_BlockY, int a_Bl
{
m_World.SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, MetaToSet);
}
-
- SetBlockPowered(a_BlockX, a_BlockY - 1, a_BlockZ, a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_REDSTONE_WIRE); // Power block beneath
}
+ // Wire still powered, power blocks beneath
+ SetBlockPowered(a_BlockX, a_BlockY - 1, a_BlockZ, a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_REDSTONE_WIRE);
+ SetDirectionLinkedPowered(a_BlockX, a_BlockY, a_BlockZ, BLOCK_FACE_YM, E_BLOCK_REDSTONE_WIRE);
+
if (m_World.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ) != 0) // A powered wire
{
switch (GetWireDirection(a_BlockX, a_BlockY, a_BlockZ))
@@ -820,7 +821,7 @@ void cRedstoneSimulator::HandleTrapdoor(int a_BlockX, int a_BlockY, int a_BlockZ
-bool cRedstoneSimulator::AreCoordsPowered(int a_BlockX, int a_BlockY, int a_BlockZ)
+bool cRedstoneSimulator::AreCoordsDirectlyPowered(int a_BlockX, int a_BlockY, int a_BlockZ)
{
for (PoweredBlocksList::const_iterator itr = m_PoweredBlocks.begin(); itr != m_PoweredBlocks.end(); ++itr) // Check powered list
{
@@ -829,7 +830,15 @@ bool cRedstoneSimulator::AreCoordsPowered(int a_BlockX, int a_BlockY, int a_Bloc
return true;
}
}
+ return false;
+}
+
+
+
+
+bool cRedstoneSimulator::AreCoordsLinkedPowered(int a_BlockX, int a_BlockY, int a_BlockZ)
+{
for (LinkedBlocksList::const_iterator itr = m_LinkedPoweredBlocks.begin(); itr != m_LinkedPoweredBlocks.end(); ++itr) // Check linked powered list
{
if (itr->a_BlockPos.Equals(Vector3i(a_BlockX, a_BlockY, a_BlockZ)))
@@ -1174,24 +1183,27 @@ void cRedstoneSimulator::SetBlockLinkedPowered(
void cRedstoneSimulator::SetPlayerToggleableBlockAsSimulated(int a_BlockX, int a_BlockY, int a_BlockZ, bool WasLastStatePowered)
{
- for (SimulatedPlayerToggleableList::const_iterator itr = m_SimulatedPlayerToggleableBlocks.begin(); itr != m_SimulatedPlayerToggleableBlocks.end(); ++itr)
+ for (SimulatedPlayerToggleableList::iterator itr = m_SimulatedPlayerToggleableBlocks.begin(); itr != m_SimulatedPlayerToggleableBlocks.end(); ++itr)
{
- if (itr->a_BlockPos.Equals(Vector3i(a_BlockX, a_BlockY, a_BlockZ)))
+ if (!itr->a_BlockPos.Equals(Vector3i(a_BlockX, a_BlockY, a_BlockZ)))
{
- if (itr->WasLastStatePowered != WasLastStatePowered)
- {
- // If power states different, erase the old listing in preparation to add new one
- m_SimulatedPlayerToggleableBlocks.erase(itr);
- break;
- }
- else
- {
- // If states the same, just ignore
- return;
- }
+ continue;
+ }
+
+ if (itr->WasLastStatePowered != WasLastStatePowered)
+ {
+ // If power states different, update listing
+ itr->WasLastStatePowered = WasLastStatePowered;
+ return;
+ }
+ else
+ {
+ // If states the same, just ignore
+ return;
}
}
+ // We have arrive here; no block must be in list - add one
sSimulatedPlayerToggleableList RC;
RC.a_BlockPos = Vector3i(a_BlockX, a_BlockY, a_BlockZ);
RC.WasLastStatePowered = WasLastStatePowered;
diff --git a/src/Simulator/RedstoneSimulator.h b/src/Simulator/RedstoneSimulator.h
index 7c1fd62e8..23ac510fc 100644
--- a/src/Simulator/RedstoneSimulator.h
+++ b/src/Simulator/RedstoneSimulator.h
@@ -127,7 +127,11 @@ private:
void SetAllDirsAsPowered(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_SourceBlock);
/// <summary>Returns if a coordinate is powered or linked powered</summary>
- bool AreCoordsPowered(int a_BlockX, int a_BlockY, int a_BlockZ);
+ bool AreCoordsPowered(int a_BlockX, int a_BlockY, int a_BlockZ) { return AreCoordsDirectlyPowered(a_BlockX, a_BlockY, a_BlockZ) || AreCoordsLinkedPowered(a_BlockX, a_BlockY, a_BlockZ); }
+ /// <summary>Returns if a coordinate is in the directly powered blocks list</summary>
+ bool AreCoordsDirectlyPowered(int a_BlockX, int a_BlockY, int a_BlockZ);
+ /// <summary>Returns if a coordinate is in the indirectly powered blocks list</summary>
+ bool AreCoordsLinkedPowered(int a_BlockX, int a_BlockY, int a_BlockZ);
/// <summary>Returns if a coordinate was marked as simulated (for blocks toggleable by players)</summary>
bool AreCoordsSimulated(int a_BlockX, int a_BlockY, int a_BlockZ, bool IsCurrentStatePowered);
/// <summary>Returns if a repeater is powered</summary>