fix(core): Fixes item mask in incoming mobile packet (#568)
- [X] FIxes the item mask in incoming mobile packet - [X] Streamlines some of the send info stuff - [X] Adds a few missing packet initializations
This commit is contained in:
parent
ee61c5a257
commit
b51bab5f1d
9 changed files with 27 additions and 32 deletions
|
|
@ -51,7 +51,7 @@ namespace Server.Network
|
|||
return;
|
||||
}
|
||||
|
||||
Span<byte> buffer = stackalloc byte[OPLPacketLength];
|
||||
Span<byte> buffer = stackalloc byte[OPLPacketLength].InitializePacket();
|
||||
CreateOPLInfo(buffer, serial, hash);
|
||||
|
||||
ns.Send(buffer);
|
||||
|
|
@ -82,7 +82,7 @@ namespace Server.Network
|
|||
ns.Send(buffer);
|
||||
}
|
||||
|
||||
public static int CreateWorldEntity(Span<byte> buffer, IEntity entity, bool isSA, bool isHS)
|
||||
public static int CreateWorldEntity(Span<byte> buffer, IEntity entity, bool isHS)
|
||||
{
|
||||
if (buffer[0] != 0)
|
||||
{
|
||||
|
|
@ -121,7 +121,7 @@ namespace Server.Network
|
|||
type = 1;
|
||||
gfx = mobile.BodyValue;
|
||||
hue = mobile.Hue;
|
||||
flags = mobile.GetPacketFlags(isSA);
|
||||
flags = mobile.GetPacketFlags(true);
|
||||
}
|
||||
|
||||
writer.Write((byte)type);
|
||||
|
|
@ -136,7 +136,7 @@ namespace Server.Network
|
|||
writer.Write((short)(entity.Y & 0x3FFF));
|
||||
writer.Write((sbyte)entity.Z);
|
||||
|
||||
writer.Write((byte)light);
|
||||
writer.Write(light);
|
||||
writer.Write((short)hue);
|
||||
writer.Write((byte)flags);
|
||||
|
||||
|
|
|
|||
|
|
@ -25,12 +25,13 @@ namespace Server.Network
|
|||
{
|
||||
if (buffer[0] != 0)
|
||||
{
|
||||
// This assumes the packet was sliced properly
|
||||
return buffer.Length;
|
||||
}
|
||||
|
||||
var itemID = item is BaseMulti ? item.ItemID | 0x4000 : item.ItemID & 0x3FFF;
|
||||
var hasAmount = item.Amount != 0;
|
||||
var amount = item.Amount;
|
||||
var hasAmount = amount != 0;
|
||||
var serial = hasAmount ? item.Serial | 0x80000000 : item.Serial & 0x7FFFFFFF;
|
||||
var loc = item.Location;
|
||||
var hue = item.Hue;
|
||||
|
|
@ -52,7 +53,7 @@ namespace Server.Network
|
|||
writer.Write(serial);
|
||||
writer.Write((ushort)itemID);
|
||||
|
||||
if (amount != 0)
|
||||
if (hasAmount)
|
||||
{
|
||||
writer.Write((ushort)amount);
|
||||
}
|
||||
|
|
@ -60,24 +61,24 @@ namespace Server.Network
|
|||
writer.Write((ushort)x);
|
||||
writer.Write((ushort)y);
|
||||
|
||||
if (direction != 0)
|
||||
if (hasDirection)
|
||||
{
|
||||
writer.Write((byte)direction);
|
||||
}
|
||||
|
||||
writer.Write((sbyte)loc.Z);
|
||||
|
||||
if (hue != 0)
|
||||
if (hasHue)
|
||||
{
|
||||
writer.Write((ushort)hue);
|
||||
}
|
||||
|
||||
if (flags != 0)
|
||||
if (hasFlags)
|
||||
{
|
||||
writer.Write((byte)flags);
|
||||
}
|
||||
|
||||
return writer.Position;
|
||||
return writer.BytesWritten;
|
||||
}
|
||||
|
||||
public static void SendWorldItem(this NetState ns, Item item)
|
||||
|
|
@ -87,10 +88,10 @@ namespace Server.Network
|
|||
return;
|
||||
}
|
||||
|
||||
Span<byte> buffer = stackalloc byte[OutgoingEntityPackets.MaxWorldEntityPacketLength];
|
||||
Span<byte> buffer = stackalloc byte[OutgoingEntityPackets.MaxWorldEntityPacketLength].InitializePacket();
|
||||
|
||||
var length = ns.StygianAbyss ?
|
||||
OutgoingEntityPackets.CreateWorldEntity(buffer, item, ns.StygianAbyss, ns.HighSeas) :
|
||||
OutgoingEntityPackets.CreateWorldEntity(buffer, item, ns.HighSeas) :
|
||||
CreateWorldItem(buffer, item);
|
||||
|
||||
ns.Send(buffer.SliceToLength(length));
|
||||
|
|
|
|||
|
|
@ -628,7 +628,7 @@ namespace Server.Network
|
|||
var itemID = item.ItemID & itemIdMask;
|
||||
var writeHue = newPacket || hue != 0;
|
||||
|
||||
if (!newPacket)
|
||||
if (!newPacket && writeHue)
|
||||
{
|
||||
itemID |= 0x8000;
|
||||
}
|
||||
|
|
@ -651,7 +651,7 @@ namespace Server.Network
|
|||
var itemID = beheld.HairItemID & itemIdMask;
|
||||
var writeHue = newPacket || hue != 0;
|
||||
|
||||
if (!newPacket)
|
||||
if (!newPacket && writeHue)
|
||||
{
|
||||
itemID |= 0x8000;
|
||||
}
|
||||
|
|
@ -674,7 +674,7 @@ namespace Server.Network
|
|||
var itemID = beheld.FacialHairItemID & itemIdMask;
|
||||
var writeHue = newPacket || hue != 0;
|
||||
|
||||
if (!newPacket)
|
||||
if (!newPacket && writeHue)
|
||||
{
|
||||
itemID |= 0x8000;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue