From 013da806ec20b62a742aded9a9d2b8131193f30d Mon Sep 17 00:00:00 2001 From: jfhumann Date: Fri, 18 Apr 2014 21:09:44 +0200 Subject: Did some static analysis, fixed some bugs and optimized a lot of code --- src/Protocol/Protocol16x.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'src/Protocol/Protocol16x.cpp') diff --git a/src/Protocol/Protocol16x.cpp b/src/Protocol/Protocol16x.cpp index 3da23a1dc..35bc8665d 100644 --- a/src/Protocol/Protocol16x.cpp +++ b/src/Protocol/Protocol16x.cpp @@ -131,9 +131,10 @@ void cProtocol161::SendHealth(void) { cCSLock Lock(m_CSPacket); WriteByte (PACKET_UPDATE_HEALTH); - WriteFloat((float)m_Client->GetPlayer()->GetHealth()); - WriteShort((short)m_Client->GetPlayer()->GetFoodLevel()); - WriteFloat((float)m_Client->GetPlayer()->GetFoodSaturationLevel()); + cPlayer * Player = m_Client->GetPlayer(); + WriteFloat((float)Player->GetHealth()); + WriteShort((short)Player->GetFoodLevel()); + WriteFloat((float)Player->GetFoodSaturationLevel()); Flush(); } @@ -144,11 +145,12 @@ void cProtocol161::SendHealth(void) void cProtocol161::SendPlayerMaxSpeed(void) { cCSLock Lock(m_CSPacket); + cPlayer * Player = m_Client->GetPlayer(); WriteByte(PACKET_ENTITY_PROPERTIES); - WriteInt(m_Client->GetPlayer()->GetUniqueID()); + WriteInt(Player->GetUniqueID()); WriteInt(1); WriteString("generic.movementSpeed"); - WriteDouble(0.1 * m_Client->GetPlayer()->GetMaxSpeed()); + WriteDouble(0.1 * Player->GetMaxSpeed()); Flush(); } @@ -276,11 +278,12 @@ cProtocol162::cProtocol162(cClientHandle * a_Client) : void cProtocol162::SendPlayerMaxSpeed(void) { cCSLock Lock(m_CSPacket); + cPlayer * Player = m_Client->GetPlayer(); WriteByte(PACKET_ENTITY_PROPERTIES); - WriteInt(m_Client->GetPlayer()->GetUniqueID()); + WriteInt(Player->GetUniqueID()); WriteInt(1); WriteString("generic.movementSpeed"); - WriteDouble(0.1 * m_Client->GetPlayer()->GetMaxSpeed()); + WriteDouble(0.1 * Player->GetMaxSpeed()); WriteShort(0); Flush(); } -- cgit v1.2.3 From 9f58046b5b6f5a0814461ad68d7612343dc3c2f5 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Mon, 21 Apr 2014 08:22:25 +0200 Subject: Allow 1.6.4 Forge clients to log in. Fixes #913. --- src/Protocol/Protocol16x.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/Protocol/Protocol16x.cpp') diff --git a/src/Protocol/Protocol16x.cpp b/src/Protocol/Protocol16x.cpp index 3da23a1dc..8d79213af 100644 --- a/src/Protocol/Protocol16x.cpp +++ b/src/Protocol/Protocol16x.cpp @@ -214,6 +214,25 @@ int cProtocol161::ParseEntityAction(void) +int cProtocol161::ParseLogin(void) +{ + // The login packet is sent by Forge clients only + // Only parse the packet, do no extra processing + // Note that the types and the names have been only guessed and are not verified at all! + HANDLE_PACKET_READ(ReadBEInt, int, Int1); + HANDLE_PACKET_READ(ReadBEUTF16String16, AString, String1); + HANDLE_PACKET_READ(ReadChar, char, Char1); + HANDLE_PACKET_READ(ReadChar, char, Char2); + HANDLE_PACKET_READ(ReadChar, char, Char3); + HANDLE_PACKET_READ(ReadByte, Byte, Byte1); + HANDLE_PACKET_READ(ReadByte, Byte, Byte2); + return PARSE_OK; +} + + + + + int cProtocol161::ParsePlayerAbilities(void) { HANDLE_PACKET_READ(ReadByte, Byte, Flags); -- cgit v1.2.3