Skip to content

Commit

Permalink
fix: Fixes edge cases with the network packet loop (modernuo#1959)
Browse files Browse the repository at this point in the history
  • Loading branch information
kamronbatman authored Sep 20, 2024
1 parent e0fcde8 commit 2a7aa19
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
15 changes: 10 additions & 5 deletions Projects/Server/Network/NetState/NetState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ public void HandleReceive(bool throttled = false)

if (newSeed == 0)
{
HandleError(0, 0);
Disconnect(string.Empty);
return;
}

Expand All @@ -602,16 +602,16 @@ public void HandleReceive(bool throttled = false)
_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);
Expand Down Expand Up @@ -659,7 +659,12 @@ public void HandleReceive(bool throttled = false)

case ProtocolState.GameServer_AwaitingGameServerLogin:
{
if (packetId != 0x91 && packetId != 0x80)
if (packetId == 0x80)
{
goto case ProtocolState.LoginServer_AwaitingLogin;
}

if (packetId != 0x91)
{
HandleError(packetId, packetLength);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ public static unsafe void Configure()
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);
Expand Down

0 comments on commit 2a7aa19

Please sign in to comment.