Merge branch 'master' into Fixes
This commit is contained in:
commit
dd423a2467
@ -43,11 +43,17 @@ void cHangingEntity::SpawnOn(cClientHandle & a_ClientHandle)
|
|||||||
// The client uses different values for item frame directions and block faces. Our constants are for the block faces, so we convert them here to item frame faces
|
// The client uses different values for item frame directions and block faces. Our constants are for the block faces, so we convert them here to item frame faces
|
||||||
switch (m_BlockFace)
|
switch (m_BlockFace)
|
||||||
{
|
{
|
||||||
case BLOCK_FACE_ZP: break; // Initialised to zero
|
case BLOCK_FACE_ZP: Dir = 0; break;
|
||||||
case BLOCK_FACE_ZM: Dir = 2; break;
|
case BLOCK_FACE_ZM: Dir = 2; break;
|
||||||
case BLOCK_FACE_XM: Dir = 1; break;
|
case BLOCK_FACE_XM: Dir = 1; break;
|
||||||
case BLOCK_FACE_XP: Dir = 3; break;
|
case BLOCK_FACE_XP: Dir = 3; break;
|
||||||
default: ASSERT(!"Unhandled block face when trying to spawn item frame!"); return;
|
default:
|
||||||
|
{
|
||||||
|
LOGINFO("Invalid face (%d) in a cHangingEntity at {%d, %d, %d}, adjusting to BLOCK_FACE_XP.",
|
||||||
|
m_BlockFace, (int)GetPosX(), (int)GetPosY(), (int)GetPosZ()
|
||||||
|
);
|
||||||
|
Dir = 3;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((Dir == 0) || (Dir == 2)) // Probably a client bug, but two directions are flipped and contrary to the norm, so we do -180
|
if ((Dir == 0) || (Dir == 2)) // Probably a client bug, but two directions are flipped and contrary to the norm, so we do -180
|
||||||
|
@ -1519,9 +1519,6 @@ void cProtocol172::AddReceivedData(const char * a_Data, size_t a_Size)
|
|||||||
VERIFY(m_ReceivedData.ReadToByteBuffer(bb, (int)PacketLen));
|
VERIFY(m_ReceivedData.ReadToByteBuffer(bb, (int)PacketLen));
|
||||||
m_ReceivedData.CommitRead();
|
m_ReceivedData.CommitRead();
|
||||||
|
|
||||||
// Write one NUL extra, so that we can detect over-reads
|
|
||||||
bb.Write("\0", 1);
|
|
||||||
|
|
||||||
UInt32 PacketType;
|
UInt32 PacketType;
|
||||||
if (!bb.ReadVarInt(PacketType))
|
if (!bb.ReadVarInt(PacketType))
|
||||||
{
|
{
|
||||||
@ -1529,6 +1526,9 @@ void cProtocol172::AddReceivedData(const char * a_Data, size_t a_Size)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Write one NUL extra, so that we can detect over-reads
|
||||||
|
bb.Write("\0", 1);
|
||||||
|
|
||||||
// Log the packet info into the comm log file:
|
// Log the packet info into the comm log file:
|
||||||
if (g_ShouldLogCommIn)
|
if (g_ShouldLogCommIn)
|
||||||
{
|
{
|
||||||
@ -1536,7 +1536,7 @@ void cProtocol172::AddReceivedData(const char * a_Data, size_t a_Size)
|
|||||||
bb.ReadAll(PacketData);
|
bb.ReadAll(PacketData);
|
||||||
bb.ResetRead();
|
bb.ResetRead();
|
||||||
bb.ReadVarInt(PacketType);
|
bb.ReadVarInt(PacketType);
|
||||||
ASSERT(PacketData.size() > 0);
|
ASSERT(PacketData.size() > 0); // We have written an extra NUL, so there had to be at least one byte read
|
||||||
PacketData.resize(PacketData.size() - 1);
|
PacketData.resize(PacketData.size() - 1);
|
||||||
AString PacketDataHex;
|
AString PacketDataHex;
|
||||||
CreateHexDump(PacketDataHex, PacketData.data(), PacketData.size(), 16);
|
CreateHexDump(PacketDataHex, PacketData.data(), PacketData.size(), 16);
|
||||||
|
@ -1716,7 +1716,7 @@ void cProtocol180::AddReceivedData(const char * a_Data, size_t a_Size)
|
|||||||
m_ReceivedData.ResetRead();
|
m_ReceivedData.ResetRead();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
cByteBuffer bb(PacketLen);
|
cByteBuffer bb(PacketLen + 1);
|
||||||
VERIFY(m_ReceivedData.ReadToByteBuffer(bb, (int)PacketLen));
|
VERIFY(m_ReceivedData.ReadToByteBuffer(bb, (int)PacketLen));
|
||||||
m_ReceivedData.CommitRead();
|
m_ReceivedData.CommitRead();
|
||||||
|
|
||||||
@ -1731,9 +1731,6 @@ void cProtocol180::AddReceivedData(const char * a_Data, size_t a_Size)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write one NUL extra, so that we can detect over-reads
|
|
||||||
bb.Write("\0", 1);
|
|
||||||
|
|
||||||
UInt32 PacketType;
|
UInt32 PacketType;
|
||||||
if (!bb.ReadVarInt(PacketType))
|
if (!bb.ReadVarInt(PacketType))
|
||||||
{
|
{
|
||||||
@ -1741,6 +1738,9 @@ void cProtocol180::AddReceivedData(const char * a_Data, size_t a_Size)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Write one NUL extra, so that we can detect over-reads
|
||||||
|
bb.Write("\0", 1);
|
||||||
|
|
||||||
// Log the packet info into the comm log file:
|
// Log the packet info into the comm log file:
|
||||||
if (g_ShouldLogCommIn)
|
if (g_ShouldLogCommIn)
|
||||||
{
|
{
|
||||||
@ -1748,7 +1748,7 @@ void cProtocol180::AddReceivedData(const char * a_Data, size_t a_Size)
|
|||||||
bb.ReadAll(PacketData);
|
bb.ReadAll(PacketData);
|
||||||
bb.ResetRead();
|
bb.ResetRead();
|
||||||
bb.ReadVarInt(PacketType);
|
bb.ReadVarInt(PacketType);
|
||||||
ASSERT(PacketData.size() > 0);
|
ASSERT(PacketData.size() > 0); // We have written an extra NUL, so there had to be at least one byte read
|
||||||
PacketData.resize(PacketData.size() - 1);
|
PacketData.resize(PacketData.size() - 1);
|
||||||
AString PacketDataHex;
|
AString PacketDataHex;
|
||||||
CreateHexDump(PacketDataHex, PacketData.data(), PacketData.size(), 16);
|
CreateHexDump(PacketDataHex, PacketData.data(), PacketData.size(), 16);
|
||||||
@ -1782,7 +1782,8 @@ void cProtocol180::AddReceivedData(const char * a_Data, size_t a_Size)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bb.GetReadableSpace() != 0)
|
// The packet should have 1 byte left in the buffer - the NUL we had added
|
||||||
|
if (bb.GetReadableSpace() != 1)
|
||||||
{
|
{
|
||||||
// Read more or less than packet length, report as error
|
// Read more or less than packet length, report as error
|
||||||
LOGWARNING("Protocol 1.8: Wrong number of bytes read for packet 0x%x, state %d. Read " SIZE_T_FMT " bytes, packet contained %u bytes",
|
LOGWARNING("Protocol 1.8: Wrong number of bytes read for packet 0x%x, state %d. Read " SIZE_T_FMT " bytes, packet contained %u bytes",
|
||||||
|
@ -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
|
// Check if eastern(right) neighbor is a powered on repeater who is facing us
|
||||||
BLOCKTYPE Block = 0;
|
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 & 0x03) == 0x03)
|
||||||
if (OtherRepeaterDir == 0x3) { return true; } // If so, I am latched/locked
|
{
|
||||||
|
return true;
|
||||||
|
} // If so, I am latched/locked
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if western(left) neighbor is a powered on repeater who is facing us
|
// 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 & 0x03) == 0x01)
|
||||||
if (OtherRepeaterDir == 0x1) { return true; } // If so, I am latched/locked
|
{
|
||||||
|
return true;
|
||||||
|
} // If so, I am latched/locked
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
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
|
// Check if southern(down) neighbor is a powered on repeater who is facing us
|
||||||
BLOCKTYPE Block = 0;
|
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 & 0x03) == 0x00)
|
||||||
if (OtherRepeaterDir == 0x0) { return true; } // If so, am latched/locked
|
{
|
||||||
|
return true;
|
||||||
|
} // If so, am latched/locked
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if northern(up) neighbor is a powered on repeater who is facing us
|
// 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 & 0x03) == 0x02)
|
||||||
if (OtherRepeaterDir == 0x2) { return true; } // If so, I am latched/locked
|
{
|
||||||
|
return true;
|
||||||
|
} // If so, I am latched/locked
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user