summaryrefslogtreecommitdiffstats
path: root/src/Protocol/ProtocolRecognizer.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-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()
+ }
}