Example #1
0
        public override void Read(StreamHandler reader)
        {
            Caster   = reader.ReadPackedGuid();
            SpellId  = reader.ReadUInt32();
            Duration = reader.ReadInt32();

            HaveFlags = reader.ReadBoolean();
            if (HaveFlags)
            {
                TargetFlags1 = reader.ReadUInt32();
                TargetFlags2 = reader.ReadUInt32();
            }

            Unk_HaveData2 = reader.ReadBoolean();
            if (Unk_HaveData2)
            {
                Unk_Guid1 = reader.ReadPackedGuid();
                Unk_UInt3 = reader.ReadUInt32();
                Unk_Byte  = reader.ReadByte();
                if (Unk_Byte == 2)
                {
                    Unk_Guid2 = reader.ReadPackedGuid();
                }
            }
        }
Example #2
0
        public override void Read(StreamHandler reader)
        {
            uint DisplayedItemCount = reader.ReadUInt32();

            Items = new AuctionListItem[DisplayedItemCount];
            for (uint i = 0; i < DisplayedItemCount; ++i)
                Items[i] = reader.ReadStruct<AuctionListItem>();

            TotalItemCount = reader.ReadUInt32();
            NextSearchDelayMs = reader.ReadUInt32();
        }
Example #3
0
        public override void Read(StreamHandler reader)
        {
            ContainerSlot = (InventorySlot)reader.ReadByte();
            Slot          = (InventorySlot)reader.ReadByte();
            CastId        = reader.ReadByte();
            SpellId       = reader.ReadUInt32();
            ItemGuid      = reader.ReadGuid();
            GlyphSlot     = reader.ReadUInt32();
            UnkFlags      = reader.ReadByte();

            TargetData.Read(reader);
        }
Example #4
0
        public override void Read(StreamHandler reader)
        {
            ContainerSlot = (InventorySlot)reader.ReadByte();
            Slot = (InventorySlot)reader.ReadByte();
            CastId = reader.ReadByte();
            SpellId = reader.ReadUInt32();
            ItemGuid = reader.ReadGuid();
            GlyphSlot = reader.ReadUInt32();
            UnkFlags = reader.ReadByte();

            TargetData.Read(reader);
        }
Example #5
0
        public override void Read(StreamHandler reader)
        {
            uint DisplayedItemCount = reader.ReadUInt32();

            Items = new AuctionListItem[DisplayedItemCount];
            for (uint i = 0; i < DisplayedItemCount; ++i)
            {
                Items[i] = reader.ReadStruct <AuctionListItem>();
            }

            TotalItemCount    = reader.ReadUInt32();
            NextSearchDelayMs = reader.ReadUInt32();
        }
Example #6
0
        public override void Read(StreamHandler reader)
        {
            this.Roles = (GroupRoles)reader.ReadUInt32();

            reader.Skip(2); // 2 bools

            uint count = reader.ReadByte();
            Dungeons = new DungeonEntry[count];
            for (uint i = 0; i < count; ++i)
                Dungeons[i] = new DungeonEntry(reader.ReadUInt32());

            reader.Skip(4);

            this.Comment = reader.ReadCString();
        }
Example #7
0
 public override void Read(StreamHandler Reader)
 {
     this.Count      = Reader.ReadByte();
     this.Seed       = Reader.ReadUInt32();
     this.ClientSeed = Reader.ReadBytes(16);
     this.ServerSeed = Reader.ReadBytes(16);
 }
Example #8
0
 protected override void ElementRead(StreamHandler reader, int index)
 {
     if (index == -5)
         this.Unk = reader.ReadUInt32();
     else
         this.Data[-index - 1] = reader.ReadBytes(reader.ReadInt32());
 }
Example #9
0
 protected override void ElementRead(StreamHandler reader, int index)
 {
     if (index == -2)
         this.NewValue = reader.ReadUInt32();
     else
         base.ElementRead(reader, index);
 }
Example #10
0
        public void Read(StreamHandler Reader)
        {
            Flags = (SpellCastTargetFlags)Reader.ReadUInt32();

            if ((Flags & (
                     SpellCastTargetFlags.Unit | SpellCastTargetFlags.Unk2 |
                     SpellCastTargetFlags.Object |
                     SpellCastTargetFlags.Corpse | SpellCastTargetFlags.PvPCorpse
                     )) != 0)
            {
                TargetUnit = Reader.ReadPackedGuid();
            }

            if ((Flags & (SpellCastTargetFlags.Item | SpellCastTargetFlags.TradeItem)) != 0)
            {
                TargetItem = Reader.ReadPackedGuid();
            }

            if ((Flags & SpellCastTargetFlags.SourceLocation) != 0)
            {
                SourceTransportGuid = Reader.ReadPackedGuid();
                SourceLocation      = Reader.ReadVector3();
            }

            if ((Flags & SpellCastTargetFlags.DestLocation) != 0)
            {
                DestTransportGuid = Reader.ReadPackedGuid();
                DestLocation      = Reader.ReadVector3();
            }

            if ((Flags & SpellCastTargetFlags.String) != 0)
            {
                StringTarget = Reader.ReadCString();
            }
        }
Example #11
0
        public void Read(StreamHandler Reader)
        {
            Flags = (SpellCastTargetFlags)Reader.ReadUInt32();

            if ((Flags & (
                SpellCastTargetFlags.Unit   | SpellCastTargetFlags.Unk2 |
                SpellCastTargetFlags.Object |
                SpellCastTargetFlags.Corpse | SpellCastTargetFlags.PvPCorpse
                )) != 0)
                TargetUnit = Reader.ReadPackedGuid();

            if ((Flags & (SpellCastTargetFlags.Item | SpellCastTargetFlags.TradeItem)) != 0)
                TargetItem = Reader.ReadPackedGuid();

            if ((Flags & SpellCastTargetFlags.SourceLocation) != 0)
            {
                SourceTransportGuid = Reader.ReadPackedGuid();
                SourceLocation = Reader.ReadVector3();
            }

            if ((Flags & SpellCastTargetFlags.DestLocation) != 0)
            {
                DestTransportGuid = Reader.ReadPackedGuid();
                DestLocation = Reader.ReadVector3();
            }

            if ((Flags & SpellCastTargetFlags.String) != 0)
                StringTarget = Reader.ReadCString();
        }
Example #12
0
 protected override void ElementRead(StreamHandler reader, int index)
 {
     if (index == -1)
         this.ChangeCounter = reader.ReadUInt32();
     else
         throw new InvalidOperationException("Unknown read element: " + index);
 }
Example #13
0
        private UpdateFields ReadValues(StreamHandler Reader)
        {
            var values = new UpdateFields();

            byte blocksCount = Reader.ReadByte();

            int[] updatemask = new int[blocksCount];

            for (int i = 0; i < updatemask.Length; ++i)
            {
                updatemask[i] = Reader.ReadInt32();
            }

            var mask = new BitArray(updatemask);

            for (uint i = 0; i < mask.Count; ++i)
            {
                if (mask[(int)i])
                {
                    values[i] = Reader.ReadUInt32();
                }
            }

            return(values);
        }
Example #14
0
 public override void Read(StreamHandler Reader)
 {
     this.Count = Reader.ReadByte();
     this.Seed = Reader.ReadUInt32();
     this.ClientSeed = Reader.ReadBytes(16);
     this.ServerSeed = Reader.ReadBytes(16);
 }
Example #15
0
 protected override void ReadElement(StreamHandler reader, MovementStatusElements element, MovementStatus status, byte[] guid, byte[] tguid)
 {
     if (element == MovementStatusElements.GenericDword0)
         this.ChangeCounter = reader.ReadUInt32();
     else
         base.ReadElement(reader, element, status, guid, tguid);
 }
Example #16
0
        public void Read(StreamHandler Reader)
        {
            Slot  = Reader.ReadByte();
            Spell = Reader.ReadUInt32();

            Caster = Unit;

            if (Spell != 0)
            {
                Flags   = (AuraFlags)Reader.ReadUInt16();
                Level   = Reader.ReadByte();
                Charges = Reader.ReadByte();

                if ((Flags & AuraFlags.NotCaster) == 0)
                {
                    Caster = Reader.ReadPackedGuid();
                }

                if ((Flags & AuraFlags.Duration) != 0)
                {
                    MaxDuration = Reader.ReadUInt32();
                    var currentDurationMs = Reader.ReadUInt32();

                    this.AppliedTime = (uint)Environment.TickCount - currentDurationMs;
                }

                if ((Flags & AuraFlags.BasePoints) != 0)
                {
                    for (int i = 0; i < MaxEffects; ++i)
                    {
                        if ((Flags & (AuraFlags)(1 << i)) != 0)
                        {
                            BasePoints[i] = Reader.ReadInt32();
                        }
                        else
                        {
                            BasePoints[i] = 0;
                        }
                    }
                }
                else
                {
                    Array.Clear(BasePoints, 0, MaxEffects);
                }
            }
        }
Example #17
0
        public override void Read(StreamHandler reader)
        {
            this.Roles = (GroupRoles)reader.ReadUInt32();

            reader.Skip(2); // 2 bools

            uint count = reader.ReadByte();

            Dungeons = new DungeonEntry[count];
            for (uint i = 0; i < count; ++i)
            {
                Dungeons[i] = new DungeonEntry(reader.ReadUInt32());
            }

            reader.Skip(4);

            this.Comment = reader.ReadCString();
        }
Example #18
0
        private void ReadObjectDestroyUpdate(StreamHandler Reader)
        {
            uint nObjects = Reader.ReadUInt32();

            for (var i = 0; i < nObjects; ++i)
            {
                m_destroyedObjects.Add(Reader.ReadPackedGuid());
            }
        }
Example #19
0
        public override void Read(StreamHandler reader)
        {
            this.Unit = reader.ReadPackedGuid();

            var count = reader.ReadInt32();
            this.ThreatList = new ThreatUpdatePair[count];
            for (int i = 0; i < count; ++i)
                this.ThreatList[i] = new ThreatUpdatePair { Unit = reader.ReadPackedGuid(), Threat = reader.ReadUInt32() };
        }
Example #20
0
 protected override void ElementRead(StreamHandler reader, int index)
 {
     if (index == -1)
     {
         this.ChangeCounter = reader.ReadUInt32();
     }
     else
     {
         throw new InvalidOperationException("Unknown read element: " + index);
     }
 }
Example #21
0
 protected override void ReadElement(StreamHandler reader, MovementStatusElements element, MovementStatus status, byte[] guid, byte[] tguid)
 {
     if (element == MovementStatusElements.GenericDword0)
     {
         this.ChangeCounter = reader.ReadUInt32();
     }
     else
     {
         base.ReadElement(reader, element, status, guid, tguid);
     }
 }
 protected override void ElementRead(StreamHandler reader, int index)
 {
     if (index == -2)
     {
         this.NewValue = reader.ReadUInt32();
     }
     else
     {
         base.ElementRead(reader, index);
     }
 }
Example #23
0
 protected override void ElementRead(StreamHandler reader, int index)
 {
     if (index == -5)
     {
         this.Unk = reader.ReadUInt32();
     }
     else
     {
         this.Data[-index - 1] = reader.ReadBytes(reader.ReadInt32());
     }
 }
Example #24
0
        public override void Read(StreamHandler reader)
        {
            Dungeon      = new DungeonEntry(reader.ReadUInt32());
            State        = (LFGState)reader.ReadByte();
            ProposalId   = reader.ReadUInt32();
            BossesKilled = reader.ReadUInt32();
            SameDungeon  = reader.ReadBoolean();

            byte count = reader.ReadByte();

            this.Players = new PlayerInfo[count];
            for (byte i = 0; i < count; ++i)
            {
                this.Players[i].Role       = (GroupRoles)reader.ReadUInt32();
                this.Players[i].SelfPlayer = reader.ReadBoolean();
                this.Players[i].InDungeon  = reader.ReadBoolean();
                this.Players[i].SameGroup  = reader.ReadBoolean();
                this.Players[i].Answered   = reader.ReadBoolean();
                this.Players[i].Accepted   = reader.ReadBoolean();
            }
        }
Example #25
0
        public override void Read(StreamHandler reader)
        {
            Caster = reader.ReadPackedGuid();
            SpellId = reader.ReadUInt32();
            Duration = reader.ReadInt32();

            HaveFlags = reader.ReadBoolean();
            if (HaveFlags)
            {
                TargetFlags1 = reader.ReadUInt32();
                TargetFlags2 = reader.ReadUInt32();
            }

            Unk_HaveData2 = reader.ReadBoolean();
            if (Unk_HaveData2)
            {
                Unk_Guid1 = reader.ReadPackedGuid();
                Unk_UInt3 = reader.ReadUInt32();
                Unk_Byte = reader.ReadByte();
                if (Unk_Byte == 2)
                    Unk_Guid2 = reader.ReadPackedGuid();
            }
        }
Example #26
0
        public override void Read(StreamHandler reader)
        {
            this.Unit = reader.ReadPackedGuid();

            var count = reader.ReadInt32();

            this.ThreatList = new ThreatUpdatePair[count];
            for (int i = 0; i < count; ++i)
            {
                this.ThreatList[i] = new ThreatUpdatePair {
                    Unit = reader.ReadPackedGuid(), Threat = reader.ReadUInt32()
                }
            }
            ;
        }
Example #27
0
        public override void Read(StreamHandler Reader)
        {
            byte[] blob = Reader.ReadBytes(256);
            Token           = Reader.ReadUInt32();
            UnknownULong    = Reader.ReadUInt64();
            ConnectionIndex = Reader.ReadByte();

            // hardcoded in client
            byte[] modulus1 =
            {
                0x91, 0xD5, 0x9B, 0xB7, 0xD4, 0xE1, 0x83, 0xA5, 0x22, 0x2B, 0x5F, 0x38, 0xF4, 0xB8, 0x86, 0xFF,
                0x32, 0x84, 0x38, 0x2D, 0x99, 0x38, 0x8F, 0xBA, 0xF3, 0xC9, 0x22, 0x5D, 0x51, 0x73, 0x1E, 0x28,
                0x87, 0x24, 0x8F, 0xB5, 0xC9, 0xB0, 0x7C, 0x95, 0xD0, 0x6B, 0x5B, 0xF4, 0x94, 0xC5, 0x94, 0x9D,
                0xFA, 0x6F, 0x47, 0x3A, 0xA3, 0x86, 0xC0, 0xA8, 0x37, 0xF3, 0x9B, 0xEF, 0x2F, 0xC1, 0xFB, 0xB3,
                0xF4, 0x1C, 0x2B, 0x0E, 0xD3, 0x6D, 0x88, 0xBB, 0x02, 0xE0, 0x4E, 0x63, 0xFA, 0x76, 0xE3, 0x43,
                0xF9, 0x01, 0xFD, 0x23, 0x5E, 0x6A, 0x0B, 0x14, 0xEC, 0x5E, 0x91, 0x34, 0x0D, 0x0B, 0x4F, 0xA3,
                0x5A, 0x46, 0xC5, 0x5E, 0xDC, 0xB5, 0xCD, 0xC1, 0x47, 0x6B, 0x59, 0xCA, 0xFA, 0xA9, 0xBE, 0x24,
                0x9F, 0xF5, 0x05, 0x6B, 0xBB, 0x67, 0x8B, 0xB7, 0xE4, 0x3A, 0x43, 0x00, 0x5C, 0x1C, 0xB7, 0xCA,
                0x98, 0x90, 0x79, 0x77, 0x6D, 0x05, 0x4F, 0x83, 0xCC, 0xAC, 0x06, 0x2E, 0x50, 0x11, 0x87, 0x23,
                0xD8, 0xA6, 0xF7, 0x6F, 0x7A, 0x59, 0x87, 0xA6, 0xDE, 0x5D, 0xD8, 0xEC, 0x44, 0xBE, 0x45, 0x31,
                0x7F, 0x8A, 0xF0, 0x58, 0x89, 0x53, 0x74, 0xDF, 0xCC, 0xAD, 0x01, 0x24, 0xD8, 0x19, 0x65, 0x1C,
                0x25, 0xD3, 0xE1, 0x6B, 0x8B, 0xDA, 0xFE, 0x1D, 0xA4, 0x2C, 0x8B, 0x25, 0xED, 0x7C, 0xFF, 0x6A,
                0xE0, 0x63, 0xD0, 0x52, 0x20, 0x7E, 0x62, 0x49, 0xD2, 0xB3, 0x6B, 0xCC, 0x91, 0x69, 0xA5, 0x08,
                0x8B, 0x69, 0x65, 0xFF, 0xB9, 0xC9, 0x17, 0x02, 0x5D, 0xD8, 0x8E, 0x1A, 0x63, 0xD9, 0x2A, 0x7F,
                0xDB, 0xE3, 0xF8, 0x76, 0x6D, 0xEA, 0x0E, 0x36, 0x98, 0x78, 0x19, 0xC5, 0x87, 0xBA, 0x6C, 0x20,
                0xB6, 0x08, 0x44, 0x04, 0x4C, 0xA8, 0xD5, 0xB6, 0x9D, 0x4D, 0x00, 0x20, 0x40, 0x00, 0x90, 0x04
            };

            // hardcoded in client
            byte[] exp = { 0x01, 0x00, 0x01, 0x00 };

            BigInteger res_bn = BigInteger.ModPow(new BigInteger(blob), new BigInteger(exp), new BigInteger(modulus1));

            FixedBlob = FixBlob(res_bn.ToByteArray());

            ServerHash = new byte[0];
            Port       = BitConverter.ToUInt16(FixedBlob, 21);
            IP         = new IPAddress(FixedBlob.Take(4).ToArray());

            //byte[] bytes = new byte[0]
            //    .Concat(BitConverter.GetBytes(Port))
            //    .Concat(BitConverter.GetBytes(ip))
            //    .ToArray();

            //SHA1Managed sha1 = new SHA1Managed();
            ComputedHash = new byte[0]; //sha1.ComputeHash(bytes);
        }
Example #28
0
        public override void Read(StreamHandler Reader)
        {
            Caster      = Reader.ReadPackedGuid();
            CastInvoker = Reader.ReadPackedGuid();
            CastId      = Reader.ReadByte();
            SpellId     = Reader.ReadUInt32();
            Flags       = (CastFlags)Reader.ReadUInt32();
            Unk43       = Reader.ReadUInt32();
            Unk43_2     = Reader.ReadUInt32();

            TargetData.Read(Reader);

            if ((Flags & CastFlags.PredictedPower) != 0)
            {
                PredictedPower = Reader.ReadUInt32();
            }

            if ((Flags & CastFlags.RuneStates) != 0)
            {
                RunesBefore = (RuneStates)Reader.ReadByte();
                RunesAfter  = (RuneStates)Reader.ReadByte();
                for (int i = 0; i < RuneCooldowns.Length; ++i)
                {
                    RuneCooldowns[i] = Reader.ReadByte();
                }
            }

            if ((Flags & CastFlags.Ammo) != 0)
            {
                ProjectileDisplayId     = Reader.ReadUInt32();
                ProjectileInventoryType = (InventorySlotType)Reader.ReadUInt32();
            }

            if ((Flags & CastFlags.Unk0x04000000) != 0)
            {
                Unk0x04000000_UInt32_1 = Reader.ReadUInt32();
                Unk0x04000000_UInt32_2 = Reader.ReadUInt32();
            }
        }
Example #29
0
        public override void Read(StreamHandler Reader)
        {
            byte[] blob = Reader.ReadBytes(256);
            Token = Reader.ReadUInt32();
            UnknownULong = Reader.ReadUInt64();
            ConnectionIndex = Reader.ReadByte();

            // hardcoded in client
            byte[] modulus1 = {
                    0x91, 0xD5, 0x9B, 0xB7, 0xD4, 0xE1, 0x83, 0xA5, 0x22, 0x2B, 0x5F, 0x38, 0xF4, 0xB8, 0x86, 0xFF, 
                    0x32, 0x84, 0x38, 0x2D, 0x99, 0x38, 0x8F, 0xBA, 0xF3, 0xC9, 0x22, 0x5D, 0x51, 0x73, 0x1E, 0x28, 
                    0x87, 0x24, 0x8F, 0xB5, 0xC9, 0xB0, 0x7C, 0x95, 0xD0, 0x6B, 0x5B, 0xF4, 0x94, 0xC5, 0x94, 0x9D, 
                    0xFA, 0x6F, 0x47, 0x3A, 0xA3, 0x86, 0xC0, 0xA8, 0x37, 0xF3, 0x9B, 0xEF, 0x2F, 0xC1, 0xFB, 0xB3, 
                    0xF4, 0x1C, 0x2B, 0x0E, 0xD3, 0x6D, 0x88, 0xBB, 0x02, 0xE0, 0x4E, 0x63, 0xFA, 0x76, 0xE3, 0x43, 
                    0xF9, 0x01, 0xFD, 0x23, 0x5E, 0x6A, 0x0B, 0x14, 0xEC, 0x5E, 0x91, 0x34, 0x0D, 0x0B, 0x4F, 0xA3, 
                    0x5A, 0x46, 0xC5, 0x5E, 0xDC, 0xB5, 0xCD, 0xC1, 0x47, 0x6B, 0x59, 0xCA, 0xFA, 0xA9, 0xBE, 0x24, 
                    0x9F, 0xF5, 0x05, 0x6B, 0xBB, 0x67, 0x8B, 0xB7, 0xE4, 0x3A, 0x43, 0x00, 0x5C, 0x1C, 0xB7, 0xCA, 
                    0x98, 0x90, 0x79, 0x77, 0x6D, 0x05, 0x4F, 0x83, 0xCC, 0xAC, 0x06, 0x2E, 0x50, 0x11, 0x87, 0x23, 
                    0xD8, 0xA6, 0xF7, 0x6F, 0x7A, 0x59, 0x87, 0xA6, 0xDE, 0x5D, 0xD8, 0xEC, 0x44, 0xBE, 0x45, 0x31, 
                    0x7F, 0x8A, 0xF0, 0x58, 0x89, 0x53, 0x74, 0xDF, 0xCC, 0xAD, 0x01, 0x24, 0xD8, 0x19, 0x65, 0x1C, 
                    0x25, 0xD3, 0xE1, 0x6B, 0x8B, 0xDA, 0xFE, 0x1D, 0xA4, 0x2C, 0x8B, 0x25, 0xED, 0x7C, 0xFF, 0x6A, 
                    0xE0, 0x63, 0xD0, 0x52, 0x20, 0x7E, 0x62, 0x49, 0xD2, 0xB3, 0x6B, 0xCC, 0x91, 0x69, 0xA5, 0x08, 
                    0x8B, 0x69, 0x65, 0xFF, 0xB9, 0xC9, 0x17, 0x02, 0x5D, 0xD8, 0x8E, 0x1A, 0x63, 0xD9, 0x2A, 0x7F, 
                    0xDB, 0xE3, 0xF8, 0x76, 0x6D, 0xEA, 0x0E, 0x36, 0x98, 0x78, 0x19, 0xC5, 0x87, 0xBA, 0x6C, 0x20, 
                    0xB6, 0x08, 0x44, 0x04, 0x4C, 0xA8, 0xD5, 0xB6, 0x9D, 0x4D, 0x00, 0x20, 0x40, 0x00, 0x90, 0x04
                };

            // hardcoded in client
            byte[] exp = { 0x01, 0x00, 0x01, 0x00 };

            BigInteger res_bn = BigInteger.ModPow(new BigInteger(blob), new BigInteger(exp), new BigInteger(modulus1));

            FixedBlob = FixBlob(res_bn.ToByteArray());

            ServerHash = new byte[0];
            Port = BitConverter.ToUInt16(FixedBlob, 21);
            IP = new IPAddress(FixedBlob.Take(4).ToArray());

            //byte[] bytes = new byte[0]
            //    .Concat(BitConverter.GetBytes(Port))
            //    .Concat(BitConverter.GetBytes(ip))
            //    .ToArray();

            //SHA1Managed sha1 = new SHA1Managed();
            ComputedHash = new byte[0]; //sha1.ComputeHash(bytes);
        }
Example #30
0
        public override void Read(StreamHandler reader)
        {
            this.Guid = reader.ReadGuid();
            this.Type = (LootType)reader.ReadByte();
            this.Gold = new Money(reader.ReadUInt32());
            byte itemCount     = reader.ReadByte();
            byte currencyCount = reader.ReadByte();

            for (int i = 0; i < itemCount; ++i)
            {
                Item item = reader.ReadStruct <Item>();
                Items.Add(item);
            }

            for (int i = 0; i < currencyCount; ++i)
            {
                Currency currency = reader.ReadStruct <Currency>();
                Currencies.Add(currency);
            }
        }
Example #31
0
        public override void Read(StreamHandler reader)
        {
            this.Guid = reader.ReadGuid();
            this.Type = (LootType)reader.ReadByte();
            this.Gold = new Money(reader.ReadUInt32());
            byte itemCount = reader.ReadByte();
            byte currencyCount = reader.ReadByte();

            for (int i = 0; i < itemCount; ++i)
            {
                Item item = reader.ReadStruct<Item>();
                Items.Add(item);
            }

            for (int i = 0; i < currencyCount; ++i)
            {
                Currency currency = reader.ReadStruct<Currency>();
                Currencies.Add(currency);
            }
        }
Example #32
0
        public override void Read(StreamHandler reader)
        {
            this.UpdateType = (LFGUpdateType)reader.ReadByte();
            this.ExtraData  = reader.ReadBoolean();
            if (ExtraData)
            {
                this.Queued = reader.ReadBoolean();

                reader.Skip(2); // 2 bools

                uint count = reader.ReadByte();
                Dungeons = new DungeonEntry[count];
                for (uint i = 0; i < count; ++i)
                {
                    Dungeons[i] = new DungeonEntry(reader.ReadUInt32());
                }

                this.Comment = reader.ReadCString();
            }
        }
Example #33
0
        public override void Read(StreamHandler reader)
        {
            Dungeon = new DungeonEntry(reader.ReadUInt32());
            State = (LFGState)reader.ReadByte();
            ProposalId = reader.ReadUInt32();
            BossesKilled = reader.ReadUInt32();
            SameDungeon = reader.ReadBoolean();

            byte count = reader.ReadByte();
            this.Players = new PlayerInfo[count];
            for (byte i = 0; i < count; ++i)
            {
                this.Players[i].Role = (GroupRoles)reader.ReadUInt32();
                this.Players[i].SelfPlayer = reader.ReadBoolean();
                this.Players[i].InDungeon = reader.ReadBoolean();
                this.Players[i].SameGroup = reader.ReadBoolean();
                this.Players[i].Answered = reader.ReadBoolean();
                this.Players[i].Accepted = reader.ReadBoolean();
            }
        }
        private void ReadFromStreamHandler(StreamHandler Reader, WowOpcodes opcode)
        {
            GameMasterMessage = (opcode == WowOpcodes.SMSG_GM_MESSAGECHAT);

            m_type = (ChatMessageType)Reader.ReadByte();
            if (m_type == ChatMessageType.Addon2)
            {
                m_type = ChatMessageType.Addon;
            }

            m_language      = (Language)Reader.ReadUInt32();
            m_senderGUID    = Reader.ReadGuid();
            m_unknownUInt32 = Reader.ReadUInt32();

            switch (m_type)
            {
            case ChatMessageType.MonsterSay:
            case ChatMessageType.MonsterParty:
            case ChatMessageType.MonsterYell:
            case ChatMessageType.MonsterWhisper:
            case ChatMessageType.MonsterEmote:
            case ChatMessageType.BattleNet:
            case ChatMessageType.RaidBossEmote:
            case ChatMessageType.RaidBossWhisper:
                Reader.Skip(4);
                m_senderName = Reader.ReadCString();
                m_targetGUID = Reader.ReadGuid();
                if (!m_targetGUID.IsEmpty &&
                    !m_targetGUID.IsPlayer &&
                    !m_targetGUID.IsPet)
                {
                    Reader.Skip(4);
                    m_targetName = Reader.ReadCString();
                }
                if (m_language == Language.Addon)
                {
                    m_addonPrefix = Reader.ReadCString();
                }
                Reader.Skip(4);
                m_text  = Reader.ReadCString();
                m_flags = (ChatMessageFlags)Reader.ReadByte();
                if (m_type == ChatMessageType.RaidBossEmote || m_type == ChatMessageType.RaidBossWhisper)
                {
                    m_displayTime  = Reader.ReadSingle();
                    m_suspendEvent = Reader.ReadBoolean();
                }
                break;

            case ChatMessageType.BGSystemNeutral:
            case ChatMessageType.BGSystemAlliance:
            case ChatMessageType.BGSystemHorde:
                m_targetGUID = Reader.ReadGuid();
                if (!m_targetGUID.IsEmpty &&
                    !m_targetGUID.IsPlayer)
                {
                    Reader.Skip(4);
                    m_targetName = Reader.ReadCString();
                }
                if (m_language == Language.Addon)
                {
                    m_addonPrefix = Reader.ReadCString();
                }
                Reader.Skip(4);
                m_text  = Reader.ReadCString();
                m_flags = (ChatMessageFlags)Reader.ReadByte();
                break;

            case ChatMessageType.Achievement:
            case ChatMessageType.GuildAchievement:
                m_targetGUID = Reader.ReadGuid();
                if (m_language == Language.Addon)
                {
                    m_addonPrefix = Reader.ReadCString();
                }
                Reader.Skip(4);
                m_text          = Reader.ReadCString();
                m_flags         = (ChatMessageFlags)Reader.ReadByte();
                m_achievementId = Reader.ReadUInt32();
                break;

            case ChatMessageType.WhisperForeign:
                Reader.Skip(4);
                m_senderName = Reader.ReadCString();
                m_targetGUID = Reader.ReadGuid();
                if (m_language == Language.Addon)
                {
                    m_addonPrefix = Reader.ReadCString();
                }
                Reader.Skip(4);
                m_text  = Reader.ReadCString();
                m_flags = (ChatMessageFlags)Reader.ReadByte();
                break;

            default:
                if (GameMasterMessage)
                {
                    Reader.Skip(4);
                    m_senderName = Reader.ReadCString();
                }
                if (m_type == ChatMessageType.Channel)
                {
                    m_channel = Reader.ReadCString();
                }
                m_targetGUID = Reader.ReadGuid();
                if (m_language == Language.Addon)
                {
                    m_addonPrefix = Reader.ReadCString();
                }
                Reader.Skip(4);
                m_text  = Reader.ReadCString();
                m_flags = (ChatMessageFlags)Reader.ReadByte();
                break;
            }
        }
Example #35
0
 public override void Read(StreamHandler reader)
 {
     Entity = reader.ReadGuid();
     Model = reader.ReadUInt32();
     Race = (Races)reader.ReadByte();
     Gender = (Genders)reader.ReadByte();
     Class = (Classes)reader.ReadByte();
     Skin = reader.ReadByte();
     Face = reader.ReadByte();
     Hair = reader.ReadByte();
     HairColor = reader.ReadByte();
     FaceFeatures = reader.ReadByte();
     Guild = reader.ReadGuid();
     Head = reader.ReadUInt32();
     Shoulders = reader.ReadUInt32();
     Body = reader.ReadUInt32();
     Chest = reader.ReadUInt32();
     Waist = reader.ReadUInt32();
     Legs = reader.ReadUInt32();
     Feet = reader.ReadUInt32();
     Wrists = reader.ReadUInt32();
     Hands = reader.ReadUInt32();
     Back = reader.ReadUInt32();
     Tabard = reader.ReadUInt32();
 }
        protected virtual void ReadElement(StreamHandler reader, MovementStatusElements element, MovementStatus status, byte[] guid, byte[] tguid)
        {
            if (element >= MovementStatusElements.GuidByte0 && element <= MovementStatusElements.GuidByte7)
            {
                ReadByteMask(reader, ref guid[element - MovementStatusElements.GuidByte0]);
                return;
            }

            if (element >= MovementStatusElements.TransportGuidByte0 &&
                element <= MovementStatusElements.TransportGuidByte7)
            {
                if (status.HaveTransportData)
                    ReadByteMask(reader, ref tguid[element - MovementStatusElements.TransportGuidByte0]);
                return;
            }

            if (element >= MovementStatusElements.GuidByte0_2 && element <= MovementStatusElements.GuidByte7_2)
            {
                ReadByteSeq(reader, ref guid[element - MovementStatusElements.GuidByte0_2]);
                return;
            }

            if (element >= MovementStatusElements.TransportGuidByte0_2 &&
                element <= MovementStatusElements.TransportGuidByte7_2)
            {
                if (status.HaveTransportData)
                    ReadByteSeq(reader, ref tguid[element - MovementStatusElements.TransportGuidByte0_2]);
                return;
            }

            switch (element)
            {
                case MovementStatusElements.Flags:
                    status.Flags = (MovementFlags)(!reader.UnalignedReadBit() ? 1 : 0);
                    break;
                case MovementStatusElements.Flags_2:
                    if (status.Flags != 0)
                        status.Flags = (MovementFlags)reader.UnalignedReadInt(30);
                    break;
                case MovementStatusElements.Flags2:
                    status.Flags2 = (MovementFlags2)(!reader.UnalignedReadBit() ? 1 : 0);
                    break;
                case MovementStatusElements.Flags2_2:
                    if (status.Flags2 != 0)
                        status.Flags2 = (MovementFlags2)reader.UnalignedReadSmallInt(12);
                    break;
                case MovementStatusElements.Timestamp:
                    status.TimeStamp = !reader.UnalignedReadBit() ? 1U : 0U;
                    break;
                case MovementStatusElements.Timestamp_2:
                    if (status.TimeStamp != 0)
                        status.TimeStamp = reader.ReadUInt32();
                    break;
                case MovementStatusElements.HaveFallData:
                    status.HaveFallData = reader.UnalignedReadBit();
                    break;
                case MovementStatusElements.HaveFallDirection:
                    if (status.HaveFallData)
                        status.HaveFallDirection = reader.UnalignedReadBit();
                    break;
                case MovementStatusElements.HaveTransportData:
                    status.HaveTransportData = reader.UnalignedReadBit();
                    break;
                case MovementStatusElements.TransportHaveTime2:
                    if (status.HaveTransportData)
                        status.HaveTransportTime2 = reader.UnalignedReadBit();
                    break;
                case MovementStatusElements.TransportHaveTime3:
                    if (status.HaveTransportData)
                        status.HaveTransportTime3 = reader.UnalignedReadBit();
                    break;
                case MovementStatusElements.HaveSpline:
                    status.HaveSpline = reader.UnalignedReadBit();
                    break;
                case MovementStatusElements.HaveSpline2:
                    status.HaveSpline2 = reader.UnalignedReadBit();
                    break;
                case MovementStatusElements.PositionX:
                    status.Position.X = reader.ReadSingle();
                    break;
                case MovementStatusElements.PositionY:
                    status.Position.Y = reader.ReadSingle();
                    break;
                case MovementStatusElements.PositionZ:
                    status.Position.Z = reader.ReadSingle();
                    break;
                case MovementStatusElements.PositionO:
                    status.Orientation = !reader.UnalignedReadBit() ? 1.0f : 0.0f;
                    break;
                case MovementStatusElements.PositionO_2:
                    if (status.Orientation != 0.0f)
                        status.Orientation = reader.ReadSingle();
                    break;
                case MovementStatusElements.Pitch:
                    status.HavePitch = !reader.UnalignedReadBit();
                    break;
                case MovementStatusElements.Pitch_2:
                    if (status.HavePitch)
                        status.Pitch = reader.ReadSingle();
                    break;
                case MovementStatusElements.FallTime:
                    if (status.HaveFallData)
                        status.FallTime = reader.ReadUInt32();
                    break;
                case MovementStatusElements.SplineElev:
                    status.HaveSplineElevation = !reader.UnalignedReadBit();
                    break;
                case MovementStatusElements.SplineElev_2:
                    if (status.HaveSplineElevation)
                        status.SplineElevation = reader.ReadSingle();
                    break;
                case MovementStatusElements.FallHorizontalSpeed:
                    if (status.HaveFallDirection)
                        status.FallHorizontalSpeed = reader.ReadSingle();
                    break;
                case MovementStatusElements.FallVerticalSpeed:
                    if (status.HaveFallData)
                        status.FallVerticalSpeed = reader.ReadSingle();
                    break;
                case MovementStatusElements.FallCosAngle:
                    if (status.HaveFallDirection)
                        status.FallCosAngle = reader.ReadSingle();
                    break;
                case MovementStatusElements.FallSinAngle:
                    if (status.HaveFallDirection)
                        status.FallSinAngle = reader.ReadSingle();
                    break;
                case MovementStatusElements.TransportSeat:
                    if (status.HaveTransportData)
                        status.TransportSeat = reader.ReadSByte();
                    break;
                case MovementStatusElements.TransportPositionO:
                    if (status.HaveTransportData)
                        status.TransportFacing = reader.ReadSingle();
                    break;
                case MovementStatusElements.TransportPositionX:
                    if (status.HaveTransportData)
                        status.TransportPosition.X = reader.ReadSingle();
                    break;
                case MovementStatusElements.TransportPositionY:
                    if (status.HaveTransportData)
                        status.TransportPosition.Y = reader.ReadSingle();
                    break;
                case MovementStatusElements.TransportPositionZ:
                    if (status.HaveTransportData)
                        status.TransportPosition.Z = reader.ReadSingle();
                    break;
                case MovementStatusElements.TransportTime:
                    if (status.HaveTransportData)
                        status.TransportTime = reader.ReadUInt32();
                    break;
                case MovementStatusElements.TransportTime2:
                    if (status.HaveTransportTime2)
                        status.TransportTime2 = reader.ReadUInt32();
                    break;
                case MovementStatusElements.TransportTime3:
                    if (status.HaveTransportTime3)
                        status.TransportTime3 = reader.ReadUInt32();
                    break;
                default:
                    throw new InvalidOperationException("Unknown element: " + element);
            }
        }
Example #37
0
        public void Read(StreamHandler Reader)
        {
            Slot = Reader.ReadByte();
            Spell = Reader.ReadUInt32();

            Caster = Unit;

            if (Spell != 0)
            {
                Flags = (AuraFlags)Reader.ReadUInt16();
                Level = Reader.ReadByte();
                Charges = Reader.ReadByte();

                if ((Flags & AuraFlags.NotCaster) == 0)
                    Caster = Reader.ReadPackedGuid();

                if ((Flags & AuraFlags.Duration) != 0)
                {
                    MaxDuration = Reader.ReadUInt32();
                    var currentDurationMs = Reader.ReadUInt32();

                    this.AppliedTime = (uint)Environment.TickCount - currentDurationMs;
                }

                if ((Flags & AuraFlags.BasePoints) != 0)
                {
                    for (int i = 0; i < MaxEffects; ++i)
                    {
                        if ((Flags & (AuraFlags)(1 << i)) != 0)
                            BasePoints[i] = Reader.ReadInt32();
                        else
                            BasePoints[i] = 0;
                    }
                }
                else
                    Array.Clear(BasePoints, 0, MaxEffects);
            }
        }
Example #38
0
        protected virtual void ReadElement(StreamHandler reader, MovementStatusElements element, MovementStatus status, byte[] guid, byte[] tguid)
        {
            if (element >= MovementStatusElements.GuidByte0 && element <= MovementStatusElements.GuidByte7)
            {
                ReadByteMask(reader, ref guid[element - MovementStatusElements.GuidByte0]);
                return;
            }

            if (element >= MovementStatusElements.TransportGuidByte0 &&
                element <= MovementStatusElements.TransportGuidByte7)
            {
                if (status.HaveTransportData)
                {
                    ReadByteMask(reader, ref tguid[element - MovementStatusElements.TransportGuidByte0]);
                }
                return;
            }

            if (element >= MovementStatusElements.GuidByte0_2 && element <= MovementStatusElements.GuidByte7_2)
            {
                ReadByteSeq(reader, ref guid[element - MovementStatusElements.GuidByte0_2]);
                return;
            }

            if (element >= MovementStatusElements.TransportGuidByte0_2 &&
                element <= MovementStatusElements.TransportGuidByte7_2)
            {
                if (status.HaveTransportData)
                {
                    ReadByteSeq(reader, ref tguid[element - MovementStatusElements.TransportGuidByte0_2]);
                }
                return;
            }

            switch (element)
            {
            case MovementStatusElements.Flags:
                status.Flags = (MovementFlags)(!reader.UnalignedReadBit() ? 1 : 0);
                break;

            case MovementStatusElements.Flags_2:
                if (status.Flags != 0)
                {
                    status.Flags = (MovementFlags)reader.UnalignedReadInt(30);
                }
                break;

            case MovementStatusElements.Flags2:
                status.Flags2 = (MovementFlags2)(!reader.UnalignedReadBit() ? 1 : 0);
                break;

            case MovementStatusElements.Flags2_2:
                if (status.Flags2 != 0)
                {
                    status.Flags2 = (MovementFlags2)reader.UnalignedReadSmallInt(12);
                }
                break;

            case MovementStatusElements.Timestamp:
                status.TimeStamp = !reader.UnalignedReadBit() ? 1U : 0U;
                break;

            case MovementStatusElements.Timestamp_2:
                if (status.TimeStamp != 0)
                {
                    status.TimeStamp = reader.ReadUInt32();
                }
                break;

            case MovementStatusElements.HaveFallData:
                status.HaveFallData = reader.UnalignedReadBit();
                break;

            case MovementStatusElements.HaveFallDirection:
                if (status.HaveFallData)
                {
                    status.HaveFallDirection = reader.UnalignedReadBit();
                }
                break;

            case MovementStatusElements.HaveTransportData:
                status.HaveTransportData = reader.UnalignedReadBit();
                break;

            case MovementStatusElements.TransportHaveTime2:
                if (status.HaveTransportData)
                {
                    status.HaveTransportTime2 = reader.UnalignedReadBit();
                }
                break;

            case MovementStatusElements.TransportHaveTime3:
                if (status.HaveTransportData)
                {
                    status.HaveTransportTime3 = reader.UnalignedReadBit();
                }
                break;

            case MovementStatusElements.HaveSpline:
                status.HaveSpline = reader.UnalignedReadBit();
                break;

            case MovementStatusElements.HaveSpline2:
                status.HaveSpline2 = reader.UnalignedReadBit();
                break;

            case MovementStatusElements.PositionX:
                status.Position.X = reader.ReadSingle();
                break;

            case MovementStatusElements.PositionY:
                status.Position.Y = reader.ReadSingle();
                break;

            case MovementStatusElements.PositionZ:
                status.Position.Z = reader.ReadSingle();
                break;

            case MovementStatusElements.PositionO:
                status.Orientation = !reader.UnalignedReadBit() ? 1.0f : 0.0f;
                break;

            case MovementStatusElements.PositionO_2:
                if (status.Orientation != 0.0f)
                {
                    status.Orientation = reader.ReadSingle();
                }
                break;

            case MovementStatusElements.Pitch:
                status.HavePitch = !reader.UnalignedReadBit();
                break;

            case MovementStatusElements.Pitch_2:
                if (status.HavePitch)
                {
                    status.Pitch = reader.ReadSingle();
                }
                break;

            case MovementStatusElements.FallTime:
                if (status.HaveFallData)
                {
                    status.FallTime = reader.ReadUInt32();
                }
                break;

            case MovementStatusElements.SplineElev:
                status.HaveSplineElevation = !reader.UnalignedReadBit();
                break;

            case MovementStatusElements.SplineElev_2:
                if (status.HaveSplineElevation)
                {
                    status.SplineElevation = reader.ReadSingle();
                }
                break;

            case MovementStatusElements.FallHorizontalSpeed:
                if (status.HaveFallDirection)
                {
                    status.FallHorizontalSpeed = reader.ReadSingle();
                }
                break;

            case MovementStatusElements.FallVerticalSpeed:
                if (status.HaveFallData)
                {
                    status.FallVerticalSpeed = reader.ReadSingle();
                }
                break;

            case MovementStatusElements.FallCosAngle:
                if (status.HaveFallDirection)
                {
                    status.FallCosAngle = reader.ReadSingle();
                }
                break;

            case MovementStatusElements.FallSinAngle:
                if (status.HaveFallDirection)
                {
                    status.FallSinAngle = reader.ReadSingle();
                }
                break;

            case MovementStatusElements.TransportSeat:
                if (status.HaveTransportData)
                {
                    status.TransportSeat = reader.ReadSByte();
                }
                break;

            case MovementStatusElements.TransportPositionO:
                if (status.HaveTransportData)
                {
                    status.TransportFacing = reader.ReadSingle();
                }
                break;

            case MovementStatusElements.TransportPositionX:
                if (status.HaveTransportData)
                {
                    status.TransportPosition.X = reader.ReadSingle();
                }
                break;

            case MovementStatusElements.TransportPositionY:
                if (status.HaveTransportData)
                {
                    status.TransportPosition.Y = reader.ReadSingle();
                }
                break;

            case MovementStatusElements.TransportPositionZ:
                if (status.HaveTransportData)
                {
                    status.TransportPosition.Z = reader.ReadSingle();
                }
                break;

            case MovementStatusElements.TransportTime:
                if (status.HaveTransportData)
                {
                    status.TransportTime = reader.ReadUInt32();
                }
                break;

            case MovementStatusElements.TransportTime2:
                if (status.HaveTransportTime2)
                {
                    status.TransportTime2 = reader.ReadUInt32();
                }
                break;

            case MovementStatusElements.TransportTime3:
                if (status.HaveTransportTime3)
                {
                    status.TransportTime3 = reader.ReadUInt32();
                }
                break;

            default:
                throw new InvalidOperationException("Unknown element: " + element);
            }
        }
 protected override void ElementRead(StreamHandler reader, int index)
 {
     this.Time = reader.ReadUInt32();
 }
Example #40
0
 private void ReadObjectDestroyUpdate(StreamHandler Reader)
 {
     uint nObjects = Reader.ReadUInt32();
     for (var i = 0; i < nObjects; ++i)
         m_destroyedObjects.Add(Reader.ReadPackedGuid());
 }
Example #41
0
        public unsafe MovementInfo(StreamHandler Reader)
        {
            var guid = new WowGuid();
            this.HaveAttackingTarget = Reader.UnalignedReadBit();
            guid.Bytes[2] = Reader.UnalignedReadTinyInt(1);
            this.HaveVehicleData = Reader.UnalignedReadBit();
            guid.Bytes[1] = Reader.UnalignedReadTinyInt(1);
            guid.Bytes[4] = Reader.UnalignedReadTinyInt(1);
            guid.Bytes[3] = Reader.UnalignedReadTinyInt(1);
            this.HaveTransportTime = Reader.UnalignedReadBit();
            this.HaveGameObjectPosition = Reader.UnalignedReadBit();
            bool field_1C8 = Reader.UnalignedReadBit();
            bool field_1AC = Reader.UnalignedReadBit();
            this.HaveGameObjectRotation = Reader.UnalignedReadBit();
            this.Living = Reader.UnalignedReadBit();
            this.HavePosition = Reader.UnalignedReadBit();
            var arrCounter = Reader.UnalignedReadInt(24);
            guid.Bytes[0] = Reader.UnalignedReadTinyInt(1);

            bool havePFlags = false;
            WowGuid p_guid;
            uint splinePoints = 0;
            bool havePFlags2 = false;
            bool haveOrientation = false;

            if (this.Living)
            {
                this.HaveTransportData = Reader.UnalignedReadBit();
                if (this.HaveTransportData)
                {
                    fixed (byte* bytes = this.TransportGuid.Bytes)
                    {
                        bytes[2] = Reader.UnalignedReadTinyInt(1);
                        bytes[7] = Reader.UnalignedReadTinyInt(1);
                        bytes[5] = Reader.UnalignedReadTinyInt(1);
                        this.HaveTransportTime3 = Reader.UnalignedReadBit();
                        bytes[3] = Reader.UnalignedReadTinyInt(1);
                        bytes[0] = Reader.UnalignedReadTinyInt(1);
                        bytes[4] = Reader.UnalignedReadTinyInt(1);
                        bytes[1] = Reader.UnalignedReadTinyInt(1);
                        this.HaveTransportTime2 = Reader.UnalignedReadBit();
                        bytes[6] = Reader.UnalignedReadTinyInt(1);
                    }
                }

                this.HaveSpline2 = Reader.UnalignedReadBit();
                p_guid.Bytes[7] = Reader.UnalignedReadTinyInt(1);
                p_guid.Bytes[6] = Reader.UnalignedReadTinyInt(1);
                p_guid.Bytes[5] = Reader.UnalignedReadTinyInt(1);
                p_guid.Bytes[2] = Reader.UnalignedReadTinyInt(1);
                p_guid.Bytes[4] = Reader.UnalignedReadTinyInt(1);
                havePFlags = !Reader.UnalignedReadBit();
                p_guid.Bytes[1] = Reader.UnalignedReadTinyInt(1);
                this.SelfTarget = Reader.UnalignedReadBit();
                this.TimeStamp = !Reader.UnalignedReadBit() ? 1U : 0U;
                havePFlags2 = !Reader.UnalignedReadBit();

                if (this.HaveSpline2)
                {
                    this.HaveSpline = Reader.UnalignedReadBit();
                    if (this.HaveSpline)
                    {
                        this.Spline.HaveDurationMultiplier = Reader.UnalignedReadBit();
                        this.Spline.Flags = (SplineFlags)Reader.UnalignedReadInt(25);
                        this.Spline.SplineMode = (SplineMode)Reader.UnalignedReadTinyInt(2);
                        this.Spline.HaveUnknown1 = Reader.UnalignedReadBit();
                        splinePoints = Reader.UnalignedReadInt(22);
                        var type = Reader.UnalignedReadTinyInt(2);
                        switch (type)
                        {
                            case 0:
                                this.Spline.SplineType = SplineType.FacingSpot;
                                break;
                            case 1:
                                this.Spline.SplineType = SplineType.Normal;
                                break;
                            case 2:
                                this.Spline.SplineType = SplineType.FacingTarget;
                                break;
                            case 3:
                                this.Spline.SplineType = SplineType.FacingAngle;
                                break;
                        }
                        if (this.Spline.SplineType == SplineType.FacingTarget)
                        {
                            fixed (byte* bytes = this.Spline.FacingTarget.Bytes)
                            {
                                bytes[7] = Reader.UnalignedReadTinyInt(1);
                                bytes[3] = Reader.UnalignedReadTinyInt(1);
                                bytes[4] = Reader.UnalignedReadTinyInt(1);
                                bytes[2] = Reader.UnalignedReadTinyInt(1);
                                bytes[1] = Reader.UnalignedReadTinyInt(1);
                                bytes[6] = Reader.UnalignedReadTinyInt(1);
                                bytes[0] = Reader.UnalignedReadTinyInt(1);
                                bytes[5] = Reader.UnalignedReadTinyInt(1);
                            }
                        }
                    }
                }

                p_guid.Bytes[3] = Reader.UnalignedReadTinyInt(1);
                if (havePFlags)
                    this.Flags = (MovementFlags)Reader.UnalignedReadInt(30);
                this.HavePitch = !Reader.UnalignedReadBit();
                this.HaveFallData = Reader.UnalignedReadBit();

                if (havePFlags2)
                    this.Flags2 = (MovementFlags2)Reader.UnalignedReadSmallInt(12);

                p_guid.Bytes[0] = Reader.UnalignedReadTinyInt(1);
                haveOrientation = !Reader.UnalignedReadBit();

                if (this.HaveFallData)
                    this.HaveFallDirection = Reader.UnalignedReadBit();

                this.HaveSplineElevation = !Reader.UnalignedReadBit();
            }

            if (this.HaveGameObjectPosition)
            {
                fixed (byte* bytes = this.TransportGuid.Bytes)
                {
                    bytes[1] = Reader.UnalignedReadTinyInt(1);
                    this.HaveTransportTime3 = Reader.UnalignedReadBit();
                    bytes[3] = Reader.UnalignedReadTinyInt(1);
                    bytes[2] = Reader.UnalignedReadTinyInt(1);
                    bytes[6] = Reader.UnalignedReadTinyInt(1);
                    bytes[5] = Reader.UnalignedReadTinyInt(1);
                    bytes[0] = Reader.UnalignedReadTinyInt(1);
                    bytes[4] = Reader.UnalignedReadTinyInt(1);
                    this.HaveTransportTime2 = Reader.UnalignedReadBit();
                    bytes[7] = Reader.UnalignedReadTinyInt(1);
                }
            }

            ushort field_1B2 = 0;
            ushort field_1AE = 0;
            ushort field_1B0 = 0;
            if (field_1AC)
            {
                field_1B2 = (ushort)(!Reader.UnalignedReadBit() ? 1 : 0);
                field_1AE = (ushort)(!Reader.UnalignedReadBit() ? 1 : 0);
                field_1B0 = (ushort)(!Reader.UnalignedReadBit() ? 1 : 0);
            }

            if (this.HaveAttackingTarget)
            {
                fixed (byte* bytes = this.AttackingTarget.Bytes)
                {
                    bytes[3] = Reader.UnalignedReadTinyInt(1);
                    bytes[4] = Reader.UnalignedReadTinyInt(1);
                    bytes[6] = Reader.UnalignedReadTinyInt(1);
                    bytes[0] = Reader.UnalignedReadTinyInt(1);
                    bytes[1] = Reader.UnalignedReadTinyInt(1);
                    bytes[7] = Reader.UnalignedReadTinyInt(1);
                    bytes[5] = Reader.UnalignedReadTinyInt(1);
                    bytes[2] = Reader.UnalignedReadTinyInt(1);
                }
            }

            this.UnkUInt32 = new uint[arrCounter];
            for (uint i = 0; i < arrCounter; ++i)
            {
                this.UnkUInt32[i] = Reader.ReadUInt32();
            }

            if (this.HavePosition)
            {
                Reader
                    .ReadSingle(out this.Position.Z)
                    .ReadSingle(out this.Orientation)
                    .ReadSingle(out this.Position.X)
                    .ReadSingle(out this.Position.Y);
            }

            if (this.HaveVehicleData)
            {
                Reader
                    .ReadUInt32(out this.VehicleId)
                    .ReadSingle(out this.VehicleAimAdjustement);
            }

            if (this.HaveGameObjectPosition)
            {
                fixed (byte* bytes = this.TransportGuid.Bytes)
                {
                    Reader
                        .ReadXorByte(ref bytes[1])
                        .ReadXorByte(ref bytes[4])
                        .ReadSingle(out this.TransportPosition.Z);

                    if (this.HaveTransportTime3)
                        this.TransportTime3 = Reader.ReadUInt32();

                    this.TransportTime = Reader.ReadUInt32();

                    Reader
                        .ReadXorByte(ref bytes[5])
                        .ReadXorByte(ref bytes[6])
                        .ReadSingle(out this.TransportPosition.X)
                        .ReadXorByte(ref bytes[2]);

                    if (this.HaveTransportTime2)
                        this.TransportTime2 = Reader.ReadUInt32();

                    Reader
                        .ReadSByte(out this.TransportSeat)
                        .ReadXorByte(ref bytes[3])
                        .ReadSingle(out this.TransportPosition.Y)
                        .ReadSingle(out this.TransportFacing)
                        .ReadXorByte(ref bytes[7])
                        .ReadXorByte(ref bytes[0]);
                }
            }

            if (this.Living)
            {
                if (this.HaveSpline2)
                {
                    if (this.HaveSpline)
                    {
                        var points = this.Spline.Points;
                        points.Capacity = (int)splinePoints;
                        for (int i = 0; i < splinePoints; i++)
                            points.Add(new Vector3()
                            {
                                Y = Reader.ReadSingle(),
                                X = Reader.ReadSingle(),
                                Z = Reader.ReadSingle()
                            });

                        if (this.Spline.HaveDurationMultiplier)
                        {
                            this.Spline.DurationMultiplier = Reader.ReadSingle();
                        }

                        this.Spline.UnknownFloat2 = Reader.ReadSingle();

                        if (this.Spline.SplineType == SplineType.FacingTarget)
                        {
                            fixed (byte* bytes = this.Spline.FacingTarget.Bytes)
                            {
                                Reader
                                    .ReadXorByte(ref bytes[3])
                                    .ReadXorByte(ref bytes[4])
                                    .ReadXorByte(ref bytes[5])
                                    .ReadXorByte(ref bytes[7])
                                    .ReadXorByte(ref bytes[2])
                                    .ReadXorByte(ref bytes[0])
                                    .ReadXorByte(ref bytes[6])
                                    .ReadXorByte(ref bytes[1]);
                            }
                        }

                        if (this.Spline.HaveUnknown1)
                        {
                            this.Spline.Unknown1 = Reader.ReadUInt32();
                        }

                        this.Spline.UnknownFloat3 = Reader.ReadSingle();
                        this.Spline.Unknown2 = Reader.ReadUInt32();

                        if (this.Spline.SplineType == SplineType.FacingSpot)
                        {
                            Reader
                                .ReadSingle(out this.Spline.FacingSpot.Y)
                                .ReadSingle(out this.Spline.FacingSpot.Z)
                                .ReadSingle(out this.Spline.FacingSpot.X);
                        }

                        this.Spline.CurrentTime = Reader.ReadUInt32();

                        if (this.Spline.SplineType == SplineType.FacingAngle)
                            this.Spline.FacingAngle = Reader.ReadSingle();
                    }

                    Reader
                        .ReadSingle(out this.Spline.EndPoint.Z)
                        .ReadSingle(out this.Spline.EndPoint.Y)
                        .ReadUInt32(out this.Spline.FullTime)
                        .ReadSingle(out this.Spline.EndPoint.X);
                }

                this.Speeds[8] = Reader.ReadSingle();

                // Transport Data
                if (this.HaveTransportData)
                {
                    fixed (byte* bytes = this.TransportGuid.Bytes)
                    {
                        Reader
                            .ReadXorByte(ref bytes[4])
                            .ReadSingle(out this.TransportPosition.Z)
                            .ReadXorByte(ref bytes[7])
                            .ReadXorByte(ref bytes[5])
                            .ReadXorByte(ref bytes[1])
                            .ReadSingle(out this.TransportPosition.X)
                            .ReadXorByte(ref bytes[3])
                            .ReadXorByte(ref bytes[6]);

                        if (this.HaveTransportTime3)
                            this.TransportTime3 = Reader.ReadUInt32();

                        Reader
                            .ReadSingle(out this.TransportPosition.Y)
                            .ReadSByte(out this.TransportSeat)
                            .ReadSingle(out this.TransportFacing);

                        if (this.HaveTransportTime2)
                            this.TransportTime2 = Reader.ReadUInt32();

                        Reader
                            .ReadXorByte(ref bytes[2])
                            .ReadUInt32(out this.TransportTime)
                            .ReadXorByte(ref bytes[0]);
                    }
                }

                Reader
                    .ReadSingle(out this.Speeds[7])
                    .ReadSingle(out this.Position.X);

                if (this.HavePitch)
                    Reader.ReadSingle(out this.Pitch);

                // Fall Data
                if (this.HaveFallData)
                {
                    Reader.ReadUInt32(out this.FallTime);
                    if (this.HaveFallDirection)
                    {
                        Reader
                            .ReadSingle(out this.FallSinAngle)
                            .ReadSingle(out this.FallHorizontalSpeed)
                            .ReadSingle(out this.FallCosAngle);
                    }
                    Reader.ReadSingle(out this.FallVerticalSpeed);
                }

                Reader
                    .ReadXorByte(ref p_guid.Bytes[7])
                    .ReadSingle(out this.Speeds[4])
                    .ReadXorByte(ref p_guid.Bytes[0])
                    .ReadXorByte(ref p_guid.Bytes[5]);

                if (this.TimeStamp != 0)
                    this.TimeStamp = Reader.ReadUInt32();

                Reader
                    .ReadSingle(out this.Position.Z)
                    .ReadSingle(out this.Speeds[6])
                    .ReadXorByte(ref p_guid.Bytes[1])
                    .ReadSingle(out this.Speeds[2])
                    .ReadSingle(out this.Speeds[5])
                    .ReadSingle(out this.Speeds[3])
                    .ReadSingle(out this.Speeds[0])
                    .ReadXorByte(ref p_guid.Bytes[3])
                    .ReadXorByte(ref p_guid.Bytes[4])
                    .ReadXorByte(ref p_guid.Bytes[2])
                    .ReadXorByte(ref p_guid.Bytes[6]);

                if (this.HaveSplineElevation)
                    this.SplineElevation = Reader.ReadSingle();

                this.Position.Y = Reader.ReadSingle();

                if (haveOrientation)
                    this.Orientation = Reader.ReadSingle();

                this.Speeds[1] = Reader.ReadSingle();
            }

            if (field_1C8)
            {
                Console.WriteLine("Error: 16 floats @ 1CC detected !!!");

                Reader.ReadBytes(16 * 4); // 16 floats starting at 1CC
                var field_20C = Reader.ReadByte();
            }

            // transport time
            if (this.HaveTransportTime)
                Reader.ReadUInt32(out this.TransportTime);

            // unk2 ?
            if (field_1AC)
            {
                Console.WriteLine("Error: 3 shorts @ 1AE detected !!!");

                if (field_1B0 != 0)
                    field_1B0 = Reader.ReadUInt16();
                if (field_1B2 != 0)
                    field_1B2 = Reader.ReadUInt16();
                if (field_1AE != 0)
                    field_1AE = Reader.ReadUInt16();
            }

            // go rotation?
            if (this.HaveGameObjectRotation)
                this.GameObjectRotation = Reader.ReadUInt64().UnpackQuaternion();

            // target guid?
            if (this.HaveAttackingTarget)
            {
                fixed (byte* bytes = this.AttackingTarget.Bytes)
                {
                    Reader
                        .ReadXorByte(ref bytes[3])
                        .ReadXorByte(ref bytes[5])
                        .ReadXorByte(ref bytes[0])
                        .ReadXorByte(ref bytes[7])
                        .ReadXorByte(ref bytes[2])
                        .ReadXorByte(ref bytes[4])
                        .ReadXorByte(ref bytes[6])
                        .ReadXorByte(ref bytes[1]);
                }
            }

            this.Guid = guid;
        }
Example #42
0
        private UpdateFields ReadValues(StreamHandler Reader)
        {
            var values = new UpdateFields();

            byte blocksCount = Reader.ReadByte();
            int[] updatemask = new int[blocksCount];

            for (int i = 0; i < updatemask.Length; ++i)
                updatemask[i] = Reader.ReadInt32();

            var mask = new BitArray(updatemask);

            for (uint i = 0; i < mask.Count; ++i)
                if (mask[(int)i])
                    values[i] = Reader.ReadUInt32();

            return values;
        }
        protected override void InternalParse()
        {
            int row;
            int size;
            DB2Ids type;

            Output.AppendLine("Data Size: " + (size = Reader.ReadInt32()));
            byte[] data = Reader.ReadBytes(size);

            Output.AppendLine("Type: " + (type = (DB2Ids)Reader.ReadUInt32()));
            Output.AppendLine("Row: " + (row = Reader.ReadInt32()));
            Output.AppendLine("Time(?): " + Reader.ReadUInt32().AsUnixTime());
            Output.AppendLine();

            if (row < 0)
                return;

            using (var dataReader = new StreamHandler(data))
            {
                if (type == DB2Ids.Item)
                {
                    Output.AppendLine("Item Id: " + dataReader.ReadUInt32());
                    Output.AppendLine("Class: " + (ItemClass)dataReader.ReadUInt32());
                    Output.AppendLine("SubClass: " + (ItemSubClass)dataReader.ReadUInt32());
                    Output.AppendLine("Unk -1: " + dataReader.ReadInt32());
                    Output.AppendLine("Material: " + (Material)dataReader.ReadUInt32());
                    Output.AppendLine("Display Id: " + dataReader.ReadUInt32());
                    Output.AppendLine("Inventory Type: " + (InventorySlot)dataReader.ReadUInt32());
                    Output.AppendLine("Sheath: " + dataReader.ReadUInt32());
                }
                else if (type == DB2Ids.ItemSparse)
                {
                    Output.AppendLine("id: " + dataReader.ReadInt32());
                    Output.AppendLine("quality: " + (ItemQuality)dataReader.ReadInt32());
                    Output.AppendLine("flags: " + dataReader.ReadUInt32());
                    Output.AppendLine("flags2: " + dataReader.ReadUInt32());
                    Output.AppendLine("4.3.2 float1: " + dataReader.ReadSingle()); // 0.95-1.05
                    Output.AppendLine("4.3.2 float2: " + dataReader.ReadSingle()); // 0, 1, 4, huge
                    Output.AppendLine("4.3.2 int: " + dataReader.ReadUInt32()); // stack count
                    Output.AppendLine("buyprice: " + dataReader.ReadInt32());
                    Output.AppendLine("sellprice: " + dataReader.ReadInt32());
                    Output.AppendLine("inventorytype: " + dataReader.ReadInt32());
                    Output.AppendLine("allowableclass: " + dataReader.ReadInt32());
                    Output.AppendLine("allowablerace: " + dataReader.ReadInt32());
                    Output.AppendLine("itemlevel: " + dataReader.ReadInt32());
                    Output.AppendLine("requiredlevel: " + dataReader.ReadInt32());
                    Output.AppendLine("requiredskill: " + dataReader.ReadInt32());
                    Output.AppendLine("requiredskillrank: " + dataReader.ReadInt32());
                    Output.AppendLine("requiredspell: " + dataReader.ReadInt32());
                    Output.AppendLine("requiredhonorrank: " + dataReader.ReadInt32());
                    Output.AppendLine("requiredcityrank: " + dataReader.ReadInt32());
                    Output.AppendLine("requiredreputationfaction: " + dataReader.ReadInt32());
                    Output.AppendLine("requiredreputationrank: " + dataReader.ReadInt32());
                    Output.AppendLine("maxcount: " + dataReader.ReadInt32());
                    Output.AppendLine("stackable: " + dataReader.ReadInt32());
                    Output.AppendLine("containerslots: " + dataReader.ReadInt32());
                    Output.AppendLine("stat_type1: " + dataReader.ReadInt32());
                    Output.AppendLine("stat_type2: " + dataReader.ReadInt32());
                    Output.AppendLine("stat_type3: " + dataReader.ReadInt32());
                    Output.AppendLine("stat_type4: " + dataReader.ReadInt32());
                    Output.AppendLine("stat_type5: " + dataReader.ReadInt32());
                    Output.AppendLine("stat_type6: " + dataReader.ReadInt32());
                    Output.AppendLine("stat_type7: " + dataReader.ReadInt32());
                    Output.AppendLine("stat_type8: " + dataReader.ReadInt32());
                    Output.AppendLine("stat_type9: " + dataReader.ReadInt32());
                    Output.AppendLine("stat_type10: " + dataReader.ReadInt32());
                    Output.AppendLine("stat_value1: " + dataReader.ReadInt32());
                    Output.AppendLine("stat_value2: " + dataReader.ReadInt32());
                    Output.AppendLine("stat_value3: " + dataReader.ReadInt32());
                    Output.AppendLine("stat_value4: " + dataReader.ReadInt32());
                    Output.AppendLine("stat_value5: " + dataReader.ReadInt32());
                    Output.AppendLine("stat_value6: " + dataReader.ReadInt32());
                    Output.AppendLine("stat_value7: " + dataReader.ReadInt32());
                    Output.AppendLine("stat_value8: " + dataReader.ReadInt32());
                    Output.AppendLine("stat_value9: " + dataReader.ReadInt32());
                    Output.AppendLine("stat_value10: " + dataReader.ReadInt32());
                    Output.AppendLine("stat_unk1_1: " + dataReader.ReadInt32());
                    Output.AppendLine("stat_unk1_2: " + dataReader.ReadInt32());
                    Output.AppendLine("stat_unk1_3: " + dataReader.ReadInt32());
                    Output.AppendLine("stat_unk1_4: " + dataReader.ReadInt32());
                    Output.AppendLine("stat_unk1_5: " + dataReader.ReadInt32());
                    Output.AppendLine("stat_unk1_6: " + dataReader.ReadInt32());
                    Output.AppendLine("stat_unk1_7: " + dataReader.ReadInt32());
                    Output.AppendLine("stat_unk1_8: " + dataReader.ReadInt32());
                    Output.AppendLine("stat_unk1_9: " + dataReader.ReadInt32());
                    Output.AppendLine("stat_unk1_10: " + dataReader.ReadInt32());
                    Output.AppendLine("stat_unk2_1: " + dataReader.ReadInt32());
                    Output.AppendLine("stat_unk2_2: " + dataReader.ReadInt32());
                    Output.AppendLine("stat_unk2_3: " + dataReader.ReadInt32());
                    Output.AppendLine("stat_unk2_4: " + dataReader.ReadInt32());
                    Output.AppendLine("stat_unk2_5: " + dataReader.ReadInt32());
                    Output.AppendLine("stat_unk2_6: " + dataReader.ReadInt32());
                    Output.AppendLine("stat_unk2_7: " + dataReader.ReadInt32());
                    Output.AppendLine("stat_unk2_8: " + dataReader.ReadInt32());
                    Output.AppendLine("stat_unk2_9: " + dataReader.ReadInt32());
                    Output.AppendLine("stat_unk2_10: " + dataReader.ReadInt32());
                    Output.AppendLine("scalingstatdistribution: " + dataReader.ReadInt32());
                    Output.AppendLine("damagetype: " + dataReader.ReadInt32());
                    Output.AppendLine("delay: " + dataReader.ReadInt32());
                    Output.AppendLine("rangedmodrange: " + dataReader.ReadSingle());
                    Output.AppendLine("spellid_1: " + dataReader.ReadInt32());
                    Output.AppendLine("spellid_2: " + dataReader.ReadInt32());
                    Output.AppendLine("spellid_3: " + dataReader.ReadInt32());
                    Output.AppendLine("spellid_4: " + dataReader.ReadInt32());
                    Output.AppendLine("spellid_5: " + dataReader.ReadInt32());
                    Output.AppendLine("spelltrigger_1: " + dataReader.ReadInt32());
                    Output.AppendLine("spelltrigger_2: " + dataReader.ReadInt32());
                    Output.AppendLine("spelltrigger_3: " + dataReader.ReadInt32());
                    Output.AppendLine("spelltrigger_4: " + dataReader.ReadInt32());
                    Output.AppendLine("spelltrigger_5: " + dataReader.ReadInt32());
                    Output.AppendLine("spellcharges_1: " + dataReader.ReadInt32());
                    Output.AppendLine("spellcharges_2: " + dataReader.ReadInt32());
                    Output.AppendLine("spellcharges_3: " + dataReader.ReadInt32());
                    Output.AppendLine("spellcharges_4: " + dataReader.ReadInt32());
                    Output.AppendLine("spellcharges_5: " + dataReader.ReadInt32());
                    Output.AppendLine("spellcooldown_1: " + dataReader.ReadInt32());
                    Output.AppendLine("spellcooldown_2: " + dataReader.ReadInt32());
                    Output.AppendLine("spellcooldown_3: " + dataReader.ReadInt32());
                    Output.AppendLine("spellcooldown_4: " + dataReader.ReadInt32());
                    Output.AppendLine("spellcooldown_5: " + dataReader.ReadInt32());
                    Output.AppendLine("spellcategory_1: " + dataReader.ReadInt32());
                    Output.AppendLine("spellcategory_2: " + dataReader.ReadInt32());
                    Output.AppendLine("spellcategory_3: " + dataReader.ReadInt32());
                    Output.AppendLine("spellcategory_4: " + dataReader.ReadInt32());
                    Output.AppendLine("spellcategory_5: " + dataReader.ReadInt32());
                    Output.AppendLine("spellcategorycooldown_1: " + dataReader.ReadInt32());
                    Output.AppendLine("spellcategorycooldown_2: " + dataReader.ReadInt32());
                    Output.AppendLine("spellcategorycooldown_3: " + dataReader.ReadInt32());
                    Output.AppendLine("spellcategorycooldown_4: " + dataReader.ReadInt32());
                    Output.AppendLine("spellcategorycooldown_5: " + dataReader.ReadInt32());
                    Output.AppendLine("bonding: " + dataReader.ReadInt32());
                    Output.AppendLine("name: " + dataReader.ReadPascalString16());
                    Output.AppendLine("name2: " + dataReader.ReadPascalString16());
                    Output.AppendLine("name3: " + dataReader.ReadPascalString16());
                    Output.AppendLine("name4: " + dataReader.ReadPascalString16());
                    Output.AppendLine("description: " + dataReader.ReadPascalString16());
                    Output.AppendLine("pagetext: " + dataReader.ReadInt32());
                    Output.AppendLine("languageid: " + dataReader.ReadInt32());
                    Output.AppendLine("pagematerial: " + dataReader.ReadInt32());
                    Output.AppendLine("startquest: " + dataReader.ReadInt32());
                    Output.AppendLine("lockid: " + dataReader.ReadInt32());
                    Output.AppendLine("material: " + dataReader.ReadInt32());
                    Output.AppendLine("sheath: " + dataReader.ReadInt32());
                    Output.AppendLine("randomproperty: " + dataReader.ReadInt32());
                    Output.AppendLine("randomsuffix: " + dataReader.ReadInt32());
                    Output.AppendLine("itemset: " + dataReader.ReadInt32());
                    Output.AppendLine("area: " + dataReader.ReadInt32());
                    Output.AppendLine("map: " + dataReader.ReadInt32());
                    Output.AppendLine("bagfamily: " + dataReader.ReadInt32());
                    Output.AppendLine("totemcategory: " + dataReader.ReadInt32());
                    Output.AppendLine("socketcolor_1: " + dataReader.ReadInt32());
                    Output.AppendLine("socketcolor_2: " + dataReader.ReadInt32());
                    Output.AppendLine("socketcolor_3: " + dataReader.ReadInt32());
                    Output.AppendLine("socketcontent_1: " + dataReader.ReadInt32());
                    Output.AppendLine("socketcontent_2: " + dataReader.ReadInt32());
                    Output.AppendLine("socketcontent_3: " + dataReader.ReadInt32());
                    Output.AppendLine("socketbonus: " + dataReader.ReadInt32());
                    Output.AppendLine("gemproperties: " + dataReader.ReadInt32());
                    Output.AppendLine("armordamagemodifier: " + dataReader.ReadSingle());
                    Output.AppendLine("duration: " + dataReader.ReadInt32());
                    Output.AppendLine("itemlimitcategory: " + dataReader.ReadInt32());
                    Output.AppendLine("holidayid: " + dataReader.ReadInt32());
                    Output.AppendLine("statscalingfactor: " + dataReader.ReadSingle());
                    Output.AppendLine("arch_field_130: " + dataReader.ReadInt32());
                    Output.AppendLine("arch_field_131: " + dataReader.ReadInt32());
                }
                else
                    throw new Exception("Unknown item update type: " + type);

                if (!dataReader.IsRead)
                    throw new Exception("Data was not read fully, bytes still not read: " + dataReader.RemainingLength);
            }
        }
Example #44
0
        protected override void InternalParse()
        {
            int    row;
            int    size;
            DB2Ids type;

            Output.AppendLine("Data Size: " + (size = Reader.ReadInt32()));
            byte[] data = Reader.ReadBytes(size);

            Output.AppendLine("Type: " + (type = (DB2Ids)Reader.ReadUInt32()));
            Output.AppendLine("Row: " + (row = Reader.ReadInt32()));
            Output.AppendLine("Time(?): " + Reader.ReadUInt32().AsUnixTime());
            Output.AppendLine();

            if (row < 0)
            {
                return;
            }

            using (var dataReader = new StreamHandler(data))
            {
                if (type == DB2Ids.Item)
                {
                    Output.AppendLine("Item Id: " + dataReader.ReadUInt32());
                    Output.AppendLine("Class: " + (ItemClass)dataReader.ReadUInt32());
                    Output.AppendLine("SubClass: " + (ItemSubClass)dataReader.ReadUInt32());
                    Output.AppendLine("Unk -1: " + dataReader.ReadInt32());
                    Output.AppendLine("Material: " + (Material)dataReader.ReadUInt32());
                    Output.AppendLine("Display Id: " + dataReader.ReadUInt32());
                    Output.AppendLine("Inventory Type: " + (InventorySlot)dataReader.ReadUInt32());
                    Output.AppendLine("Sheath: " + dataReader.ReadUInt32());
                }
                else if (type == DB2Ids.ItemSparse)
                {
                    Output.AppendLine("id: " + dataReader.ReadInt32());
                    Output.AppendLine("quality: " + (ItemQuality)dataReader.ReadInt32());
                    Output.AppendLine("flags: " + dataReader.ReadUInt32());
                    Output.AppendLine("flags2: " + dataReader.ReadUInt32());
                    Output.AppendLine("4.3.2 float1: " + dataReader.ReadSingle()); // 0.95-1.05
                    Output.AppendLine("4.3.2 float2: " + dataReader.ReadSingle()); // 0, 1, 4, huge
                    Output.AppendLine("4.3.2 int: " + dataReader.ReadUInt32());    // stack count
                    Output.AppendLine("buyprice: " + dataReader.ReadInt32());
                    Output.AppendLine("sellprice: " + dataReader.ReadInt32());
                    Output.AppendLine("inventorytype: " + dataReader.ReadInt32());
                    Output.AppendLine("allowableclass: " + dataReader.ReadInt32());
                    Output.AppendLine("allowablerace: " + dataReader.ReadInt32());
                    Output.AppendLine("itemlevel: " + dataReader.ReadInt32());
                    Output.AppendLine("requiredlevel: " + dataReader.ReadInt32());
                    Output.AppendLine("requiredskill: " + dataReader.ReadInt32());
                    Output.AppendLine("requiredskillrank: " + dataReader.ReadInt32());
                    Output.AppendLine("requiredspell: " + dataReader.ReadInt32());
                    Output.AppendLine("requiredhonorrank: " + dataReader.ReadInt32());
                    Output.AppendLine("requiredcityrank: " + dataReader.ReadInt32());
                    Output.AppendLine("requiredreputationfaction: " + dataReader.ReadInt32());
                    Output.AppendLine("requiredreputationrank: " + dataReader.ReadInt32());
                    Output.AppendLine("maxcount: " + dataReader.ReadInt32());
                    Output.AppendLine("stackable: " + dataReader.ReadInt32());
                    Output.AppendLine("containerslots: " + dataReader.ReadInt32());
                    Output.AppendLine("stat_type1: " + dataReader.ReadInt32());
                    Output.AppendLine("stat_type2: " + dataReader.ReadInt32());
                    Output.AppendLine("stat_type3: " + dataReader.ReadInt32());
                    Output.AppendLine("stat_type4: " + dataReader.ReadInt32());
                    Output.AppendLine("stat_type5: " + dataReader.ReadInt32());
                    Output.AppendLine("stat_type6: " + dataReader.ReadInt32());
                    Output.AppendLine("stat_type7: " + dataReader.ReadInt32());
                    Output.AppendLine("stat_type8: " + dataReader.ReadInt32());
                    Output.AppendLine("stat_type9: " + dataReader.ReadInt32());
                    Output.AppendLine("stat_type10: " + dataReader.ReadInt32());
                    Output.AppendLine("stat_value1: " + dataReader.ReadInt32());
                    Output.AppendLine("stat_value2: " + dataReader.ReadInt32());
                    Output.AppendLine("stat_value3: " + dataReader.ReadInt32());
                    Output.AppendLine("stat_value4: " + dataReader.ReadInt32());
                    Output.AppendLine("stat_value5: " + dataReader.ReadInt32());
                    Output.AppendLine("stat_value6: " + dataReader.ReadInt32());
                    Output.AppendLine("stat_value7: " + dataReader.ReadInt32());
                    Output.AppendLine("stat_value8: " + dataReader.ReadInt32());
                    Output.AppendLine("stat_value9: " + dataReader.ReadInt32());
                    Output.AppendLine("stat_value10: " + dataReader.ReadInt32());
                    Output.AppendLine("stat_unk1_1: " + dataReader.ReadInt32());
                    Output.AppendLine("stat_unk1_2: " + dataReader.ReadInt32());
                    Output.AppendLine("stat_unk1_3: " + dataReader.ReadInt32());
                    Output.AppendLine("stat_unk1_4: " + dataReader.ReadInt32());
                    Output.AppendLine("stat_unk1_5: " + dataReader.ReadInt32());
                    Output.AppendLine("stat_unk1_6: " + dataReader.ReadInt32());
                    Output.AppendLine("stat_unk1_7: " + dataReader.ReadInt32());
                    Output.AppendLine("stat_unk1_8: " + dataReader.ReadInt32());
                    Output.AppendLine("stat_unk1_9: " + dataReader.ReadInt32());
                    Output.AppendLine("stat_unk1_10: " + dataReader.ReadInt32());
                    Output.AppendLine("stat_unk2_1: " + dataReader.ReadInt32());
                    Output.AppendLine("stat_unk2_2: " + dataReader.ReadInt32());
                    Output.AppendLine("stat_unk2_3: " + dataReader.ReadInt32());
                    Output.AppendLine("stat_unk2_4: " + dataReader.ReadInt32());
                    Output.AppendLine("stat_unk2_5: " + dataReader.ReadInt32());
                    Output.AppendLine("stat_unk2_6: " + dataReader.ReadInt32());
                    Output.AppendLine("stat_unk2_7: " + dataReader.ReadInt32());
                    Output.AppendLine("stat_unk2_8: " + dataReader.ReadInt32());
                    Output.AppendLine("stat_unk2_9: " + dataReader.ReadInt32());
                    Output.AppendLine("stat_unk2_10: " + dataReader.ReadInt32());
                    Output.AppendLine("scalingstatdistribution: " + dataReader.ReadInt32());
                    Output.AppendLine("damagetype: " + dataReader.ReadInt32());
                    Output.AppendLine("delay: " + dataReader.ReadInt32());
                    Output.AppendLine("rangedmodrange: " + dataReader.ReadSingle());
                    Output.AppendLine("spellid_1: " + dataReader.ReadInt32());
                    Output.AppendLine("spellid_2: " + dataReader.ReadInt32());
                    Output.AppendLine("spellid_3: " + dataReader.ReadInt32());
                    Output.AppendLine("spellid_4: " + dataReader.ReadInt32());
                    Output.AppendLine("spellid_5: " + dataReader.ReadInt32());
                    Output.AppendLine("spelltrigger_1: " + dataReader.ReadInt32());
                    Output.AppendLine("spelltrigger_2: " + dataReader.ReadInt32());
                    Output.AppendLine("spelltrigger_3: " + dataReader.ReadInt32());
                    Output.AppendLine("spelltrigger_4: " + dataReader.ReadInt32());
                    Output.AppendLine("spelltrigger_5: " + dataReader.ReadInt32());
                    Output.AppendLine("spellcharges_1: " + dataReader.ReadInt32());
                    Output.AppendLine("spellcharges_2: " + dataReader.ReadInt32());
                    Output.AppendLine("spellcharges_3: " + dataReader.ReadInt32());
                    Output.AppendLine("spellcharges_4: " + dataReader.ReadInt32());
                    Output.AppendLine("spellcharges_5: " + dataReader.ReadInt32());
                    Output.AppendLine("spellcooldown_1: " + dataReader.ReadInt32());
                    Output.AppendLine("spellcooldown_2: " + dataReader.ReadInt32());
                    Output.AppendLine("spellcooldown_3: " + dataReader.ReadInt32());
                    Output.AppendLine("spellcooldown_4: " + dataReader.ReadInt32());
                    Output.AppendLine("spellcooldown_5: " + dataReader.ReadInt32());
                    Output.AppendLine("spellcategory_1: " + dataReader.ReadInt32());
                    Output.AppendLine("spellcategory_2: " + dataReader.ReadInt32());
                    Output.AppendLine("spellcategory_3: " + dataReader.ReadInt32());
                    Output.AppendLine("spellcategory_4: " + dataReader.ReadInt32());
                    Output.AppendLine("spellcategory_5: " + dataReader.ReadInt32());
                    Output.AppendLine("spellcategorycooldown_1: " + dataReader.ReadInt32());
                    Output.AppendLine("spellcategorycooldown_2: " + dataReader.ReadInt32());
                    Output.AppendLine("spellcategorycooldown_3: " + dataReader.ReadInt32());
                    Output.AppendLine("spellcategorycooldown_4: " + dataReader.ReadInt32());
                    Output.AppendLine("spellcategorycooldown_5: " + dataReader.ReadInt32());
                    Output.AppendLine("bonding: " + dataReader.ReadInt32());
                    Output.AppendLine("name: " + dataReader.ReadPascalString16());
                    Output.AppendLine("name2: " + dataReader.ReadPascalString16());
                    Output.AppendLine("name3: " + dataReader.ReadPascalString16());
                    Output.AppendLine("name4: " + dataReader.ReadPascalString16());
                    Output.AppendLine("description: " + dataReader.ReadPascalString16());
                    Output.AppendLine("pagetext: " + dataReader.ReadInt32());
                    Output.AppendLine("languageid: " + dataReader.ReadInt32());
                    Output.AppendLine("pagematerial: " + dataReader.ReadInt32());
                    Output.AppendLine("startquest: " + dataReader.ReadInt32());
                    Output.AppendLine("lockid: " + dataReader.ReadInt32());
                    Output.AppendLine("material: " + dataReader.ReadInt32());
                    Output.AppendLine("sheath: " + dataReader.ReadInt32());
                    Output.AppendLine("randomproperty: " + dataReader.ReadInt32());
                    Output.AppendLine("randomsuffix: " + dataReader.ReadInt32());
                    Output.AppendLine("itemset: " + dataReader.ReadInt32());
                    Output.AppendLine("area: " + dataReader.ReadInt32());
                    Output.AppendLine("map: " + dataReader.ReadInt32());
                    Output.AppendLine("bagfamily: " + dataReader.ReadInt32());
                    Output.AppendLine("totemcategory: " + dataReader.ReadInt32());
                    Output.AppendLine("socketcolor_1: " + dataReader.ReadInt32());
                    Output.AppendLine("socketcolor_2: " + dataReader.ReadInt32());
                    Output.AppendLine("socketcolor_3: " + dataReader.ReadInt32());
                    Output.AppendLine("socketcontent_1: " + dataReader.ReadInt32());
                    Output.AppendLine("socketcontent_2: " + dataReader.ReadInt32());
                    Output.AppendLine("socketcontent_3: " + dataReader.ReadInt32());
                    Output.AppendLine("socketbonus: " + dataReader.ReadInt32());
                    Output.AppendLine("gemproperties: " + dataReader.ReadInt32());
                    Output.AppendLine("armordamagemodifier: " + dataReader.ReadSingle());
                    Output.AppendLine("duration: " + dataReader.ReadInt32());
                    Output.AppendLine("itemlimitcategory: " + dataReader.ReadInt32());
                    Output.AppendLine("holidayid: " + dataReader.ReadInt32());
                    Output.AppendLine("statscalingfactor: " + dataReader.ReadSingle());
                    Output.AppendLine("arch_field_130: " + dataReader.ReadInt32());
                    Output.AppendLine("arch_field_131: " + dataReader.ReadInt32());
                }
                else
                {
                    throw new Exception("Unknown item update type: " + type);
                }

                if (!dataReader.IsRead)
                {
                    throw new Exception("Data was not read fully, bytes still not read: " + dataReader.RemainingLength);
                }
            }
        }
 protected override void ElementRead(StreamHandler reader, int index)
 {
     this.Time = reader.ReadUInt32();
 }
Example #46
0
        public override void Read(StreamHandler reader)
        {
            this.UpdateType = (LFGUpdateType)reader.ReadByte();
            this.ExtraData = reader.ReadBoolean();
            if (ExtraData)
            {
                this.Queued = reader.ReadBoolean();

                reader.Skip(2); // 2 bools

                uint count = reader.ReadByte();
                Dungeons = new DungeonEntry[count];
                for (uint i = 0; i < count; ++i)
                    Dungeons[i] = new DungeonEntry(reader.ReadUInt32());

                this.Comment = reader.ReadCString();
            }
        }
Example #47
0
        public override void Read(StreamHandler Reader)
        {
            Caster = Reader.ReadPackedGuid();
            CastInvoker = Reader.ReadPackedGuid();
            CastId = Reader.ReadByte();
            SpellId = Reader.ReadUInt32();
            Flags = (CastFlags)Reader.ReadUInt32();
            Unk43 = Reader.ReadUInt32();
            CastTime = Reader.ReadUInt32();

            byte hits = Reader.ReadByte();
            Hits.Capacity = hits;
            for (byte i = 0; i < hits; ++i)
                Hits.Add(Reader.ReadGuid());

            byte misses = Reader.ReadByte();
            Misses.Capacity = misses;
            for (byte i = 0; i < misses; ++i)
            {
                var miss = new MissData();
                miss.Read(Reader);
                Misses.Add(miss);
            }

            TargetData.Read(Reader);

            if ((Flags & CastFlags.PredictedPower) != 0)
                PredictedPower = Reader.ReadUInt32();

            if ((Flags & CastFlags.RuneStates) != 0)
            {
                RunesBefore = (RuneStates)Reader.ReadByte();
                RunesAfter = (RuneStates)Reader.ReadByte();
                for (int i = 0; i < RuneCooldowns.Length; ++i)
                    RuneCooldowns[i] = Reader.ReadByte();
            }

            if ((Flags & CastFlags.Unk0x00020000) != 0)
            {
                Unk0x20000_Float = Reader.ReadSingle();
                Unk0x20000_UInt32 = Reader.ReadUInt32();
            }

            if ((Flags & CastFlags.Ammo) != 0)
            {
                ProjectileDisplayId = Reader.ReadUInt32();
                ProjectileInventoryType = (InventorySlotType)Reader.ReadUInt32();
            }

            if ((Flags & CastFlags.Unk0x00080000) != 0)
            {
                Unk0x80000_UInt32_1 = Reader.ReadUInt32();
                Unk0x80000_UInt32_2 = Reader.ReadUInt32();
            }

            if ((TargetData.Flags & SpellCastTargetFlags.DestLocation) != 0)
                DestLocationCounter = Reader.ReadByte();

            if ((TargetData.Flags & SpellCastTargetFlags.Unk4) != 0)
            {
                uint count = Reader.ReadUInt32();
                Unk4_Count = count;
                Unk4_List.Capacity = (int)count;

                for (uint i = 0; i < count; ++i)
                {
                    Vector3 v3 = Reader.ReadVector3();
                    WowGuid guid = Reader.ReadGuid();
                    Unk4_List.Add(new KeyValuePair<WowGuid, Vector3>(guid, v3));
                    if (guid.IsEmpty)
                        break;
                }
            }
        }
Example #48
0
        protected override unsafe void InternalOpenForReading(Stream stream, bool closeStream)
        {
            base.InternalOpenForReading(stream, closeStream);

            int optLen;

            var headerBytes = m_stream.ReadBytes(MainHeader.Size);

            fixed(byte *ptr = headerBytes)
            {
                var header = (MainHeader *)ptr;

                GetClientBuildInfo(header->ClientBuild);

                var langBytes = stackalloc byte[5];

                langBytes[0] = header->Lang[0];
                langBytes[1] = header->Lang[1];
                langBytes[2] = (byte)'-';
                langBytes[3] = header->Lang[2];
                langBytes[4] = header->Lang[3];
                var lang = new string((sbyte *)langBytes, 0, 5);

                try
                {
                    this.Culture = CultureInfo.GetCultureInfo(lang);
                }
                catch
                {
                }

                optLen = header->OptionalHeaderLength;
                Marshal.Copy(new IntPtr(header->SessionKey), m_sessionKey, 0, 40);
                this.SnifferId  = (PktSnifferId)header->SnifferId;
                this.StartTicks = header->StartedOnTicks;
                this.StartTime  = header->StartedOnUnix.AsUnixTime();
            }

            if (this.SnifferId == PktSnifferId.Kamilla)
            {
                using (var reader = new StreamHandler(m_stream.ReadBytes(optLen)))
                {
                    var flags = (OptHeaderFlags)reader.ReadUInt32();

                    if ((flags & OptHeaderFlags.HasOCAD) != 0)
                    {
                        reader.Skip(4);
                    }

                    if ((flags & OptHeaderFlags.HasSnifferDescString) != 0)
                    {
                        this.SnifferDesc = reader.ReadCString();
                    }

                    if ((flags & OptHeaderFlags.HasFCAD) != 0)
                    {
                        this.FCAD = reader.ReadBytes(16);
                    }

                    if ((flags & OptHeaderFlags.HasSCAD) != 0)
                    {
                        this.SCAD = reader.ReadBytes(16);
                    }
                }
            }
            else
            {
                m_stream.Skip(optLen);
            }

            this.InternalSetCapacity((int)((m_stream.Length - m_stream.Position) / 100));
        }
Example #49
0
        public override void Read(StreamHandler Reader)
        {
            Caster = Reader.ReadPackedGuid();
            CastInvoker = Reader.ReadPackedGuid();
            CastId = Reader.ReadByte();
            SpellId = Reader.ReadUInt32();
            Flags = (CastFlags)Reader.ReadUInt32();
            Unk43 = Reader.ReadUInt32();
            Unk43_2 = Reader.ReadUInt32();

            TargetData.Read(Reader);

            if ((Flags & CastFlags.PredictedPower) != 0)
                PredictedPower = Reader.ReadUInt32();

            if ((Flags & CastFlags.RuneStates) != 0)
            {
                RunesBefore = (RuneStates)Reader.ReadByte();
                RunesAfter = (RuneStates)Reader.ReadByte();
                for (int i = 0; i < RuneCooldowns.Length; ++i)
                    RuneCooldowns[i] = Reader.ReadByte();
            }

            if ((Flags & CastFlags.Ammo) != 0)
            {
                ProjectileDisplayId = Reader.ReadUInt32();
                ProjectileInventoryType = (InventorySlotType)Reader.ReadUInt32();
            }

            if ((Flags & CastFlags.Unk0x04000000) != 0)
            {
                Unk0x04000000_UInt32_1 = Reader.ReadUInt32();
                Unk0x04000000_UInt32_2 = Reader.ReadUInt32();
            }
        }
Example #50
0
        /// <summary>
        /// Reads the spline info from the current stream,
        /// advancing the current position by spline info's size.
        /// </summary>
        public static SplineInfo ReadSplineInfo(this StreamHandler Reader)
        {
            var info = new SplineInfo();

            var flags = info.Flags = (SplineFlags)Reader.ReadUInt32();

            if ((flags & SplineFlags.FinalPoint) != SplineFlags.None)
            {
                info.FinalPoint = Reader.ReadVector3();
            }

            if ((flags & SplineFlags.FinalTarget) != SplineFlags.None)
            {
                info.FinalGuid = Reader.ReadGuid();
            }

            if ((flags & SplineFlags.FinalOrient) != SplineFlags.None)
            {
                info.FinalRotation = Reader.ReadSingle();
            }

            info.CurrentTime        = Reader.ReadUInt32();
            info.FullTime           = Reader.ReadUInt32();
            info.Unknown1           = Reader.ReadUInt32();
            info.DurationMultiplier = Reader.ReadSingle();
            info.UnknownFloat2      = Reader.ReadSingle();
            info.UnknownFloat3      = Reader.ReadSingle();
            info.Unknown2           = Reader.ReadUInt32();
            int count = Reader.ReadInt32();

            var points = info.Points;

            points.Capacity = count;
            for (int i = 0; i < count; ++i)
            {
                points.Add(Reader.ReadVector3());
            }

            if ((flags & (SplineFlags.Flying | SplineFlags.CatMullRom)) != 0)
            {
                if ((flags & SplineFlags.Cyclic) != 0)
                {
                    points.RemoveAt(0);

                    if ((flags & SplineFlags.EnterCycle) != 0)
                    {
                        points.RemoveAt(0);
                    }

                    points.RemoveAt(points.Count - 1);
                    points.RemoveAt(points.Count - 1);
                }
                else
                {
                    points.RemoveAt(0);
                    points.RemoveAt(points.Count - 1);
                }
            }

            info.SplineMode = (SplineMode)Reader.ReadByte();
            info.EndPoint   = Reader.ReadVector3();

            return(info);
        }
Example #51
0
        public override void Read(StreamHandler Reader)
        {
            Caster      = Reader.ReadPackedGuid();
            CastInvoker = Reader.ReadPackedGuid();
            CastId      = Reader.ReadByte();
            SpellId     = Reader.ReadUInt32();
            Flags       = (CastFlags)Reader.ReadUInt32();
            Unk43       = Reader.ReadUInt32();
            CastTime    = Reader.ReadUInt32();

            byte hits = Reader.ReadByte();

            Hits.Capacity = hits;
            for (byte i = 0; i < hits; ++i)
            {
                Hits.Add(Reader.ReadGuid());
            }

            byte misses = Reader.ReadByte();

            Misses.Capacity = misses;
            for (byte i = 0; i < misses; ++i)
            {
                var miss = new MissData();
                miss.Read(Reader);
                Misses.Add(miss);
            }

            TargetData.Read(Reader);

            if ((Flags & CastFlags.PredictedPower) != 0)
            {
                PredictedPower = Reader.ReadUInt32();
            }

            if ((Flags & CastFlags.RuneStates) != 0)
            {
                RunesBefore = (RuneStates)Reader.ReadByte();
                RunesAfter  = (RuneStates)Reader.ReadByte();
                for (int i = 0; i < RuneCooldowns.Length; ++i)
                {
                    RuneCooldowns[i] = Reader.ReadByte();
                }
            }

            if ((Flags & CastFlags.Unk0x00020000) != 0)
            {
                Unk0x20000_Float  = Reader.ReadSingle();
                Unk0x20000_UInt32 = Reader.ReadUInt32();
            }

            if ((Flags & CastFlags.Ammo) != 0)
            {
                ProjectileDisplayId     = Reader.ReadUInt32();
                ProjectileInventoryType = (InventorySlotType)Reader.ReadUInt32();
            }

            if ((Flags & CastFlags.Unk0x00080000) != 0)
            {
                Unk0x80000_UInt32_1 = Reader.ReadUInt32();
                Unk0x80000_UInt32_2 = Reader.ReadUInt32();
            }

            if ((TargetData.Flags & SpellCastTargetFlags.DestLocation) != 0)
            {
                DestLocationCounter = Reader.ReadByte();
            }

            if ((TargetData.Flags & SpellCastTargetFlags.Unk4) != 0)
            {
                uint count = Reader.ReadUInt32();
                Unk4_Count         = count;
                Unk4_List.Capacity = (int)count;

                for (uint i = 0; i < count; ++i)
                {
                    Vector3 v3   = Reader.ReadVector3();
                    WowGuid guid = Reader.ReadGuid();
                    Unk4_List.Add(new KeyValuePair <WowGuid, Vector3>(guid, v3));
                    if (guid.IsEmpty)
                    {
                        break;
                    }
                }
            }
        }
Example #52
0
        private void ReadFromStreamHandler(StreamHandler Reader, WowOpcodes opcode)
        {
            GameMasterMessage = (opcode == WowOpcodes.SMSG_GM_MESSAGECHAT);

            m_type = (ChatMessageType)Reader.ReadByte();
            if (m_type == ChatMessageType.Addon2)
                m_type = ChatMessageType.Addon;

            m_language = (Language)Reader.ReadUInt32();
            m_senderGUID = Reader.ReadGuid();
            m_unknownUInt32 = Reader.ReadUInt32();

            switch (m_type)
            {
                case ChatMessageType.MonsterSay:
                case ChatMessageType.MonsterParty:
                case ChatMessageType.MonsterYell:
                case ChatMessageType.MonsterWhisper:
                case ChatMessageType.MonsterEmote:
                case ChatMessageType.BattleNet:
                case ChatMessageType.RaidBossEmote:
                case ChatMessageType.RaidBossWhisper:
                    Reader.Skip(4);
                    m_senderName = Reader.ReadCString();
                    m_targetGUID = Reader.ReadGuid();
                    if (!m_targetGUID.IsEmpty
                        && !m_targetGUID.IsPlayer
                        && !m_targetGUID.IsPet)
                    {
                        Reader.Skip(4);
                        m_targetName = Reader.ReadCString();
                    }
                    if (m_language == Language.Addon)
                        m_addonPrefix = Reader.ReadCString();
                    Reader.Skip(4);
                    m_text = Reader.ReadCString();
                    m_flags = (ChatMessageFlags)Reader.ReadByte();
                    if (m_type == ChatMessageType.RaidBossEmote || m_type == ChatMessageType.RaidBossWhisper)
                    {
                        m_displayTime = Reader.ReadSingle();
                        m_suspendEvent = Reader.ReadBoolean();
                    }
                    break;
                case ChatMessageType.BGSystemNeutral:
                case ChatMessageType.BGSystemAlliance:
                case ChatMessageType.BGSystemHorde:
                    m_targetGUID = Reader.ReadGuid();
                    if (!m_targetGUID.IsEmpty
                        && !m_targetGUID.IsPlayer)
                    {
                        Reader.Skip(4);
                        m_targetName = Reader.ReadCString();
                    }
                    if (m_language == Language.Addon)
                        m_addonPrefix = Reader.ReadCString();
                    Reader.Skip(4);
                    m_text = Reader.ReadCString();
                    m_flags = (ChatMessageFlags)Reader.ReadByte();
                    break;
                case ChatMessageType.Achievement:
                case ChatMessageType.GuildAchievement:
                    m_targetGUID = Reader.ReadGuid();
                    if (m_language == Language.Addon)
                        m_addonPrefix = Reader.ReadCString();
                    Reader.Skip(4);
                    m_text = Reader.ReadCString();
                    m_flags = (ChatMessageFlags)Reader.ReadByte();
                    m_achievementId = Reader.ReadUInt32();
                    break;
                case ChatMessageType.WhisperForeign:
                    Reader.Skip(4);
                    m_senderName = Reader.ReadCString();
                    m_targetGUID = Reader.ReadGuid();
                    if (m_language == Language.Addon)
                        m_addonPrefix = Reader.ReadCString();
                    Reader.Skip(4);
                    m_text = Reader.ReadCString();
                    m_flags = (ChatMessageFlags)Reader.ReadByte();
                    break;
                default:
                    if (GameMasterMessage)
                    {
                        Reader.Skip(4);
                        m_senderName = Reader.ReadCString();
                    }
                    if (m_type == ChatMessageType.Channel)
                        m_channel = Reader.ReadCString();
                    m_targetGUID = Reader.ReadGuid();
                    if (m_language == Language.Addon)
                        m_addonPrefix = Reader.ReadCString();
                    Reader.Skip(4);
                    m_text = Reader.ReadCString();
                    m_flags = (ChatMessageFlags)Reader.ReadByte();
                    break;
            }
        }
Example #53
0
        protected unsafe override void InternalOpenForReading(Stream stream, bool closeStream)
        {
            base.InternalOpenForReading(stream, closeStream);

            int optLen;

            var headerBytes = m_stream.ReadBytes(MainHeader.Size);
            fixed (byte* ptr = headerBytes)
            {
                var header = (MainHeader*)ptr;
                GetClientBuildInfo(header->ClientBuild);

                var langBytes = stackalloc byte[5];
                langBytes[0] = header->Lang[0];
                langBytes[1] = header->Lang[1];
                langBytes[2] = (byte)'-';
                langBytes[3] = header->Lang[2];
                langBytes[4] = header->Lang[3];
                var lang = new string((sbyte*)langBytes, 0, 5);
                try
                {
                    this.Culture = CultureInfo.GetCultureInfo(lang);
                }
                catch
                {
                }

                optLen = header->OptionalHeaderLength;
                Marshal.Copy(new IntPtr(header->SessionKey), m_sessionKey, 0, 40);
                this.SnifferId = (PktSnifferId)header->SnifferId;
                this.StartTicks = header->StartedOnTicks;
                this.StartTime = header->StartedOnUnix.AsUnixTime();
            }

            if (this.SnifferId == PktSnifferId.Kamilla)
            {
                using (var reader = new StreamHandler(m_stream.ReadBytes(optLen)))
                {
                    var flags = (OptHeaderFlags)reader.ReadUInt32();

                    if ((flags & OptHeaderFlags.HasOCAD) != 0)
                        reader.Skip(4);

                    if ((flags & OptHeaderFlags.HasSnifferDescString) != 0)
                        this.SnifferDesc = reader.ReadCString();

                    if ((flags & OptHeaderFlags.HasFCAD) != 0)
                        this.FCAD = reader.ReadBytes(16);

                    if ((flags & OptHeaderFlags.HasSCAD) != 0)
                        this.SCAD = reader.ReadBytes(16);
                }
            }
            else
                m_stream.Skip(optLen);

            this.InternalSetCapacity((int)((m_stream.Length - m_stream.Position) / 100));
        }
Example #54
0
 public override void Read(StreamHandler reader)
 {
     Entity       = reader.ReadGuid();
     Model        = reader.ReadUInt32();
     Race         = (Races)reader.ReadByte();
     Gender       = (Genders)reader.ReadByte();
     Class        = (Classes)reader.ReadByte();
     Skin         = reader.ReadByte();
     Face         = reader.ReadByte();
     Hair         = reader.ReadByte();
     HairColor    = reader.ReadByte();
     FaceFeatures = reader.ReadByte();
     Guild        = reader.ReadGuid();
     Head         = reader.ReadUInt32();
     Shoulders    = reader.ReadUInt32();
     Body         = reader.ReadUInt32();
     Chest        = reader.ReadUInt32();
     Waist        = reader.ReadUInt32();
     Legs         = reader.ReadUInt32();
     Feet         = reader.ReadUInt32();
     Wrists       = reader.ReadUInt32();
     Hands        = reader.ReadUInt32();
     Back         = reader.ReadUInt32();
     Tabard       = reader.ReadUInt32();
 }
Example #55
0
        public unsafe MovementInfo(StreamHandler Reader)
        {
            var guid = new WowGuid();

            this.HaveAttackingTarget    = Reader.UnalignedReadBit();
            guid.Bytes[2]               = Reader.UnalignedReadTinyInt(1);
            this.HaveVehicleData        = Reader.UnalignedReadBit();
            guid.Bytes[1]               = Reader.UnalignedReadTinyInt(1);
            guid.Bytes[4]               = Reader.UnalignedReadTinyInt(1);
            guid.Bytes[3]               = Reader.UnalignedReadTinyInt(1);
            this.HaveTransportTime      = Reader.UnalignedReadBit();
            this.HaveGameObjectPosition = Reader.UnalignedReadBit();
            bool field_1C8 = Reader.UnalignedReadBit();
            bool field_1AC = Reader.UnalignedReadBit();

            this.HaveGameObjectRotation = Reader.UnalignedReadBit();
            this.Living       = Reader.UnalignedReadBit();
            this.HavePosition = Reader.UnalignedReadBit();
            var arrCounter = Reader.UnalignedReadInt(24);

            guid.Bytes[0] = Reader.UnalignedReadTinyInt(1);

            bool    havePFlags = false;
            WowGuid p_guid;
            uint    splinePoints    = 0;
            bool    havePFlags2     = false;
            bool    haveOrientation = false;

            if (this.Living)
            {
                this.HaveTransportData = Reader.UnalignedReadBit();
                if (this.HaveTransportData)
                {
                    fixed(byte *bytes = this.TransportGuid.Bytes)
                    {
                        bytes[2] = Reader.UnalignedReadTinyInt(1);
                        bytes[7] = Reader.UnalignedReadTinyInt(1);
                        bytes[5] = Reader.UnalignedReadTinyInt(1);
                        this.HaveTransportTime3 = Reader.UnalignedReadBit();
                        bytes[3] = Reader.UnalignedReadTinyInt(1);
                        bytes[0] = Reader.UnalignedReadTinyInt(1);
                        bytes[4] = Reader.UnalignedReadTinyInt(1);
                        bytes[1] = Reader.UnalignedReadTinyInt(1);
                        this.HaveTransportTime2 = Reader.UnalignedReadBit();
                        bytes[6] = Reader.UnalignedReadTinyInt(1);
                    }
                }

                this.HaveSpline2 = Reader.UnalignedReadBit();
                p_guid.Bytes[7]  = Reader.UnalignedReadTinyInt(1);
                p_guid.Bytes[6]  = Reader.UnalignedReadTinyInt(1);
                p_guid.Bytes[5]  = Reader.UnalignedReadTinyInt(1);
                p_guid.Bytes[2]  = Reader.UnalignedReadTinyInt(1);
                p_guid.Bytes[4]  = Reader.UnalignedReadTinyInt(1);
                havePFlags       = !Reader.UnalignedReadBit();
                p_guid.Bytes[1]  = Reader.UnalignedReadTinyInt(1);
                this.SelfTarget  = Reader.UnalignedReadBit();
                this.TimeStamp   = !Reader.UnalignedReadBit() ? 1U : 0U;
                havePFlags2      = !Reader.UnalignedReadBit();

                if (this.HaveSpline2)
                {
                    this.HaveSpline = Reader.UnalignedReadBit();
                    if (this.HaveSpline)
                    {
                        this.Spline.HaveDurationMultiplier = Reader.UnalignedReadBit();
                        this.Spline.Flags        = (SplineFlags)Reader.UnalignedReadInt(25);
                        this.Spline.SplineMode   = (SplineMode)Reader.UnalignedReadTinyInt(2);
                        this.Spline.HaveUnknown1 = Reader.UnalignedReadBit();
                        splinePoints             = Reader.UnalignedReadInt(22);
                        var type = Reader.UnalignedReadTinyInt(2);
                        switch (type)
                        {
                        case 0:
                            this.Spline.SplineType = SplineType.FacingSpot;
                            break;

                        case 1:
                            this.Spline.SplineType = SplineType.Normal;
                            break;

                        case 2:
                            this.Spline.SplineType = SplineType.FacingTarget;
                            break;

                        case 3:
                            this.Spline.SplineType = SplineType.FacingAngle;
                            break;
                        }
                        if (this.Spline.SplineType == SplineType.FacingTarget)
                        {
                            fixed(byte *bytes = this.Spline.FacingTarget.Bytes)
                            {
                                bytes[7] = Reader.UnalignedReadTinyInt(1);
                                bytes[3] = Reader.UnalignedReadTinyInt(1);
                                bytes[4] = Reader.UnalignedReadTinyInt(1);
                                bytes[2] = Reader.UnalignedReadTinyInt(1);
                                bytes[1] = Reader.UnalignedReadTinyInt(1);
                                bytes[6] = Reader.UnalignedReadTinyInt(1);
                                bytes[0] = Reader.UnalignedReadTinyInt(1);
                                bytes[5] = Reader.UnalignedReadTinyInt(1);
                            }
                        }
                    }
                }

                p_guid.Bytes[3] = Reader.UnalignedReadTinyInt(1);
                if (havePFlags)
                {
                    this.Flags = (MovementFlags)Reader.UnalignedReadInt(30);
                }
                this.HavePitch    = !Reader.UnalignedReadBit();
                this.HaveFallData = Reader.UnalignedReadBit();

                if (havePFlags2)
                {
                    this.Flags2 = (MovementFlags2)Reader.UnalignedReadSmallInt(12);
                }

                p_guid.Bytes[0] = Reader.UnalignedReadTinyInt(1);
                haveOrientation = !Reader.UnalignedReadBit();

                if (this.HaveFallData)
                {
                    this.HaveFallDirection = Reader.UnalignedReadBit();
                }

                this.HaveSplineElevation = !Reader.UnalignedReadBit();
            }

            if (this.HaveGameObjectPosition)
            {
                fixed(byte *bytes = this.TransportGuid.Bytes)
                {
                    bytes[1] = Reader.UnalignedReadTinyInt(1);
                    this.HaveTransportTime3 = Reader.UnalignedReadBit();
                    bytes[3] = Reader.UnalignedReadTinyInt(1);
                    bytes[2] = Reader.UnalignedReadTinyInt(1);
                    bytes[6] = Reader.UnalignedReadTinyInt(1);
                    bytes[5] = Reader.UnalignedReadTinyInt(1);
                    bytes[0] = Reader.UnalignedReadTinyInt(1);
                    bytes[4] = Reader.UnalignedReadTinyInt(1);
                    this.HaveTransportTime2 = Reader.UnalignedReadBit();
                    bytes[7] = Reader.UnalignedReadTinyInt(1);
                }
            }

            ushort field_1B2 = 0;
            ushort field_1AE = 0;
            ushort field_1B0 = 0;

            if (field_1AC)
            {
                field_1B2 = (ushort)(!Reader.UnalignedReadBit() ? 1 : 0);
                field_1AE = (ushort)(!Reader.UnalignedReadBit() ? 1 : 0);
                field_1B0 = (ushort)(!Reader.UnalignedReadBit() ? 1 : 0);
            }

            if (this.HaveAttackingTarget)
            {
                fixed(byte *bytes = this.AttackingTarget.Bytes)
                {
                    bytes[3] = Reader.UnalignedReadTinyInt(1);
                    bytes[4] = Reader.UnalignedReadTinyInt(1);
                    bytes[6] = Reader.UnalignedReadTinyInt(1);
                    bytes[0] = Reader.UnalignedReadTinyInt(1);
                    bytes[1] = Reader.UnalignedReadTinyInt(1);
                    bytes[7] = Reader.UnalignedReadTinyInt(1);
                    bytes[5] = Reader.UnalignedReadTinyInt(1);
                    bytes[2] = Reader.UnalignedReadTinyInt(1);
                }
            }

            this.UnkUInt32 = new uint[arrCounter];
            for (uint i = 0; i < arrCounter; ++i)
            {
                this.UnkUInt32[i] = Reader.ReadUInt32();
            }

            if (this.HavePosition)
            {
                Reader
                .ReadSingle(out this.Position.Z)
                .ReadSingle(out this.Orientation)
                .ReadSingle(out this.Position.X)
                .ReadSingle(out this.Position.Y);
            }

            if (this.HaveVehicleData)
            {
                Reader
                .ReadUInt32(out this.VehicleId)
                .ReadSingle(out this.VehicleAimAdjustement);
            }

            if (this.HaveGameObjectPosition)
            {
                fixed(byte *bytes = this.TransportGuid.Bytes)
                {
                    Reader
                    .ReadXorByte(ref bytes[1])
                    .ReadXorByte(ref bytes[4])
                    .ReadSingle(out this.TransportPosition.Z);

                    if (this.HaveTransportTime3)
                    {
                        this.TransportTime3 = Reader.ReadUInt32();
                    }

                    this.TransportTime = Reader.ReadUInt32();

                    Reader
                    .ReadXorByte(ref bytes[5])
                    .ReadXorByte(ref bytes[6])
                    .ReadSingle(out this.TransportPosition.X)
                    .ReadXorByte(ref bytes[2]);

                    if (this.HaveTransportTime2)
                    {
                        this.TransportTime2 = Reader.ReadUInt32();
                    }

                    Reader
                    .ReadSByte(out this.TransportSeat)
                    .ReadXorByte(ref bytes[3])
                    .ReadSingle(out this.TransportPosition.Y)
                    .ReadSingle(out this.TransportFacing)
                    .ReadXorByte(ref bytes[7])
                    .ReadXorByte(ref bytes[0]);
                }
            }

            if (this.Living)
            {
                if (this.HaveSpline2)
                {
                    if (this.HaveSpline)
                    {
                        var points = this.Spline.Points;
                        points.Capacity = (int)splinePoints;
                        for (int i = 0; i < splinePoints; i++)
                        {
                            points.Add(new Vector3()
                            {
                                Y = Reader.ReadSingle(),
                                X = Reader.ReadSingle(),
                                Z = Reader.ReadSingle()
                            });
                        }

                        if (this.Spline.HaveDurationMultiplier)
                        {
                            this.Spline.DurationMultiplier = Reader.ReadSingle();
                        }

                        this.Spline.UnknownFloat2 = Reader.ReadSingle();

                        if (this.Spline.SplineType == SplineType.FacingTarget)
                        {
                            fixed(byte *bytes = this.Spline.FacingTarget.Bytes)
                            {
                                Reader
                                .ReadXorByte(ref bytes[3])
                                .ReadXorByte(ref bytes[4])
                                .ReadXorByte(ref bytes[5])
                                .ReadXorByte(ref bytes[7])
                                .ReadXorByte(ref bytes[2])
                                .ReadXorByte(ref bytes[0])
                                .ReadXorByte(ref bytes[6])
                                .ReadXorByte(ref bytes[1]);
                            }
                        }

                        if (this.Spline.HaveUnknown1)
                        {
                            this.Spline.Unknown1 = Reader.ReadUInt32();
                        }

                        this.Spline.UnknownFloat3 = Reader.ReadSingle();
                        this.Spline.Unknown2      = Reader.ReadUInt32();

                        if (this.Spline.SplineType == SplineType.FacingSpot)
                        {
                            Reader
                            .ReadSingle(out this.Spline.FacingSpot.Y)
                            .ReadSingle(out this.Spline.FacingSpot.Z)
                            .ReadSingle(out this.Spline.FacingSpot.X);
                        }

                        this.Spline.CurrentTime = Reader.ReadUInt32();

                        if (this.Spline.SplineType == SplineType.FacingAngle)
                        {
                            this.Spline.FacingAngle = Reader.ReadSingle();
                        }
                    }

                    Reader
                    .ReadSingle(out this.Spline.EndPoint.Z)
                    .ReadSingle(out this.Spline.EndPoint.Y)
                    .ReadUInt32(out this.Spline.FullTime)
                    .ReadSingle(out this.Spline.EndPoint.X);
                }

                this.Speeds[8] = Reader.ReadSingle();

                // Transport Data
                if (this.HaveTransportData)
                {
                    fixed(byte *bytes = this.TransportGuid.Bytes)
                    {
                        Reader
                        .ReadXorByte(ref bytes[4])
                        .ReadSingle(out this.TransportPosition.Z)
                        .ReadXorByte(ref bytes[7])
                        .ReadXorByte(ref bytes[5])
                        .ReadXorByte(ref bytes[1])
                        .ReadSingle(out this.TransportPosition.X)
                        .ReadXorByte(ref bytes[3])
                        .ReadXorByte(ref bytes[6]);

                        if (this.HaveTransportTime3)
                        {
                            this.TransportTime3 = Reader.ReadUInt32();
                        }

                        Reader
                        .ReadSingle(out this.TransportPosition.Y)
                        .ReadSByte(out this.TransportSeat)
                        .ReadSingle(out this.TransportFacing);

                        if (this.HaveTransportTime2)
                        {
                            this.TransportTime2 = Reader.ReadUInt32();
                        }

                        Reader
                        .ReadXorByte(ref bytes[2])
                        .ReadUInt32(out this.TransportTime)
                        .ReadXorByte(ref bytes[0]);
                    }
                }

                Reader
                .ReadSingle(out this.Speeds[7])
                .ReadSingle(out this.Position.X);

                if (this.HavePitch)
                {
                    Reader.ReadSingle(out this.Pitch);
                }

                // Fall Data
                if (this.HaveFallData)
                {
                    Reader.ReadUInt32(out this.FallTime);
                    if (this.HaveFallDirection)
                    {
                        Reader
                        .ReadSingle(out this.FallSinAngle)
                        .ReadSingle(out this.FallHorizontalSpeed)
                        .ReadSingle(out this.FallCosAngle);
                    }
                    Reader.ReadSingle(out this.FallVerticalSpeed);
                }

                Reader
                .ReadXorByte(ref p_guid.Bytes[7])
                .ReadSingle(out this.Speeds[4])
                .ReadXorByte(ref p_guid.Bytes[0])
                .ReadXorByte(ref p_guid.Bytes[5]);

                if (this.TimeStamp != 0)
                {
                    this.TimeStamp = Reader.ReadUInt32();
                }

                Reader
                .ReadSingle(out this.Position.Z)
                .ReadSingle(out this.Speeds[6])
                .ReadXorByte(ref p_guid.Bytes[1])
                .ReadSingle(out this.Speeds[2])
                .ReadSingle(out this.Speeds[5])
                .ReadSingle(out this.Speeds[3])
                .ReadSingle(out this.Speeds[0])
                .ReadXorByte(ref p_guid.Bytes[3])
                .ReadXorByte(ref p_guid.Bytes[4])
                .ReadXorByte(ref p_guid.Bytes[2])
                .ReadXorByte(ref p_guid.Bytes[6]);

                if (this.HaveSplineElevation)
                {
                    this.SplineElevation = Reader.ReadSingle();
                }

                this.Position.Y = Reader.ReadSingle();

                if (haveOrientation)
                {
                    this.Orientation = Reader.ReadSingle();
                }

                this.Speeds[1] = Reader.ReadSingle();
            }

            if (field_1C8)
            {
                Console.WriteLine("Error: 16 floats @ 1CC detected !!!");

                Reader.ReadBytes(16 * 4); // 16 floats starting at 1CC
                var field_20C = Reader.ReadByte();
            }

            // transport time
            if (this.HaveTransportTime)
            {
                Reader.ReadUInt32(out this.TransportTime);
            }

            // unk2 ?
            if (field_1AC)
            {
                Console.WriteLine("Error: 3 shorts @ 1AE detected !!!");

                if (field_1B0 != 0)
                {
                    field_1B0 = Reader.ReadUInt16();
                }
                if (field_1B2 != 0)
                {
                    field_1B2 = Reader.ReadUInt16();
                }
                if (field_1AE != 0)
                {
                    field_1AE = Reader.ReadUInt16();
                }
            }

            // go rotation?
            if (this.HaveGameObjectRotation)
            {
                this.GameObjectRotation = Reader.ReadUInt64().UnpackQuaternion();
            }

            // target guid?
            if (this.HaveAttackingTarget)
            {
                fixed(byte *bytes = this.AttackingTarget.Bytes)
                {
                    Reader
                    .ReadXorByte(ref bytes[3])
                    .ReadXorByte(ref bytes[5])
                    .ReadXorByte(ref bytes[0])
                    .ReadXorByte(ref bytes[7])
                    .ReadXorByte(ref bytes[2])
                    .ReadXorByte(ref bytes[4])
                    .ReadXorByte(ref bytes[6])
                    .ReadXorByte(ref bytes[1]);
                }
            }

            this.Guid = guid;
        }