Fix names not disappearing when using LegendCraft.

This commit is contained in:
UnknownShadow200 2015-11-01 10:16:27 +11:00
parent 1f8d4574d4
commit ddba1b1838

View File

@ -333,6 +333,7 @@ namespace ClassicalSharp {
game.UpdateBlock( x, y, z, type ); game.UpdateBlock( x, y, z, type );
} }
bool[] needRemoveNames;
void HandleAddEntity() { void HandleAddEntity() {
byte entityId = reader.ReadUInt8(); byte entityId = reader.ReadUInt8();
string name = reader.ReadAsciiString(); string name = reader.ReadAsciiString();
@ -342,8 +343,12 @@ namespace ClassicalSharp {
// Some servers (such as LegendCraft) declare they support ExtPlayerList but // Some servers (such as LegendCraft) declare they support ExtPlayerList but
// don't send ExtAddPlayerName packets. So we add a special case here, even // don't send ExtAddPlayerName packets. So we add a special case here, even
// though it is technically against the specification. // though it is technically against the specification.
if( UsingExtPlayerList ) if( UsingExtPlayerList ) {
AddCpeInfo( entityId, name, name, "Players", 0 ); AddCpeInfo( entityId, name, name, "Players", 0 );
if( needRemoveNames == null )
needRemoveNames = new bool[EntityList.MaxCount];
needRemoveNames[entityId] = true;
}
} }
void HandleEntityTeleport() { void HandleEntityTeleport() {
@ -390,6 +395,14 @@ namespace ClassicalSharp {
player.Despawn(); player.Despawn();
game.Players[entityId] = null; game.Players[entityId] = null;
} }
// See comment about LegendCraft in AddEntity
if( needRemoveNames != null &&
needRemoveNames[entityId] && player != null ) {
game.Events.RaiseCpeListInfoRemoved( entityId );
game.CpePlayersList[entityId] = null;
needRemoveNames[entityId] = false;
}
} }
void HandleMessage() { void HandleMessage() {