1
0

Protocol 1.7: Fixed crashes and d/c with bad packets.

Fixes #332.
This commit is contained in:
madmaxoft 2013-11-10 22:55:42 +01:00
parent f0aab7c580
commit 480ff3789b

View File

@ -215,7 +215,7 @@ void cProtocol172::SendDestroyEntity(const cEntity & a_Entity)
void cProtocol172::SendDisconnect(const AString & a_Reason) void cProtocol172::SendDisconnect(const AString & a_Reason)
{ {
cPacketizer Pkt(*this, 0x40); cPacketizer Pkt(*this, 0x40);
Pkt.WriteString(a_Reason); Pkt.WriteString(EscapeString(a_Reason));
} }
@ -503,7 +503,7 @@ void cProtocol172::SendPlayerListItem(const cPlayer & a_Player, bool a_IsOnline)
cPacketizer Pkt(*this, 0x38); // Playerlist Item packet cPacketizer Pkt(*this, 0x38); // Playerlist Item packet
Pkt.WriteString(a_Player.GetName()); Pkt.WriteString(a_Player.GetName());
Pkt.WriteBool(a_IsOnline); Pkt.WriteBool(a_IsOnline);
Pkt.WriteShort(a_Player.GetClientHandle()->GetPing()); Pkt.WriteShort(a_IsOnline ? a_Player.GetClientHandle()->GetPing() : 0);
} }
@ -564,7 +564,7 @@ void cProtocol172::SendPlayerSpawn(const cPlayer & a_Player)
{ {
// Called to spawn another player for the client // Called to spawn another player for the client
cPacketizer Pkt(*this, 0x0c); // Spawn Player packet cPacketizer Pkt(*this, 0x0c); // Spawn Player packet
Pkt.WriteInt(a_Player.GetUniqueID()); Pkt.WriteVarInt(a_Player.GetUniqueID());
Pkt.WriteString(Printf("%d", a_Player.GetUniqueID())); // TODO: Proper UUID Pkt.WriteString(Printf("%d", a_Player.GetUniqueID())); // TODO: Proper UUID
Pkt.WriteString(a_Player.GetName()); Pkt.WriteString(a_Player.GetName());
Pkt.WriteFPInt(a_Player.GetPosX()); Pkt.WriteFPInt(a_Player.GetPosX());