Beispiel #1
0
        public CustomHousePlane(PacketReader reader)
        {
            byte[] data = reader.ReadBytes(4);
            Index = data[0];
            int uncompressedsize = data[1] + ((data[3] & 0xF0) << 4);
            int compressedLength = data[2] + ((data[3] & 0xF) << 8);

            ItemData = new byte[uncompressedsize];
            ZlibCompression.Unpack(ItemData, ref uncompressedsize, reader.ReadBytes(compressedLength), compressedLength);
            IsFloor = ((Index & 0x20) == 0x20);
            Index  &= 0x1F;
        }
Beispiel #2
0
        public CompressedGumpPacket(PacketReader reader)
            : base(0xDD, "Compressed Gump")
        {
            GumpSerial = reader.ReadInt32();
            GumpTypeID = reader.ReadInt32();
            X          = reader.ReadInt32();
            Y          = reader.ReadInt32();

            int compressedLength   = reader.ReadInt32() - 4;
            int decompressedLength = reader.ReadInt32();

            byte[] compressedData   = reader.ReadBytes(compressedLength);
            byte[] decompressedData = new byte[decompressedLength];

            if (ZlibCompression.Unpack(decompressedData, ref decompressedLength, compressedData, compressedLength) != ZLibError.Okay)
            {
                // Problem decompressing, go ahead and quit.
                return;
            }
            else
            {
                GumpData = Encoding.ASCII.GetString(decompressedData);

                int    numTextLines           = reader.ReadInt32();
                int    compressedTextLength   = reader.ReadInt32() - 4;
                int    decompressedTextLength = reader.ReadInt32();
                byte[] decompressedText       = new byte[decompressedTextLength];
                if (numTextLines > 0 && decompressedTextLength > 0)
                {
                    byte[] compressedTextData = reader.ReadBytes(compressedTextLength);
                    ZlibCompression.Unpack(decompressedText, ref decompressedTextLength, compressedTextData, compressedTextLength);
                    int           index = 0;
                    List <string> lines = new List <string>();
                    for (int i = 0; i < numTextLines; i++)
                    {
                        int length = decompressedText[index] * 256 + decompressedText[index + 1];
                        index += 2;
                        byte[] b = new byte[length * 2];
                        Array.Copy(decompressedText, index, b, 0, length * 2);
                        index += length * 2;
                        lines.Add(Encoding.BigEndianUnicode.GetString(b));
                    }
                    TextLines = lines.ToArray();
                }
                else
                {
                    TextLines = new string[0];
                }
            }
        }