feat: Adds a memory mirrored ring buffer for networking. (#1533)
## Breaking Changes
Incoming packet registration signature has changed to:
```cs
delegate* void OnReceiveCallback(NetState state, SpanReader reader, int packetLength);
IncomingPackets.Register(int packetID, int length, bool ingame, OnReceiveCallback onReceive);
```
For example, an incoming packet handler signature would now look like this:
```cs
public static void SomeIncomingPacket(NetState state, SpanReader reader, int packetLength)
{
// Parse the data
}
```
## Summary
Updates the network Pipe class to use a mirrored memory technique. This technique involves mapping the same physical memory to two contiguous virtual memory spaces so the byte buffer appears duplicated. This allows writing to a double-sized array to wrap around without the need for the `CircularBuffer` classes.
In practice this allows us to use `Span<byte>` as if the buffer was a regular array.
### Bug Fixes
- [X] Fixes bad fixed length string parsing
This commit is contained in:
parent
629a5008c3
commit
10a69bf754
83 changed files with 958 additions and 2432 deletions
|
|
@ -14,6 +14,7 @@
|
|||
*************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Buffers;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using CV = Server.ClientVersion;
|
||||
|
|
@ -54,7 +55,7 @@ public static class IncomingAccountPackets
|
|||
IncomingPackets.Register(0xF8, 106, false, &CreateCharacter);
|
||||
}
|
||||
|
||||
public static void CreateCharacter(NetState state, CircularBufferReader reader, int packetLength)
|
||||
public static void CreateCharacter(NetState state, SpanReader reader, int packetLength)
|
||||
{
|
||||
reader.Seek(9, SeekOrigin.Current);
|
||||
/*
|
||||
|
|
@ -184,7 +185,7 @@ public static class IncomingAccountPackets
|
|||
}
|
||||
}
|
||||
|
||||
public static void DeleteCharacter(NetState state, CircularBufferReader reader, int packetLength)
|
||||
public static void DeleteCharacter(NetState state, SpanReader reader, int packetLength)
|
||||
{
|
||||
reader.Seek(30, SeekOrigin.Current);
|
||||
var index = reader.ReadInt32();
|
||||
|
|
@ -192,18 +193,18 @@ public static class IncomingAccountPackets
|
|||
EventSink.InvokeDeleteRequest(state, index);
|
||||
}
|
||||
|
||||
public static void AccountID(NetState state, CircularBufferReader reader, int packetLength)
|
||||
public static void AccountID(NetState state, SpanReader reader, int packetLength)
|
||||
{
|
||||
}
|
||||
|
||||
public static void ClientVersion(NetState state, CircularBufferReader reader, int packetLength)
|
||||
public static void ClientVersion(NetState state, SpanReader reader, int packetLength)
|
||||
{
|
||||
var version = state.Version = new CV(reader.ReadAscii());
|
||||
|
||||
EventSink.InvokeClientVersionReceived(state, version);
|
||||
}
|
||||
|
||||
public static void ClientType(NetState state, CircularBufferReader reader, int packetLength)
|
||||
public static void ClientType(NetState state, SpanReader reader, int packetLength)
|
||||
{
|
||||
reader.ReadUInt16();
|
||||
|
||||
|
|
@ -213,7 +214,7 @@ public static class IncomingAccountPackets
|
|||
EventSink.InvokeClientVersionReceived(state, version);
|
||||
}
|
||||
|
||||
public static void PlayCharacter(NetState state, CircularBufferReader reader, int packetLength)
|
||||
public static void PlayCharacter(NetState state, SpanReader reader, int packetLength)
|
||||
{
|
||||
reader.Seek(36, SeekOrigin.Current); // 4 = 0xEDEDEDED, 30 = Name, 2 = unknown
|
||||
var flags = reader.ReadInt32();
|
||||
|
|
@ -345,7 +346,7 @@ public static class IncomingAccountPackets
|
|||
return authID;
|
||||
}
|
||||
|
||||
public static void GameLogin(NetState state, CircularBufferReader reader, int packetLength)
|
||||
public static void GameLogin(NetState state, SpanReader reader, int packetLength)
|
||||
{
|
||||
// TODO: Connection throttling
|
||||
|
||||
|
|
@ -399,7 +400,7 @@ public static class IncomingAccountPackets
|
|||
}
|
||||
}
|
||||
|
||||
public static void PlayServer(NetState state, CircularBufferReader reader, int packetLength)
|
||||
public static void PlayServer(NetState state, SpanReader reader, int packetLength)
|
||||
{
|
||||
int index = reader.ReadInt16();
|
||||
var info = state.ServerInfo;
|
||||
|
|
@ -420,7 +421,7 @@ public static class IncomingAccountPackets
|
|||
}
|
||||
}
|
||||
|
||||
public static void LoginServerSeed(NetState state, CircularBufferReader reader, int packetLength)
|
||||
public static void LoginServerSeed(NetState state, SpanReader reader, int packetLength)
|
||||
{
|
||||
state.Seed = reader.ReadInt32();
|
||||
state.Seeded = true;
|
||||
|
|
@ -440,7 +441,7 @@ public static class IncomingAccountPackets
|
|||
state.Version = new ClientVersion(clientMaj, clientMin, clientRev, clientPat);
|
||||
}
|
||||
|
||||
public static void AccountLogin(NetState state, CircularBufferReader reader, int packetLength)
|
||||
public static void AccountLogin(NetState state, SpanReader reader, int packetLength)
|
||||
{
|
||||
// TODO: Throttle Connection
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
*************************************************************************/
|
||||
|
||||
using System.Buffers;
|
||||
|
||||
namespace Server.Network;
|
||||
|
||||
public static class IncomingEntityPackets
|
||||
|
|
@ -27,7 +29,7 @@ public static class IncomingEntityPackets
|
|||
IncomingPackets.Register(0xD6, 0, true, &BatchQueryProperties);
|
||||
}
|
||||
|
||||
public static void ObjectHelpRequest(NetState state, CircularBufferReader reader, int packetLength)
|
||||
public static void ObjectHelpRequest(NetState state, SpanReader reader, int packetLength)
|
||||
{
|
||||
var from = state.Mobile;
|
||||
|
||||
|
|
@ -56,7 +58,7 @@ public static class IncomingEntityPackets
|
|||
}
|
||||
}
|
||||
|
||||
public static void UseReq(NetState state, CircularBufferReader reader, int packetLength)
|
||||
public static void UseReq(NetState state, SpanReader reader, int packetLength)
|
||||
{
|
||||
var from = state.Mobile;
|
||||
|
||||
|
|
@ -100,7 +102,7 @@ public static class IncomingEntityPackets
|
|||
}
|
||||
}
|
||||
|
||||
public static void LookReq(NetState state, CircularBufferReader reader, int packetLength)
|
||||
public static void LookReq(NetState state, SpanReader reader, int packetLength)
|
||||
{
|
||||
var from = state.Mobile;
|
||||
|
||||
|
|
@ -149,7 +151,7 @@ public static class IncomingEntityPackets
|
|||
}
|
||||
}
|
||||
|
||||
public static void BatchQueryProperties(NetState state, CircularBufferReader reader, int packetLength)
|
||||
public static void BatchQueryProperties(NetState state, SpanReader reader, int packetLength)
|
||||
{
|
||||
if (!ObjectPropertyList.Enabled)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
*************************************************************************/
|
||||
|
||||
using System.Buffers;
|
||||
using Server.ContextMenus;
|
||||
|
||||
namespace Server.Network;
|
||||
|
|
@ -59,16 +60,16 @@ public static class IncomingExtendedCommandPackets
|
|||
RegisterExtended(0x32, true, &ToggleFlying);
|
||||
}
|
||||
|
||||
private static void UnhandledBF(NetState state, CircularBufferReader reader, int packetLength)
|
||||
private static void UnhandledBF(NetState state, SpanReader reader, int packetLength)
|
||||
{
|
||||
}
|
||||
|
||||
public static void Empty(NetState state, CircularBufferReader reader, int packetLength)
|
||||
public static void Empty(NetState state, SpanReader reader, int packetLength)
|
||||
{
|
||||
}
|
||||
|
||||
public static unsafe void RegisterExtended(int packetID, bool ingame,
|
||||
delegate*<NetState, CircularBufferReader, int, void> onReceive)
|
||||
delegate*<NetState, SpanReader, int, void> onReceive)
|
||||
{
|
||||
if (packetID is >= 0 and < 0x100)
|
||||
{
|
||||
|
|
@ -87,7 +88,7 @@ public static class IncomingExtendedCommandPackets
|
|||
}
|
||||
}
|
||||
|
||||
public static unsafe void ExtendedCommand(NetState state, CircularBufferReader reader, int packetLength)
|
||||
public static unsafe void ExtendedCommand(NetState state, SpanReader reader, int packetLength)
|
||||
{
|
||||
int packetId = reader.ReadUInt16();
|
||||
|
||||
|
|
@ -95,7 +96,7 @@ public static class IncomingExtendedCommandPackets
|
|||
|
||||
if (ph == null)
|
||||
{
|
||||
reader.Trace(state);
|
||||
state.Trace(reader.Buffer);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -116,14 +117,13 @@ public static class IncomingExtendedCommandPackets
|
|||
}
|
||||
}
|
||||
|
||||
public static void ScreenSize(NetState state, CircularBufferReader reader, int packetLength)
|
||||
public static void ScreenSize(NetState state, SpanReader reader, int packetLength)
|
||||
{
|
||||
var width = reader.ReadInt32();
|
||||
var unk = reader.ReadInt32();
|
||||
}
|
||||
|
||||
// TODO: Move out of the core
|
||||
public static void PartyMessage(NetState state, CircularBufferReader reader, int packetLength)
|
||||
public static void PartyMessage(NetState state, SpanReader reader, int packetLength)
|
||||
{
|
||||
if (state.Mobile == null)
|
||||
{
|
||||
|
|
@ -154,22 +154,22 @@ public static class IncomingExtendedCommandPackets
|
|||
PartyMessage_Decline(state, reader, packetLength);
|
||||
break;
|
||||
default:
|
||||
reader.Trace(state);
|
||||
state.Trace(reader.Buffer);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public static void PartyMessage_AddMember(NetState state, CircularBufferReader reader, int packetLength)
|
||||
public static void PartyMessage_AddMember(NetState state, SpanReader reader, int packetLength)
|
||||
{
|
||||
PartyCommands.Handler?.OnAdd(state.Mobile);
|
||||
}
|
||||
|
||||
public static void PartyMessage_RemoveMember(NetState state, CircularBufferReader reader, int packetLength)
|
||||
public static void PartyMessage_RemoveMember(NetState state, SpanReader reader, int packetLength)
|
||||
{
|
||||
PartyCommands.Handler?.OnRemove(state.Mobile, World.FindMobile((Serial)reader.ReadUInt32()));
|
||||
}
|
||||
|
||||
public static void PartyMessage_PrivateMessage(NetState state, CircularBufferReader reader, int packetLength)
|
||||
public static void PartyMessage_PrivateMessage(NetState state, SpanReader reader, int packetLength)
|
||||
{
|
||||
PartyCommands.Handler?.OnPrivateMessage(
|
||||
state.Mobile,
|
||||
|
|
@ -178,27 +178,27 @@ public static class IncomingExtendedCommandPackets
|
|||
);
|
||||
}
|
||||
|
||||
public static void PartyMessage_PublicMessage(NetState state, CircularBufferReader reader, int packetLength)
|
||||
public static void PartyMessage_PublicMessage(NetState state, SpanReader reader, int packetLength)
|
||||
{
|
||||
PartyCommands.Handler?.OnPublicMessage(state.Mobile, reader.ReadBigUniSafe());
|
||||
}
|
||||
|
||||
public static void PartyMessage_SetCanLoot(NetState state, CircularBufferReader reader, int packetLength)
|
||||
public static void PartyMessage_SetCanLoot(NetState state, SpanReader reader, int packetLength)
|
||||
{
|
||||
PartyCommands.Handler?.OnSetCanLoot(state.Mobile, reader.ReadBoolean());
|
||||
}
|
||||
|
||||
public static void PartyMessage_Accept(NetState state, CircularBufferReader reader, int packetLength)
|
||||
public static void PartyMessage_Accept(NetState state, SpanReader reader, int packetLength)
|
||||
{
|
||||
PartyCommands.Handler?.OnAccept(state.Mobile, World.FindMobile((Serial)reader.ReadUInt32()));
|
||||
}
|
||||
|
||||
public static void PartyMessage_Decline(NetState state, CircularBufferReader reader, int packetLength)
|
||||
public static void PartyMessage_Decline(NetState state, SpanReader reader, int packetLength)
|
||||
{
|
||||
PartyCommands.Handler?.OnDecline(state.Mobile, World.FindMobile((Serial)reader.ReadUInt32()));
|
||||
}
|
||||
|
||||
public static void Animate(NetState state, CircularBufferReader reader, int packetLength)
|
||||
public static void Animate(NetState state, SpanReader reader, int packetLength)
|
||||
{
|
||||
var from = state.Mobile;
|
||||
|
||||
|
|
@ -222,7 +222,7 @@ public static class IncomingExtendedCommandPackets
|
|||
}
|
||||
}
|
||||
|
||||
public static void CastSpell(NetState state, CircularBufferReader reader, int packetLength)
|
||||
public static void CastSpell(NetState state, SpanReader reader, int packetLength)
|
||||
{
|
||||
var from = state.Mobile;
|
||||
|
||||
|
|
@ -237,12 +237,12 @@ public static class IncomingExtendedCommandPackets
|
|||
EventSink.InvokeCastSpellRequest(from, spellID, spellbook);
|
||||
}
|
||||
|
||||
public static void ToggleFlying(NetState state, CircularBufferReader reader, int packetLength)
|
||||
public static void ToggleFlying(NetState state, SpanReader reader, int packetLength)
|
||||
{
|
||||
state.Mobile?.ToggleFlying();
|
||||
}
|
||||
|
||||
public static void StunRequest(NetState state, CircularBufferReader reader, int packetLength)
|
||||
public static void StunRequest(NetState state, SpanReader reader, int packetLength)
|
||||
{
|
||||
var from = state.Mobile;
|
||||
|
||||
|
|
@ -254,7 +254,7 @@ public static class IncomingExtendedCommandPackets
|
|||
EventSink.InvokeStunRequest(from);
|
||||
}
|
||||
|
||||
public static void DisarmRequest(NetState state, CircularBufferReader reader, int packetLength)
|
||||
public static void DisarmRequest(NetState state, SpanReader reader, int packetLength)
|
||||
{
|
||||
var from = state.Mobile;
|
||||
|
||||
|
|
@ -266,7 +266,7 @@ public static class IncomingExtendedCommandPackets
|
|||
EventSink.InvokeDisarmRequest(from);
|
||||
}
|
||||
|
||||
public static void StatLockChange(NetState state, CircularBufferReader reader, int packetLength)
|
||||
public static void StatLockChange(NetState state, SpanReader reader, int packetLength)
|
||||
{
|
||||
var from = state.Mobile;
|
||||
|
||||
|
|
@ -297,12 +297,12 @@ public static class IncomingExtendedCommandPackets
|
|||
}
|
||||
}
|
||||
|
||||
public static void CloseStatus(NetState state, CircularBufferReader reader, int packetLength)
|
||||
public static void CloseStatus(NetState state, SpanReader reader, int packetLength)
|
||||
{
|
||||
var serial = (Serial)reader.ReadUInt32();
|
||||
}
|
||||
|
||||
public static void Language(NetState state, CircularBufferReader reader, int packetLength)
|
||||
public static void Language(NetState state, SpanReader reader, int packetLength)
|
||||
{
|
||||
var from = state.Mobile;
|
||||
|
||||
|
|
@ -314,7 +314,7 @@ public static class IncomingExtendedCommandPackets
|
|||
from.Language = reader.ReadAscii(4);
|
||||
}
|
||||
|
||||
public static void QueryProperties(NetState state, CircularBufferReader reader, int packetLength)
|
||||
public static void QueryProperties(NetState state, SpanReader reader, int packetLength)
|
||||
{
|
||||
if (!ObjectPropertyList.Enabled)
|
||||
{
|
||||
|
|
@ -346,7 +346,7 @@ public static class IncomingExtendedCommandPackets
|
|||
}
|
||||
}
|
||||
|
||||
public static void ContextMenuResponse(NetState state, CircularBufferReader reader, int packetLength)
|
||||
public static void ContextMenuResponse(NetState state, SpanReader reader, int packetLength)
|
||||
{
|
||||
var from = state.Mobile;
|
||||
|
||||
|
|
@ -402,7 +402,7 @@ public static class IncomingExtendedCommandPackets
|
|||
}
|
||||
}
|
||||
|
||||
public static void ContextMenuRequest(NetState state, CircularBufferReader reader, int packetLength)
|
||||
public static void ContextMenuRequest(NetState state, SpanReader reader, int packetLength)
|
||||
{
|
||||
var from = state.Mobile;
|
||||
var target = World.FindEntity((Serial)reader.ReadUInt32());
|
||||
|
|
@ -437,7 +437,7 @@ public static class IncomingExtendedCommandPackets
|
|||
}
|
||||
}
|
||||
|
||||
public static void BandageTarget(NetState state, CircularBufferReader reader, int packetLength)
|
||||
public static void BandageTarget(NetState state, SpanReader reader, int packetLength)
|
||||
{
|
||||
var from = state.Mobile;
|
||||
|
||||
|
|
@ -472,21 +472,21 @@ public static class IncomingExtendedCommandPackets
|
|||
}
|
||||
}
|
||||
|
||||
public static void TargetedSpell(NetState state, CircularBufferReader reader, int packetLength)
|
||||
public static void TargetedSpell(NetState state, SpanReader reader, int packetLength)
|
||||
{
|
||||
var spellId = (short)(reader.ReadInt16() - 1); // zero based;
|
||||
|
||||
EventSink.InvokeTargetedSpell(state.Mobile, World.FindEntity((Serial)reader.ReadUInt32()), spellId);
|
||||
}
|
||||
|
||||
public static void TargetedSkillUse(NetState state, CircularBufferReader reader, int packetLength)
|
||||
public static void TargetedSkillUse(NetState state, SpanReader reader, int packetLength)
|
||||
{
|
||||
var skillId = reader.ReadInt16();
|
||||
|
||||
EventSink.InvokeTargetedSkillUse(state.Mobile, World.FindEntity((Serial)reader.ReadUInt32()), skillId);
|
||||
}
|
||||
|
||||
public static void TargetByResourceMacro(NetState state, CircularBufferReader reader, int packetLength)
|
||||
public static void TargetByResourceMacro(NetState state, SpanReader reader, int packetLength)
|
||||
{
|
||||
var serial = (Serial)reader.ReadUInt32();
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
*************************************************************************/
|
||||
|
||||
using System.Buffers;
|
||||
|
||||
namespace Server.Network;
|
||||
|
||||
public static class IncomingHousePackets
|
||||
|
|
@ -22,7 +24,7 @@ public static class IncomingHousePackets
|
|||
IncomingPackets.Register(0xFB, 2, false, &ShowPublicHouseContent);
|
||||
}
|
||||
|
||||
public static void ShowPublicHouseContent(NetState state, CircularBufferReader reader, int packetLength)
|
||||
public static void ShowPublicHouseContent(NetState state, SpanReader reader, int packetLength)
|
||||
{
|
||||
var showPublicHouseContent = reader.ReadBoolean();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
*************************************************************************/
|
||||
|
||||
using System.Buffers;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Server.Items;
|
||||
|
|
@ -30,7 +31,7 @@ public static class IncomingItemPackets
|
|||
IncomingPackets.Register(0xED, 0, false, &UnequipMacro);
|
||||
}
|
||||
|
||||
public static void LiftReq(NetState state, CircularBufferReader reader, int packetLength)
|
||||
public static void LiftReq(NetState state, SpanReader reader, int packetLength)
|
||||
{
|
||||
var serial = (Serial)reader.ReadUInt32();
|
||||
int amount = reader.ReadUInt16();
|
||||
|
|
@ -39,7 +40,7 @@ public static class IncomingItemPackets
|
|||
state.Mobile.Lift(item, amount, out _, out _);
|
||||
}
|
||||
|
||||
public static void EquipReq(NetState state, CircularBufferReader reader, int packetLength)
|
||||
public static void EquipReq(NetState state, SpanReader reader, int packetLength)
|
||||
{
|
||||
var from = state.Mobile;
|
||||
var item = from.Holding;
|
||||
|
|
@ -64,7 +65,7 @@ public static class IncomingItemPackets
|
|||
item.ClearBounce();
|
||||
}
|
||||
|
||||
public static void DropReq(NetState state, CircularBufferReader reader, int packetLength)
|
||||
public static void DropReq(NetState state, SpanReader reader, int packetLength)
|
||||
{
|
||||
reader.ReadInt32(); // serial, ignored
|
||||
int x = reader.ReadInt16();
|
||||
|
|
@ -107,7 +108,7 @@ public static class IncomingItemPackets
|
|||
}
|
||||
}
|
||||
|
||||
public static void EquipMacro(NetState state, CircularBufferReader reader, int packetLength)
|
||||
public static void EquipMacro(NetState state, SpanReader reader, int packetLength)
|
||||
{
|
||||
int count = reader.ReadByte();
|
||||
var serialList = new List<Serial>(count);
|
||||
|
|
@ -119,7 +120,7 @@ public static class IncomingItemPackets
|
|||
EventSink.InvokeEquipMacro(state.Mobile, serialList);
|
||||
}
|
||||
|
||||
public static void UnequipMacro(NetState state, CircularBufferReader reader, int packetLength)
|
||||
public static void UnequipMacro(NetState state, SpanReader reader, int packetLength)
|
||||
{
|
||||
int count = reader.ReadByte();
|
||||
var layers = new List<Layer>(count);
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
*************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Buffers;
|
||||
|
||||
namespace Server.Network;
|
||||
|
||||
|
|
@ -27,7 +28,7 @@ public static class IncomingMessagePackets
|
|||
IncomingPackets.Register(0xAD, 0, true, &UnicodeSpeech);
|
||||
}
|
||||
|
||||
public static void AsciiSpeech(NetState state, CircularBufferReader reader, int packetLength)
|
||||
public static void AsciiSpeech(NetState state, SpanReader reader, int packetLength)
|
||||
{
|
||||
var from = state.Mobile;
|
||||
|
||||
|
|
@ -54,7 +55,7 @@ public static class IncomingMessagePackets
|
|||
from.DoSpeech(text, Array.Empty<int>(), type, Utility.ClipDyedHue(hue));
|
||||
}
|
||||
|
||||
public static void UnicodeSpeech(NetState state, CircularBufferReader reader, int packetLength)
|
||||
public static void UnicodeSpeech(NetState state, SpanReader reader, int packetLength)
|
||||
{
|
||||
var from = state.Mobile;
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
*************************************************************************/
|
||||
|
||||
using System.Buffers;
|
||||
using Server.Items;
|
||||
|
||||
namespace Server.Network;
|
||||
|
|
@ -27,7 +28,7 @@ public static class IncomingMobilePackets
|
|||
IncomingPackets.Register(0x6F, 0, true, &SecureTrade);
|
||||
}
|
||||
|
||||
public static void RenameRequest(NetState state, CircularBufferReader reader, int packetLength)
|
||||
public static void RenameRequest(NetState state, SpanReader reader, int packetLength)
|
||||
{
|
||||
var from = state.Mobile;
|
||||
var targ = World.FindMobile((Serial)reader.ReadUInt32());
|
||||
|
|
@ -38,7 +39,7 @@ public static class IncomingMobilePackets
|
|||
}
|
||||
}
|
||||
|
||||
public static void MobileNameRequest(NetState state, CircularBufferReader reader, int packetLength)
|
||||
public static void MobileNameRequest(NetState state, SpanReader reader, int packetLength)
|
||||
{
|
||||
var m = World.FindMobile((Serial)reader.ReadUInt32());
|
||||
|
||||
|
|
@ -48,7 +49,7 @@ public static class IncomingMobilePackets
|
|||
}
|
||||
}
|
||||
|
||||
public static void ProfileReq(NetState state, CircularBufferReader reader, int packetLength)
|
||||
public static void ProfileReq(NetState state, SpanReader reader, int packetLength)
|
||||
{
|
||||
int type = reader.ReadByte();
|
||||
var serial = (Serial)reader.ReadUInt32();
|
||||
|
|
@ -88,7 +89,7 @@ public static class IncomingMobilePackets
|
|||
}
|
||||
}
|
||||
|
||||
public static void SecureTrade(NetState state, CircularBufferReader reader, int packetLength)
|
||||
public static void SecureTrade(NetState state, SpanReader reader, int packetLength)
|
||||
{
|
||||
switch (reader.ReadByte())
|
||||
{
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
*************************************************************************/
|
||||
|
||||
using System.Buffers;
|
||||
|
||||
namespace Server.Network;
|
||||
|
||||
public static class IncomingMovementPackets
|
||||
|
|
@ -25,7 +27,7 @@ public static class IncomingMovementPackets
|
|||
// IncomingPackets.Register(0xF1, 9, true, TimeSyncReq);
|
||||
}
|
||||
|
||||
public static void NewMovementReq(NetState ns, CircularBufferReader reader)
|
||||
public static void NewMovementReq(NetState ns, SpanReader reader)
|
||||
{
|
||||
var from = ns.Mobile;
|
||||
|
||||
|
|
@ -71,14 +73,14 @@ public static class IncomingMovementPackets
|
|||
}
|
||||
}
|
||||
|
||||
public static void TimeSyncReq(NetState ns, CircularBufferReader reader)
|
||||
public static void TimeSyncReq(NetState ns, SpanReader reader)
|
||||
{
|
||||
reader.ReadUInt64(); // Client Time?
|
||||
|
||||
ns.SendTimeSyncResponse();
|
||||
}
|
||||
|
||||
public static void MovementReq(NetState state, CircularBufferReader reader, int packetLength)
|
||||
public static void MovementReq(NetState state, SpanReader reader, int packetLength)
|
||||
{
|
||||
var from = state.Mobile;
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
*************************************************************************/
|
||||
|
||||
using System.Buffers;
|
||||
using System.Diagnostics;
|
||||
using Microsoft.Toolkit.HighPerformance;
|
||||
using Server.Diagnostics;
|
||||
|
|
@ -54,18 +55,18 @@ public static class IncomingPlayerPackets
|
|||
IncomingPackets.RegisterEncoded(0x32, true, &QuestGumpRequest);
|
||||
}
|
||||
|
||||
public static void DeathStatusResponse(NetState state, CircularBufferReader reader, int packetLength)
|
||||
public static void DeathStatusResponse(NetState state, SpanReader reader, int packetLength)
|
||||
{
|
||||
// Ignored
|
||||
}
|
||||
|
||||
public static void RequestScrollWindow(NetState state, CircularBufferReader reader, int packetLength)
|
||||
public static void RequestScrollWindow(NetState state, SpanReader reader, int packetLength)
|
||||
{
|
||||
int lastTip = reader.ReadInt16();
|
||||
int type = reader.ReadByte();
|
||||
}
|
||||
|
||||
public static void AttackReq(NetState state, CircularBufferReader reader, int packetLength)
|
||||
public static void AttackReq(NetState state, SpanReader reader, int packetLength)
|
||||
{
|
||||
var from = state.Mobile;
|
||||
|
||||
|
|
@ -82,7 +83,7 @@ public static class IncomingPlayerPackets
|
|||
}
|
||||
}
|
||||
|
||||
public static void HuePickerResponse(NetState state, CircularBufferReader reader, int packetLength)
|
||||
public static void HuePickerResponse(NetState state, SpanReader reader, int packetLength)
|
||||
{
|
||||
var serial = reader.ReadUInt32();
|
||||
_ = reader.ReadInt16(); // Item ID
|
||||
|
|
@ -99,7 +100,7 @@ public static class IncomingPlayerPackets
|
|||
}
|
||||
}
|
||||
|
||||
public static void SystemInfo(NetState state, CircularBufferReader reader, int packetLength)
|
||||
public static void SystemInfo(NetState state, SpanReader reader, int packetLength)
|
||||
{
|
||||
int v1 = reader.ReadByte();
|
||||
int v2 = reader.ReadUInt16();
|
||||
|
|
@ -115,7 +116,7 @@ public static class IncomingPlayerPackets
|
|||
var v8 = reader.ReadInt32();
|
||||
}
|
||||
|
||||
public static void TextCommand(NetState state, CircularBufferReader reader, int packetLength)
|
||||
public static void TextCommand(NetState state, SpanReader reader, int packetLength)
|
||||
{
|
||||
var from = state.Mobile;
|
||||
|
||||
|
|
@ -210,7 +211,7 @@ public static class IncomingPlayerPackets
|
|||
}
|
||||
}
|
||||
|
||||
public static void AsciiPromptResponse(NetState state, CircularBufferReader reader, int packetLength)
|
||||
public static void AsciiPromptResponse(NetState state, SpanReader reader, int packetLength)
|
||||
{
|
||||
var from = state.Mobile;
|
||||
|
||||
|
|
@ -246,7 +247,7 @@ public static class IncomingPlayerPackets
|
|||
}
|
||||
}
|
||||
|
||||
public static void UnicodePromptResponse(NetState state, CircularBufferReader reader, int packetLength)
|
||||
public static void UnicodePromptResponse(NetState state, SpanReader reader, int packetLength)
|
||||
{
|
||||
var from = state.Mobile;
|
||||
|
||||
|
|
@ -283,7 +284,7 @@ public static class IncomingPlayerPackets
|
|||
}
|
||||
}
|
||||
|
||||
public static void MenuResponse(NetState state, CircularBufferReader reader, int packetLength)
|
||||
public static void MenuResponse(NetState state, SpanReader reader, int packetLength)
|
||||
{
|
||||
var serial = reader.ReadUInt32();
|
||||
int menuID = reader.ReadInt16(); // unused in our implementation
|
||||
|
|
@ -313,33 +314,33 @@ public static class IncomingPlayerPackets
|
|||
}
|
||||
}
|
||||
|
||||
public static void Disconnect(NetState state, CircularBufferReader reader, int packetLength)
|
||||
public static void Disconnect(NetState state, SpanReader reader, int packetLength)
|
||||
{
|
||||
var minusOne = reader.ReadInt32();
|
||||
}
|
||||
|
||||
public static void ConfigurationFile(NetState state, CircularBufferReader reader, int packetLength)
|
||||
public static void ConfigurationFile(NetState state, SpanReader reader, int packetLength)
|
||||
{
|
||||
}
|
||||
|
||||
public static void LogoutReq(NetState state, CircularBufferReader reader, int packetLength)
|
||||
public static void LogoutReq(NetState state, SpanReader reader, int packetLength)
|
||||
{
|
||||
state.SendLogoutAck();
|
||||
}
|
||||
|
||||
public static void ChangeSkillLock(NetState state, CircularBufferReader reader, int packetLength)
|
||||
public static void ChangeSkillLock(NetState state, SpanReader reader, int packetLength)
|
||||
{
|
||||
var s = state.Mobile.Skills[reader.ReadInt16()];
|
||||
|
||||
s?.SetLockNoRelay((SkillLock)reader.ReadByte());
|
||||
}
|
||||
|
||||
public static void HelpRequest(NetState state, CircularBufferReader reader, int packetLength)
|
||||
public static void HelpRequest(NetState state, SpanReader reader, int packetLength)
|
||||
{
|
||||
EventSink.InvokeHelpRequest(state.Mobile);
|
||||
}
|
||||
|
||||
public static void DisplayGumpResponse(NetState state, CircularBufferReader reader, int packetLength)
|
||||
public static void DisplayGumpResponse(NetState state, SpanReader reader, int packetLength)
|
||||
{
|
||||
var serial = (Serial)reader.ReadUInt32();
|
||||
var typeID = reader.ReadInt32();
|
||||
|
|
@ -481,13 +482,13 @@ public static class IncomingPlayerPackets
|
|||
}
|
||||
}
|
||||
|
||||
public static void SetWarMode(NetState state, CircularBufferReader reader, int packetLength)
|
||||
public static void SetWarMode(NetState state, SpanReader reader, int packetLength)
|
||||
{
|
||||
state.Mobile?.DelayChangeWarmode(reader.ReadBoolean());
|
||||
}
|
||||
|
||||
// TODO: Throttle/make this more safe
|
||||
public static void Resynchronize(NetState state, CircularBufferReader reader, int packetLength)
|
||||
public static void Resynchronize(NetState state, SpanReader reader, int packetLength)
|
||||
{
|
||||
var from = state.Mobile;
|
||||
|
||||
|
|
@ -504,17 +505,17 @@ public static class IncomingPlayerPackets
|
|||
state.Sequence = 0;
|
||||
}
|
||||
|
||||
public static void PingReq(NetState state, CircularBufferReader reader, int packetLength)
|
||||
public static void PingReq(NetState state, SpanReader reader, int packetLength)
|
||||
{
|
||||
state.SendPingAck(reader.ReadByte());
|
||||
}
|
||||
|
||||
public static void SetUpdateRange(NetState state, CircularBufferReader reader, int packetLength)
|
||||
public static void SetUpdateRange(NetState state, SpanReader reader, int packetLength)
|
||||
{
|
||||
state.SendChangeUpdateRange(18);
|
||||
}
|
||||
|
||||
public static void MobileQuery(NetState state, CircularBufferReader reader, int packetLength)
|
||||
public static void MobileQuery(NetState state, SpanReader reader, int packetLength)
|
||||
{
|
||||
var from = state.Mobile;
|
||||
if (from == null)
|
||||
|
|
@ -545,13 +546,13 @@ public static class IncomingPlayerPackets
|
|||
}
|
||||
default:
|
||||
{
|
||||
reader.Trace(state);
|
||||
state.Trace(reader.Buffer);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void CrashReport(NetState state, CircularBufferReader reader, int packetLength)
|
||||
public static void CrashReport(NetState state, SpanReader reader, int packetLength)
|
||||
{
|
||||
var clientMaj = reader.ReadByte();
|
||||
var clientMin = reader.ReadByte();
|
||||
|
|
@ -595,7 +596,7 @@ public static class IncomingPlayerPackets
|
|||
EventSink.InvokeQuestGumpRequest(state.Mobile);
|
||||
}
|
||||
|
||||
public static unsafe void EncodedCommand(NetState state, CircularBufferReader reader, int packetLength)
|
||||
public static unsafe void EncodedCommand(NetState state, SpanReader reader, int packetLength)
|
||||
{
|
||||
var e = World.FindEntity((Serial)reader.ReadUInt32());
|
||||
int packetId = reader.ReadUInt16();
|
||||
|
|
@ -612,7 +613,7 @@ public static class IncomingPlayerPackets
|
|||
|
||||
if (ph == null)
|
||||
{
|
||||
reader.Trace(state);
|
||||
state.Trace(reader.Buffer);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
*************************************************************************/
|
||||
|
||||
using System.Buffers;
|
||||
using Server.Diagnostics;
|
||||
using Server.Targeting;
|
||||
|
||||
|
|
@ -25,7 +26,7 @@ public static class IncomingTargetingPackets
|
|||
IncomingPackets.Register(0x6C, 19, true, &TargetResponse);
|
||||
}
|
||||
|
||||
public static void TargetResponse(NetState state, CircularBufferReader reader, int packetLength)
|
||||
public static void TargetResponse(NetState state, SpanReader reader, int packetLength)
|
||||
{
|
||||
int type = reader.ReadByte();
|
||||
var targetID = reader.ReadInt32();
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
*************************************************************************/
|
||||
|
||||
using System.Buffers;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Server.Network;
|
||||
|
|
@ -25,7 +26,7 @@ public static class IncomingVendorPackets
|
|||
IncomingPackets.Register(0x9F, 0, true, &VendorSellReply);
|
||||
}
|
||||
|
||||
public static void VendorBuyReply(NetState state, CircularBufferReader reader, int packetLength)
|
||||
public static void VendorBuyReply(NetState state, SpanReader reader, int packetLength)
|
||||
{
|
||||
var vendor = World.FindMobile((Serial)reader.ReadUInt32());
|
||||
|
||||
|
|
@ -65,7 +66,7 @@ public static class IncomingVendorPackets
|
|||
state.SendEndVendorBuy(vendor.Serial);
|
||||
}
|
||||
|
||||
public static void VendorSellReply(NetState state, CircularBufferReader reader, int packetLength)
|
||||
public static void VendorSellReply(NetState state, SpanReader reader, int packetLength)
|
||||
{
|
||||
var serial = (Serial)reader.ReadUInt32();
|
||||
var vendor = World.FindMobile(serial);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue