Updated chunk sending to 1.8
This commit is contained in:
parent
10a30a03e3
commit
38124bcce3
@ -182,25 +182,26 @@ void cChunkDataSerializer::Serialize80(AString & a_Data, int a_ChunkX, int a_Chu
|
||||
// TODO: Do not copy data and then compress it; rather, compress partial blocks of data (zlib *can* stream)
|
||||
|
||||
// Blocktypes converter (1.8 included the meta into the blocktype):
|
||||
/*unsigned short Blocks[ARRAYCOUNT(m_BlockTypes)];
|
||||
unsigned char Blocks[cChunkDef::NumBlocks * 2];
|
||||
size_t LastOffset = 0;
|
||||
for (size_t Index = 0; Index < cChunkDef::NumBlocks; Index++)
|
||||
{
|
||||
BLOCKTYPE BlockType = m_BlockTypes[Index];
|
||||
BLOCKTYPE BlockType = m_BlockTypes[Index] & 0xFF;
|
||||
NIBBLETYPE BlockMeta = m_BlockMetas[Index / 2] >> ((Index & 1) * 4) & 0x0f;
|
||||
Blocks[Index] = ((unsigned short)BlockType << 4) | ((unsigned short)BlockMeta);
|
||||
}*/
|
||||
Blocks[LastOffset] = (BlockType << 4) | ((unsigned char)BlockMeta);
|
||||
Blocks[LastOffset + 1] = (unsigned char)BlockType >> 4;
|
||||
LastOffset += 2;
|
||||
}
|
||||
|
||||
const int BiomeDataSize = cChunkDef::Width * cChunkDef::Width;
|
||||
const int MetadataOffset = sizeof(m_BlockTypes);
|
||||
const int BlockLightOffset = MetadataOffset + sizeof(m_BlockMetas);
|
||||
const int BlockLightOffset = sizeof(Blocks);
|
||||
const int SkyLightOffset = BlockLightOffset + sizeof(m_BlockLight);
|
||||
const int BiomeOffset = SkyLightOffset + sizeof(m_BlockSkyLight);
|
||||
const int DataSize = BiomeOffset + BiomeDataSize;
|
||||
|
||||
// Temporary buffer for the composed data:
|
||||
char AllData [DataSize];
|
||||
memcpy(AllData, m_BlockTypes, sizeof(m_BlockTypes));
|
||||
memcpy(AllData + MetadataOffset, m_BlockMetas, sizeof(m_BlockMetas));
|
||||
memcpy(AllData, Blocks, sizeof(Blocks));
|
||||
memcpy(AllData + BlockLightOffset, m_BlockLight, sizeof(m_BlockLight));
|
||||
memcpy(AllData + SkyLightOffset, m_BlockSkyLight, sizeof(m_BlockSkyLight));
|
||||
memcpy(AllData + BiomeOffset, m_BiomeData, BiomeDataSize);
|
||||
|
@ -1531,9 +1531,6 @@ void cProtocol172::AddReceivedData(const char * a_Data, size_t a_Size)
|
||||
VERIFY(m_ReceivedData.ReadToByteBuffer(bb, (int)PacketLen));
|
||||
m_ReceivedData.CommitRead();
|
||||
|
||||
// Write one NUL extra, so that we can detect over-reads
|
||||
bb.Write("\0", 1);
|
||||
|
||||
// 1.8 - Compressed packets
|
||||
if ((m_State == 3) && (GetProtocolVersion() == cProtocolRecognizer::PROTO_VERSION_1_8_0))
|
||||
{
|
||||
@ -1545,6 +1542,9 @@ void cProtocol172::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;
|
||||
if (!bb.ReadVarInt(PacketType))
|
||||
{
|
||||
|
@ -121,7 +121,7 @@ void cProtocol180::SendPlayerMoveLook(void)
|
||||
{
|
||||
ASSERT(m_State == 3); // In game mode?
|
||||
|
||||
/*cPacketizer Pkt(*this, 0x08); // Player Position And Look packet
|
||||
cPacketizer Pkt(*this, 0x08); // Player Position And Look packet
|
||||
cPlayer * Player = m_Client->GetPlayer();
|
||||
Pkt.WriteDouble(Player->GetPosX());
|
||||
|
||||
@ -131,7 +131,7 @@ void cProtocol180::SendPlayerMoveLook(void)
|
||||
Pkt.WriteDouble(Player->GetPosZ());
|
||||
Pkt.WriteFloat((float)Player->GetYaw());
|
||||
Pkt.WriteFloat((float)Player->GetPitch());
|
||||
Pkt.WriteByte(0);*/
|
||||
Pkt.WriteByte(0);
|
||||
}
|
||||
|
||||
|
||||
@ -168,12 +168,12 @@ void cProtocol180::SendEntityVelocity(const cEntity & a_Entity)
|
||||
{
|
||||
ASSERT(m_State == 3); // In game mode?
|
||||
|
||||
/*cPacketizer Pkt(*this, 0x12); // Entity Velocity packet
|
||||
cPacketizer Pkt(*this, 0x12); // Entity Velocity packet
|
||||
Pkt.WriteVarInt(a_Entity.GetUniqueID());
|
||||
// 400 = 8000 / 20 ... Conversion from our speed in m/s to 8000 m/tick
|
||||
Pkt.WriteShort((short)(a_Entity.GetSpeedX() * 400));
|
||||
Pkt.WriteShort((short)(a_Entity.GetSpeedY() * 400));
|
||||
Pkt.WriteShort((short)(a_Entity.GetSpeedZ() * 400));*/
|
||||
Pkt.WriteShort((short)(a_Entity.GetSpeedZ() * 400));
|
||||
}
|
||||
|
||||
|
||||
@ -395,9 +395,9 @@ void cProtocol180::SendPluginMessage(const AString & a_Channel, const AString &
|
||||
{
|
||||
ASSERT(m_State == 3); // In game mode?
|
||||
|
||||
/*cPacketizer Pkt(*this, 0x3f);
|
||||
cPacketizer Pkt(*this, 0x3f);
|
||||
Pkt.WriteString(a_Channel);
|
||||
Pkt.WriteBuf(a_Message.data(), a_Message.size());*/
|
||||
Pkt.WriteBuf(a_Message.data(), a_Message.size());
|
||||
}
|
||||
|
||||
|
||||
@ -672,10 +672,7 @@ void cProtocol180::HandlePacketPluginMessage(cByteBuffer & a_ByteBuffer)
|
||||
{
|
||||
HANDLE_READ(a_ByteBuffer, ReadVarUTF8String, AString, Channel);
|
||||
AString Data;
|
||||
if (!a_ByteBuffer.ReadString(Data, a_ByteBuffer.GetReadableSpace() - 1))
|
||||
{
|
||||
return;
|
||||
}
|
||||
a_ByteBuffer.ReadAll(Data);
|
||||
m_Client->HandlePluginMessage(Channel, Data);
|
||||
}
|
||||
|
||||
|
@ -56,8 +56,6 @@ public:
|
||||
|
||||
virtual void SendSoundParticleEffect (int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data) override;
|
||||
virtual void SendLoginSuccess (void) override;
|
||||
virtual void SendPlayerAbilities (void) override {}
|
||||
virtual void SendWindowClose (const cWindow & a_Window) override {}
|
||||
virtual void SendPickupSpawn (const cPickup & a_Pickup) override {}
|
||||
virtual void SendSpawnObject (const cEntity & a_Entity, char a_ObjectType, int a_ObjectData, Byte a_Yaw, Byte a_Pitch) override {}
|
||||
virtual void SendInventorySlot (char a_WindowID, short a_SlotNum, const cItem & a_Item) override {}
|
||||
|
Loading…
Reference in New Issue
Block a user