fix: Fixes client crash while selling items to NPC (#1296)

This commit is contained in:
Kamron Batman 2022-12-05 20:16:31 -08:00 committed by GitHub
parent f82f61b4c5
commit bfb987c758
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 12 deletions

View file

@ -22,7 +22,7 @@ namespace Server.Network;
public static class OutgoingVendorSellPackets
{
public static void SendVendorSellList(this NetState ns, Serial vendor, List<SellItemState> list)
public static void SendVendorSellList(this NetState ns, Serial vendor, HashSet<SellItemState> set)
{
if (ns.CannotSendPackets())
{
@ -30,9 +30,8 @@ public static class OutgoingVendorSellPackets
}
var maxLength = 9;
for (int i = 0; i < list.Count; i++)
foreach (var sis in set)
{
var sis = list[i];
var item = sis.Item;
maxLength += 14 + Math.Max(item.Name?.Length ?? 0, sis.Name?.Length ?? 0);
}
@ -42,11 +41,10 @@ public static class OutgoingVendorSellPackets
writer.Seek(2, SeekOrigin.Current);
writer.Write(vendor);
writer.Write((ushort)list.Count);
writer.Write((ushort)set.Count);
for (var i = 0; i < list.Count; i++)
foreach (var sis in set)
{
var sis = list[i];
var item = sis.Item;
writer.Write(item.Serial);
writer.Write((ushort)item.ItemID);