MC 1.7: Skip potential extra data in tab-list items

See issue #84 for more info
This commit is contained in:
ORelio 2015-07-07 22:43:27 +02:00
parent f5a67090c2
commit a6a9814163

View file

@ -90,9 +90,11 @@ namespace MinecraftClient.Protocol.Handlers
handler.OnTextReceived(ChatParser.ParseText(readNextString()));
break;
case 0x38:
string name = readNextString();
int name_len = readNextVarInt();
string name = readNextString(name_len);
bool online = readNextBool();
short ping = readNextShort();
readData(size - getVarInt(id).Length - getVarInt(name.Length).Length - name_len - 3); //Skip extradata
Guid FakeUUID = new Guid(MD5.Create().ComputeHash(Encoding.UTF8.GetBytes(name)).Take(16).ToArray());
if (online)
{
@ -176,11 +178,13 @@ namespace MinecraftClient.Protocol.Handlers
/// <summary>
/// Read a string from the network
/// </summary>
/// <param name="length">String length</param>
/// <returns>The string</returns>
private string readNextString()
private string readNextString(int length = -1)
{
int length = readNextVarInt();
if (length < 0)
length = readNextVarInt();
if (length > 0)
{
byte[] cache = new byte[length];