fix: Fixes edge cases with the network packet loop (#1959)

This commit is contained in:
Kamron Batman 2024-09-19 18:25:30 -07:00 committed by GitHub
parent e0fcde885c
commit 2a7aa1905b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 6 deletions

View file

@ -591,7 +591,7 @@ public partial class NetState : IComparable<NetState>, IValueLinkListNode<NetSta
if (newSeed == 0)
{
HandleError(0, 0);
Disconnect(string.Empty);
return;
}
@ -602,16 +602,16 @@ public partial class NetState : IComparable<NetState>, IValueLinkListNode<NetSta
_parserState = ParserState.AwaitingNextPacket;
_protocolState = ProtocolState.GameServer_AwaitingGameServerLogin;
}
else
else // Don't allow partial packets on initial connection, just disconnect them.
{
_parserState = ParserState.AwaitingPartialPacket;
Disconnect(string.Empty);
}
break;
}
case ProtocolState.LoginServer_AwaitingLogin:
{
if (packetId != 0xCF && packetId != 0x80)
if (packetId != 0x80)
{
LogInfo("Possible encrypted client detected, disconnecting...");
HandleError(packetId, packetLength);
@ -659,7 +659,12 @@ public partial class NetState : IComparable<NetState>, IValueLinkListNode<NetSta
case ProtocolState.GameServer_AwaitingGameServerLogin:
{
if (packetId != 0x91 && packetId != 0x80)
if (packetId == 0x80)
{
goto case ProtocolState.LoginServer_AwaitingLogin;
}
if (packetId != 0x91)
{
HandleError(packetId, packetLength);
return;

View file

@ -64,7 +64,6 @@ public static class IncomingAccountPackets
IncomingPackets.Register(0x91, &GameLogin, 65, outgameOnly: true);
IncomingPackets.Register(0xA0, &PlayServer, 3, outgameOnly: true);
IncomingPackets.Register(0xBD, &ClientVersion);
IncomingPackets.Register(0xCF, &AccountLogin, outgameOnly: true);
IncomingPackets.Register(0xE1, &ClientType);
IncomingPackets.Register(0xEF, &LoginServerSeed, 21, outgameOnly: true);
IncomingPackets.Register(0xF8, &CreateCharacter, 106, outgameOnly: true);