using System;
using System.IO;
using Crysome.Common.Network.Packets;

namespace Crysome.Common.Network.FileTransfer;

public sealed class FtSackPacket : IPacket
{
	public uint TransferId;

	public int HighestContiguous;

	public int[] NackList;

	public void Write(BinaryWriter w)
	{
		w.Write(TransferId);
		w.Write(HighestContiguous);
		short num = (short)((NackList != null) ? Math.Min(NackList.Length, 128) : 0);
		w.Write(num);
		for (int i = 0; i < num; i++)
		{
			w.Write(NackList[i]);
		}
	}

	public void Read(BinaryReader r)
	{
		TransferId = r.ReadUInt32();
		HighestContiguous = r.ReadInt32();
		int num = r.ReadInt16();
		NackList = new int[num];
		for (int i = 0; i < num; i++)
		{
			NackList[i] = r.ReadInt32();
		}
	}
}
