diff options
Diffstat (limited to '')
-rw-r--r-- | src/Protocol/Protocol_1_9.cpp | 188 |
1 files changed, 22 insertions, 166 deletions
diff --git a/src/Protocol/Protocol_1_9.cpp b/src/Protocol/Protocol_1_9.cpp index e17832175..90e770134 100644 --- a/src/Protocol/Protocol_1_9.cpp +++ b/src/Protocol/Protocol_1_9.cpp @@ -581,6 +581,15 @@ UInt32 cProtocol_1_9_0::GetPacketID(cProtocol::ePacketType a_Packet) +cProtocol::Version cProtocol_1_9_0::GetProtocolVersion() +{ + return Version::Version_1_9_0; +} + + + + + bool cProtocol_1_9_0::HandlePacket(cByteBuffer & a_ByteBuffer, UInt32 a_PacketType) { switch (m_State) @@ -673,51 +682,6 @@ bool cProtocol_1_9_0::HandlePacket(cByteBuffer & a_ByteBuffer, UInt32 a_PacketTy -void cProtocol_1_9_0::HandlePacketStatusRequest(cByteBuffer & a_ByteBuffer) -{ - cServer * Server = cRoot::Get()->GetServer(); - AString ServerDescription = Server->GetDescription(); - auto NumPlayers = static_cast<signed>(Server->GetNumPlayers()); - auto MaxPlayers = static_cast<signed>(Server->GetMaxPlayers()); - AString Favicon = Server->GetFaviconData(); - cRoot::Get()->GetPluginManager()->CallHookServerPing(*m_Client, ServerDescription, NumPlayers, MaxPlayers, Favicon); - - // Version: - Json::Value Version; - Version["name"] = "Cuberite 1.9"; - Version["protocol"] = 107; - - // Players: - Json::Value Players; - Players["online"] = NumPlayers; - Players["max"] = MaxPlayers; - // TODO: Add "sample" - - // Description: - Json::Value Description; - Description["text"] = ServerDescription.c_str(); - - // Create the response: - Json::Value ResponseValue; - ResponseValue["version"] = Version; - ResponseValue["players"] = Players; - ResponseValue["description"] = Description; - m_Client->ForgeAugmentServerListPing(ResponseValue); - if (!Favicon.empty()) - { - ResponseValue["favicon"] = Printf("data:image/png;base64,%s", Favicon.c_str()); - } - - auto Response = JsonUtils::WriteFastString(ResponseValue); - - cPacketizer Pkt(*this, pktStatusResponse); - Pkt.WriteString(Response); -} - - - - - void cProtocol_1_9_0::HandlePacketAnimation(cByteBuffer & a_ByteBuffer) { HANDLE_READ(a_ByteBuffer, ReadVarInt, Int32, Hand); @@ -2251,45 +2215,9 @@ void cProtocol_1_9_1::SendLogin(const cPlayer & a_Player, const cWorld & a_World -void cProtocol_1_9_1::HandlePacketStatusRequest(cByteBuffer & a_ByteBuffer) +cProtocol::Version cProtocol_1_9_1::GetProtocolVersion() { - cServer * Server = cRoot::Get()->GetServer(); - AString ServerDescription = Server->GetDescription(); - auto NumPlayers = static_cast<signed>(Server->GetNumPlayers()); - auto MaxPlayers = static_cast<signed>(Server->GetMaxPlayers()); - AString Favicon = Server->GetFaviconData(); - cRoot::Get()->GetPluginManager()->CallHookServerPing(*m_Client, ServerDescription, NumPlayers, MaxPlayers, Favicon); - - // Version: - Json::Value Version; - Version["name"] = "Cuberite 1.9.1"; - Version["protocol"] = 108; - - // Players: - Json::Value Players; - Players["online"] = NumPlayers; - Players["max"] = MaxPlayers; - // TODO: Add "sample" - - // Description: - Json::Value Description; - Description["text"] = ServerDescription.c_str(); - - // Create the response: - Json::Value ResponseValue; - ResponseValue["version"] = Version; - ResponseValue["players"] = Players; - ResponseValue["description"] = Description; - m_Client->ForgeAugmentServerListPing(ResponseValue); - if (!Favicon.empty()) - { - ResponseValue["favicon"] = Printf("data:image/png;base64,%s", Favicon.c_str()); - } - - AString Response = JsonUtils::WriteFastString(ResponseValue); - - cPacketizer Pkt(*this, pktStatusResponse); - Pkt.WriteString(Response); + return Version::Version_1_9_1; } @@ -2308,45 +2236,9 @@ cProtocol_1_9_2::cProtocol_1_9_2(cClientHandle * a_Client, const AString & a_Ser -void cProtocol_1_9_2::HandlePacketStatusRequest(cByteBuffer & a_ByteBuffer) +cProtocol::Version cProtocol_1_9_2::GetProtocolVersion() { - cServer * Server = cRoot::Get()->GetServer(); - AString ServerDescription = Server->GetDescription(); - auto NumPlayers = static_cast<signed>(Server->GetNumPlayers()); - auto MaxPlayers = static_cast<signed>(Server->GetMaxPlayers()); - AString Favicon = Server->GetFaviconData(); - cRoot::Get()->GetPluginManager()->CallHookServerPing(*m_Client, ServerDescription, NumPlayers, MaxPlayers, Favicon); - - // Version: - Json::Value Version; - Version["name"] = "Cuberite 1.9.2"; - Version["protocol"] = 109; - - // Players: - Json::Value Players; - Players["online"] = NumPlayers; - Players["max"] = MaxPlayers; - // TODO: Add "sample" - - // Description: - Json::Value Description; - Description["text"] = ServerDescription.c_str(); - - // Create the response: - Json::Value ResponseValue; - ResponseValue["version"] = Version; - ResponseValue["players"] = Players; - ResponseValue["description"] = Description; - m_Client->ForgeAugmentServerListPing(ResponseValue); - if (!Favicon.empty()) - { - ResponseValue["favicon"] = Printf("data:image/png;base64,%s", Favicon.c_str()); - } - - AString Response = JsonUtils::WriteFastString(ResponseValue); - - cPacketizer Pkt(*this, pktStatusResponse); - Pkt.WriteString(Response); + return Version::Version_1_9_2; } @@ -2365,51 +2257,6 @@ cProtocol_1_9_4::cProtocol_1_9_4(cClientHandle * a_Client, const AString & a_Ser -void cProtocol_1_9_4::HandlePacketStatusRequest(cByteBuffer & a_ByteBuffer) -{ - cServer * Server = cRoot::Get()->GetServer(); - AString ServerDescription = Server->GetDescription(); - auto NumPlayers = static_cast<signed>(Server->GetNumPlayers()); - auto MaxPlayers = static_cast<signed>(Server->GetMaxPlayers()); - AString Favicon = Server->GetFaviconData(); - cRoot::Get()->GetPluginManager()->CallHookServerPing(*m_Client, ServerDescription, NumPlayers, MaxPlayers, Favicon); - - // Version: - Json::Value Version; - Version["name"] = "Cuberite 1.9.4"; - Version["protocol"] = 110; - - // Players: - Json::Value Players; - Players["online"] = NumPlayers; - Players["max"] = MaxPlayers; - // TODO: Add "sample" - - // Description: - Json::Value Description; - Description["text"] = ServerDescription.c_str(); - - // Create the response: - Json::Value ResponseValue; - ResponseValue["version"] = Version; - ResponseValue["players"] = Players; - ResponseValue["description"] = Description; - m_Client->ForgeAugmentServerListPing(ResponseValue); - if (!Favicon.empty()) - { - ResponseValue["favicon"] = Printf("data:image/png;base64,%s", Favicon.c_str()); - } - - AString Response = JsonUtils::WriteFastString(ResponseValue); - - cPacketizer Pkt(*this, pktStatusResponse); - Pkt.WriteString(Response); -} - - - - - void cProtocol_1_9_4::SendChunkData(int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer) { ASSERT(m_State == 3); // In game mode? @@ -2462,6 +2309,15 @@ void cProtocol_1_9_4::SendUpdateSign(int a_BlockX, int a_BlockY, int a_BlockZ, c +cProtocol::Version cProtocol_1_9_4::GetProtocolVersion() +{ + return Version::Version_1_9_4; +} + + + + + UInt32 cProtocol_1_9_4::GetPacketID(cProtocol::ePacketType a_Packet) { switch (a_Packet) |