summaryrefslogtreecommitdiffstats
path: root/src/Protocol
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@hotmail.co.uk>2014-09-27 23:13:37 +0200
committerTiger Wang <ziwei.tiger@hotmail.co.uk>2014-09-27 23:13:37 +0200
commit1f8ee70d55d0d076583e14329ca09377c41b12e0 (patch)
treeb9d021314c75e76c24895f3c2cc2b27744a9c900 /src/Protocol
parentMerge remote-tracking branch 'origin/master' into endofsupport (diff)
downloadcuberite-1f8ee70d55d0d076583e14329ca09377c41b12e0.tar
cuberite-1f8ee70d55d0d076583e14329ca09377c41b12e0.tar.gz
cuberite-1f8ee70d55d0d076583e14329ca09377c41b12e0.tar.bz2
cuberite-1f8ee70d55d0d076583e14329ca09377c41b12e0.tar.lz
cuberite-1f8ee70d55d0d076583e14329ca09377c41b12e0.tar.xz
cuberite-1f8ee70d55d0d076583e14329ca09377c41b12e0.tar.zst
cuberite-1f8ee70d55d0d076583e14329ca09377c41b12e0.zip
Diffstat (limited to 'src/Protocol')
-rw-r--r--src/Protocol/ProtocolRecognizer.cpp17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/Protocol/ProtocolRecognizer.cpp b/src/Protocol/ProtocolRecognizer.cpp
index bfa5334d5..93d7cf0aa 100644
--- a/src/Protocol/ProtocolRecognizer.cpp
+++ b/src/Protocol/ProtocolRecognizer.cpp
@@ -190,8 +190,21 @@ void cProtocolRecognizer::SendDestroyEntity(const cEntity & a_Entity)
void cProtocolRecognizer::SendDisconnect(const AString & a_Reason)
{
- ASSERT(m_Protocol != NULL);
- m_Protocol->SendDisconnect(a_Reason);
+ if (m_Protocol != NULL)
+ {
+ m_Protocol->SendDisconnect(a_Reason);
+ }
+ else
+ {
+ // This is used when the client sends a server-ping, respond with the default packet:
+ static const int Packet = 0xff; // PACKET_DISCONNECT
+ SendData((const char *)&Packet, 1); // WriteByte()
+
+ AString & UTF16 = UTF8ToRawBEUTF16(a_Reason.c_str(), a_Reason.length());
+ static const short Size = htons((short)(UTF16.size() / 2));
+ SendData((const char *)&Size, 2); // WriteShort()
+ SendData(UTF16.data(), UTF16.size()); // WriteString()
+ }
}