1
0

Added handshake processing to protocol 1.7.

This fixes #495
This commit is contained in:
madmaxoft
2014-01-13 20:32:15 +01:00
parent 9af16c3f28
commit ada54b79d7
2 changed files with 29 additions and 2 deletions

View File

@@ -216,8 +216,23 @@ void cProtocol172::SendDestroyEntity(const cEntity & a_Entity)
void cProtocol172::SendDisconnect(const AString & a_Reason)
{
cPacketizer Pkt(*this, 0x40);
Pkt.WriteString(Printf("{\"text\":\"%s\"}", EscapeString(a_Reason).c_str()));
switch (m_State)
{
case 2:
{
// During login:
cPacketizer Pkt(*this, 0);
Pkt.WriteString(Printf("{\"text\":\"%s\"}", EscapeString(a_Reason).c_str()));
break;
}
case 3:
{
// In-game:
cPacketizer Pkt(*this, 0x40);
Pkt.WriteString(Printf("{\"text\":\"%s\"}", EscapeString(a_Reason).c_str()));
break;
}
}
}
@@ -1156,6 +1171,12 @@ void cProtocol172::HandlePacketLoginStart(cByteBuffer & a_ByteBuffer)
// TODO: Protocol encryption should be set up here if not localhost / auth
if (!m_Client->HandleHandshake(Username))
{
// The client is not welcome here, they have been sent a Kick packet already
return;
}
// Send login success:
{
cPacketizer Pkt(*this, 0x02); // Login success packet