mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
Fix crash on empty player list updates
Player list updates on MC 1.8 handler did not take into account the amount of items in the list and were only processing the first item, including when there wasn't any item to process. Unfortunately some weird servers were sending useless empty tab-list updates, causing a crash. Should fix issue #78 and forum posts 1267, 1269, 1284. Thanks dbear20, link3321, gerik43, Darkaegis, k3ldon and Ryan6578 for their bug reports! :)
This commit is contained in:
parent
80b468b301
commit
840ac01dc5
1 changed files with 16 additions and 20 deletions
|
|
@ -146,19 +146,22 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
case 0x38: //Player List update
|
case 0x38: //Player List update
|
||||||
int action = readNextVarInt(ref packetData);
|
int action = readNextVarInt(ref packetData);
|
||||||
int numActions = readNextVarInt(ref packetData);
|
int numActions = readNextVarInt(ref packetData);
|
||||||
Guid uuid = readNextUUID(ref packetData);
|
for (int i = 0; i < numActions; i++)
|
||||||
switch (action)
|
|
||||||
{
|
{
|
||||||
case 0x00: //Player Join
|
Guid uuid = readNextUUID(ref packetData);
|
||||||
string name = readNextString(ref packetData);
|
switch (action)
|
||||||
handler.OnPlayerJoin(uuid, name);
|
{
|
||||||
break;
|
case 0x00: //Player Join
|
||||||
case 0x04: //Player Leave
|
string name = readNextString(ref packetData);
|
||||||
handler.OnPlayerLeave(uuid);
|
handler.OnPlayerJoin(uuid, name);
|
||||||
break;
|
break;
|
||||||
default:
|
case 0x04: //Player Leave
|
||||||
//Unknown player list item type
|
handler.OnPlayerLeave(uuid);
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
//Unknown player list item type
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 0x3A: //Tab-Complete Result
|
case 0x3A: //Tab-Complete Result
|
||||||
|
|
@ -282,14 +285,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
|
|
||||||
private Guid readNextUUID(ref byte[] cache)
|
private Guid readNextUUID(ref byte[] cache)
|
||||||
{
|
{
|
||||||
try
|
return new Guid(readData(16, ref cache));
|
||||||
{
|
|
||||||
return new Guid(readData(16, ref cache));
|
|
||||||
}
|
|
||||||
catch (ArgumentException)
|
|
||||||
{
|
|
||||||
return Guid.Empty;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue