fix(core): Removes 6017 handler (#411)

- [X] Removes 6017 handler since it is only used in one place
- [X] Exposes a ref int to modify the packet length. This is acceptable since we technically have access to the entire reader/buffer.
This commit is contained in:
Kamron Batman 2021-01-16 13:43:16 -08:00 committed by GitHub
parent dc44142d29
commit 97f311d7be
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
24 changed files with 126 additions and 129 deletions

View file

@ -24,14 +24,13 @@ namespace Server.Network
public static void Configure()
{
IncomingPackets.Register(0x07, 7, true, LiftReq);
IncomingPackets.Register(0x08, 14, true, DropReq);
IncomingPackets.Register(0x08, 15, true, DropReq);
IncomingPackets.Register(0x13, 10, true, EquipReq);
IncomingPackets.Register(0xEC, 0, false, EquipMacro);
IncomingPackets.Register(0xED, 0, false, UnequipMacro);
IncomingPackets.Register6017(0x08, 15, true, DropReq6017);
}
public static void LiftReq(NetState state, CircularBufferReader reader)
public static void LiftReq(NetState state, CircularBufferReader reader, ref int packetLength)
{
Serial serial = reader.ReadUInt32();
int amount = reader.ReadUInt16();
@ -40,7 +39,7 @@ namespace Server.Network
state.Mobile.Lift(item, amount, out _, out _);
}
public static void EquipReq(NetState state, CircularBufferReader reader)
public static void EquipReq(NetState state, CircularBufferReader reader, ref int packetLength)
{
var from = state.Mobile;
var item = from.Holding;
@ -65,12 +64,21 @@ namespace Server.Network
item.ClearBounce();
}
public static void DropReq(NetState state, CircularBufferReader reader)
public static void DropReq(NetState state, CircularBufferReader reader, ref int packetLength)
{
reader.ReadInt32(); // serial, ignored
int x = reader.ReadInt16();
int y = reader.ReadInt16();
int z = reader.ReadSByte();
if (state.ContainerGridLines)
{
reader.ReadByte(); // Grid Location?
}
else
{
packetLength -= 1;
}
Serial dest = reader.ReadUInt32();
var loc = new Point3D(x, y, z);
@ -102,7 +110,7 @@ namespace Server.Network
}
}
public static void DropReq6017(NetState state, CircularBufferReader reader)
public static void DropReq6017(NetState state, CircularBufferReader reader, ref int packetLength)
{
reader.ReadInt32(); // serial, ignored
int x = reader.ReadInt16();
@ -140,7 +148,7 @@ namespace Server.Network
}
}
public static void EquipMacro(NetState state, CircularBufferReader reader)
public static void EquipMacro(NetState state, CircularBufferReader reader, ref int packetLength)
{
int count = reader.ReadByte();
var serialList = new List<Serial>(count);
@ -152,7 +160,7 @@ namespace Server.Network
EventSink.InvokeEquipMacro(state.Mobile, serialList);
}
public static void UnequipMacro(NetState state, CircularBufferReader reader)
public static void UnequipMacro(NetState state, CircularBufferReader reader, ref int packetLength)
{
int count = reader.ReadByte();
var layers = new List<Layer>(count);