示例#1
0
        public override void Deserialize(Packet rawPacket)
        {
            this.rawPacket = rawPacket;
            var reader = new ArrayPacketReader(rawPacket.Payload);

            reader.Skip(1);
            ItemId = reader.ReadObjectId();
            Type   = reader.ReadModelId();
            reader.Skip(1);
            Layer    = reader.ReadLayer();
            PlayerId = reader.ReadObjectId();
            Color    = reader.ReadColor();
        }
示例#2
0
        public override void Deserialize(Packet rawPacket)
        {
            this.rawPacket = rawPacket;

            var reader = new ArrayPacketReader(rawPacket.Payload);

            reader.Skip(2);
            Id = reader.ReadUShort();
            reader.Skip(2);

            var x = reader.ReadUShort();
            var y = reader.ReadUShort();

            Location = new Location3D(x, y, 0);
        }
        public override void Deserialize(Packet rawPacket)
        {
            this.rawPacket = rawPacket;

            var reader = new ArrayPacketReader(rawPacket.Payload);

            reader.Skip(1);

            ItemId = reader.ReadObjectId();
            Type   = reader.ReadModelId();
            reader.Skip(1);
            Amount      = reader.ReadUShort();
            Location    = new Location2D(reader.ReadUShort(), reader.ReadUShort());
            ContainerId = reader.ReadObjectId();
            Color       = (Color)reader.ReadUShort();
        }
        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);
            }
        }
示例#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();
        }
示例#6
0
        public override void Deserialize(Packet rawPacket)
        {
            _rawPacket = rawPacket;

            var reader = new ArrayPacketReader(rawPacket.Payload);

            reader.Skip(3);

            Serial               = reader.ReadUInt();
            BoatSpeed            = reader.ReadByte();
            (MovingDirection, _) = reader.ReadDirection();
            (FacingDirection, _) = reader.ReadDirection();
            ushort x = reader.ReadUShort();
            ushort y = reader.ReadUShort();
            ushort z = reader.ReadUShort();

            int count = reader.ReadUShort();

            PositionEntities = new PositionEntity[count];
            for (int i = 0; i < count; i++)
            {
                uint   cSerial = reader.ReadUInt();
                ushort cx      = reader.ReadUShort();
                ushort cy      = reader.ReadUShort();
                ushort cz      = reader.ReadUShort();

                PositionEntities[i] = new PositionEntity(cSerial, new Location3D(cx, cy, 0));
            }
        }
示例#7
0
        public override void Deserialize(Packet rawPacket)
        {
            this.rawPacket = rawPacket;
            var reader = new ArrayPacketReader(rawPacket.Payload);

            reader.Skip(1);

            PlayerId = reader.ReadObjectId();
            uint unknown1 = reader.ReadUInt();

            BodyType = reader.ReadModelId();
            ushort xloc     = reader.ReadUShort();
            ushort yloc     = reader.ReadUShort();
            byte   unknown2 = reader.ReadByte();
            sbyte  zloc     = reader.ReadSByte();

            Location = new Location3D(xloc, yloc, zloc);
            (Direction, MovementType) = reader.ReadDirection();

            //reader.Skip(5);

            //var minX = reader.ReadUShort();
            //var minY = reader.ReadUShort();
            //var maxX = reader.ReadUShort();
            //var maxY = reader.ReadUShort();
            //MapBoundary = new MapBoundary(minX, minY, maxX, maxY);
        }
示例#8
0
        public override void Deserialize(Packet rawPacket)
        {
            this.rawPacket = rawPacket;
            var reader = new ArrayPacketReader(rawPacket.Payload);

            reader.Skip(3);
            byte type = reader.ReadByte();

            if (type == 0x24)
            {
                string skillText = reader.ReadNullTerminatedString();

                bool skillFound = false;
                foreach (var pair in skills)
                {
                    if (skillText.Equals(pair.Value))
                    {
                        Skill      = pair.Key;
                        skillFound = true;
                        break;
                    }
                }
                if (!skillFound)
                {
                    throw new NotImplementedException($"Unknown skill text: {skillText ?? "null"}");
                }
            }
        }
示例#9
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);
            }
        }
示例#10
0
        public override void Deserialize(Packet rawPacket)
        {
            this.rawPacket = rawPacket;
            var reader = new ArrayPacketReader(rawPacket.Payload);

            reader.Skip(3);
            byte type = reader.ReadByte();

            var values = new List <SkillValue>();

            ushort skillNumber;
            ushort value;
            ushort unmodifiedValue;

            switch (type)
            {
            case 0x00:
                skillNumber = reader.ReadUShort();

                while (skillNumber != 0)
                {
                    value           = reader.ReadUShort();
                    unmodifiedValue = reader.ReadUShort();
                    reader.Skip(1);     // skill lock

                    values.Add(new SkillValue((Skill)skillNumber, value, unmodifiedValue));

                    skillNumber = reader.ReadUShort();
                }
                break;

            case 0xFF:
                skillNumber = reader.ReadUShort();
                var skill = skillNumber != 0 ? (Skill)(skillNumber + 1) : Skill.None;
                value           = reader.ReadUShort();
                unmodifiedValue = reader.ReadUShort();
                reader.Skip(1);     // skill lock
                values.Add(new SkillValue(skill, value, unmodifiedValue));
                break;

            default:
                throw new NotImplementedException($"Unknown type {type} of SendSkills packet.");
            }


            Values = values.ToArray();
        }
示例#11
0
        public override void Deserialize(Packet rawPacket)
        {
            var reader = new ArrayPacketReader(rawPacket.Payload);

            reader.Skip(1);

            Level = reader.ReadByte();
        }
示例#12
0
        public override void Deserialize(Packet rawPacket)
        {
            this.rawPacket = rawPacket;

            var reader = new ArrayPacketReader(rawPacket.Payload);

            reader.Skip(1);
            ItemId = reader.ReadObjectId();
        }
        public override void Deserialize(Packet rawPacket)
        {
            this.rawPacket = rawPacket;

            var reader = new ArrayPacketReader(rawPacket.Payload);

            reader.Skip(3);
            Type = reader.ReadByte();
        }
示例#14
0
        public void Deserialize(Packet rawPacket)
        {
            this.rawPacket = rawPacket;

            var reader = new ArrayPacketReader(rawPacket.Payload);

            reader.Skip(5);
            GumpTypeId = (GumpTypeId)reader.ReadUInt();
        }
示例#15
0
        public override void Deserialize(Packet rawPacket)
        {
            this.rawPacket = rawPacket;

            var reader = new ArrayPacketReader(rawPacket.Payload);
            reader.Skip(1);

            Choice = (PauseClientChoice) reader.ReadByte();
        }
示例#16
0
        public override void Deserialize(Packet rawPacket)
        {
            this.rawPacket = rawPacket;
            var reader = new ArrayPacketReader(rawPacket.Payload);

            reader.Skip(1);

            ChosenServerId = reader.ReadUShort();
        }
示例#17
0
        public override void Deserialize(Packet rawPacket)
        {
            this.rawPacket = rawPacket;
            var reader = new ArrayPacketReader(rawPacket.Payload);

            reader.Skip(1);

            Flags = reader.ReadUInt();
        }
示例#18
0
        public void Deserialize(Packet rawPacket)
        {
            this.rawPacket = rawPacket;

            var reader = new ArrayPacketReader(rawPacket.Payload);

            reader.Skip(5);
            MapId = reader.ReadByte();
        }
示例#19
0
        public override void Deserialize(Packet rawPacket)
        {
            this.rawPacket = rawPacket;
            var reader = new ArrayPacketReader(rawPacket.Payload);

            reader.Skip(3);
            uint   rawId   = reader.ReadUInt();
            ushort rawType = reader.ReadUShort();

            uint finalId;

            if ((rawId & 0x80000000) != 0)
            {
                finalId = rawId - 0x80000000;
                Amount  = reader.ReadUShort();
            }
            else
            {
                Amount  = 1;
                finalId = rawId;
            }
            Id = new ObjectId(finalId);

            if ((rawType & 0x8000) != 0)
            {
                throw new PacketParsingException(rawPacket, "Not implementated: Type & 0x8000");
            }

            Type = rawType;

            ushort xloc = reader.ReadUShort();
            ushort yloc = reader.ReadUShort();

            if ((xloc & 0x8000) != 0)
            {
                xloc -= 0x8000;

                (Facing, _) = reader.ReadDirection();
            }

            sbyte zloc = reader.ReadSByte();

            if ((yloc & 0x8000) != 0)
            {
                yloc -= 0x8000;
                Dye   = (Color)reader.ReadUShort();
            }

            if ((yloc & 0x4000) != 0)
            {
                yloc -= 0x4000;
                Flags = (ObjectFlag)reader.ReadByte();
            }

            Location = new Location3D(xloc, yloc, zloc);
        }
        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);
        }
示例#21
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);
        }
示例#22
0
        public override void Deserialize(Packet rawPacket)
        {
            this.rawPacket = rawPacket;
            var reader = new ArrayPacketReader(rawPacket.Payload);

            reader.Skip(1);
            PlayerId      = reader.ReadObjectId();
            MaxHealth     = reader.ReadUShort();
            CurrentHealth = reader.ReadUShort();
        }
示例#23
0
        public override void Deserialize(Packet rawPacket)
        {
            this.rawPacket = rawPacket;
            var reader = new ArrayPacketReader(rawPacket.Payload);

            reader.Skip(3);
            Id         = new GumpInstanceId(reader.ReadUInt());
            GumpTypeId = new GumpTypeId(reader.ReadUInt());
            TriggerId  = new GumpControlId(reader.ReadUInt());
        }
        public override void Deserialize(Packet rawPacket)
        {
            var reader = new ArrayPacketReader(rawPacket.Payload);

            reader.Skip(1);
            GameServerIp = new byte[4];
            reader.Read(GameServerIp, 0, 4);
            GameServerPort = reader.ReadUShort();
            payload        = rawPacket.Payload;
        }
示例#25
0
        public override void Deserialize(Packet rawPacket)
        {
            this.rawPacket = rawPacket;

            var reader = new ArrayPacketReader(rawPacket.Payload);

            reader.Skip(1);

            ContainerId = reader.ReadObjectId();
            GumpModel   = reader.ReadModelId();
        }
示例#26
0
        public override void Deserialize(Packet rawPacket)
        {
            this.rawPacket = rawPacket;

            var reader = new ArrayPacketReader(rawPacket.Payload);

            reader.Skip(1);
            Seed = new byte[4];
            reader.Read(Seed, 0, 4);

            ClientVersion = new Version(reader.ReadInt(), reader.ReadInt(), reader.ReadInt(), reader.ReadInt());
        }
示例#27
0
        public override void Deserialize(Packet rawPacket)
        {
            this.rawPacket = rawPacket;

            var reader = new ArrayPacketReader(rawPacket.Payload);

            reader.Skip(1);

            var size = reader.ReadUShort();

            GumpId     = (GumpInstanceId)reader.ReadUInt();
            GumpTypeId = (GumpTypeId)reader.ReadUInt();
            X          = reader.ReadInt();
            Y          = reader.ReadInt();
            int clen = reader.ReadInt() - 4;
            int dlen = (int)reader.ReadUInt();

            byte[] data = new byte[clen];
            reader.Read(data, 0, clen);
            byte[] decData = new byte[dlen];

            Decompress(data, 0, decData, dlen);
            Commands = Encoding.UTF8.GetString(decData);

            uint linesNum = reader.ReadUInt();

            if (linesNum > 0)
            {
                clen = reader.ReadInt() - 4;
                dlen = reader.ReadInt();

                data = new byte[clen];
                reader.Read(data, 0, clen);

                decData = new byte[dlen];
                Decompress(data, 0, decData, dlen);
                TextLines = new string[linesNum];

                for (int i = 0, index = 0; i < linesNum; i++)
                {
                    int    length = (decData[index++] << 8) | decData[index++];
                    byte[] text   = new byte[length * 2];
                    Buffer.BlockCopy(decData, index, text, 0, text.Length);
                    index       += text.Length;
                    TextLines[i] = Encoding.BigEndianUnicode.GetString(text);
                }
            }
            else
            {
                TextLines = Array.Empty <string>();
            }
        }
示例#28
0
        public override void Deserialize(Packet rawPacket)
        {
            this.rawPacket = rawPacket;
            var reader = new ArrayPacketReader(rawPacket.Payload);

            reader.Skip(1);

            PlayerId = reader.ReadObjectId();
            BodyType = reader.ReadModelId();
            reader.Skip(1); // unknown

            Color = reader.ReadColor();
            Flags = reader.ReadByte();

            var xloc = reader.ReadUShort();
            var yloc = reader.ReadUShort();

            reader.Skip(2); // unknown
            (Direction, MovementType) = reader.ReadDirection();
            var zloc = reader.ReadSByte();

            Location = new Location3D(xloc, yloc, zloc);
        }
示例#29
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);
        }
示例#30
0
        public override void Deserialize(Packet rawPacket)
        {
            this.rawPacket = rawPacket;

            var reader = new ArrayPacketReader(rawPacket.Payload);

            reader.Skip(1);

            MapId      = reader.ReadObjectId();
            MapArt     = reader.ReadModelId();
            UpperLeft  = new Location2D(reader.ReadUShort(), reader.ReadUShort());
            LowerRight = new Location2D(reader.ReadUShort(), reader.ReadUShort());
            Width      = reader.ReadUShort();
            Height     = reader.ReadUShort();
        }