From bd9da4d83d86a1f4d83c6e3f8673ffba877144a4 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Sun, 15 Nov 2015 13:41:31 +1100 Subject: [PATCH] Workaround for when ExtInfo is received after ExtEntry packets. --- ClassicalSharp/Network/NetworkProcessor.CPE.cs | 11 +++++++++-- ClassicalSharp/Network/NetworkProcessor.Original.cs | 4 ++-- ClassicalSharp/Network/NetworkProcessor.cs | 2 +- ClassicalSharp/Utils/Utils.cs | 2 +- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/ClassicalSharp/Network/NetworkProcessor.CPE.cs b/ClassicalSharp/Network/NetworkProcessor.CPE.cs index 0f4a1dc1c..ca32dc75b 100644 --- a/ClassicalSharp/Network/NetworkProcessor.CPE.cs +++ b/ClassicalSharp/Network/NetworkProcessor.CPE.cs @@ -67,7 +67,11 @@ namespace ClassicalSharp { void HandleCpeExtInfo() { string appName = reader.ReadAsciiString(); game.Chat.Add( "Server identified itself as: " + appName ); - cpeServerExtensionsCount = reader.ReadInt16(); + + // Workaround for MCGalaxy that send ExtEntry sync but ExtInfoAsync. This means + // ExtEntry may sometimes arrive before ExtInfo, and thus we have to use += instead of = + cpeServerExtensionsCount += reader.ReadInt16(); + SendCpeExtInfoReply(); } void HandleCpeExtEntry() { @@ -92,7 +96,10 @@ namespace ClassicalSharp { ServerSupportsFullCP437 = true; } cpeServerExtensionsCount--; - + SendCpeExtInfoReply(); + } + + void SendCpeExtInfoReply() { if( cpeServerExtensionsCount == 0 ) { MakeExtInfo( Program.AppName, clientExtensions.Length ); SendPacket(); diff --git a/ClassicalSharp/Network/NetworkProcessor.Original.cs b/ClassicalSharp/Network/NetworkProcessor.Original.cs index 647c94ef5..872f70045 100644 --- a/ClassicalSharp/Network/NetworkProcessor.Original.cs +++ b/ClassicalSharp/Network/NetworkProcessor.Original.cs @@ -173,8 +173,8 @@ namespace ClassicalSharp { name = Utils.RemoveEndPlus( name ); AddEntity( entityId, name, name, true ); - // Some servers (such as LegendCraft) declare they support ExtPlayerList but - // don't send ExtAddPlayerName packets. So we add a special case here, even + // Workaround for LegendCraft as it declares it supports ExtPlayerList but + // doesn't send ExtAddPlayerName packets. So we add a special case here, even // though it is technically against the specification. if( UsingExtPlayerList ) { AddCpeInfo( entityId, name, name, "Players", 0 ); diff --git a/ClassicalSharp/Network/NetworkProcessor.cs b/ClassicalSharp/Network/NetworkProcessor.cs index ac995f309..15ad4d218 100644 --- a/ClassicalSharp/Network/NetworkProcessor.cs +++ b/ClassicalSharp/Network/NetworkProcessor.cs @@ -114,7 +114,7 @@ namespace ClassicalSharp { while( reader.size > 0 ) { byte opcode = reader.buffer[0]; - // Fix for older D3 servers which wrote one byte too many for HackControl packets. + // Workaround for older D3 servers which wrote one byte too many for HackControl packets. if( opcode == 0xFF && lastOpcode == PacketId.CpeHackControl ) { reader.Remove( 1 ); game.LocalPlayer.CalculateJumpVelocity( 1.4f ); // assume default jump height diff --git a/ClassicalSharp/Utils/Utils.cs b/ClassicalSharp/Utils/Utils.cs index d97e9640f..890986acc 100644 --- a/ClassicalSharp/Utils/Utils.cs +++ b/ClassicalSharp/Utils/Utils.cs @@ -68,7 +68,7 @@ namespace ClassicalSharp { /// Returns a string with a + removed if it is the last character in the string. public static string RemoveEndPlus( string value ) { - // Some servers (e.g. MCDzienny) use a '+' at the end to distinguish classicube.net accounts + // Workaround for MCDzienny (and others) use a '+' at the end to distinguish classicube.net accounts // from minecraft.net accounts. Unfortunately they also send this ending + to the client. if( String.IsNullOrEmpty( value ) ) return value;