fix: Fixes more packet initializations (#1507)

This commit is contained in:
Kamron Batman 2023-09-19 00:02:17 -07:00 • committed by GitHub
parent 0bec97639f
commit 2a3e048b86
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 26 additions and 23 deletions

View file

@ -379,7 +379,7 @@ public static class Effects
int speed, int duration, bool fixedDirection = false, bool explodes = false, int hue = 0, int renderMode = 0 int speed, int duration, bool fixedDirection = false, bool explodes = false, int hue = 0, int renderMode = 0
) )
{ {
Span<byte> effect = stackalloc byte[OutgoingEffectPackets.HuedEffectLength]; Span<byte> effect = stackalloc byte[OutgoingEffectPackets.HuedEffectLength].InitializePacket();
OutgoingEffectPackets.CreateMovingHuedEffect( OutgoingEffectPackets.CreateMovingHuedEffect(
effect, effect,
from, to, itemID, fromLocation, toLocation, speed, duration, fixedDirection, from, to, itemID, fromLocation, toLocation, speed, duration, fixedDirection,

View file

@ -17,7 +17,7 @@ public static class OutgoingVirtualHairPackets
return; return;
} }
Span<byte> buffer = stackalloc byte[EquipUpdatePacketLength]; Span<byte> buffer = stackalloc byte[EquipUpdatePacketLength].InitializePacket();
CreateHairEquipUpdatePacket(buffer, m, hairSerial, itemId, hue, layer); CreateHairEquipUpdatePacket(buffer, m, hairSerial, itemId, hue, layer);
ns.Send(buffer); ns.Send(buffer);
} }
@ -47,7 +47,7 @@ public static class OutgoingVirtualHairPackets
return; return;
} }
Span<byte> buffer = stackalloc byte[RemovePacketLength]; Span<byte> buffer = stackalloc byte[RemovePacketLength].InitializePacket();
CreateRemoveHairPacket(buffer, hairSerial); CreateRemoveHairPacket(buffer, hairSerial);
ns.Send(buffer); ns.Send(buffer);
} }

View file

@ -8994,7 +8994,8 @@ public partial class Mobile : IHued, IComparable<Mobile>, ISpawnable, IObjectPro
return; return;
} }
Span<byte> buffer = stackalloc byte[OutgoingMessagePackets.GetMaxMessageLocalizedAffixLength(affix, args)].InitializePacket(); Span<byte> buffer = stackalloc byte[OutgoingMessagePackets.GetMaxMessageLocalizedAffixLength(affix, args)]
.InitializePacket();
var eable = m_Map.GetClientsInRange(m_Location); var eable = m_Map.GetClientsInRange(m_Location);

View file

@ -41,7 +41,7 @@ public static class OutgoingMessagePackets
return; return;
} }
Span<byte> buffer = stackalloc byte[GetMaxMessageLocalizedLength(args)]; Span<byte> buffer = stackalloc byte[GetMaxMessageLocalizedLength(args)].InitializePacket();
var length = CreateMessageLocalized( var length = CreateMessageLocalized(
buffer, serial, graphic, type, hue, font, number, name, args buffer, serial, graphic, type, hue, font, number, name, args
); );

View file

@ -94,7 +94,7 @@ public static class OutgoingMobilePackets
return; return;
} }
Span<byte> span = stackalloc byte[DeathAnimationPacketLength]; Span<byte> span = stackalloc byte[DeathAnimationPacketLength].InitializePacket();
CreateDeathAnimation(span, killed, corpse); CreateDeathAnimation(span, killed, corpse);
ns.Send(span); ns.Send(span);
} }
@ -200,7 +200,7 @@ public static class OutgoingMobilePackets
return; return;
} }
Span<byte> span = stackalloc byte[MobileAttributePacketLength]; Span<byte> span = stackalloc byte[MobileAttributePacketLength].InitializePacket();
CreateMobileHits(span, m, normalize); CreateMobileHits(span, m, normalize);
ns.Send(span); ns.Send(span);
} }
@ -225,7 +225,7 @@ public static class OutgoingMobilePackets
return; return;
} }
Span<byte> span = stackalloc byte[MobileAttributePacketLength]; Span<byte> span = stackalloc byte[MobileAttributePacketLength].InitializePacket();
CreateMobileMana(span, m, normalize); CreateMobileMana(span, m, normalize);
ns.Send(span); ns.Send(span);
} }
@ -250,7 +250,7 @@ public static class OutgoingMobilePackets
return; return;
} }
Span<byte> span = stackalloc byte[MobileAttributePacketLength]; Span<byte> span = stackalloc byte[MobileAttributePacketLength].InitializePacket();
CreateMobileStam(span, m, normalize); CreateMobileStam(span, m, normalize);
ns.Send(span); ns.Send(span);
} }
@ -275,7 +275,7 @@ public static class OutgoingMobilePackets
return; return;
} }
Span<byte> span = stackalloc byte[MobileAttributesPacketLength]; Span<byte> span = stackalloc byte[MobileAttributesPacketLength].InitializePacket();
CreateMobileAttributes(span, m, normalize); CreateMobileAttributes(span, m, normalize);
ns.Send(span); ns.Send(span);
} }
@ -344,7 +344,7 @@ public static class OutgoingMobilePackets
return; return;
} }
Span<byte> span = stackalloc byte[MobileAnimationPacketLength]; Span<byte> span = stackalloc byte[MobileAnimationPacketLength].InitializePacket();
CreateMobileAnimation(span, mobile, action, frameCount, repeatCount, forward, repeat, delay); CreateMobileAnimation(span, mobile, action, frameCount, repeatCount, forward, repeat, delay);
ns.Send(span); ns.Send(span);
} }
@ -369,7 +369,7 @@ public static class OutgoingMobilePackets
return; return;
} }
Span<byte> span = stackalloc byte[NewMobileAnimationPacketLength]; Span<byte> span = stackalloc byte[NewMobileAnimationPacketLength].InitializePacket();
CreateNewMobileAnimation(span, mobile, action, frameCount, delay); CreateNewMobileAnimation(span, mobile, action, frameCount, delay);
ns.Send(span); ns.Send(span);
} }
@ -381,7 +381,7 @@ public static class OutgoingMobilePackets
return; return;
} }
Span<byte> span = stackalloc byte[MobileHealthbarPacketLength]; Span<byte> span = stackalloc byte[MobileHealthbarPacketLength].InitializePacket();
CreateMobileHealthbar(span, m, healthbar); CreateMobileHealthbar(span, m, healthbar);
ns.Send(span); ns.Send(span);
} }
@ -436,7 +436,7 @@ public static class OutgoingMobilePackets
return; return;
} }
Span<byte> buffer = stackalloc byte[MobileStatusCompactLength]; Span<byte> buffer = stackalloc byte[MobileStatusCompactLength].InitializePacket();
CreateMobileStatusCompact(buffer, m, canBeRenamed); CreateMobileStatusCompact(buffer, m, canBeRenamed);
ns.Send(buffer); ns.Send(buffer);
@ -487,7 +487,7 @@ public static class OutgoingMobilePackets
} }
} }
Span<byte> buffer = stackalloc byte[length]; Span<byte> buffer = stackalloc byte[length].InitializePacket();
CreateMobileStatus(buffer, beheld, version, beheld.CanBeRenamedBy(beholder)); CreateMobileStatus(buffer, beheld, version, beheld.CanBeRenamedBy(beholder));
ns.Send(buffer); ns.Send(buffer);
} }

View file

@ -50,7 +50,7 @@ namespace Server.Engines.PartySystem
public void OnStamChanged(Mobile m) public void OnStamChanged(Mobile m)
{ {
Span<byte> p = stackalloc byte[OutgoingMobilePackets.MobileAttributePacketLength]; Span<byte> p = stackalloc byte[OutgoingMobilePackets.MobileAttributePacketLength].InitializePacket();
OutgoingMobilePackets.CreateMobileStam(p, m, true); OutgoingMobilePackets.CreateMobileStam(p, m, true);
for (var i = 0; i < Members.Count; ++i) for (var i = 0; i < Members.Count; ++i)
@ -67,7 +67,7 @@ namespace Server.Engines.PartySystem
public void OnManaChanged(Mobile m) public void OnManaChanged(Mobile m)
{ {
Span<byte> p = stackalloc byte[OutgoingMobilePackets.MobileAttributePacketLength]; Span<byte> p = stackalloc byte[OutgoingMobilePackets.MobileAttributePacketLength].InitializePacket();
OutgoingMobilePackets.CreateMobileMana(p, m, true); OutgoingMobilePackets.CreateMobileMana(p, m, true);
for (var i = 0; i < Members.Count; ++i) for (var i = 0; i < Members.Count; ++i)
@ -226,7 +226,8 @@ namespace Server.Engines.PartySystem
return; return;
} }
Span<byte> buffer = stackalloc byte[OutgoingMessagePackets.GetMaxMessageLocalizedAffixLength(from.Name, "")]; Span<byte> buffer = stackalloc byte[OutgoingMessagePackets.GetMaxMessageLocalizedAffixLength(from.Name, "")]
.InitializePacket();
var length = OutgoingMessagePackets.CreateMessageLocalizedAffix( var length = OutgoingMessagePackets.CreateMessageLocalizedAffix(
buffer, buffer,
Serial.MinusOne, Serial.MinusOne,
@ -499,7 +500,8 @@ namespace Server.Engines.PartySystem
m_Mobile.SendLocalizedMessage(1005437); // You have rejoined the party. m_Mobile.SendLocalizedMessage(1005437); // You have rejoined the party.
m_Mobile.NetState.SendPartyMemberList(p); m_Mobile.NetState.SendPartyMemberList(p);
Span<byte> buffer = stackalloc byte[OutgoingMessagePackets.GetMaxMessageLocalizedAffixLength(m_Mobile.Name, "")].InitializePacket(); Span<byte> buffer = stackalloc byte[OutgoingMessagePackets.GetMaxMessageLocalizedAffixLength(m_Mobile.Name, "")]
.InitializePacket();
Span<byte> attrsPacket = stackalloc byte[OutgoingMobilePackets.MobileAttributesPacketLength].InitializePacket(); Span<byte> attrsPacket = stackalloc byte[OutgoingMobilePackets.MobileAttributesPacketLength].InitializePacket();
var ns = m_Mobile.NetState; var ns = m_Mobile.NetState;

View file

@ -54,7 +54,7 @@ namespace Server.Engines.PartySystem
return; return;
} }
Span<byte> buffer = stackalloc byte[GetPartyMemberListPacketLength(p.Count)]; Span<byte> buffer = stackalloc byte[GetPartyMemberListPacketLength(p.Count)].InitializePacket();
CreatePartyMemberList(buffer, p); CreatePartyMemberList(buffer, p);
ns.Send(buffer); ns.Send(buffer);
@ -70,7 +70,7 @@ namespace Server.Engines.PartySystem
return; return;
} }
Span<byte> buffer = stackalloc byte[GetPartyRemoveMemberPacketLength(p?.Count ?? 0)]; Span<byte> buffer = stackalloc byte[GetPartyRemoveMemberPacketLength(p?.Count ?? 0)].InitializePacket();
CreatePartyRemoveMember(buffer, m, p); CreatePartyRemoveMember(buffer, m, p);
ns.Send(buffer); ns.Send(buffer);
@ -110,7 +110,7 @@ namespace Server.Engines.PartySystem
return; return;
} }
Span<byte> buffer = stackalloc byte[GetPartyTextMessagePacketLength(text)]; Span<byte> buffer = stackalloc byte[GetPartyTextMessagePacketLength(text)].InitializePacket();
CreatePartyTextMessage(buffer, m, text, toAll); CreatePartyTextMessage(buffer, m, text, toAll);
ns.Send(buffer); ns.Send(buffer);

View file

@ -3864,7 +3864,7 @@ namespace Server.Mobiles
IsDeadPet = false; IsDeadPet = false;
Span<byte> buffer = stackalloc byte[OutgoingMobilePackets.BondedStatusPacketLength]; Span<byte> buffer = stackalloc byte[OutgoingMobilePackets.BondedStatusPacketLength].InitializePacket();
OutgoingMobilePackets.CreateBondedStatus(buffer, Serial, false); OutgoingMobilePackets.CreateBondedStatus(buffer, Serial, false);
Effects.SendPacket(Location, Map, buffer); Effects.SendPacket(Location, Map, buffer);