상속: WowGuid
예제 #1
0
        public void TestConstructor()
        {
            var guid = new WowGuid64(1);

            Assert.IsNotNull(guid);
            Assert.AreEqual(1, guid.Low);
            Assert.AreEqual(0, guid.High);
        }
예제 #2
0
        public void TestGetHashCode()
        {
            var guid1 = new WowGuid64(0xF130005C0500105F);
            var guid15 = new WowGuid64(0xF130005C0500105F);
            var guid2 = new WowGuid64(0x600000002B2D7C9);

            Assert.AreEqual(guid1.GetHashCode(), guid15.GetHashCode());
            Assert.AreNotEqual(guid1.GetHashCode(), guid2.GetHashCode());
        }
예제 #3
0
        public void TestGetHighType()
        {
            var guid1 = new WowGuid64(0xF130005C0500105F);
            var guid2 = new WowGuid64(0x600000002B2D7C9);
            var guid3 = new WowGuid64(0);

            Assert.AreEqual(HighGuidType.Creature, guid1.GetHighType());
            Assert.AreEqual(HighGuidType.Player, guid2.GetHighType());
            Assert.AreEqual(HighGuidType.Null, guid3.GetHighType());
        }
예제 #4
0
        public WowGuid ReadGuid()
        {
            var guid = new WowGuid64(ReadUInt64());

            if (WriteToFile)
            {
                WriteToFile = Filters.CheckFilter(guid);
            }
            return(guid);
        }
예제 #5
0
        public void TestGetLow()
        {
            var guid1 = new WowGuid64(0xF130005C0500105F);
            var guid2 = new WowGuid64(0x600000002B2D7C9);
            var guid3 = new WowGuid64(0);

            Assert.AreEqual(0x105F, guid1.GetLow());
            Assert.AreEqual(0x2B2D7C9, guid2.GetLow());
            Assert.AreEqual(0, guid3.GetLow());
        }
예제 #6
0
        public WowGuid ReadPackedGuid()
        {
            var guid = new WowGuid64(ReadPackedUInt64());

            if (!guid.IsEmpty() && WriteToFile)
            {
                WriteToFile = Filters.CheckFilter(guid);
            }

            return(guid);
        }
예제 #7
0
        public void TestGetEntry()
        {
            ClientVersion.SetVersion(ClientVersionBuild.V3_3_5a_12340);

            var guid1 = new WowGuid64(0xF130005C0500105F);
            var guid2 = new WowGuid64(0x600000002B2D7C9);
            var guid3 = new WowGuid64(0);

            Assert.AreEqual(0x5C05, guid1.GetEntry());
            Assert.AreEqual(0, guid2.GetEntry());
            Assert.AreEqual(0, guid3.GetEntry());
        }
예제 #8
0
        public void TestEquals()
        {
            var guid1 = new WowGuid64(0xF130005C0500105F);
            var guid2 = new WowGuid64(0x600000002B2D7C9);
            var guid25 = new WowGuid64(0x600000002B2D7C9);
            var guid3 = new WowGuid64(0);

            Assert.IsFalse(guid1.Equals(guid2));
            Assert.IsTrue(guid2.Equals(guid25));
            Assert.IsTrue(guid2.Equals((object) guid25));
            Assert.IsFalse(guid2.Equals(new object()));
            Assert.IsTrue(guid3.Equals(guid3));
        }
예제 #9
0
        public static void HandlePetNameQuery(Packet packet)
        {
            var number = new byte[8];
            var guid = new byte[8];

            guid[6] = packet.ReadBit();
            number[4] = packet.ReadBit();
            number[6] = packet.ReadBit();
            number[5] = packet.ReadBit();
            guid[4] = packet.ReadBit();
            number[7] = packet.ReadBit();
            guid[5] = packet.ReadBit();
            guid[3] = packet.ReadBit();
            guid[2] = packet.ReadBit();
            guid[7] = packet.ReadBit();
            number[1] = packet.ReadBit();
            number[0] = packet.ReadBit();
            number[2] = packet.ReadBit();
            number[3] = packet.ReadBit();
            guid[1] = packet.ReadBit();
            guid[0] = packet.ReadBit();

            packet.ReadXORByte(guid, 7);
            packet.ReadXORByte(number, 2);
            packet.ReadXORByte(guid, 4);
            packet.ReadXORByte(guid, 6);
            packet.ReadXORByte(guid, 5);
            packet.ReadXORByte(number, 5);
            packet.ReadXORByte(guid, 3);
            packet.ReadXORByte(number, 0);
            packet.ReadXORByte(number, 6);
            packet.ReadXORByte(guid, 1);
            packet.ReadXORByte(number, 4);
            packet.ReadXORByte(guid, 0);
            packet.ReadXORByte(number, 7);
            packet.ReadXORByte(number, 1);
            packet.ReadXORByte(guid, 2);
            packet.ReadXORByte(number, 3);

            packet.WriteGuid("Guid2", number);
            packet.WriteGuid("Guid3", guid);

            var GUID = new WowGuid64(BitConverter.ToUInt64(guid, 0));
            var Number = BitConverter.ToUInt64(number, 0);
            packet.WriteGuid("Guid", guid);
            packet.AddValue("Pet Number", Number);

            // Store temporary name (will be replaced in SMSG_QUERY_PET_NAME_RESPONSE)
            StoreGetters.AddName(GUID, Number.ToString(CultureInfo.InvariantCulture));
        }
예제 #10
0
        public static void HandleCharEnum433(Packet packet)
        {
            var unkCounter = packet.ReadBits("Unk Counter", 23);
            var count = packet.ReadBits("Char count", 17);

            var charGuids = new byte[count][];
            var guildGuids = new byte[count][];
            var firstLogins = new bool[count];
            var nameLenghts = new uint[count];

            for (var c = 0; c < count; ++c)
            {
                charGuids[c] = new byte[8];
                guildGuids[c] = new byte[8];
                //100%  pozition, and flag
                //%50   flag
                //20    nothing

                charGuids[c][0] = packet.ReadBit(); //100%
                guildGuids[c][0] = packet.ReadBit();//50%
                charGuids[c][2] = packet.ReadBit(); //100%
                guildGuids[c][2] = packet.ReadBit();//50%
                firstLogins[c] = packet.ReadBit();                  //100%
                charGuids[c][3] = packet.ReadBit(); //100%
                charGuids[c][6] = packet.ReadBit(); //100%
                guildGuids[c][2] = packet.ReadBit();//20%

                charGuids[c][4] = packet.ReadBit(); //20%
                charGuids[c][5] = packet.ReadBit(); //20%
                nameLenghts[c] = packet.ReadBits(4);                //100%
                guildGuids[c][3] = packet.ReadBit();//20%
                guildGuids[c][4] = packet.ReadBit();//50%

                guildGuids[c][5] = packet.ReadBit();//20%
                charGuids[c][1] = packet.ReadBit(); //100%
                packet.ReadBit();                                   //20%
                guildGuids[c][6] = packet.ReadBit();//20%
                charGuids[c][7] = packet.ReadBit(); //100%
                guildGuids[c][7] = packet.ReadBit();//50%
                packet.ReadBit();                                   //20%
                packet.ReadBit();                                   //20%
            }

            // no idea, not used in client
            packet.ReadByte();

            for (int c = 0; c < count; ++c)
            {
                Vector3 pos = new Vector3();

                for (var itm = 0; itm < 19; ++itm)
                {
                    packet.ReadInt32("Item EnchantID", c, itm);
                    packet.ReadInt32("Item DisplayID", c, itm);
                    packet.ReadByteE<InventoryType>("Item InventoryType", c, itm);
                }

                for (var itm = 0; itm < 4; ++itm)
                {
                    packet.ReadInt32("Bag EnchantID", c, itm);
                    packet.ReadInt32("Bag DisplayID", c, itm);
                    packet.ReadByteE<InventoryType>("Bag InventoryType", c, itm);
                }

                var zone = packet.ReadUInt32<ZoneId>("Zone Id", c);
                packet.ReadInt32("Pet Level", c);
                packet.ReadInt32E<CharacterFlag>("CharacterFlag", c);

                packet.ReadByte("Facial Hair", c);

                packet.ReadXORByte(guildGuids[c], 0);
                    packet.ReadXORByte(charGuids[c], 0);

                packet.ReadXORByte(charGuids[c], 2);
                if (guildGuids[c][2] != 0)
                    //  guildGuids[c][2] ^= packet.ReadByte();

                    if (charGuids[c][7] != 0)
                        charGuids[c][7] ^= packet.ReadByte();
                if (guildGuids[c][7] != 0)
                    // guildGuids[c][7] ^= packet.ReadByte();

                    packet.ReadByte("List Order", c);
                packet.ReadInt32("Pet Display ID", c);

                // no ideal //////////////////////////////
                if (charGuids[c][4] != 0)
                    charGuids[c][4] ^= packet.ReadByte();

                if (guildGuids[c][4] != 0)
                    // guildGuids[c][4] ^= packet.ReadByte();

                if (charGuids[c][5] != 0)
                        // charGuids[c][5] ^= packet.ReadByte();

                if (guildGuids[c][5] != 0)
                            // guildGuids[c][5] ^= packet.ReadByte();

                if (guildGuids[c][1] != 0)
                                // guildGuids[c][1] ^= packet.ReadByte();

                                if (guildGuids[c][3] != 0)
                                    // guildGuids[c][3] ^= packet.ReadByte();

                                    if (guildGuids[c][6] != 0)
                                        // guildGuids[c][6] ^= packet.ReadByte();

                                        //////////////////////////////////////////

                                        if (charGuids[c][3] != 0)
                                            charGuids[c][3] ^= packet.ReadByte();

                var klass = packet.ReadByteE<Class>("Class", c);

                if (charGuids[c][6] != 0)
                    charGuids[c][6] ^= packet.ReadByte();

                pos.X = packet.ReadSingle("Position X", c);

                if (charGuids[c][1] != 0)
                    charGuids[c][1] ^= packet.ReadByte();

                var race = packet.ReadByteE<Race>("Race", c);
                packet.ReadInt32("Pet Family", c);
                pos.Y = packet.ReadSingle("Position Y", c);
                packet.ReadByteE<Gender>("Gender", c);
                packet.ReadByte("Hair Style", c);
                var level = packet.ReadByte("Level", c);
                pos.Z = packet.ReadSingle("Position Z", c);
                packet.ReadUInt32E<CustomizationFlag>("CustomizationFlag", c);
                packet.ReadByte("Skin", c);
                packet.ReadByte("Hair Color", c);
                packet.ReadByte("Face", c);
                var mapId = packet.ReadInt32("Map", c);
                var name = packet.ReadWoWString("Name", (int)nameLenghts[c], c);

                var playerGuid = new WowGuid64(BitConverter.ToUInt64(charGuids[c], 0));

                packet.WriteGuid("Character GUID", charGuids[c], c);
                packet.WriteGuid("Guild GUID", guildGuids[c], c);

                if (firstLogins[c])
                {
                    PlayerCreateInfo startPos = new PlayerCreateInfo { Race = race, Class = klass, Map = (uint)mapId, Zone = zone, Position = pos, Orientation = 0 };
                    Storage.StartPositions.Add(startPos, packet.TimeSpan);
                }

                var playerInfo = new Player { Race = race, Class = klass, Name = name, FirstLogin = firstLogins[c], Level = level };
                if (Storage.Objects.ContainsKey(playerGuid))
                    Storage.Objects[playerGuid] = new Tuple<WoWObject, TimeSpan?>(playerInfo, packet.TimeSpan);
                else
                    Storage.Objects.Add(playerGuid, playerInfo, packet.TimeSpan);
                StoreGetters.AddName(playerGuid, name);
            }

            for (var c = 0; c < unkCounter; c++)
            {
                packet.ReadUInt32("Unk1", c);
                packet.ReadByte("Unk2", c);
            }
        }
예제 #11
0
        public static void HandleCharEnum422(Packet packet)
        {
            packet.ReadByte("Unk Flag");
            int count = packet.ReadInt32("Char Count");
            packet.ReadInt32("Unk Count");
            var firstLogin = new bool[count];
            var playerGuid = new byte[count][];
            var guildGuid = new byte[count][];

            for (int c = 0; c < count; c++)
            {
                playerGuid[c] = new byte[8];
                guildGuid[c] = new byte[8];

                guildGuid[c][5] = packet.ReadBit();//0
                playerGuid[c][4] = packet.ReadBit();//1
                guildGuid[c][3] = packet.ReadBit();//2
                guildGuid[c][7] = packet.ReadBit();//3
                guildGuid[c][1] = packet.ReadBit();//4
                guildGuid[c][6] = packet.ReadBit();//5
                playerGuid[c][5] = packet.ReadBit();//6
                playerGuid[c][6] = packet.ReadBit();//7
                playerGuid[c][3] = packet.ReadBit();//8
                playerGuid[c][2] = packet.ReadBit();//9
                guildGuid[c][4] = packet.ReadBit();//10
                playerGuid[c][0] = packet.ReadBit();//11
                playerGuid[c][1] = packet.ReadBit();//12
                guildGuid[c][2] = packet.ReadBit();//13
                playerGuid[c][7] = packet.ReadBit();//14
                guildGuid[c][0] = packet.ReadBit();//15
                firstLogin[c] = packet.ReadBit();//16
            }

            for (int c = 0; c < count; c++)
            {
                var name = packet.ReadCString("Name", c);

                packet.ReadXORByte(guildGuid[c], 5);

                packet.ReadByte("Face", c);
                var mapId = packet.ReadInt32("Map", c);

                packet.ReadXORByte(playerGuid[c], 1);
                packet.ReadXORByte(playerGuid[c], 4);
                packet.ReadXORByte(guildGuid[c], 4);
                packet.ReadXORByte(guildGuid[c], 0);

                var pos = packet.ReadVector3("Position", c);

                packet.ReadXORByte(playerGuid[c], 0);

                var zone = packet.ReadInt32<ZoneId>("Zone Id", c);
                packet.ReadInt32("Pet Level", c);

                packet.ReadXORByte(playerGuid[c], 3);

                packet.ReadXORByte(playerGuid[c], 7);

                packet.ReadByte("Facial Hair", c);
                packet.ReadByte("Skin", c);
                var klass = packet.ReadByteE<Class>("Class", c);
                packet.ReadInt32("Pet Family", c);
                packet.ReadInt32E<CharacterFlag>("CharacterFlag", c);

                packet.ReadXORByte(playerGuid[c], 2);

                packet.ReadInt32("Pet Display ID", c);

                packet.ReadXORByte(guildGuid[c], 7);

                var level = packet.ReadByte("Level", c);

                packet.ReadXORByte(playerGuid[c], 6);

                packet.ReadByte("Hair Style", c);

                packet.ReadXORByte(guildGuid[c], 2);

                var race = packet.ReadByteE<Race>("Race", c);
                packet.ReadByte("Hair Color", c);

                packet.ReadXORByte(guildGuid[c], 6);

                packet.ReadByteE<Gender>("Gender", c);

                packet.ReadXORByte(playerGuid[c], 5);

                packet.ReadXORByte(guildGuid[c], 3);

                packet.ReadByte("List Order", c);

                for (int itm = 0; itm < 19; itm++)
                {
                    packet.ReadInt32("Item EnchantID", c, itm);
                    packet.ReadByteE<InventoryType>("Item InventoryType", c, itm);
                    packet.ReadInt32("Item DisplayID", c, itm);
                }

                for (int itm = 0; itm < 4; itm++)
                {
                    packet.ReadInt32("Bag EnchantID", c, itm);
                    packet.ReadByteE<InventoryType>("Bag InventoryType", c, itm);
                    packet.ReadInt32("Bag DisplayID", c, itm);
                }

                packet.ReadUInt32E<CustomizationFlag>("CustomizationFlag", c);

                packet.ReadXORByte(guildGuid[c], 1);

                var guidPlayer = new WowGuid64(BitConverter.ToUInt64(playerGuid[c], 0));

                packet.WriteGuid("Character Guid", playerGuid[c],c);
                packet.WriteGuid("Guild Guid", guildGuid[c],c);

                if (firstLogin[c])
                {
                    PlayerCreateInfo startPos = new PlayerCreateInfo { Race = race, Class = klass, Map = (uint)mapId, Zone = (uint)zone, Position = pos, Orientation = 0 };
                    Storage.StartPositions.Add(startPos, packet.TimeSpan);
                }

                var playerInfo = new Player { Race = race, Class = klass, Name = name, FirstLogin = firstLogin[c], Level = level };
                if (Storage.Objects.ContainsKey(guidPlayer))
                    Storage.Objects[guidPlayer] = new Tuple<WoWObject, TimeSpan?>(playerInfo, packet.TimeSpan);
                else
                    Storage.Objects.Add(guidPlayer, playerInfo, packet.TimeSpan);
                StoreGetters.AddName(guidPlayer, name);
            }
        }
예제 #12
0
        public static void HandleVendorInventoryList(Packet packet)
        {
            var npcVendor = new NpcVendor();

            var guid = new byte[8];

            guid[5] = packet.ReadBit();
            guid[7] = packet.ReadBit();
            guid[1] = packet.ReadBit();
            guid[3] = packet.ReadBit();
            guid[6] = packet.ReadBit();

            var itemCount = packet.ReadBits(18);

            var unkBit = new uint[itemCount];
            var hasExtendedCost = new bool[itemCount];
            var hasCondition = new bool[itemCount];

            for (var i = 0; i < itemCount; ++i)
            {
                unkBit[i] = packet.ReadBit();
                hasExtendedCost[i] = !packet.ReadBit(); // +44
                hasCondition[i] = !packet.ReadBit(); // +36
            }

            guid[4] = packet.ReadBit();
            guid[0] = packet.ReadBit();
            guid[2] = packet.ReadBit();

            packet.ReadByte("Byte10");

            npcVendor.VendorItems = new List<VendorItem>((int)itemCount);
            for (var i = 0; i < itemCount; ++i)
            {
                var vendorItem = new VendorItem();

                packet.AddValue("unkBit", unkBit[i], i);

                packet.ReadInt32("Max Durability", i);   // +16
                packet.ReadInt32("Price", i);   // +20
                vendorItem.Type = packet.ReadUInt32("Type", i);    // +4
                var maxCount = packet.ReadInt32("Max Count", i);     // +24
                packet.ReadInt32("Display ID", i);    // +12
                var buyCount = packet.ReadUInt32("Buy Count", i);    // +28

                vendorItem.ItemId = (uint)packet.ReadInt32<ItemId>("Item ID", i);   // +8

                if (hasExtendedCost[i])
                    vendorItem.ExtendedCostId = packet.ReadUInt32("Extended Cost", i);    // +36

                packet.ReadInt32("Item Upgrade ID", i);   // +32

                if (hasCondition[i])
                    packet.ReadInt32("Condition ID", i);    // +40

                vendorItem.Slot = packet.ReadUInt32("Item Position", i);    // +0

                npcVendor.VendorItems.Add(vendorItem);
            }

            packet.ParseBitStream(guid, 3, 7, 0, 6, 2, 1, 4, 5);

            packet.WriteGuid("Guid", guid);

            var vendorGUID = new WowGuid64(BitConverter.ToUInt64(guid, 0));
            Storage.NpcVendors.Add(vendorGUID.GetEntry(), npcVendor, packet.TimeSpan);
        }
예제 #13
0
        public static void HandleServerTrainerList(Packet packet)
        {
            var npcTrainer = new NpcTrainer();

            var guid = new byte[8];

            guid[4] = packet.ReadBit();
            guid[5] = packet.ReadBit();
            var count = (int)packet.ReadBits(19);
            var titleLen = packet.ReadBits(11);
            guid[6] = packet.ReadBit();
            guid[2] = packet.ReadBit();
            guid[7] = packet.ReadBit();
            guid[1] = packet.ReadBit();
            guid[3] = packet.ReadBit();
            guid[0] = packet.ReadBit();

            packet.ReadXORByte(guid, 4);

            npcTrainer.TrainerSpells = new List<TrainerSpell>(count);
            for (var i = 0; i < count; ++i)
            {
                var trainerSpell = new TrainerSpell();
                trainerSpell.RequiredLevel = packet.ReadByte("Required Level", i);
                trainerSpell.Cost = packet.ReadUInt32("Cost", i);
                trainerSpell.Spell = (uint)packet.ReadInt32<SpellId>("Spell ID", i);
                for (var j = 0; j < 3; ++j)
                    packet.ReadInt32("Int818", i, j);
                trainerSpell.RequiredSkill = packet.ReadUInt32("Required Skill", i);
                trainerSpell.RequiredSkillLevel = packet.ReadUInt32("Required Skill Level", i);
                packet.ReadByteE<TrainerSpellState>("State", i);

                npcTrainer.TrainerSpells.Add(trainerSpell);
            }

            npcTrainer.Title = packet.ReadWoWString("Title", titleLen);
            packet.ReadXORByte(guid, 6);
            packet.ReadXORByte(guid, 7);
            packet.ReadXORByte(guid, 1);
            packet.ReadXORByte(guid, 3);
            packet.ReadInt32("Unk Int32"); // Same unk exists in CMSG_TRAINER_BUY_SPELL
            packet.ReadXORByte(guid, 5);
            packet.ReadXORByte(guid, 0);
            packet.ReadXORByte(guid, 2);
            npcTrainer.Type = packet.ReadInt32E<TrainerType>("Type");

            packet.WriteGuid("Guid", guid);
            var GUID = new WowGuid64(BitConverter.ToUInt64(guid, 0));

            if (Storage.NpcTrainers.ContainsKey(GUID.GetEntry()))
            {
                var oldTrainer = Storage.NpcTrainers[GUID.GetEntry()];
                if (oldTrainer != null)
                {
                    foreach (var trainerSpell in npcTrainer.TrainerSpells)
                        oldTrainer.Item1.TrainerSpells.Add(trainerSpell);
                }
            }
            else
                Storage.NpcTrainers.Add(GUID.GetEntry(), npcTrainer, packet.TimeSpan);
        }
예제 #14
0
        public static void HandlePetNameQuery(Packet packet)
        {
            var guid1 = new byte[8];
            var guid2 = new byte[8];

            guid2[0] = packet.ReadBit();
            guid2[5] = packet.ReadBit();
            guid1[1] = packet.ReadBit();
            guid1[7] = packet.ReadBit();
            guid2[7] = packet.ReadBit();
            guid1[6] = packet.ReadBit();
            guid1[4] = packet.ReadBit();
            guid1[5] = packet.ReadBit();
            guid1[0] = packet.ReadBit();
            guid2[3] = packet.ReadBit();
            guid2[6] = packet.ReadBit();
            guid2[2] = packet.ReadBit();
            guid1[3] = packet.ReadBit();
            guid1[2] = packet.ReadBit();
            guid2[1] = packet.ReadBit();
            guid2[4] = packet.ReadBit();

            packet.ReadXORByte(guid2, 2);
            packet.ReadXORByte(guid2, 1);
            packet.ReadXORByte(guid2, 0);
            packet.ReadXORByte(guid2, 7);
            packet.ReadXORByte(guid1, 5);
            packet.ReadXORByte(guid1, 0);
            packet.ReadXORByte(guid2, 6);
            packet.ReadXORByte(guid1, 4);
            packet.ReadXORByte(guid2, 5);
            packet.ReadXORByte(guid1, 2);
            packet.ReadXORByte(guid1, 6);
            packet.ReadXORByte(guid2, 3);
            packet.ReadXORByte(guid1, 3);
            packet.ReadXORByte(guid2, 4);
            packet.ReadXORByte(guid1, 1);
            packet.ReadXORByte(guid1, 7);

            var GUID = new WowGuid64(BitConverter.ToUInt64(guid1, 0));
            var Number = BitConverter.ToUInt64(guid2, 0);
            packet.WriteGuid("Guid", guid1);
            packet.AddValue("Pet Number", Number);

            // Store temporary name (will be replaced in SMSG_QUERY_PET_NAME_RESPONSE)
            StoreGetters.AddName(GUID, Number.ToString(CultureInfo.InvariantCulture));
        }
예제 #15
0
        public static void HandleMessageChat(Packet packet)
        {
            var text = new CreatureText();
            uint entry = 0;

            //text.Language = packet.ReadEnum<Language>("Language", TypeCode.Int32);

            var hasSenderName = !packet.ReadBit("!hasSenderName");
            packet.ReadBit("Show only in bubble"); // 0 Show in chat log, 1 for showing only in bubble
            var SenderLen = 0u;
            if (hasSenderName)
                SenderLen = packet.ReadBits("SenderLen", 11);

            packet.ReadBit("!unk48*4");
            // unk52*4 = 0;
            var hasChannelName = !packet.ReadBit("!hasChannelName");
            packet.ReadBit("unk5273*4");
            var has1494 = !packet.ReadBit("!unk1494h"); // dword ptr [esi+1494h] = ("has unk1494h") ? 0 : ds:dword_D26EA8
            var chatTag = !packet.ReadBit("!chatTag"); // 5264*2
            var hasRealmID1 = !packet.ReadBit("!hasRealmID1"); // 56

            var guid4 = packet.StartBitStream(0, 1, 5, 4, 3, 2, 6, 7);

            if (chatTag)
                packet.ReadBits("chatTag", 9); // 5264*2

            packet.ReadBit("!unk40*4");
            // unk44*4 = 0
            var guid3 = packet.StartBitStream(7, 6, 1, 4, 0, 2, 3, 5);
            packet.ReadBit("!unk24*4");
            // unk28*4 = 0
            var hasLanguage = !packet.ReadBit("!hasLanguage"); // 17
            var hasPrefix = !packet.ReadBit("!hasPrefix");

            var guid = packet.StartBitStream(0, 3, 7, 2, 1, 5, 4, 6);

            var hasAchievementID = !packet.ReadBit("!hasAchievementID"); // 5260*4
            var hasMessage = !packet.ReadBit("!hasMessage"); // 2259

            var ChannelLen = 0u;
            if (hasChannelName)
                ChannelLen = packet.ReadBits("ChannelLen", 7); // 2134

            var MessageLen = 0u;
            if (hasMessage)
                MessageLen = packet.ReadBits("MessageLen", 12);

            var hasReceiverName = !packet.ReadBit("!hasReceiverName"); // 1089

            var PrefixLen = 0u;
            if (hasPrefix)
                PrefixLen = packet.ReadBits("PrefixLen", 5); // 2114*4

            var hasRealmID2 = !packet.ReadBit("!hasRealmID2"); // 60

            var ReceiverLen = 0u;
            if (hasReceiverName)
                ReceiverLen = packet.ReadBits("ReceiverLen", 11);

            packet.ReadBit("!unk32*4");
            // unk36 = 0

            var guid2 = packet.StartBitStream(2, 5, 7, 4, 0, 1, 3, 6);
            packet.ParseBitStream(guid2, 4, 5, 7, 3, 2, 6, 0, 1);

            if (hasChannelName)
                packet.ReadWoWString("ChannelName", ChannelLen);

            if (hasPrefix)
                packet.ReadWoWString("Prefix", PrefixLen);

            if (has1494)
                packet.ReadSingle("unk1494");

            packet.ParseBitStream(guid, 4, 7, 1, 5, 0, 6, 2, 3);

            var unitGuid = new WowGuid64(BitConverter.ToUInt64(guid, 0));

            if (unitGuid.GetObjectType() == ObjectType.Unit)
                entry = unitGuid.GetEntry();

            text.Type = (ChatMessageType)packet.ReadByteE<ChatMessageType548>("Type");

            if (hasAchievementID)
                packet.ReadUInt32("AchievementID");

            packet.ParseBitStream(guid4, 1, 3, 4, 6, 0, 2, 5, 7);
            packet.ParseBitStream(guid3, 2, 5, 3, 6, 7, 4, 1, 0);

            if (hasLanguage)
                packet.ReadByte("Language");

            if (hasRealmID2)
                packet.ReadInt32("RealmID2"); // 60

            if (hasMessage)
                text.Text = packet.ReadWoWString("Message", MessageLen);

            if (hasReceiverName)
                text.ReceiverName = packet.ReadWoWString("Receiver Name", ReceiverLen);

            if (hasSenderName)
                text.SenderName = packet.ReadWoWString("Sender Name", SenderLen);

            if (hasRealmID1)
                packet.ReadInt32("RealmID1"); // 56

            text.SenderGUID = packet.WriteGuid("SenderGUID", guid);
            text.ReceiverGUID = packet.WriteGuid("ReceiverGUID", guid3);
            packet.WriteGuid("GuildGUID", guid2);
            packet.WriteGuid("GroupGUID", guid4);

            if (text.SenderGUID.GetObjectType() == ObjectType.Unit)
                entry = text.SenderGUID.GetEntry();
            else if (text.ReceiverGUID.GetObjectType() == ObjectType.Unit)
                entry = text.ReceiverGUID.GetEntry();

            if (entry != 0)
                Storage.CreatureTexts.Add(entry, text, packet.TimeSpan);
        }
예제 #16
0
        public static void HandleAuraUpdate(Packet packet)
        {
            var guid = new byte[8];

            guid[3] = packet.ReadBit();
            guid[6] = packet.ReadBit();
            guid[0] = packet.ReadBit();
            guid[7] = packet.ReadBit();
            guid[5] = packet.ReadBit();
            guid[4] = packet.ReadBit();

            var bits0 = packet.ReadBits(24);

            var bit10 = packet.ReadBit();

            var hasAura = new bool[bits0];
            var hasCasterGUID = new bool[bits0];
            var hasMaxDuration = new bool[bits0];
            var hasDuration = new bool[bits0];
            var bits48 = new uint[bits0];
            var casterGUID = new byte[bits0][];
            var effectCount = new uint[bits0];

            for (var i = 0; i < bits0; ++i)
            {
                hasAura[i] = packet.ReadBit();

                if (hasAura[i])
                {
                    effectCount[i] = packet.ReadBits(22);
                    bits48[i] = packet.ReadBits(22);

                    hasCasterGUID[i] = packet.ReadBit();
                    if (hasCasterGUID[i])
                    {
                        casterGUID[i] = new byte[8];
                        packet.StartBitStream(casterGUID[i], 7, 4, 2, 5, 6, 1, 3, 0);
                    }

                    hasMaxDuration[i] = packet.ReadBit();
                    hasDuration[i] = packet.ReadBit();
                }
            }

            guid[1] = packet.ReadBit();
            guid[2] = packet.ReadBit();

            var auras = new List<Aura>();
            for (var i = 0; i < bits0; ++i)
            {
                if (hasAura[i])
                {
                    var aura = new Aura();
                    if (hasCasterGUID[i])
                    {
                        packet.ParseBitStream(casterGUID[i], 0, 3, 7, 1, 2, 5, 4, 6);
                        packet.WriteGuid("Caster GUID", casterGUID[i], i);
                        aura.CasterGuid = new WowGuid64(BitConverter.ToUInt64(casterGUID[i], 0));
                    }

                    aura.Duration = hasDuration[i] ? packet.ReadInt32("Duration", i) : 0;

                    for (var j = 0; j < bits48[i]; ++j)
                        packet.ReadSingle("Float3", i, j);

                    for (var j = 0; j < effectCount[i]; ++j)
                        packet.ReadSingle("Effect Value", i, j);

                    aura.Level = packet.ReadUInt16("Caster Level", i);

                    aura.MaxDuration = hasMaxDuration[i] ? packet.ReadInt32("Max Duration", i) : 0;

                    aura.Charges = packet.ReadByte("Charges", i);
                    aura.SpellId = packet.ReadUInt32("Spell Id", i);
                    aura.AuraFlags = packet.ReadByteE<AuraFlagMoP>("Flags", i);
                    packet.ReadInt32("Effect Mask", i);

                    auras.Add(aura);
                    packet.AddSniffData(StoreNameType.Spell, (int)aura.SpellId, "AURA_UPDATE");
                }

                packet.ReadByte("Slot", i);
            }

            packet.ParseBitStream(guid, 5, 1, 2, 6, 0, 7, 4, 3);

            packet.WriteGuid("Guid", guid);

            var GUID = new WowGuid64(BitConverter.ToUInt64(guid, 0));
            if (Storage.Objects.ContainsKey(GUID))
            {
                var unit = Storage.Objects[GUID].Item1 as Unit;
                if (unit != null)
                {
                    // If this is the first packet that sends auras
                    // (hopefully at spawn time) add it to the "Auras" field,
                    // if not create another row of auras in AddedAuras
                    // (similar to ChangedUpdateFields)

                    if (unit.Auras == null)
                        unit.Auras = auras;
                    else
                        unit.AddedAuras.Add(auras);
                }
            }
        }
예제 #17
0
        public static void HandleCharEnum510(Packet packet)
        {
            var unkCounter = packet.ReadBits("Unk Counter", 23);
            var count = packet.ReadBits("Char count", 17);

            var charGuids = new byte[count][];
            var guildGuids = new byte[count][];
            var firstLogins = new bool[count];
            var nameLenghts = new uint[count];

            for (int c = 0; c < count; ++c)
            {
                charGuids[c] = new byte[8];
                guildGuids[c] = new byte[8];

                charGuids[c][7] = packet.ReadBit();
                charGuids[c][0] = packet.ReadBit();
                charGuids[c][4] = packet.ReadBit();
                guildGuids[c][2] = packet.ReadBit();
                charGuids[c][5] = packet.ReadBit();
                charGuids[c][3] = packet.ReadBit();
                nameLenghts[c] = packet.ReadBits(7);
                guildGuids[c][0] = packet.ReadBit();
                guildGuids[c][5] = packet.ReadBit();
                guildGuids[c][3] = packet.ReadBit();
                firstLogins[c] = packet.ReadBit();
                guildGuids[c][6] = packet.ReadBit();
                guildGuids[c][7] = packet.ReadBit();
                charGuids[c][1] = packet.ReadBit();
                guildGuids[c][4] = packet.ReadBit();
                guildGuids[c][1] = packet.ReadBit();
                charGuids[c][2] = packet.ReadBit();
                charGuids[c][6] = packet.ReadBit();
            }

            packet.ReadBit("Unk bit");
            packet.ResetBitReader();

            for (int c = 0; c < count; ++c)
            {
                Vector3 pos = new Vector3();

                packet.ReadInt32E<CharacterFlag>("CharacterFlag", c);
                packet.ReadInt32("Pet Family", c);
                pos.Z = packet.ReadSingle("Position Z", c);
                packet.ReadXORByte(charGuids[c], 7);
                packet.ReadXORByte(guildGuids[c], 6);

                for (var itm = 0; itm < 23; ++itm)
                {
                    packet.ReadInt32("Item EnchantID", c, itm);
                    packet.ReadByteE<InventoryType>("Item InventoryType", c, itm);
                    packet.ReadInt32("Item DisplayID", c, itm);
                }

                pos.X = packet.ReadSingle("Position X", c);
                var klass = packet.ReadByteE<Class>("Class", c);
                packet.ReadXORByte(charGuids[c], 5);
                pos.Y = packet.ReadSingle("Position Y", c);
                packet.ReadXORByte(guildGuids[c], 3);
                packet.ReadXORByte(charGuids[c], 6);
                packet.ReadInt32("Pet Level", c);
                packet.ReadInt32("Pet Display ID", c);
                packet.ReadXORByte(charGuids[c], 2);
                packet.ReadXORByte(charGuids[c], 1);
                packet.ReadByte("Hair Color", c);
                packet.ReadByte("Facial Hair", c);
                packet.ReadXORByte(guildGuids[c], 2);
                var zone = packet.ReadUInt32<ZoneId>("Zone Id", c);
                packet.ReadByte("List Order", c);
                packet.ReadXORByte(charGuids[c], 0);
                packet.ReadXORByte(guildGuids[c], 1);
                packet.ReadByte("Skin", c);
                packet.ReadXORByte(charGuids[c], 4);
                packet.ReadXORByte(guildGuids[c], 5);
                var name = packet.ReadWoWString("Name", (int)nameLenghts[c], c);
                packet.ReadXORByte(guildGuids[c], 0);
                var level = packet.ReadByte("Level", c);
                packet.ReadXORByte(charGuids[c], 3);
                packet.ReadXORByte(guildGuids[c], 7);
                packet.ReadByte("Hair Style", c);
                packet.ReadXORByte(guildGuids[c], 4);
                packet.ReadByteE<Gender>("Gender", c);
                var mapId = packet.ReadInt32<MapId>("Map Id", c);
                packet.ReadUInt32E<CustomizationFlag>("CustomizationFlag", c);
                var race = packet.ReadByteE<Race>("Race", c);
                packet.ReadByte("Face", c);

                var playerGuid = new WowGuid64(BitConverter.ToUInt64(charGuids[c], 0));

                packet.WriteGuid("Character GUID", charGuids[c], c);
                packet.WriteGuid("Guild GUID", guildGuids[c], c);

                if (firstLogins[c])
                {
                    PlayerCreateInfo startPos = new PlayerCreateInfo { Race = race, Class = klass, Map = (uint)mapId, Zone = zone, Position = pos, Orientation = 0 };
                    Storage.StartPositions.Add(startPos, packet.TimeSpan);
                }

                var playerInfo = new Player { Race = race, Class = klass, Name = name, FirstLogin = firstLogins[c], Level = level };
                if (Storage.Objects.ContainsKey(playerGuid))
                    Storage.Objects[playerGuid] = new Tuple<WoWObject, TimeSpan?>(playerInfo, packet.TimeSpan);
                else
                    Storage.Objects.Add(playerGuid, playerInfo, packet.TimeSpan);
                StoreGetters.AddName(playerGuid, name);
            }

            for (var i = 0; i < unkCounter; ++i)
            {
                packet.ReadByte("Unk byte", i);
                packet.ReadUInt32("Unk int", i);
            }
        }
예제 #18
0
        public static void HandleClientCharDelete(Packet packet)
        {
            var playerGuid = new byte[8];

            playerGuid[1] = packet.ReadBit();
            playerGuid[4] = packet.ReadBit();
            playerGuid[7] = packet.ReadBit();
            playerGuid[5] = packet.ReadBit();
            playerGuid[3] = packet.ReadBit();
            playerGuid[2] = packet.ReadBit();
            playerGuid[0] = packet.ReadBit();
            playerGuid[6] = packet.ReadBit();

            packet.ParseBitStream(playerGuid, 2, 0, 4, 1, 5, 3, 7, 6);

            var guid = new WowGuid64(BitConverter.ToUInt64(playerGuid, 0));
            packet.WriteGuid("GUID", playerGuid);
        }
예제 #19
0
        public static void HandleOnMonsterMove(Packet packet)
        {
            var guid3 = new byte[8];
            var target = new byte[8];
            var pos = new Vector3();

            pos.Z = packet.ReadSingle(); // 24
            pos.X = packet.ReadSingle(); // 16
            packet.ReadInt32("Spline ID");
            pos.Y = packet.ReadSingle(); //20
            packet.WriteLine("Pos: {0}", pos);
            var transportPos = new Vector3
            {
                Y = packet.ReadSingle(), // 48
                Z = packet.ReadSingle(), // 52
                X = packet.ReadSingle(), // 44
            };
            packet.WriteLine("transportPos: {0}", transportPos);
            var hasAngle = !packet.ReadBit("!hasAngle");
            guid3[0] = packet.ReadBit();
            var splineType = packet.ReadBitsE<SplineType>("Spline Type", 3);
            if (splineType == SplineType.FacingTarget)
            {
                target = packet.StartBitStream(6, 4, 3, 0, 5, 7, 1, 2); // 184
            }
            var unk76 = !packet.ReadBit("!unk76");
            var unk69 = !packet.ReadBit("!unk69");
            var unk120 = -packet.ReadBit("unk120");

            var uncompressedSplineCount = packet.ReadBits("uncompressedSplineCount", 20);
            var hasSplineFlags = !packet.ReadBit("!hasSplineFlags");
            guid3[3] = packet.ReadBit();
            var unk108 = !packet.ReadBit("!unk108");
            var unk88 = !packet.ReadBit("!unk88");
            var unk109 = !packet.ReadBit("!unk109");
            var hasDutation = !packet.ReadBit("!hasduration");
            guid3[7] = packet.ReadBit();
            guid3[4] = packet.ReadBit();
            var unk72 = !packet.ReadBit("!unk72");
            guid3[5] = packet.ReadBit();
            var compressedSplineCount = packet.ReadBits("compressedSplineCount", 22);
            guid3[6] = packet.ReadBit();
            var unk112 = packet.ReadBit("!unk112") ? 0u : 1u;
            var guid2 = packet.StartBitStream(7, 1, 3, 0, 6, 4, 5, 2); // 112
            var unk176 = packet.ReadBit("unk176");
            var unk78 = 0u;
            var count140 = 0u;
            if (unk176)
            {
                unk78 = packet.ReadBits("unk78*2", 2);
                count140 = packet.ReadBits("count140", 22);
            }
            var unk56 = packet.ReadBit("unk56");
            guid3[2] = packet.ReadBit();
            guid3[1] = packet.ReadBit();
            for (var i = 0; i < compressedSplineCount; i++)
            {
                var vec = packet.ReadPackedVector3();
                vec.X += pos.X;
                vec.Y += pos.Y;
                vec.Z += pos.Z;
                packet.WriteLine("[{0}] Waypoint: {1}", i, vec); // not completed
            }
            packet.ParseBitStream(guid3, 1);
            packet.ParseBitStream(guid2, 6, 4, 1, 7, 0, 3, 5, 2);
            packet.WriteGuid("Guid2", guid2);

            for (var i = 0; i < uncompressedSplineCount; i++)
            {
                var point = new Vector3
                {
                    Y = packet.ReadSingle(), // 100
                    X = packet.ReadSingle(), // 96
                    Z = packet.ReadSingle(), // 104
                };
                packet.WriteLine("[{0}] Point: {1}", i, point);
            }

            if (unk72)
                packet.ReadInt32("unk72");

            if (splineType == SplineType.FacingTarget)
            {
                packet.ParseBitStream(target, 5, 7, 0, 4, 3, 2, 6, 1);
                packet.WriteGuid("Target", target);
            }

            packet.ParseBitStream(guid3, 5);

            if (hasAngle)
                packet.ReadSingle("Angle");

            if (unk176)
            {
                for (var i = 0; i < count140; i++)
                {
                    packet.ReadInt16("unk146", i);
                    packet.ReadInt16("unk144", i);
                }
                packet.ReadSingle("unka8h*4");
                packet.ReadInt16("unk82*2");
                packet.ReadInt16("unk86*2");
                packet.ReadSingle("unka0h*4");
            }

            if (unk76)
                packet.ReadInt32("unk76");

            if (splineType == SplineType.FacingAngle)
                packet.ReadSingle("Facing Angle");

            packet.ParseBitStream(guid3, 3);

            if (hasSplineFlags)
                packet.ReadUInt32E<SplineFlag>("Spline Flags");

            if (unk69)
                packet.ReadByte("unk69");

            packet.ParseBitStream(guid3, 6);

            if (unk109)
                packet.ReadByte("unk109");

            if (splineType == SplineType.FacingSpot)
            {
                var facingSpot = new Vector3
                {
                    X = packet.ReadSingle(),
                    Y = packet.ReadSingle(),
                    Z = packet.ReadSingle(),
                };
                packet.WriteLine("Facing spot: {0}", facingSpot);
            }

            packet.ParseBitStream(guid3, 0);

            if (unk120 != -1)
                packet.ReadByte("unk120");

            if (unk108)
                packet.ReadByte("unk108");

            packet.ParseBitStream(guid3, 7, 2);

            if (unk88)
                packet.ReadInt32("unk88");

            packet.ParseBitStream(guid3, 4);

            if (hasDutation)
                packet.ReadInt32("Spline Duration");

            packet.WriteGuid("Unit", guid3);

            var guidUnit = new WowGuid64(BitConverter.ToUInt64(guid3, 0));

            if (!Storage.Objects.IsEmpty() && Storage.Objects.ContainsKey(guidUnit))
            {
                var obj = Storage.Objects[guidUnit].Item1;
                UpdateField uf;
                if (obj.UpdateFields != null && obj.UpdateFields.TryGetValue(UpdateFields.GetUpdateField(UnitField.UNIT_FIELD_FLAGS), out uf))
                    if ((uf.UInt32Value & (uint)UnitFlags.IsInCombat) == 0) // movement could be because of aggro so ignore that
                        obj.Movement.HasWpsOrRandMov = true;
            }
        }
예제 #20
0
        public void TestOperators()
        {
            var guid1 = new WowGuid64(0xF130005C0500105F);
            var guid2 = new WowGuid64(0x600000002B2D7C9);
            var guid3 = new WowGuid64(0);

            Assert.IsFalse(guid1 == guid2);
            Assert.IsTrue(guid1 != guid2);

            #pragma warning disable 1718
            // ReSharper disable once EqualExpressionComparison
            Assert.IsTrue(guid3 == guid3);
            #pragma warning restore 1718
        }
        public static void HandleSpellClick(Packet packet)
        {
            var guidBytes = new byte[8];
            packet.StartBitStream(guidBytes, 7, 4, 0, 3, 6, 5);
            packet.ReadBit("unk");
            packet.StartBitStream(guidBytes, 1, 2);
            packet.ParseBitStream(guidBytes, 6, 1, 5, 4, 7, 2, 3, 0);

            packet.WriteGuid("Guid", guidBytes);

            var guid = new WowGuid64(BitConverter.ToUInt64(guidBytes, 0));
            if (guid.GetObjectType() == ObjectType.Unit)
                Storage.NpcSpellClicks.Add(guid, packet.TimeSpan);
        }
예제 #22
0
        public static void HandleCharEnum430(Packet packet)
        {
            var count = packet.ReadBits("Char count", 17);

            var charGuids = new byte[count][];
            var guildGuids = new byte[count][];
            var firstLogins = new bool[count];
            var nameLenghts = new uint[count];

            for (var c = 0; c < count; ++c)
            {
                charGuids[c] = new byte[8];
                guildGuids[c] = new byte[8];

                guildGuids[c][2] = packet.ReadBit();
                charGuids[c][2] = packet.ReadBit();
                charGuids[c][6] = packet.ReadBit();
                charGuids[c][5] = packet.ReadBit();
                charGuids[c][4] = packet.ReadBit();
                guildGuids[c][4] = packet.ReadBit();
                guildGuids[c][3] = packet.ReadBit();
                guildGuids[c][7] = packet.ReadBit();
                nameLenghts[c] = packet.ReadBits(7);
                guildGuids[c][0] = packet.ReadBit();
                charGuids[c][0] = packet.ReadBit();
                charGuids[c][3] = packet.ReadBit();
                charGuids[c][1] = packet.ReadBit();
                firstLogins[c] = packet.ReadBit();
                guildGuids[c][5] = packet.ReadBit();
                charGuids[c][7] = packet.ReadBit();
                guildGuids[c][6] = packet.ReadBit();
                guildGuids[c][1] = packet.ReadBit();
            }

            var unkCounter = packet.ReadBits("Unk Counter", 23);
            packet.ReadBit(); // no idea, not used in client

            for (int c = 0; c < count; ++c)
            {
                for (var itm = 0; itm < 19; ++itm)
                {
                    packet.ReadByteE<InventoryType>("Item InventoryType", c, itm);
                    packet.ReadInt32("Item DisplayID", c, itm);
                    packet.ReadInt32("Item EnchantID", c, itm);
                }

                for (var itm = 0; itm < 4; ++itm)
                {
                    packet.ReadByteE<InventoryType>("Bag InventoryType", c, itm);
                    packet.ReadInt32("Bag DisplayID", c, itm);
                    packet.ReadInt32("Bag EnchantID", c, itm);
                }

                packet.ReadXORByte(guildGuids[c], 0);
                packet.ReadXORByte(guildGuids[c], 1);

                packet.ReadByte("Face", c);
                packet.ReadInt32("Pet Display ID", c);
                packet.ReadXORByte(guildGuids[c], 7);

                packet.ReadByteE<Gender>("Gender", c);
                var level = packet.ReadByte("Level", c);
                packet.ReadInt32("Pet Level", c);
                var zone = packet.ReadUInt32<ZoneId>("Zone Id", c);
                var y = packet.ReadSingle("Position Y", c);
                packet.ReadInt32("Pet Family", c);
                packet.ReadByte("Hair Style", c);
                packet.ReadXORByte(charGuids[c], 1);

                var name = packet.ReadWoWString("Name", (int)nameLenghts[c], c);
                packet.ReadXORByte(charGuids[c], 0);

                var race = packet.ReadByteE<Race>("Race", c);
                packet.ReadByte("List Order", c);
                packet.ReadXORByte(charGuids[c], 7);

                var z = packet.ReadSingle("Position Z", c);
                var mapId = packet.ReadInt32("Map", c);
                packet.ReadXORByte(guildGuids[c], 4);

                packet.ReadByte("Hair Color", c);
                packet.ReadXORByte(charGuids[c], 3);

                packet.ReadInt32E<CharacterFlag>("CharacterFlag", c);
                packet.ReadByte("Skin", c);
                packet.ReadXORByte(charGuids[c], 4);
                packet.ReadXORByte(charGuids[c], 5);
                packet.ReadXORByte(guildGuids[c], 5);

                packet.ReadUInt32E<CustomizationFlag>("CustomizationFlag", c);
                var x = packet.ReadSingle("Position X", c);
                packet.ReadByte("Facial Hair", c);
                packet.ReadXORByte(charGuids[c], 6);
                packet.ReadXORByte(guildGuids[c], 3);
                packet.ReadXORByte(charGuids[c], 2);

                var clss = packet.ReadByteE<Class>("Class", c);
                packet.ReadXORByte(guildGuids[c], 6);
                packet.ReadXORByte(guildGuids[c], 2);

                var playerGuid = new WowGuid64(BitConverter.ToUInt64(charGuids[c], 0));

                packet.WriteGuid("Character GUID", charGuids[c], c);
                packet.WriteGuid("Guild GUID", guildGuids[c], c);

                if (firstLogins[c])
                {
                    var startPos = new StartPosition { Map = (uint) mapId, Position = new Vector3(x, y, z), Zone = zone };

                    Storage.StartPositions.Add(new Tuple<Race, Class>(race, clss), startPos, packet.TimeSpan);
                }

                var playerInfo = new Player{Race = race, Class = clss, Name = name, FirstLogin = firstLogins[c], Level = level};
                if (Storage.Objects.ContainsKey(playerGuid))
                    Storage.Objects[playerGuid] = new Tuple<WoWObject, TimeSpan?>(playerInfo, packet.TimeSpan);
                else
                    Storage.Objects.Add(playerGuid, playerInfo, packet.TimeSpan);
                StoreGetters.AddName(playerGuid, name);
            }

            for (var c = 0; c < unkCounter; c++)
            {
                packet.ReadUInt32("Unk1", c);
                packet.ReadByte("Unk2", c);
            }
        }
예제 #23
0
        public static void HandleCharEnum(Packet packet)
        {
            // ����� �� ���������, ���� ����������� ���� ������
            var unkCounter = packet.ReadBits("Unk Counter", 21);//[DW5]
            var count = packet.ReadBits("Char count", 16);//[DW9]

            var charGuids = new byte[count][];
            var guildGuids = new byte[count][];
            var firstLogins = new bool[count];
            var nameLenghts = new uint[count];

            for (int c = 0; c < count; ++c)
            {
                charGuids[c] = new byte[8];
                guildGuids[c] = new byte[8];

                guildGuids[c][4] = packet.ReadBit();
                charGuids[c][0] = packet.ReadBit();
                guildGuids[c][3] = packet.ReadBit();
                charGuids[c][3] = packet.ReadBit();
                charGuids[c][7] = packet.ReadBit();
                packet.ReadBit("unk bit 124", c); //124
                firstLogins[c] = packet.ReadBit(); //108
                charGuids[c][6] = packet.ReadBit();
                guildGuids[c][6] = packet.ReadBit();
                nameLenghts[c] = packet.ReadBits(6);
                charGuids[c][1] = packet.ReadBit();
                guildGuids[c][1] = packet.ReadBit();
                guildGuids[c][0] = packet.ReadBit();
                charGuids[c][4] = packet.ReadBit();
                guildGuids[c][7] = packet.ReadBit();
                charGuids[c][2] = packet.ReadBit();
                charGuids[c][5] = packet.ReadBit();
                guildGuids[c][2] = packet.ReadBit();
                guildGuids[c][5] = packet.ReadBit();
            }//+=416

            //packet.ResetBitReader();
            packet.ReadBit("UnkB16");

            for (int c = 0; c < count; ++c)
            {
                Vector3 pos = new Vector3();

                packet.ReadInt32("DW132", c);
                packet.ReadXORByte(charGuids[c], 1);//1
                packet.ReadByte("Slot", c); //57
                packet.ReadByte("Hair Style", c); //63
                packet.ReadXORByte(guildGuids[c], 2);//90
                packet.ReadXORByte(guildGuids[c], 0);//88
                packet.ReadXORByte(guildGuids[c], 6);//94
                var name = packet.ReadWoWString("Name", (int)nameLenghts[c], c);
                packet.ReadXORByte(guildGuids[c], 3);//91
                pos.X = packet.ReadSingle("Position X", c); //4Ch
                packet.ReadInt32("DW104", c);
                packet.ReadByte("Face", c); //62
                var klass = packet.ReadByteE<Class>("Class", c); //59
                packet.ReadXORByte(guildGuids[c], 5); //93

                for (var itm = 0; itm < 23; itm++)
                {
                    packet.ReadInt32("Item EnchantID", c, itm); //140 prolly need to replace those 2
                    packet.ReadByteE<InventoryType>("Item InventoryType", c, itm); //144
                    packet.ReadInt32("Item DisplayID", c, itm); //136
                }

                packet.ReadUInt32E<CustomizationFlag>("CustomizationFlag", c); //100
                packet.ReadXORByte(charGuids[c], 3); //3
                packet.ReadXORByte(charGuids[c], 5); //5
                packet.ReadInt32("PetFamily", c); //120
                packet.ReadXORByte(guildGuids[c], 4); //92
                var mapId = packet.ReadUInt32("Map", c); //72
                var race = packet.ReadByteE<Race>("Race", c); //58
                packet.ReadByte("Skin", c); //61
                packet.ReadXORByte(guildGuids[c], 1); //89
                var level = packet.ReadByte("Level", c); //66
                packet.ReadXORByte(charGuids[c], 0); //0
                packet.ReadXORByte(charGuids[c], 2); //2
                packet.ReadByte("Hair Color", c); //64
                packet.ReadByteE<Gender>("Gender", c); //60
                packet.ReadByte("Facial Hair", c); //65
                packet.ReadInt32("Pet Level", c); //116
                packet.ReadXORByte(charGuids[c], 4); //4
                packet.ReadXORByte(charGuids[c], 7); //7
                pos.Y = packet.ReadSingle("Position Y", c); //50h
                packet.ReadInt32("Pet DisplayID", c); //112
                packet.ReadInt32("DW128", c);
                packet.ReadXORByte(charGuids[c], 6); //6
                packet.ReadInt32E<CharacterFlag>("CharacterFlag", c); //96
                var zone = packet.ReadUInt32<ZoneId>("Zone Id", c); //68
                packet.ReadXORByte(guildGuids[c], 7); //95
                pos.Z = packet.ReadSingle("Position Z", c); //54h

                var playerGuid = new WowGuid64(BitConverter.ToUInt64(charGuids[c], 0));

                packet.WriteGuid("Character GUID", charGuids[c], c);
                packet.WriteGuid("Guild GUID", guildGuids[c], c);

                if (firstLogins[c])
                {
                    PlayerCreateInfo startPos = new PlayerCreateInfo { Race = race, Class = klass, Map = (uint)mapId, Zone = zone, Position = pos, Orientation = 0 };
                    Storage.StartPositions.Add(startPos, packet.TimeSpan);
                }

                var playerInfo = new Player { Race = race, Class = klass, Name = name, FirstLogin = firstLogins[c], Level = level };
                if (!Storage.Objects.IsEmpty() && Storage.Objects.ContainsKey(playerGuid))
                    Storage.Objects[playerGuid] = new Tuple<WoWObject, TimeSpan?>(playerInfo, packet.TimeSpan);
                else
                    Storage.Objects.Add(playerGuid, playerInfo, packet.TimeSpan);
                StoreGetters.AddName(playerGuid, name);
            }

            for (var i = 0; i < unkCounter; i++)
            {
                packet.ReadByte("Unk byte", i); // char_table+28+i*8
                packet.ReadUInt32("Unk int", i); // char_table+24+i*8
            }
        }
예제 #24
0
        public static void HandleMovementMessages(Packet packet)
        {
            WowGuid guid;
            if ((ClientVersion.AddedInVersion(ClientVersionBuild.V3_2_0_10192) ||
                packet.Direction == Direction.ServerToClient) && ClientVersion.Build != ClientVersionBuild.V4_2_2_14545)
                guid = packet.ReadPackedGuid("GUID");
            else
                guid = new WowGuid64();

            ReadMovementInfo(packet, guid);

            if (packet.Opcode != Opcodes.GetOpcode(Opcode.MSG_MOVE_KNOCK_BACK, Direction.Bidirectional))
                return;

            packet.ReadSingle("Sin Angle");
            packet.ReadSingle("Cos Angle");
            packet.ReadSingle("Speed");
            packet.ReadSingle("Velocity");
        }
예제 #25
0
        public static void HandleVendorInventoryList(Packet packet)
        {
            var npcVendor = new NpcVendor();

            var guid = new byte[8];

            guid[4] = packet.ReadBit();
            var itemCount = packet.ReadBits(18);
            var hasCondition = new bool[itemCount];
            var hasExtendedCost = new bool[itemCount];

            for (int i = 0; i < itemCount; ++i)
            {
                packet.ReadBit("Unk bit", i);
                hasCondition[i]= !packet.ReadBit();
                hasExtendedCost[i] = !packet.ReadBit();
            }

            guid[1] = packet.ReadBit();
            guid[6] = packet.ReadBit();
            guid[2] = packet.ReadBit();
            guid[5] = packet.ReadBit();
            guid[7] = packet.ReadBit();
            guid[0] = packet.ReadBit();
            guid[3] = packet.ReadBit();

            packet.ReadXORByte(guid, 3);

            npcVendor.VendorItems = new List<VendorItem>((int)itemCount);
            for (int i = 0; i < itemCount; ++i)
            {
                var vendorItem = new VendorItem();
                packet.ReadInt32("Max Durability", i);
                vendorItem.Type = packet.ReadUInt32("Type", i); // 1 - item, 2 - currency
                var buyCount = packet.ReadUInt32("Buy Count", i);

                if (hasExtendedCost[i])
                    vendorItem.ExtendedCostId = packet.ReadUInt32("Extended Cost", i);

                packet.ReadInt32("Price", i);
                vendorItem.ItemId = (uint)packet.ReadInt32<ItemId>("Item ID", i);
                vendorItem.Slot = packet.ReadUInt32("Item Position", i);

                if (hasCondition[i])
                    packet.ReadInt32("Condition ID", i);

                var maxCount = packet.ReadInt32("Max Count", i);
                packet.ReadInt32("Item Upgrade ID", i);
                packet.ReadInt32("Display ID", i);

                npcVendor.VendorItems.Add(vendorItem);
            }

            packet.ReadXORByte(guid, 6);
            packet.ReadXORByte(guid, 0);
            packet.ReadXORByte(guid, 2);
            packet.ReadXORByte(guid, 5);
            packet.ReadByte("Byte10");
            packet.ReadXORByte(guid, 1);
            packet.ReadXORByte(guid, 4);
            packet.ReadXORByte(guid, 7);

            packet.WriteGuid("Guid", guid);

            var vendorGUID = new WowGuid64(BitConverter.ToUInt64(guid, 0));
            Storage.NpcVendors.Add(vendorGUID.GetEntry(), npcVendor, packet.TimeSpan);
        }
예제 #26
0
        public static void HandleCharEnum(Packet packet)
        {
            packet.ReadBit("Unk bit");
            var count2 = packet.ReadBits("RIDBIT21", 21);
            var count = packet.ReadBits("Char count", 16);

            var charGuids = new byte[count][];
            var guildGuids = new byte[count][];
            var firstLogins = new bool[count];
            var nameLenghts = new uint[count];

            for (int c = 0; c < count; ++c)
            {
                charGuids[c] = new byte[8];
                guildGuids[c] = new byte[8];

                charGuids[c][3] = packet.ReadBit();
                guildGuids[c][6] = packet.ReadBit();
                guildGuids[c][3] = packet.ReadBit();
                firstLogins[c] = packet.ReadBit();
                guildGuids[c][7] = packet.ReadBit();
                nameLenghts[c] = packet.ReadBits(6);
                guildGuids[c][1] = packet.ReadBit();
                charGuids[c][6] = packet.ReadBit();
                charGuids[c][1] = packet.ReadBit();
                guildGuids[c][4] = packet.ReadBit();
                charGuids[c][5] = packet.ReadBit();
                guildGuids[c][0] = packet.ReadBit();
                charGuids[c][7] = packet.ReadBit();
                charGuids[c][2] = packet.ReadBit();
                charGuids[c][0] = packet.ReadBit();
                guildGuids[c][2] = packet.ReadBit();
                guildGuids[c][5] = packet.ReadBit();
                charGuids[c][4] = packet.ReadBit();
            }

            packet.ResetBitReader();

            for (int c = 0; c < count; ++c)
            {
                packet.ReadInt32E<CharacterFlag>("CharacterFlag", c);
                var zone = packet.ReadUInt32<ZoneId>("Zone Id", c);
                packet.ReadXORByte(charGuids[c], 0);
                packet.ReadXORByte(guildGuids[c], 5);
                packet.ReadXORByte(charGuids[c], 1);
                packet.ReadXORByte(guildGuids[c], 1);
                packet.ReadXORByte(charGuids[c], 3);
                packet.ReadInt32("Pet Family", c); // v4+116
                packet.ReadXORByte(guildGuids[c], 2);
                packet.ReadByte("Hair Style", c); // v4+63
                packet.ReadXORByte(guildGuids[c], 0);
                packet.ReadXORByte(guildGuids[c], 7);
                var y = packet.ReadSingle("Position Y", c); // v4+80
                packet.ReadXORByte(charGuids[c], 6);
                packet.ReadInt32("Pet Level", c); // v4+112
                packet.ReadXORByte(charGuids[c], 7);
                var name = packet.ReadWoWString("Name", (int)nameLenghts[c], c); // v4 + 8
                var level = packet.ReadByte("Level", c); // v4+66
                var x = packet.ReadSingle("Position X", c); //v4+76
                var clss = packet.ReadByteE<Class>("Class", c); // v4+59
                packet.ReadInt32("Pet Display ID", c); //v4+108
                packet.ReadByte("List Order", c); //v4+57
                packet.ReadByte("Facial Hair", c); // v4+65
                var z = packet.ReadSingle("Position Z", c); //v4+84
                packet.ReadXORByte(guildGuids[c], 3);
                var race = packet.ReadByteE<Race>("Race", c); //v4+58
                packet.ReadXORByte(charGuids[c], 4);

                for (int j = 0; j < 23; ++j)
                {
                    packet.ReadByteE<InventoryType>("Item InventoryType", c, j);
                    packet.ReadInt32("Item DisplayID", c, j);
                    packet.ReadInt32("Item EnchantID", c, j);
                }

                packet.ReadXORByte(guildGuids[c], 6);
                packet.ReadXORByte(charGuids[c], 2);
                packet.ReadXORByte(charGuids[c], 5);
                packet.ReadByte("Skin", c); //v4+61
                packet.ReadByte("Hair Color", c); // v4+64
                packet.ReadByte("Face", c); // v4+62
                packet.ReadXORByte(guildGuids[c], 4);
                packet.ReadUInt32E<CustomizationFlag>("CustomizationFlag", c); //v4+100
                packet.ReadByteE<Gender>("Gender", c); //v4+60
                var mapId = packet.ReadInt32<MapId>("Map Id", c); //v4+72

                for (var i = 0; i < count2; ++i)
                {
                    packet.ReadUInt32("unk1", i);
                    packet.ReadByte("unk2", i);
                }

                var playerGuid = new WowGuid64(BitConverter.ToUInt64(charGuids[c], 0));

                packet.WriteGuid("Character GUID", charGuids[c], c);
                packet.WriteGuid("Guild GUID", guildGuids[c], c);

                if (firstLogins[c])
                {
                    var startPos = new StartPosition {Map = (uint) mapId, Position = new Vector3(x, y, z), Zone = zone};

                    Storage.StartPositions.Add(new Tuple<Race, Class>(race, clss), startPos, packet.TimeSpan);
                }

                var playerInfo = new Player { Race = race, Class = clss, Name = name, FirstLogin = firstLogins[c], Level = level };
                if (Storage.Objects.ContainsKey(playerGuid))
                    Storage.Objects[playerGuid] = new Tuple<WoWObject, TimeSpan?>(playerInfo, packet.TimeSpan);
                else
                    Storage.Objects.Add(playerGuid, playerInfo, packet.TimeSpan);

                StoreGetters.AddName(playerGuid, name);
            }
        }
예제 #27
0
        public static void HandleSpellStart(Packet packet)
        {
            bool isSpellGo = packet.Opcode == Opcodes.GetOpcode(Opcode.SMSG_SPELL_GO, Direction.ServerToClient);

            var casterGUID = packet.ReadPackedGuid("Caster GUID");
            packet.ReadPackedGuid("Caster Unit GUID");

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V3_0_2_9056))
                packet.ReadByte("Cast Count");

            var spellId = packet.ReadInt32<SpellId>("Spell ID");

            if (ClientVersion.RemovedInVersion(ClientVersionBuild.V3_0_2_9056) && !isSpellGo)
                packet.ReadByte("Cast Count");

            CastFlag flags;
            if (ClientVersion.AddedInVersion(ClientVersionBuild.V3_0_2_9056))
                flags = packet.ReadInt32E<CastFlag>("Cast Flags");
            else
                flags = packet.ReadUInt16E<CastFlag>("Cast Flags");

            packet.ReadUInt32("Time");
            if (ClientVersion.AddedInVersion(ClientVersionBuild.V4_3_0_15005))
                packet.ReadUInt32("Time2");

            if (isSpellGo)
            {
                var hitCount = packet.ReadByte("Hit Count");
                for (var i = 0; i < hitCount; i++)
                    packet.ReadGuid("Hit GUID", i);

                var missCount = packet.ReadByte("Miss Count");
                for (var i = 0; i < missCount; i++)
                {
                    packet.ReadGuid("Miss GUID", i);

                    var missType = packet.ReadByteE<SpellMissType>("Miss Type", i);
                    if (missType == SpellMissType.Reflect)
                        packet.ReadByteE<SpellMissType>("Miss Reflect", i);
                }
            }

            var targetFlags = packet.ReadInt32E<TargetFlag>("Target Flags");

            WowGuid targetGUID = new WowGuid64();
            if (targetFlags.HasAnyFlag(TargetFlag.Unit | TargetFlag.CorpseEnemy | TargetFlag.GameObject |
                TargetFlag.CorpseAlly | TargetFlag.UnitMinipet))
                targetGUID = packet.ReadPackedGuid("Target GUID");

            if (targetFlags.HasAnyFlag(TargetFlag.Item | TargetFlag.TradeItem))
                packet.ReadPackedGuid("Item Target GUID");

            if (targetFlags.HasAnyFlag(TargetFlag.SourceLocation))
            {
                if (ClientVersion.AddedInVersion(ClientVersionBuild.V3_2_0_10192))
                    packet.ReadPackedGuid("Source Transport GUID");

                packet.ReadVector3("Source Position");
            }

            if (targetFlags.HasAnyFlag(TargetFlag.DestinationLocation))
            {
                if (ClientVersion.AddedInVersion(ClientVersionBuild.V3_0_8_9464))
                    packet.ReadPackedGuid("Destination Transport GUID");

                packet.ReadVector3("Destination Position");
            }

            if (targetFlags.HasAnyFlag(TargetFlag.NameString))
                packet.ReadCString("Target String");

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V3_0_2_9056))
            {
                if (flags.HasAnyFlag(CastFlag.PredictedPower))
                {
                    if (ClientVersion.AddedInVersion(ClientVersionBuild.V5_1_0_16309))
                    {
                        var count = packet.ReadUInt32("Modified Power Count");
                        for (var i = 0; i < count; i++)
                        {
                            packet.ReadUInt32E<PowerType>("Power Type", i);
                            packet.ReadInt32("Power Value", i);
                        }
                    }
                    else
                        packet.ReadInt32("Rune Cooldown");
                }

                if (flags.HasAnyFlag(CastFlag.RuneInfo))
                {
                    var spellRuneState = packet.ReadByte("Spell Rune State");
                    var playerRuneState = packet.ReadByte("Player Rune State");

                    for (var i = 0; i < 6; i++)
                    {
                        if (ClientVersion.RemovedInVersion(ClientVersionBuild.V4_2_2_14545))
                        {
                            var mask = 1 << i;
                            if ((mask & spellRuneState) == 0)
                                continue;

                            if ((mask & playerRuneState) != 0)
                                continue;
                        }

                        packet.ReadByte("Rune Cooldown Passed", i);
                    }
                }

                if (isSpellGo)
                {
                    if (flags.HasAnyFlag(CastFlag.AdjustMissile))
                    {
                        packet.ReadSingle("Elevation");
                        packet.ReadInt32("Delay time");
                    }
                }
            }

            if (flags.HasAnyFlag(CastFlag.Projectile))
            {
                packet.ReadInt32("Ammo Display ID");
                packet.ReadInt32E<InventoryType>("Ammo Inventory Type");
            }

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V3_0_2_9056))
            {
                if (isSpellGo)
                {
                    if (flags.HasAnyFlag(CastFlag.VisualChain))
                    {
                        packet.ReadInt32("Unk Int32 2");
                        packet.ReadInt32("Unk Int32 3");
                    }

                    if (targetFlags.HasAnyFlag(TargetFlag.DestinationLocation))
                        packet.ReadSByte("Unk Byte 2"); // Some count

                    if (targetFlags.HasAnyFlag(TargetFlag.ExtraTargets))
                    {
                        var targetCount = packet.ReadInt32("Extra Targets Count");
                        for (var i = 0; i < targetCount; i++)
                        {
                            packet.ReadVector3("Extra Target Position", i);
                            packet.ReadGuid("Extra Target GUID", i);
                        }
                    }
                }
                else
                {
                    if (flags.HasAnyFlag(CastFlag.Immunity))
                    {
                        packet.ReadInt32("CastSchoolImmunities");
                        packet.ReadInt32("CastImmunities");
                    }

                    if (flags.HasAnyFlag(CastFlag.HealPrediction))
                    {
                        packet.ReadInt32<SpellId>("Predicted Spell ID");

                        if (packet.ReadByte("Unk Byte") == 2)
                            packet.ReadPackedGuid("Unk Guid");
                    }
                }
            }

            if (flags.HasAnyFlag(CastFlag.Unknown21) && !isSpellGo)
            {
                NpcSpellClick spellClick = new NpcSpellClick
                {
                    SpellID = (uint) spellId,
                    CasterGUID = casterGUID,
                    TargetGUID = targetGUID
                };

                Storage.SpellClicks.Add(spellClick, packet.TimeSpan);
            }

            if (isSpellGo)
                packet.AddSniffData(StoreNameType.Spell, spellId, "SPELL_GO");
        }
예제 #28
0
        public void TestGetObjectType()
        {
            var guid1 = new WowGuid64(0xF130005C0500105F);
            var guid2 = new WowGuid64(0x600000002B2D7C9);
            var guid3 = new WowGuid64(0);

            Assert.AreEqual(ObjectType.Unit, guid1.GetObjectType());
            Assert.AreEqual(ObjectType.Player, guid2.GetObjectType());
            Assert.AreEqual(ObjectType.Object, guid3.GetObjectType());
        }
예제 #29
0
        public static void HandleNpcGossip(Packet packet)
        {
            var gossip = new Gossip();

            var guidBytes = new byte[8];

            guidBytes[7] = packet.ReadBit();
            guidBytes[6] = packet.ReadBit();
            guidBytes[1] = packet.ReadBit();

            var questgossips = packet.ReadBits(19);

            guidBytes[0] = packet.ReadBit();
            guidBytes[4] = packet.ReadBit();
            guidBytes[5] = packet.ReadBit();
            guidBytes[2] = packet.ReadBit();
            guidBytes[3] = packet.ReadBit();

            var amountOfOptions = packet.ReadBits(20);

            var boxTextLen = new uint[amountOfOptions];
            var optionTextLen = new uint[amountOfOptions];
            for (var i = 0; i < amountOfOptions; ++i)
            {
                boxTextLen[i] = packet.ReadBits(12);
                optionTextLen[i] = packet.ReadBits(12);
            }

            var titleLen = new uint[questgossips];
            for (var i = 0; i < questgossips; ++i)
            {
                packet.ReadBit("Change Icon", i);
                titleLen[i] = packet.ReadBits(9);
            }

            for (var i = 0; i < questgossips; ++i)
            {
                packet.ReadUInt32E<QuestFlags2>("Flags 2", i);
                packet.ReadUInt32<QuestId>("Quest ID", i);
                packet.ReadInt32("Level", i);
                packet.ReadUInt32("Icon", i);
                packet.ReadUInt32E<QuestFlags>("Flags", i);
                packet.ReadWoWString("Title", titleLen[i], i);
            }

            packet.ReadXORByte(guidBytes, 6);

            gossip.GossipOptions = new List<GossipOption>((int)amountOfOptions);
            for (var i = 0; i < amountOfOptions; ++i)
            {
                var gossipOption = new GossipOption
                {
                    RequiredMoney = packet.ReadUInt32("Required money", i),
                    OptionText = packet.ReadWoWString("Text", optionTextLen[i], i),
                    Index = packet.ReadUInt32("Index", i),
                    OptionIcon = packet.ReadByteE<GossipOptionIcon>("Icon", i),
                    BoxText = packet.ReadWoWString("Box Text", boxTextLen[i], i),
                    Box = packet.ReadBool("Box", i)
                };

                gossip.GossipOptions.Add(gossipOption);
            }

            packet.ReadXORByte(guidBytes, 2);

            var textId = packet.ReadUInt32("Text Id");

            packet.ReadXORByte(guidBytes, 1);
            packet.ReadXORByte(guidBytes, 5);

            var menuId = packet.ReadUInt32("Menu Id");
            packet.ReadUInt32("Friendship Faction");

            packet.ReadXORByte(guidBytes, 4);
            packet.ReadXORByte(guidBytes, 7);
            packet.ReadXORByte(guidBytes, 3);
            packet.ReadXORByte(guidBytes, 0);

            packet.WriteGuid("Guid", guidBytes);

            var guid = new WowGuid64(BitConverter.ToUInt64(guidBytes, 0));
            gossip.ObjectType = guid.GetObjectType();
            gossip.ObjectEntry = guid.GetEntry();

            if (guid.GetObjectType() == ObjectType.Unit)
                if (Storage.Objects.ContainsKey(guid))
                    ((Unit)Storage.Objects[guid].Item1).GossipId = menuId;

            if (Storage.Gossips.ContainsKey(Tuple.Create(menuId, textId)))
            {
                var oldGossipOptions = Storage.Gossips[Tuple.Create(menuId, textId)];
                if (oldGossipOptions != null)
                {
                    foreach (var gossipOptions in gossip.GossipOptions)
                        oldGossipOptions.Item1.GossipOptions.Add(gossipOptions);
                }
            }
            else
                Storage.Gossips.Add(Tuple.Create(menuId, textId), gossip, packet.TimeSpan);

            packet.AddSniffData(StoreNameType.Gossip, (int)menuId, guid.GetEntry().ToString(CultureInfo.InvariantCulture));
        }
예제 #30
0
        public void TestHasEntry()
        {
            var guid1 = new WowGuid64(0xF130005C0500105F);
            var guid2 = new WowGuid64(0x600000002B2D7C9);
            var guid3 = new WowGuid64(0);

            Assert.IsTrue(guid1.HasEntry());
            Assert.IsFalse(guid2.HasEntry());
            Assert.IsFalse(guid3.HasEntry());
        }
예제 #31
0
        public static void HandleAuraUpdate(Packet packet)
        {
            var guid = new byte[8];
            var powerGUID = new byte[8];

            packet.ReadBit(); // fake bit?

            packet.StartBitStream(guid, 6, 1, 0);

            var bits4 = (int)packet.ReadBits(24);

            packet.StartBitStream(guid, 2, 4);

            var hasPowerData = packet.ReadBit();

            var powerCount = 0u;
            if (hasPowerData)
            {
                packet.StartBitStream(powerGUID, 7, 0, 6);
                powerCount = packet.ReadBits(21);
                packet.StartBitStream(powerGUID, 3, 1, 2, 4, 5);
            }

            packet.StartBitStream(guid, 7, 3, 5);

            var hasAura = new bool[bits4];
            var hasCasterGUID = new bool[bits4];
            var hasDuration = new bool[bits4];
            var hasMaxDuration = new bool[bits4];
            var effectCount = new uint[bits4];
            var casterGUID = new byte[bits4][];
            var bitsEC = new uint[bits4];

            for (var i = 0; i < bits4; ++i)
            {
                hasAura[i] = packet.ReadBit();

                if (hasAura[i])
                {
                    hasMaxDuration[i] = packet.ReadBit();
                    effectCount[i] = packet.ReadBits(22);
                    hasCasterGUID[i] = packet.ReadBit();
                    if (hasCasterGUID[i])
                    {
                        casterGUID[i] = new byte[8];
                        packet.StartBitStream(casterGUID[i], 3, 0, 2, 6, 5, 7, 4, 1);
                    }

                    hasDuration[i] = packet.ReadBit();
                    bitsEC[i] = packet.ReadBits(22);
                }
            }

            var auras = new List<Aura>();
            for (var i = 0; i < bits4; ++i)
            {
                if (hasAura[i])
                {
                    var aura = new Aura();

                    aura.Duration = hasDuration[i] ? packet.ReadInt32("Duration", i) : 0;

                    if (hasCasterGUID[i])
                    {
                        packet.ParseBitStream(casterGUID[i], 0, 7, 5, 6, 1, 3, 2, 4);
                        packet.WriteGuid("Caster GUID", casterGUID[i], i);
                        aura.CasterGuid = new WowGuid64(BitConverter.ToUInt64(casterGUID[i], 0));
                    }
                    else
                        aura.CasterGuid = new WowGuid64();

                    aura.AuraFlags = packet.ReadByteE<AuraFlagMoP>("Flags", i);

                    for (var j = 0; j < effectCount[i]; ++j)
                        packet.ReadSingle("Effect Value", i, j);

                    aura.SpellId = packet.ReadUInt32("Spell Id", i);

                    aura.MaxDuration = hasMaxDuration[i] ? packet.ReadInt32("Max Duration", i) : 0;

                    for (var j = 0; j < bitsEC[i]; ++j)
                        packet.ReadSingle("FloatEA");

                    aura.Charges = packet.ReadByte("Charges", i);
                    packet.ReadInt32("Effect Mask", i);
                    aura.Level = packet.ReadUInt16("Caster Level", i);
                    auras.Add(aura);
                    packet.AddSniffData(StoreNameType.Spell, (int)aura.SpellId, "AURA_UPDATE");
                }

                packet.ReadByte("Slot", i);
            }

            if (hasPowerData)
            {
                packet.ReadXORByte(powerGUID, 7);
                packet.ReadXORByte(powerGUID, 4);
                packet.ReadXORByte(powerGUID, 5);
                packet.ReadXORByte(powerGUID, 1);
                packet.ReadXORByte(powerGUID, 6);
                for (var i = 0; i < powerCount; ++i)
                {
                    packet.ReadInt32("Value", i);
                    packet.ReadInt32E<PowerType>("Power type", i); // Actually powertype for class
                }

                packet.ReadInt32("Attack power");
                packet.ReadInt32("Spell power");
                packet.ReadXORByte(powerGUID, 3);
                packet.ReadInt32("Current health");
                packet.ReadXORByte(powerGUID, 0);
                packet.ReadXORByte(powerGUID, 2);
                packet.WriteGuid("Power GUID", powerGUID);
            }

            packet.ParseBitStream(guid, 0, 4, 3, 7, 5, 6, 2, 1);

            packet.WriteGuid("Guid", guid);

            var GUID = new WowGuid64(BitConverter.ToUInt64(guid, 0));
            if (Storage.Objects.ContainsKey(GUID))
            {
                var unit = Storage.Objects[GUID].Item1 as Unit;
                if (unit != null)
                {
                    // If this is the first packet that sends auras
                    // (hopefully at spawn time) add it to the "Auras" field,
                    // if not create another row of auras in AddedAuras
                    // (similar to ChangedUpdateFields)

                    if (unit.Auras == null)
                        unit.Auras = auras;
                    else
                        unit.AddedAuras.Add(auras);
                }
            }
        }
예제 #32
0
        public static void HandleNameQueryResponse(Packet packet)
        {
            var guid = packet.StartBitStream(3, 6, 7, 2, 5, 4, 0, 1);
            packet.ParseBitStream(guid, 5, 4, 7, 6, 1, 2);

            var nameData = !packet.ReadBool("!nameData");
            if (nameData)
            {
                packet.ReadInt32("RealmID"); // 108
                packet.ReadInt32("unk36");
                packet.ReadByteE<Class>("Class");
                packet.ReadByteE<Race>("Race");
                packet.ReadByte("Level");
                packet.ReadByteE<Gender>("Gender");
            }
            packet.ParseBitStream(guid, 0, 3);

            packet.WriteGuid("Guid", guid);

            if (!nameData)
                return;

            var guid2 = new byte[8];
            var guid3 = new byte[8];

            guid2[2] = packet.ReadBit();
            guid2[7] = packet.ReadBit();
            guid3[7] = packet.ReadBit();
            guid3[2] = packet.ReadBit();
            guid3[0] = packet.ReadBit();
            var unk32 = packet.ReadBit();
            guid2[4] = packet.ReadBit();
            guid3[5] = packet.ReadBit();
            guid2[1] = packet.ReadBit();
            guid2[3] = packet.ReadBit();
            guid2[0] = packet.ReadBit();

            var len = new uint[5];
            for (var i = 5; i > 0; i--)
                len[i - 1] = packet.ReadBits(7);

            guid3[6] = packet.ReadBit();
            guid3[3] = packet.ReadBit();
            guid2[5] = packet.ReadBit();
            guid3[1] = packet.ReadBit();
            guid3[4] = packet.ReadBit();

            var len56 = packet.ReadBits(6);

            guid2[6] = packet.ReadBit();

            packet.ReadXORByte(guid3, 6);
            packet.ReadXORByte(guid3, 0);

            var name = packet.ReadWoWString("Name", len56);
            var playerGuid = new WowGuid64(BitConverter.ToUInt64(guid, 0));
            StoreGetters.AddName(playerGuid, name);

            packet.ReadXORByte(guid2, 5);
            packet.ReadXORByte(guid2, 2);
            packet.ReadXORByte(guid3, 3);
            packet.ReadXORByte(guid2, 4);
            packet.ReadXORByte(guid2, 3);
            packet.ReadXORByte(guid3, 4);
            packet.ReadXORByte(guid3, 2);
            packet.ReadXORByte(guid2, 7);

            for (var i = 5; i > 0; i--)
                packet.ReadWoWString("str", len[i - 1], i);

            packet.ReadXORByte(guid2, 6);
            packet.ReadXORByte(guid3, 7);
            packet.ReadXORByte(guid3, 1);
            packet.ReadXORByte(guid2, 1);
            packet.ReadXORByte(guid3, 5);
            packet.ReadXORByte(guid2, 0);

            packet.WriteLine("Account: {0}", BitConverter.ToUInt64(guid2, 0));
            packet.WriteGuid("Guid3", guid3);

            var objectName = new ObjectName
            {
                ObjectType = ObjectType.Player,
                Name = name,
                ID = (int)playerGuid.GetLow()
            };
            Storage.ObjectNames.Add(objectName, packet.TimeSpan);
        }