/// <summary>
 /// Creates a new instance of StringPacker.
 /// </summary>
 /// <param name="strings">The strings to add.</param>
 public StringPacker(params string[] strings)
 {
     int totallength = strings.Length + 1;
     foreach (string str in strings)
         totallength += str.Length;
     stringPacket = new DataPacket(new byte[totallength]);
     stringPacket.WriteByte((byte)strings.Length, 0);
     int nextoffset = 1;
     foreach (string str in strings)
     {
         stringPacket.WriteStringWithLength(str, nextoffset, out nextoffset);
     }
 }
        /// <summary>
        /// Adds a string to the packet.
        /// </summary>
        /// <param name="str">The string to add.</param>
        public void AddString(string str)
        {
            DataPacket expanded = new DataPacket(new byte[Size + str.Length + 1]); // creates a new packet

            expanded.WriteByte((byte)(stringPacket.ReadByte(0) + 1), 0); // sets a new string packet size
            expanded.WriteBytes(stringPacket.Copy(), 0); // copies all the current strings
            if (string.IsNullOrEmpty(str) || string.IsNullOrWhiteSpace(str))
                expanded.WriteByte(0, Size);
            else
                expanded.WriteStringWithLength(str, Size); // writes the new string at the end

            stringPacket.Dispose(); // disposes the old packet
            stringPacket = expanded; // sets the old packet to be the new
        }
 public static DataPacket GeneralDataA(uint UID, uint A, uint B, uint C, ushort Type, ushort E, ushort X, ushort Y)
 {
     DataPacket Packet = new DataPacket(45, 10010);
     Packet.WriteUInt32(UID, 4);
     Packet.WriteUInt32(A, 8);
     Packet.WriteUInt32(B, 12);
     Packet.WriteUInt32(C, 16);
     Packet.WriteUInt16(Type, 20);
     Packet.WriteUInt16(E, 22);
     Packet.WriteUInt16(X, 24);
     Packet.WriteUInt16(Y, 26);
     Packet.WriteUInt32(0, 28);
     Packet.WriteUInt32(0, 32);
     Packet.WriteByte(0, 36);
     return Packet;
 }