From d12d7b671523f79f760403f3f4c0ef4efb497c79 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 14 Apr 2014 22:52:59 +0200 Subject: Implemented the 1.7.6 protocol and authenticator. Server works both in online and offline modes with 1.7.9. --- src/Protocol/Protocol17x.cpp | 62 ++++++++++++++++++++++++++++---------------- 1 file changed, 40 insertions(+), 22 deletions(-) (limited to 'src/Protocol/Protocol17x.cpp') diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp index b44c9f919..c8105c03a 100644 --- a/src/Protocol/Protocol17x.cpp +++ b/src/Protocol/Protocol17x.cpp @@ -574,6 +574,21 @@ void cProtocol172::SendLogin(const cPlayer & a_Player, const cWorld & a_World) +void cProtocol172::SendLoginSuccess(void) +{ + ASSERT(m_State == 2); // State: login? + + cPacketizer Pkt(*this, 0x02); // Login success packet + Pkt.WriteString(m_Client->GetUUID()); + Pkt.WriteString(m_Client->GetUsername()); + + m_State = 3; // State = Game +} + + + + + void cProtocol172::SendPaintingSpawn(const cPainting & a_Painting) { cPacketizer Pkt(*this, 0x10); // Spawn Painting packet @@ -1556,18 +1571,7 @@ void cProtocol172::HandlePacketLoginEncryptionResponse(cByteBuffer & a_ByteBuffe } StartEncryption(DecryptedKey); - - /* - // Send login success: - { - cPacketizer Pkt(*this, 0x02); // Login success packet - Pkt.WriteString(m_Client->GetUUID()); - Pkt.WriteString(m_Client->GetUsername()); - } - - m_State = 3; // State = Game m_Client->HandleLogin(4, m_Client->GetUsername()); - */ } @@ -1599,17 +1603,6 @@ void cProtocol172::HandlePacketLoginStart(cByteBuffer & a_ByteBuffer) return; } - // Generate an offline UUID for the player: - m_Client->GenerateOfflineUUID(); - - // Send login success: - { - cPacketizer Pkt(*this, 0x02); // Login success packet - Pkt.WriteString(m_Client->GetUUID()); - Pkt.WriteString(Username); - } - - m_State = 3; // State = Game m_Client->HandleLogin(4, Username); } @@ -2797,3 +2790,28 @@ void cProtocol176::SendPlayerSpawn(const cPlayer & a_Player) + +void cProtocol176::HandlePacketStatusRequest(cByteBuffer & a_ByteBuffer) +{ + // Send the response: + AString Response = "{\"version\":{\"name\":\"1.7.6\",\"protocol\":5},\"players\":{"; + AppendPrintf(Response, "\"max\":%u,\"online\":%u,\"sample\":[]},", + cRoot::Get()->GetServer()->GetMaxPlayers(), + cRoot::Get()->GetServer()->GetNumPlayers() + ); + AppendPrintf(Response, "\"description\":{\"text\":\"%s\"},", + cRoot::Get()->GetServer()->GetDescription().c_str() + ); + AppendPrintf(Response, "\"favicon\":\"data:image/png;base64,%s\"", + cRoot::Get()->GetServer()->GetFaviconData().c_str() + ); + Response.append("}"); + + cPacketizer Pkt(*this, 0x00); // Response packet + Pkt.WriteString(Response); +} + + + + + -- cgit v1.2.3