fix: Fixes thread guard and cleans up incoming packet reader (#1641)

### Summary
* Fixes syntax compile error when THREADGUARD is enabled.
* Removes `int packetLength` from incoming packet handles since they aren't needed.

### Developer Notes
Incoming packet handler `SpanReader` is now properly scoped to that packet by length.
This commit is contained in:
Kamron Batman 2023-12-19 17:04:09 -08:00 committed by GitHub
parent 25a75fdf24
commit 7d9bc9ff0a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
31 changed files with 190 additions and 157 deletions

View file

@ -55,7 +55,7 @@ public static class IncomingAccountPackets
IncomingPackets.Register(0xF8, 106, false, &CreateCharacter);
}
public static void CreateCharacter(NetState state, SpanReader reader, int packetLength)
public static void CreateCharacter(NetState state, SpanReader reader)
{
reader.Seek(9, SeekOrigin.Current);
/*
@ -185,7 +185,7 @@ public static class IncomingAccountPackets
}
}
public static void DeleteCharacter(NetState state, SpanReader reader, int packetLength)
public static void DeleteCharacter(NetState state, SpanReader reader)
{
reader.Seek(30, SeekOrigin.Current);
var index = reader.ReadInt32();
@ -193,18 +193,18 @@ public static class IncomingAccountPackets
EventSink.InvokeDeleteRequest(state, index);
}
public static void AccountID(NetState state, SpanReader reader, int packetLength)
public static void AccountID(NetState state, SpanReader reader)
{
}
public static void ClientVersion(NetState state, SpanReader reader, int packetLength)
public static void ClientVersion(NetState state, SpanReader reader)
{
var version = state.Version = new CV(reader.ReadAscii());
EventSink.InvokeClientVersionReceived(state, version);
}
public static void ClientType(NetState state, SpanReader reader, int packetLength)
public static void ClientType(NetState state, SpanReader reader)
{
reader.ReadUInt16();
@ -214,7 +214,7 @@ public static class IncomingAccountPackets
EventSink.InvokeClientVersionReceived(state, version);
}
public static void PlayCharacter(NetState state, SpanReader reader, int packetLength)
public static void PlayCharacter(NetState state, SpanReader reader)
{
reader.Seek(36, SeekOrigin.Current); // 4 = 0xEDEDEDED, 30 = Name, 2 = unknown
var flags = reader.ReadInt32();
@ -346,7 +346,7 @@ public static class IncomingAccountPackets
return authID;
}
public static void GameLogin(NetState state, SpanReader reader, int packetLength)
public static void GameLogin(NetState state, SpanReader reader)
{
// TODO: Connection throttling
@ -400,7 +400,7 @@ public static class IncomingAccountPackets
}
}
public static void PlayServer(NetState state, SpanReader reader, int packetLength)
public static void PlayServer(NetState state, SpanReader reader)
{
int index = reader.ReadInt16();
var info = state.ServerInfo;
@ -421,7 +421,7 @@ public static class IncomingAccountPackets
}
}
public static void LoginServerSeed(NetState state, SpanReader reader, int packetLength)
public static void LoginServerSeed(NetState state, SpanReader reader)
{
state.Seed = reader.ReadInt32();
state.Seeded = true;
@ -441,7 +441,7 @@ public static class IncomingAccountPackets
state.Version = new ClientVersion(clientMaj, clientMin, clientRev, clientPat);
}
public static void AccountLogin(NetState state, SpanReader reader, int packetLength)
public static void AccountLogin(NetState state, SpanReader reader)
{
// TODO: Throttle Connection