summaryrefslogtreecommitdiffstats
path: root/src/Protocol/ProtocolRecognizer.cpp
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2019-09-09 18:22:37 +0200
committerMattes D <github@xoft.cz>2019-09-10 09:45:28 +0200
commit2c804dd34a58ff9702bd1ab2cab30f6a61503638 (patch)
tree16b3052c65f65231898205d670c52660f79b661f /src/Protocol/ProtocolRecognizer.cpp
parentChunkGenerator: Changed to use cChunkCoords. (diff)
downloadcuberite-2c804dd34a58ff9702bd1ab2cab30f6a61503638.tar
cuberite-2c804dd34a58ff9702bd1ab2cab30f6a61503638.tar.gz
cuberite-2c804dd34a58ff9702bd1ab2cab30f6a61503638.tar.bz2
cuberite-2c804dd34a58ff9702bd1ab2cab30f6a61503638.tar.lz
cuberite-2c804dd34a58ff9702bd1ab2cab30f6a61503638.tar.xz
cuberite-2c804dd34a58ff9702bd1ab2cab30f6a61503638.tar.zst
cuberite-2c804dd34a58ff9702bd1ab2cab30f6a61503638.zip
Diffstat (limited to 'src/Protocol/ProtocolRecognizer.cpp')
-rw-r--r--src/Protocol/ProtocolRecognizer.cpp25
1 files changed, 22 insertions, 3 deletions
diff --git a/src/Protocol/ProtocolRecognizer.cpp b/src/Protocol/ProtocolRecognizer.cpp
index a8d8b4cf5..9bfa0f105 100644
--- a/src/Protocol/ProtocolRecognizer.cpp
+++ b/src/Protocol/ProtocolRecognizer.cpp
@@ -281,7 +281,7 @@ void cProtocolRecognizer::SendDisconnect(const AString & a_Reason)
else
{
AString Message = Printf("{\"text\":\"%s\"}", EscapeString(a_Reason).c_str());
- cPacketizer Pkt(*this, 0x00); // Disconnect packet (in login state)
+ cPacketizer Pkt(*this, pktDisconnectDuringLogin);
Pkt.WriteString(Message);
}
}
@@ -1196,6 +1196,25 @@ void cProtocolRecognizer::SendPacket(cPacketizer & a_Pkt)
+UInt32 cProtocolRecognizer::GetPacketID(ePacketType a_PacketType)
+{
+ switch (a_PacketType)
+ {
+ case pktDisconnectDuringLogin: return 0x00;
+ case pktStatusResponse: return 0x00;
+ case pktPingResponse: return 0x01;
+ default:
+ {
+ ASSERT(!"cProtocolRecognizer::GetPacketID() called for an unhandled packet");
+ return 0;
+ }
+ }
+}
+
+
+
+
+
void cProtocolRecognizer::HandlePacketStatusRequest(void)
{
cServer * Server = cRoot::Get()->GetServer();
@@ -1233,7 +1252,7 @@ void cProtocolRecognizer::HandlePacketStatusRequest(void)
Json::FastWriter Writer;
AString Response = Writer.write(ResponseValue);
- cPacketizer Pkt(*this, 0x00); // Response packet
+ cPacketizer Pkt(*this, pktStatusResponse);
Pkt.WriteString(Response);
}
@@ -1249,6 +1268,6 @@ void cProtocolRecognizer::HandlePacketStatusPing()
return;
}
- cPacketizer Pkt(*this, 0x01); // Pong packet
+ cPacketizer Pkt(*this, pktPingResponse);
Pkt.WriteBEInt64(Timestamp);
}