fix(core): Fixes packet issues with hair/beard (#669)
This commit is contained in:
parent
ebac984543
commit
f78a226321
4 changed files with 56 additions and 37 deletions
|
|
@ -10,7 +10,7 @@ namespace Server
|
|||
public const int EquipUpdatePacketLength = 15;
|
||||
public const int RemovePacketLength = 5;
|
||||
|
||||
public static void SendHairEquipUpdatePacket(this NetState ns, Mobile m, Serial hairSerial, Layer layer)
|
||||
public static void SendHairEquipUpdatePacket(this NetState ns, Mobile m, Serial hairSerial, int itemId, int hue, Layer layer)
|
||||
{
|
||||
if (ns == null)
|
||||
{
|
||||
|
|
@ -18,28 +18,26 @@ namespace Server
|
|||
}
|
||||
|
||||
Span<byte> buffer = stackalloc byte[EquipUpdatePacketLength];
|
||||
CreateHairEquipUpdatePacket(buffer, m, hairSerial, layer);
|
||||
CreateHairEquipUpdatePacket(buffer, m, hairSerial, itemId, hue, layer);
|
||||
ns.Send(buffer);
|
||||
}
|
||||
|
||||
public static void CreateHairEquipUpdatePacket(Span<byte> buffer, Mobile m, Serial hairSerial, Layer layer)
|
||||
public static void CreateHairEquipUpdatePacket(Span<byte> buffer, Mobile m, Serial hairSerial, int itemId, int hue, Layer layer)
|
||||
{
|
||||
if (buffer[0] != 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var hue = m.SolidHueOverride >= 0 ? m.SolidHueOverride : m.HairHue;
|
||||
|
||||
var writer = new SpanWriter(buffer);
|
||||
writer.Write((byte)0x2E); // Packet ID
|
||||
|
||||
writer.Write(hairSerial);
|
||||
writer.Write((short)m.HairItemID);
|
||||
writer.Write((short)itemId);
|
||||
writer.Write((byte)0);
|
||||
writer.Write((byte)layer);
|
||||
writer.Write(m.Serial);
|
||||
writer.Write((short)hue);
|
||||
writer.Write((short)(m.SolidHueOverride >= 0 ? m.SolidHueOverride : hue));
|
||||
}
|
||||
|
||||
public static void SendRemoveHairPacket(this NetState ns, Serial hairSerial)
|
||||
|
|
|
|||
|
|
@ -2975,6 +2975,20 @@ namespace Server
|
|||
sendFacialHair = true;
|
||||
}
|
||||
|
||||
var hairSerial = HairInfo.FakeSerial(Serial);
|
||||
var hairLength = removeHair
|
||||
? OutgoingVirtualHairPackets.RemovePacketLength
|
||||
: OutgoingVirtualHairPackets.EquipUpdatePacketLength;
|
||||
|
||||
Span<byte> hairPacket = stackalloc byte[hairLength].InitializePacket();
|
||||
|
||||
var facialHairSerial = FacialHairInfo.FakeSerial(Serial);
|
||||
var facialHairLength = removeFacialHair
|
||||
? OutgoingVirtualHairPackets.RemovePacketLength
|
||||
: OutgoingVirtualHairPackets.EquipUpdatePacketLength;
|
||||
|
||||
Span<byte> facialhairPacket = stackalloc byte[facialHairLength].InitializePacket();
|
||||
|
||||
const int cacheLength = OutgoingMobilePackets.MobileMovingPacketCacheByteLength;
|
||||
const int width = OutgoingMobilePackets.MobileMovingPacketLength;
|
||||
const int height = OutgoingMobilePackets.MobileMovingPacketCacheHeight;
|
||||
|
|
@ -3060,24 +3074,41 @@ namespace Server
|
|||
{
|
||||
if (removeHair)
|
||||
{
|
||||
ourState.SendRemoveHairPacket(HairInfo.FakeSerial(Serial));
|
||||
OutgoingVirtualHairPackets.CreateRemoveHairPacket(hairPacket, hairSerial);
|
||||
}
|
||||
else
|
||||
{
|
||||
ourState.SendHairEquipUpdatePacket(this, HairInfo.FakeSerial(Serial), Layer.Hair);
|
||||
OutgoingVirtualHairPackets.CreateHairEquipUpdatePacket(
|
||||
hairPacket,
|
||||
this,
|
||||
hairSerial,
|
||||
HairItemID,
|
||||
HairHue,
|
||||
Layer.Hair
|
||||
);
|
||||
}
|
||||
|
||||
ourState.Send(hairPacket);
|
||||
}
|
||||
|
||||
if (sendFacialHair)
|
||||
{
|
||||
if (removeFacialHair)
|
||||
{
|
||||
ourState.SendRemoveHairPacket(FacialHairInfo.FakeSerial(Serial));
|
||||
OutgoingVirtualHairPackets.CreateRemoveHairPacket(facialhairPacket, facialHairSerial);
|
||||
}
|
||||
else
|
||||
{
|
||||
ourState.SendHairEquipUpdatePacket(this, FacialHairInfo.FakeSerial(Serial), Layer.FacialHair);
|
||||
OutgoingVirtualHairPackets.CreateHairEquipUpdatePacket(
|
||||
facialhairPacket,
|
||||
this,
|
||||
facialHairSerial,
|
||||
FacialHairItemID,
|
||||
FacialHairHue,
|
||||
Layer.FacialHair
|
||||
);
|
||||
}
|
||||
ourState.Send(facialhairPacket);
|
||||
}
|
||||
|
||||
if (sendOPLUpdate)
|
||||
|
|
@ -3113,18 +3144,6 @@ namespace Server
|
|||
Span<byte> removeEntity = stackalloc byte[OutgoingEntityPackets.RemoveEntityLength].InitializePacket();
|
||||
Span<byte> hitsPacket = stackalloc byte[OutgoingMobilePackets.MobileAttributePacketLength].InitializePacket();
|
||||
|
||||
var hairLength = removeHair
|
||||
? OutgoingVirtualHairPackets.RemovePacketLength
|
||||
: OutgoingVirtualHairPackets.EquipUpdatePacketLength;
|
||||
|
||||
Span<byte> hairPacket = stackalloc byte[hairLength].InitializePacket();
|
||||
|
||||
var facialHairLength = removeFacialHair
|
||||
? OutgoingVirtualHairPackets.RemovePacketLength
|
||||
: OutgoingVirtualHairPackets.EquipUpdatePacketLength;
|
||||
|
||||
Span<byte> facialhairPacket = stackalloc byte[facialHairLength].InitializePacket();
|
||||
|
||||
foreach (var state in eable)
|
||||
{
|
||||
var beholder = state.Mobile;
|
||||
|
|
@ -3192,7 +3211,6 @@ namespace Server
|
|||
|
||||
if (sendHair)
|
||||
{
|
||||
var hairSerial = HairInfo.FakeSerial(Serial);
|
||||
if (removeHair)
|
||||
{
|
||||
OutgoingVirtualHairPackets.CreateRemoveHairPacket(hairPacket, hairSerial);
|
||||
|
|
@ -3203,6 +3221,8 @@ namespace Server
|
|||
hairPacket,
|
||||
this,
|
||||
hairSerial,
|
||||
HairItemID,
|
||||
HairHue,
|
||||
Layer.Hair
|
||||
);
|
||||
}
|
||||
|
|
@ -3212,17 +3232,18 @@ namespace Server
|
|||
|
||||
if (sendFacialHair)
|
||||
{
|
||||
var hairSerial = HairInfo.FakeSerial(Serial);
|
||||
if (removeFacialHair)
|
||||
{
|
||||
OutgoingVirtualHairPackets.CreateRemoveHairPacket(facialhairPacket, hairSerial);
|
||||
OutgoingVirtualHairPackets.CreateRemoveHairPacket(facialhairPacket, facialHairSerial);
|
||||
}
|
||||
else
|
||||
{
|
||||
OutgoingVirtualHairPackets.CreateHairEquipUpdatePacket(
|
||||
facialhairPacket,
|
||||
this,
|
||||
hairSerial,
|
||||
facialHairSerial,
|
||||
FacialHairItemID,
|
||||
FacialHairHue,
|
||||
Layer.FacialHair
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue