From 5141d05ba676df9584831ffa9ff6e8ff8905887d Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sat, 18 Jul 2020 18:57:23 +0100 Subject: Delete duplicated status request handlers Here we go again... --- src/Protocol/Protocol_1_8.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'src/Protocol/Protocol_1_8.cpp') diff --git a/src/Protocol/Protocol_1_8.cpp b/src/Protocol/Protocol_1_8.cpp index a01fb0424..1c2792461 100644 --- a/src/Protocol/Protocol_1_8.cpp +++ b/src/Protocol/Protocol_1_8.cpp @@ -2159,6 +2159,15 @@ UInt32 cProtocol_1_8_0::GetPacketID(ePacketType a_PacketType) +cProtocol::Version cProtocol_1_8_0::GetProtocolVersion() +{ + return Version::Version_1_8_0; +} + + + + + bool cProtocol_1_8_0::HandlePacket(cByteBuffer & a_ByteBuffer, UInt32 a_PacketType) { switch (m_State) @@ -2270,8 +2279,9 @@ void cProtocol_1_8_0::HandlePacketStatusRequest(cByteBuffer & a_ByteBuffer) // Version: Json::Value Version; - Version["name"] = "Cuberite 1.8"; - Version["protocol"] = 47; + const auto ProtocolVersion = GetProtocolVersion(); + Version["name"] = "Cuberite " + cMultiVersionProtocol::GetVersionTextFromInt(ProtocolVersion); + Version["protocol"] = static_cast>(ProtocolVersion); // Players: Json::Value Players; @@ -2294,10 +2304,9 @@ void cProtocol_1_8_0::HandlePacketStatusRequest(cByteBuffer & a_ByteBuffer) ResponseValue["favicon"] = Printf("data:image/png;base64,%s", Favicon.c_str()); } - auto Response = JsonUtils::WriteFastString(ResponseValue); - + // Serialize the response into a packet: cPacketizer Pkt(*this, pktStatusResponse); - Pkt.WriteString(Response); + Pkt.WriteString(JsonUtils::WriteFastString(ResponseValue)); } -- cgit v1.2.3