From b1d4b3bb96629b3624e8328d7b1a0bce5333bb7d Mon Sep 17 00:00:00 2001 From: Mattes D Date: Sat, 21 Mar 2015 13:00:20 +0100 Subject: Unified cByteBuffer types. cByteBuffer now reads and writes any of the [U]Int types. --- src/Protocol/ChunkDataSerializer.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/Protocol/ChunkDataSerializer.cpp') diff --git a/src/Protocol/ChunkDataSerializer.cpp b/src/Protocol/ChunkDataSerializer.cpp index 5d080656d..e850ceaec 100644 --- a/src/Protocol/ChunkDataSerializer.cpp +++ b/src/Protocol/ChunkDataSerializer.cpp @@ -188,10 +188,10 @@ void cChunkDataSerializer::Serialize47(AString & a_Data, int a_ChunkX, int a_Chu // Create the packet: cByteBuffer Packet(512 KiB); Packet.WriteVarInt(0x21); // Packet id (Chunk Data packet) - Packet.WriteBEInt(a_ChunkX); - Packet.WriteBEInt(a_ChunkZ); - Packet.WriteBool(true); // "Ground-up continuous", or rather, "biome data present" flag - Packet.WriteBEUShort(0xffff); // We're aways sending the full chunk with no additional data, so the bitmap is 0xffff + Packet.WriteBEInt32(a_ChunkX); + Packet.WriteBEInt32(a_ChunkZ); + Packet.WriteBool(true); // "Ground-up continuous", or rather, "biome data present" flag + Packet.WriteBEUInt16(0xffff); // We're aways sending the full chunk with no additional data, so the bitmap is 0xffff // Write the chunk size: const int BiomeDataSize = cChunkDef::Width * cChunkDef::Width; @@ -208,8 +208,8 @@ void cChunkDataSerializer::Serialize47(AString & a_Data, int a_ChunkX, int a_Chu { BLOCKTYPE BlockType = m_BlockTypes[Index] & 0xFF; NIBBLETYPE BlockMeta = m_BlockMetas[Index / 2] >> ((Index & 1) * 4) & 0x0f; - Packet.WriteByte((unsigned char)(BlockType << 4) | BlockMeta); - Packet.WriteByte((unsigned char)(BlockType >> 4)); + Packet.WriteBEUInt8(static_cast(BlockType << 4) | BlockMeta); + Packet.WriteBEUInt8(static_cast(BlockType >> 4)); } // Write the rest: -- cgit v1.2.3 From b913c5da69f362abbb70de6e11baca4cbce2b919 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Sun, 22 Mar 2015 23:09:23 +0100 Subject: Added VarInt64, normalized cPacketizer datatype names. --- src/Protocol/ChunkDataSerializer.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/Protocol/ChunkDataSerializer.cpp') diff --git a/src/Protocol/ChunkDataSerializer.cpp b/src/Protocol/ChunkDataSerializer.cpp index e850ceaec..60fd5f935 100644 --- a/src/Protocol/ChunkDataSerializer.cpp +++ b/src/Protocol/ChunkDataSerializer.cpp @@ -187,7 +187,7 @@ void cChunkDataSerializer::Serialize47(AString & a_Data, int a_ChunkX, int a_Chu // Create the packet: cByteBuffer Packet(512 KiB); - Packet.WriteVarInt(0x21); // Packet id (Chunk Data packet) + Packet.WriteVarInt32(0x21); // Packet id (Chunk Data packet) Packet.WriteBEInt32(a_ChunkX); Packet.WriteBEInt32(a_ChunkZ); Packet.WriteBool(true); // "Ground-up continuous", or rather, "biome data present" flag @@ -201,7 +201,7 @@ void cChunkDataSerializer::Serialize47(AString & a_Data, int a_ChunkX, int a_Chu sizeof(m_BlockSkyLight) + // Block sky light BiomeDataSize // Biome data ); - Packet.WriteVarInt(ChunkSize); + Packet.WriteVarInt32(ChunkSize); // Write the block types to the packet: for (size_t Index = 0; Index < cChunkDef::NumBlocks; Index++) @@ -234,8 +234,8 @@ void cChunkDataSerializer::Serialize47(AString & a_Data, int a_ChunkX, int a_Chu else { AString PostData; - Buffer.WriteVarInt((UInt32)Packet.GetUsedSpace() + 1); - Buffer.WriteVarInt(0); + Buffer.WriteVarInt32(static_cast(Packet.GetUsedSpace() + 1)); + Buffer.WriteVarInt32(0); Buffer.ReadAll(PostData); Buffer.CommitRead(); -- cgit v1.2.3