Skip to content

Commit

Permalink
Ignore usertype field in handshake packet when protocol version is le…
Browse files Browse the repository at this point in the history
…ss than 7 (Thanks rdebath, addresses #643)
  • Loading branch information
UnknownShadow200 committed Oct 4, 2021
1 parent efd4333 commit 4bcb5e3
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions MCGalaxy/Player/Player.Login.cs
Expand Up @@ -52,18 +52,25 @@ public partial class Player : IDisposable
name = NetUtils.ReadString(buffer, offset + 2);
SkinName = name; DisplayName = name; truename = name;
if (Server.Config.ClassicubeAccountPlus) name += "+";

string mppass = NetUtils.ReadString(buffer, offset + 66);
OnPlayerStartConnectingEvent.Call(this, mppass);
if (cancelconnecting) { cancelconnecting = false; return size; }

hasCpe = buffer[offset + 130] == 0x42 && Server.Config.EnableCPE;
// usertype field has different meanings depending on protocol version
// Version 7 - 0x42 for CPE supporting client, should be 0 otherwise
// Version 6 - should be 0
// Version 5 - field does not exist
if (ProtocolVersion >= Server.VERSION_0030) {
hasCpe = buffer[offset + 130] == 0x42 && Server.Config.EnableCPE;
}

level = Server.mainLevel;
Loading = true;
if (Socket.Disconnected) return size;

UpdateFallbackTable();
if (hasCpe) { SendCpeExtensions(); }
if (hasCpe) { SendCpeExtensions(); }
else { CompleteLoginProcess(); }
return size;
}
Expand Down

0 comments on commit 4bcb5e3

Please sign in to comment.