Ejemplo n.º 1
0
        public override void Deserialize(Packet rawPacket)
        {
            this.rawPacket = rawPacket;
            var reader = new ArrayPacketReader(rawPacket.Payload);

            reader.Skip(3);

            DialogId = reader.ReadUInt();
            MenuId   = reader.ReadUShort();
            var questionLength = reader.ReadByte();

            Question = reader.ReadString(questionLength);
            var responsesCount = reader.ReadByte();

            if (responsesCount == byte.MaxValue)
            {
                throw new PacketParsingException(rawPacket, $"Responses count is {responsesCount}. Cannot have byte 1 based index for all responses (last index would be 256 which cannot be encoded to a single byte).");
            }

            Responses = new DialogBoxResponse[responsesCount];


            for (byte i = 0; i < responsesCount; i++)
            {
                var modelId            = reader.ReadModelId();
                var color              = reader.ReadColor();
                var responseTextLength = reader.ReadByte();
                var responseText       = reader.ReadString(responseTextLength);

                Responses[i] = new DialogBoxResponse((byte)(i + 1), modelId, color, responseText);
            }
        }
Ejemplo n.º 2
0
        public override void Deserialize(Packet rawPacket)
        {
            this.rawPacket = rawPacket;

            var reader = new ArrayPacketReader(rawPacket.Payload);

            reader.Skip(1);
            Account  = reader.ReadString(30);
            Password = reader.ReadString(30);
        }
Ejemplo n.º 3
0
        public override void Deserialize(Packet rawPacket)
        {
            this.rawPacket = rawPacket;
            var reader = new ArrayPacketReader(rawPacket.Payload);

            reader.ReadByte();
            reader.ReadUShort();
            Type     = (SpeechType)reader.ReadByte();
            Color    = reader.ReadUShort();
            Font     = reader.ReadUShort();
            Language = reader.ReadString(4);
            if (((int)Type & 0xC0) != 0)
            {
                ushort rawBytes     = reader.ReadUShort();
                int    keywordCount = (rawBytes & 0x0FFF) >> 4;
                if (keywordCount > 0)
                {
                    reader.ReadByte();
                    keywordCount--;
                }
                while (keywordCount != 0)
                {
                    reader.ReadUShort();
                    keywordCount--;
                }

                Text = reader.ReadNullTerminatedString();
            }
            else
            {
                Text = reader.ReadNullTerminatedUnicodeString();
            }
        }
Ejemplo n.º 4
0
        public override void Deserialize(Packet rawPacket)
        {
            this.rawPacket = rawPacket;

            var reader = new ArrayPacketReader(rawPacket.Payload);

            reader.Skip(3);

            GumpId     = new GumpInstanceId(reader.ReadUInt());
            GumpTypeId = new GumpTypeId(reader.ReadUInt());
            X          = reader.ReadUInt();
            Y          = reader.ReadUInt();

            var commandSectionLength = reader.ReadUShort();

            Commands = reader.ReadString(commandSectionLength);

            var textLinesCount = reader.ReadUShort();

            TextLines = new string[textLinesCount];
            for (var i = 0; i < textLinesCount; i++)
            {
                var textLength = reader.ReadUShort();
                TextLines[i] = reader.ReadUnicodeString(textLength);
            }
        }
Ejemplo n.º 5
0
        public override void Deserialize(Packet rawPacket)
        {
            this.rawPacket = rawPacket;
            var reader = new ArrayPacketReader(rawPacket.Payload);

            reader.Skip(3);
            PlayerId      = reader.ReadObjectId();
            PlayerName    = reader.ReadString(30);
            CurrentHealth = reader.ReadUShort();
            MaxHealth     = reader.ReadUShort();
            CanRename     = reader.ReadBool();
            var validStats = reader.ReadByte(); // status flag / valid stats

            if (validStats == 0)
            {
                return;
            }

            if (validStats != 1 && validStats != 7)
            {
                throw new NotImplementedException($"unknown validStats {validStats}");
            }

            reader.ReadByte(); // sex + race
            Strength       = reader.ReadUShort();
            Dexterity      = reader.ReadUShort();
            Intelligence   = reader.ReadUShort();
            CurrentStamina = reader.ReadUShort();
            MaxStamina     = reader.ReadUShort();
            CurrentMana    = reader.ReadUShort();
            MaxMana        = reader.ReadUShort();
            Gold           = reader.ReadUInt();
            Armor          = reader.ReadUShort();
            Weight         = reader.ReadUShort();
        }
Ejemplo n.º 6
0
        public override void Deserialize(Packet rawPacket)
        {
            this.rawPacket = rawPacket;
            var reader = new ArrayPacketReader(rawPacket.Payload);

            reader.Skip(3);

            Id       = reader.ReadObjectId();
            Model    = reader.ReadModelId();
            Type     = (SpeechType)reader.ReadByte();
            Color    = (Color)reader.ReadUShort();
            Font     = reader.ReadUShort();
            Language = reader.ReadString(4);
            Name     = reader.ReadString(30);
            Message  = reader.ReadNullTerminatedUnicodeString();
        }
Ejemplo n.º 7
0
        public override void Deserialize(Packet rawPacket)
        {
            this.rawPacket = rawPacket;
            var reader = new ArrayPacketReader(rawPacket.Payload);

            reader.Skip(3);

            var charCount = reader.ReadByte();

            Characters = new CharacterItem[charCount];
            for (int i = 0; i < charCount; i++)
            {
                string name     = reader.ReadString(30);
                string password = reader.ReadString(30);
                Characters[i] = new CharacterItem
                {
                    Name = name,
                };
            }
        }
Ejemplo n.º 8
0
        public override void Deserialize(Packet rawPacket)
        {
            this.rawPacket = rawPacket;

            var reader = new ArrayPacketReader(rawPacket.Payload);

            reader.Skip(1);
            var length = reader.ReadUShort();

            Type       = (SpeechType)reader.ReadByte();
            Color      = reader.ReadColor();
            SpeechFont = reader.ReadUShort();
            Message    = reader.ReadString(length - 8);
        }
Ejemplo n.º 9
0
        public override void Deserialize(Packet rawPacket)
        {
            this.rawPacket = rawPacket;

            var reader = new ArrayPacketReader(rawPacket.Payload);

            reader.Skip(3);

            SpeakerId   = reader.ReadObjectId();
            SpeakerBody = reader.ReadModelId();
            Type        = (SpeechType)reader.ReadByte();
            Color       = reader.ReadColor();
            Font        = reader.ReadUShort();
            MessageId   = new MessageId(reader.ReadInt());
            Name        = reader.ReadString(29);
            Arguments   = reader.ReadNullTerminatedUnicodeString();
        }
Ejemplo n.º 10
0
        public override void Deserialize(Packet rawPacket)
        {
            this.rawPacket = rawPacket;

            var reader = new ArrayPacketReader(rawPacket.Payload);

            reader.Skip(5);

            CharacterName = reader.ReadString(30);
            reader.Skip(2);  // unknown
            Flags = (ClientFlags)reader.ReadUInt();
            reader.Skip(4);  // unknown
            LoginCount = reader.ReadUInt();
            reader.Skip(16); // unknown
            SlotChosen = reader.ReadUInt();

            ClientIp = new byte[4];
            reader.Read(ClientIp, 0, 4);
        }
Ejemplo n.º 11
0
        public override void Deserialize(Packet rawPacket)
        {
            this.rawPacket = rawPacket;

            var reader = new ArrayPacketReader(rawPacket.Payload);

            reader.Skip(1);

            var packetSize = reader.ReadUShort();

            SpeakerId   = reader.ReadObjectId();
            SpeakerBody = reader.ReadModelId();
            reader.ReadByte(); // type
            Color     = reader.ReadColor();
            Font      = reader.ReadUShort();
            MessageId = new MessageId(reader.ReadInt());
            reader.ReadByte(); // ignoring flags
            Name  = reader.ReadString(30);
            Affix = reader.ReadNullTerminatedString();
        }
Ejemplo n.º 12
0
        public override void Deserialize(Packet rawPacket)
        {
            this.rawPacket = rawPacket;

            var reader = new ArrayPacketReader(rawPacket.Payload);

            reader.Skip(3);

            var count = reader.ReadUShort();

            Servers = new ServerListItem[count];
            for (int i = 0; i < count; i++)
            {
                var id          = reader.ReadUShort();
                var name        = reader.ReadString(32);
                var fullPercent = reader.ReadByte();
                var timeZone    = reader.ReadByte();
                var ip          = reader.ReadUInt();

                Servers[i] = new ServerListItem(id, name, fullPercent, timeZone, ip);
            }
        }