Ejemplo n.º 1
0
        private static void OnGumpButtonPressed(PacketReader reader)
        {
            int  senderSerial  = reader.ReadInt32();
            uint gumpId        = reader.ReadUInt32();
            int  buttonId      = reader.ReadInt32();
            int  switchesCount = reader.ReadInt32();

            int[] switches = null;

            for (int i = 0; i < switchesCount; i++)
            {
                if (switches == null)
                {
                    switches = new int[switchesCount];
                }

                switches[i] = reader.ReadInt32();
            }


            Engine.GumpList.TryRemove(gumpId, out _);

            if (Engine.Gumps.GetGump(gumpId, out Gump gump))
            {
                GumpEvent?.Invoke(gumpId, senderSerial, gump);
            }

            Engine.Gumps.Remove(gumpId, buttonId, switches);
        }
        private static void OnGumpButtonPressed(PacketReader reader)
        {
            int  senderSerial = reader.ReadInt32();
            uint gumpId       = reader.ReadUInt32();
            int  buttonId     = reader.ReadInt32();

            Engine.GumpList.TryRemove(gumpId, out _);

            if (Engine.Gumps.GetGump(gumpId, out Gump gump))
            {
                GumpEvent?.Invoke(gumpId, senderSerial, gump);
            }

            Engine.Gumps.Remove(gumpId, buttonId);
        }
        private static void OnGumpButtonPressed(PacketReader reader)
        {
            int  senderSerial  = reader.ReadInt32();
            uint gumpId        = reader.ReadUInt32();
            int  buttonId      = reader.ReadInt32();
            int  switchesCount = reader.ReadInt32();

            int[] switches = null;

            for (int i = 0; i < switchesCount; i++)
            {
                if (switches == null)
                {
                    switches = new int[switchesCount];
                }

                switches[i] = reader.ReadInt32();
            }

            int textEntryCount = reader.ReadInt32();
            List <(int Key, string Value)> textEntries = new List <(int Key, string Value)>();

            for (int i = 0; i < textEntryCount; i++)
            {
                int id     = reader.ReadInt16();
                int length = reader.ReadInt16();

                textEntries.Add((id, reader.ReadUnicodeStringBE(length)));
            }

            Engine.GumpList.TryRemove(gumpId, out _);

            if (Engine.Gumps.GetGump(gumpId, out Gump gump))
            {
                GumpEvent?.Invoke(gumpId, senderSerial, gump);
            }

            Engine.Gumps.Remove(gumpId, buttonId, switches, textEntries);
        }
Ejemplo n.º 4
0
        private static void OnCompressedGump(PacketReader reader)
        {
            int  senderSerial = reader.ReadInt32();
            uint gumpId       = reader.ReadUInt32();

            Engine.GumpList.AddOrUpdate(gumpId, senderSerial, (k, v) => senderSerial);

            int x = reader.ReadInt32();
            int y = reader.ReadInt32();
            int compressedLength   = reader.ReadInt32();
            int decompressedLength = reader.ReadInt32() + 1;

            if (compressedLength <= 4)
            {
                return;
            }

            compressedLength -= 4;

            byte[] decompressedBuffer = new byte[decompressedLength];

            byte[] compressedBuffer = reader.ReadByteArray(compressedLength);

            bool success = Compression.Uncompress(ref decompressedBuffer, ref decompressedLength, compressedBuffer,
                                                  compressedLength);

            if (!success)
            {
                return;
            }

            string layout = Encoding.ASCII.GetString(decompressedBuffer);

            int linesCount = reader.ReadInt32();

            compressedLength   = reader.ReadInt32();
            decompressedLength = reader.ReadInt32() + 1;

            string[] text = new string[linesCount];

            if (compressedLength > 4)
            {
                compressedLength -= 4;

                decompressedBuffer = new byte[decompressedLength];

                compressedBuffer = reader.ReadByteArray(compressedLength);

                success = Compression.Uncompress(ref decompressedBuffer, ref decompressedLength, compressedBuffer,
                                                 compressedLength);

                if (!success)
                {
                    return;
                }

                int offset = 0;

                for (int i = 0; i < linesCount; i++)
                {
                    int length = ((decompressedBuffer[offset] << 8) | decompressedBuffer[offset + 1]) * 2;
                    offset += 2;
                    text[i] = Encoding.BigEndianUnicode.GetString(decompressedBuffer, offset, length);
                    offset += length;
                }
            }

            Gump gump = GumpParser.Parse(senderSerial, gumpId, x, y, layout, text);

            Engine.Gumps.Add(gump);

            GumpEvent?.Invoke(gumpId, senderSerial, gump);
        }
Ejemplo n.º 5
0
        private static void OnCompressedGump(PacketReader reader)
        {
            int  senderSerial = reader.ReadInt32();
            uint gumpId       = reader.ReadUInt32();

            Engine.GumpList.AddOrUpdate(gumpId, senderSerial, (k, v) => senderSerial);

            int x = reader.ReadInt32();
            int y = reader.ReadInt32();
            int compressedLength   = reader.ReadInt32();
            int decompressedLength = reader.ReadInt32() + 1;

            if (compressedLength <= 4)
            {
                return;
            }

            compressedLength -= 4;

            byte[] decompressedBuffer = new byte[decompressedLength];

            byte[] compressedBuffer = reader.ReadByteArray(compressedLength);

            bool success = Compression.Uncompress(ref decompressedBuffer, ref decompressedLength, compressedBuffer,
                                                  compressedLength);

            if (!success)
            {
                return;
            }

            string layout = Encoding.ASCII.GetString(decompressedBuffer);

            int linesCount = reader.ReadInt32();

            compressedLength   = reader.ReadInt32();
            decompressedLength = reader.ReadInt32() + 1;

            string[] text = new string[linesCount];

            if (compressedLength > 4)
            {
                compressedLength -= 4;

                decompressedBuffer = new byte[decompressedLength];

                compressedBuffer = reader.ReadByteArray(compressedLength);

                success = Compression.Uncompress(ref decompressedBuffer, ref decompressedLength, compressedBuffer,
                                                 compressedLength);

                if (!success)
                {
                    return;
                }

                int offset = 0;

                for (int i = 0; i < linesCount; i++)
                {
                    int length = ((decompressedBuffer[offset] << 8) | decompressedBuffer[offset + 1]) * 2;
                    offset += 2;
                    text[i] = Encoding.BigEndianUnicode.GetString(decompressedBuffer, offset, length);
                    offset += length;
                }
            }

            try
            {
                Gump gump = GumpParser.Parse(senderSerial, gumpId, x, y, layout, text);
                Engine.Gumps.Add(gump);

                GumpEvent?.Invoke(gumpId, senderSerial, gump);
            }
            catch (Exception e)
            {
                e.ToExceptionless().SetProperty("Serial", senderSerial).SetProperty("GumpID", gumpId)
                .SetProperty("Layout", layout).SetProperty("Text", text)
                .SetProperty("Packet", reader.GetData()).SetProperty("Player", Engine.Player.ToString())
                .SetProperty("WorldItemCount", Engine.Items.Count())
                .SetProperty("WorldMobileCount", Engine.Mobiles.Count()).Submit();
            }
        }