예제 #1
0
        public static void HandleNpcGossip(Packet packet)
        {
            var gossip = new Gossip();

            var guid = packet.ReadGuid("GUID");

            gossip.ObjectType = guid.GetObjectType();
            gossip.ObjectEntry = guid.GetEntry();

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

            if (ClientVersion.AddedInVersion(ClientType.MistsOfPandaria))
                packet.ReadUInt32("Friendship Faction");

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

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

            var count = packet.ReadUInt32("Amount of Options");

            gossip.GossipOptions = new List<GossipOption>((int) count);
            for (var i = 0; i < count; i++)
            {
                var gossipOption = new GossipOption
                {
                    Index = packet.ReadUInt32("Index", i),
                    OptionIcon = packet.ReadEnum<GossipOptionIcon>("Icon", TypeCode.Byte, i),
                    Box = packet.ReadBoolean("Box", i),
                    RequiredMoney = packet.ReadUInt32("Required money", i),
                    OptionText = packet.ReadCString("Text", i),
                    BoxText = packet.ReadCString("Box Text", i)
                };

                gossip.GossipOptions.Add(gossipOption);
            }
            Storage.Gossips.Add(Tuple.Create(menuId, textId), gossip, packet.TimeSpan);
            packet.AddSniffData(StoreNameType.Gossip, (int)menuId, guid.GetEntry().ToString(CultureInfo.InvariantCulture));

            var questgossips = packet.ReadUInt32("Amount of Quest gossips");
            for (var i = 0; i < questgossips; i++)
            {
                packet.ReadEntryWithName<UInt32>(StoreNameType.Quest, "Quest ID", i);

                packet.ReadUInt32("Icon", i);
                packet.ReadInt32("Level", i);
                packet.ReadEnum<QuestFlags>("Flags", TypeCode.UInt32, i);
                if (ClientVersion.AddedInVersion(ClientVersionBuild.V5_1_0_16309))
                    packet.ReadEnum<QuestFlags2>("Flags 2", TypeCode.UInt32, i);

                packet.ReadBoolean("Change Icon", i);
                packet.ReadCString("Title", i);
            }
        }
예제 #2
0
        public static void HandleNpcGossip(Packet packet)
        {
            var guid = packet.ReadGuid("GUID");
            var menuid = packet.ReadUInt32("Menu id");
            var textid = packet.ReadUInt32("Text id");

            GossipMenu gossip = new GossipMenu
            {
                MenuId = menuid,
                GossipOptions = new List<GossipOption>(),
                NpcTextId = textid
            };

            gossip = Stuffing.Gossips.GetOrAdd(Tuple.Create<uint,uint>(guid.GetEntry(),menuid), gossip);

            var count = packet.ReadUInt32("Amount of Options");

            for (var i = 0; i < count; i++)
            {
                GossipOption opt = new GossipOption
                {
                    Index = packet.ReadUInt32("Index", i),
                    OptionIcon = packet.ReadByte("Icon", i),
                    Box = packet.ReadBoolean("Box", i),
                    RequiredMoney = packet.ReadUInt32("Required money", i),
                    OptionText = packet.ReadCString("Text", i),
                    BoxText = packet.ReadCString("Box Text", i)
                };
                gossip.GossipOptions.Add(opt);
            }

            Stuffing.Gossips.AddOrUpdate(Tuple.Create<uint,uint>(guid.GetEntry(),menuid), gossip, (a,b) =>
            {
                b.GossipOptions = gossip.GossipOptions;
                b.NpcTextId = gossip.NpcTextId;
                return b;
            });

            var questgossips = packet.ReadUInt32("Amount of Quest gossips");
            for (var i = 0; i < questgossips; i++)
            {
                packet.ReadEntryWithName<UInt32>(StoreNameType.Quest, "Quest ID", i);

                packet.ReadUInt32("Icon", i);
                packet.ReadInt32("Level", i);
                packet.ReadEnum<QuestFlags>("Flags", TypeCode.UInt32, i);
                packet.ReadBoolean("Unk Bool", i);
                packet.ReadCString("Title", i);
            }
        }
예제 #3
0
        public static void HandleNpcGossip(Packet packet)
        {
            var gossip = new Gossip();

            var guid = packet.ReadGuid("GUID"); // TODO: Use this to assign npc entries with gossip ids

            gossip.ObjectType = guid.GetObjectType();
            gossip.ObjectEntry = guid.GetEntry();

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

            var count = packet.ReadUInt32("Amount of Options");

            gossip.GossipOptions = new List<GossipOption>((int) count);
            for (var i = 0; i < count; i++)
            {
                var gossipOption = new GossipOption();

                gossipOption.Index = packet.ReadUInt32("Index", i);
                gossipOption.OptionIcon = packet.ReadByte("Icon", i);
                gossipOption.Box = packet.ReadBoolean("Box", i);
                gossipOption.RequiredMoney = packet.ReadUInt32("Required money", i);
                gossipOption.OptionText = packet.ReadCString("Text", i);
                gossipOption.BoxText = packet.ReadCString("Box Text", i);

                gossip.GossipOptions.Add(gossipOption);
            }

            packet.AddSniffData(StoreNameType.Gossip, (int)menuId, guid.GetEntry().ToString(CultureInfo.InvariantCulture));

            Storage.Gossips.TryAdd(new Tuple<uint, uint>(menuId, textId), gossip);

            var questgossips = packet.ReadUInt32("Amount of Quest gossips");
            for (var i = 0; i < questgossips; i++)
            {
                packet.ReadEntryWithName<UInt32>(StoreNameType.Quest, "Quest ID", i);

                packet.ReadUInt32("Icon", i);
                packet.ReadInt32("Level", i);
                packet.ReadEnum<QuestFlags>("Flags", TypeCode.UInt32, i);
                packet.ReadBoolean("Unk Bool", i);
                packet.ReadCString("Title", i);
            }
        }
예제 #4
0
        public static void HandleNpcGossip(Packet packet)
        {
            var gossip = new Gossip();

            packet.ReadGuid("GUID"); // TODO: Use this to assign npc entries with gossip ids

            var menuId = packet.ReadUInt32("Menu id");

            gossip.NpcTextIds.Add(packet.ReadUInt32("Text id"));

            var count = packet.ReadUInt32("Amount of Options");
            gossip.GossipOptions = new List<GossipOption>((int)count);
            for (var i = 0; i < count; i++)
            {
                var gossipOption = new GossipOption();

                gossipOption.Index = packet.ReadUInt32("Index", i);
                gossipOption.OptionIcon = packet.ReadByte("Icon", i);
                gossipOption.Box = packet.ReadBoolean("Box", i);
                gossipOption.RequiredMoney = packet.ReadUInt32("Required money", i);
                gossipOption.OptionText = packet.ReadCString("Text", i);
                gossipOption.BoxText = packet.ReadCString("Box Text", i);

                gossip.GossipOptions.Add(gossipOption);
            }

            Stuffing.Gossips.TryAdd(menuId, gossip);

            var questgossips = packet.ReadUInt32("Amount of Quest gossips");
            for (var i = 0; i < questgossips; i++)
            {
                packet.ReadEntryWithName<UInt32>(StoreNameType.Quest, "Quest ID", i);

                packet.ReadUInt32("Icon", i);
                packet.ReadInt32("Level", i);
                packet.ReadEnum<QuestFlags>("Flags", TypeCode.UInt32, i);
                packet.ReadBoolean("Unk Bool", i);
                packet.ReadCString("Title", i);
            }
        }
예제 #5
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));
        }
예제 #6
0
        public static void HandleNpcGossip(Packet packet)
        {
            var guid = new byte[8];
            uint[] titleLen;
            uint[] OptionTextLen;
            uint[] BoxTextLen;

            var menuId = packet.ReadUInt32("Menu Id");
            packet.ReadUInt32("Friendship Faction");
            var textId = packet.ReadUInt32("Text Id");
            packet.StartBitStream(guid, 0, 1);
            var AmountOfOptions = packet.ReadBits("Amount of Options", 20);
            packet.StartBitStream(guid, 6, 7);

            OptionTextLen = new uint[AmountOfOptions];
            BoxTextLen = new uint[AmountOfOptions];
            for (var i = 0; i < AmountOfOptions; ++i)
            {
                OptionTextLen[i] = packet.ReadBits(12);
                BoxTextLen[i] = packet.ReadBits(12);
            }
            packet.StartBitStream(guid, 4, 3, 2);

            var questgossips = packet.ReadBits("Amount of Quest gossips", 19);

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

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

            var gossip = new Gossip();

            gossip.GossipOptions = new List<GossipOption>((int)AmountOfOptions);
            for (var i = 0; i < AmountOfOptions; ++i)
            {
                var gossipOption = new GossipOption
                {
                    RequiredMoney = packet.ReadUInt32("Required money", i),
                    Index = packet.ReadUInt32("Index", i),
                    BoxText = packet.ReadWoWString("Box Text", BoxTextLen[i], i),
                    Box = packet.ReadBoolean("Box", i),
                    OptionText = packet.ReadWoWString("Text", OptionTextLen[i], i),
                    OptionIcon = packet.ReadEnum<GossipOptionIcon>("Icon", TypeCode.Byte, i),
                };

                gossip.GossipOptions.Add(gossipOption);
            }

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

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

            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));
        }
예제 #7
0
        public static void HandleNpcGossip(Packet packet)
        {
            var gossip = new Gossip();

            var guid = new byte[8];

            uint[] titleLen;
            uint[] BoxTextLen;
            uint[] OptionTextLen;

            var questgossips = packet.ReadBits(19);

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

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

            var AmountOfOptions = packet.ReadBits(20);

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

            BoxTextLen = new uint[AmountOfOptions];
            OptionTextLen = new uint[AmountOfOptions];
            for (var i = 0; i < AmountOfOptions; ++i)
            {
                BoxTextLen[i] = packet.ReadBits(12);
                OptionTextLen[i] = packet.ReadBits(12);
            }

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

            for (var i = 0; i < questgossips; ++i)
            {
                packet.ReadWoWString("Title", titleLen[i], i);
                packet.ReadEnum<QuestFlags>("Flags", TypeCode.UInt32, i);//528
                packet.ReadInt32("Level", i);//8
                packet.ReadUInt32("Icon", i);//4
                packet.ReadEntry<UInt32>(StoreNameType.Quest, "Quest ID", i); //528
                packet.ReadEnum<QuestFlags2>("Flags 2", TypeCode.UInt32, i);//532
            }

            packet.ReadXORByte(guid, 1);
            packet.ReadXORByte(guid, 0);

            gossip.GossipOptions = new List<GossipOption>((int)AmountOfOptions);
            for (var i = 0; i < AmountOfOptions; ++i)
            {
                var gossipOption = new GossipOption
                {
                    RequiredMoney = packet.ReadUInt32("Required money", i),//3012
                    BoxText = packet.ReadWoWString("Box Text", BoxTextLen[i], i),//12
                    Index = packet.ReadUInt32("Index", i),//0
                    Box = packet.ReadBoolean("Box", i),
                    OptionText = packet.ReadWoWString("Text", OptionTextLen[i], i),
                    OptionIcon = packet.ReadEnum<GossipOptionIcon>("Icon", TypeCode.Byte, i),//4
                };

                gossip.GossipOptions.Add(gossipOption);
            }

            packet.ReadXORByte(guid, 5);
            packet.ReadXORByte(guid, 3);
            var menuId = packet.ReadUInt32("Menu Id");
            packet.ReadXORByte(guid, 2);
            packet.ReadXORByte(guid, 6);
            packet.ReadXORByte(guid, 4);
            packet.ReadUInt32("Friendship Faction");
            packet.ReadXORByte(guid, 7);
            var textId = packet.ReadUInt32("Text Id");

            packet.WriteGuid("Guid", guid);

            var GUID = new Guid(BitConverter.ToUInt64(guid, 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));
        }
예제 #8
0
        public static void HandleNpcGossip(Packet packet)
        {
            var gossip = new Gossip();

            var guid = packet.ReadPackedGuid128("GossipGUID");

            gossip.ObjectType = guid.GetObjectType();
            gossip.ObjectEntry = guid.GetEntry();

            var menuId = packet.ReadInt32("GossipID");
            packet.ReadInt32("FriendshipFactionID");
            var textId = packet.ReadInt32("TextID");

            var int44 = packet.ReadInt32("GossipOptions");
            var int60 = packet.ReadInt32("GossipText");

            // ClientGossipOptions
            gossip.GossipOptions = new List<GossipOption>(int44);
            for (var i = 0; i < int44; ++i)
            {
                var gossipOption = new GossipOption();

                gossipOption.Index = (uint)packet.ReadInt32("ClientOption", i);
                packet.ReadByte("OptionNPC", i);
                packet.ReadByte("OptionFlags", i);
                gossipOption.RequiredMoney = (uint)packet.ReadInt32("OptionCost", i);

                var bits3 = packet.ReadBits(12);
                var bits753 = packet.ReadBits(12);

                gossipOption.OptionText = packet.ReadWoWString("Text", bits3, i);
                gossipOption.BoxText = packet.ReadWoWString("Confirm", bits753, i);

                gossip.GossipOptions.Add(gossipOption);
            }

            // ClientGossipOptions
            for (var i = 0; i < int60; ++i)
            {
                packet.ReadInt32("QuestID", i);
                packet.ReadInt32("QuestType", i);
                packet.ReadInt32("QuestLevel", i);

                for (var j = 0; j < 2; ++j)
                    packet.ReadInt32("QuestFlags", i, j);

                packet.ResetBitReader();

                packet.ReadBit("Repeatable");

                var bits13 = packet.ReadBits(9);

                packet.ReadWoWString("QuestTitle", bits13, i);

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

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

                packet.AddSniffData(StoreNameType.Gossip, menuId, guid.GetEntry().ToString(CultureInfo.InvariantCulture));
            }
        }
예제 #9
0
        public static void HandleNpcGossip(Packet packet)
        {
            var guid = new byte[8];
            uint[] QuestTitleLength;
            uint[] OptionsMessageLength;
            uint[] BoxMessageLength;

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

            var QuestsCount = packet.ReadBits("Quests Count", 19);

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

            var OptionsCount = packet.ReadBits("Gossip Options Count", 20);

            OptionsMessageLength = new uint[OptionsCount];
            BoxMessageLength = new uint[OptionsCount];
            for (var i = 0; i < OptionsCount; ++i)
            {
                BoxMessageLength[i] = packet.ReadBits(12);
                OptionsMessageLength[i] = packet.ReadBits(12);
            }

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

            for (var i = 0; i < QuestsCount; i++)
            {
                packet.ReadEnum<QuestFlags2>("Quest Special Flags", TypeCode.UInt32, i);
                packet.ReadEntryWithName<UInt32>(StoreNameType.Quest, "Quest Id", i);
                packet.ReadUInt32("Quest Level", i);
                packet.ReadUInt32("Quest Icon", i);
                packet.ReadEnum<QuestFlags>("Quest Flags", TypeCode.UInt32, i);
                packet.ReadWoWString("Quest Titles", QuestTitleLength[i], i);
            }

            packet.ReadXORByte(guid, 6);

            var ObjectGossip = new Gossip();
            ObjectGossip.GossipOptions = new List<GossipOption>((int)OptionsCount);
            for (var i = 0; i < OptionsCount; ++i)
            {
                var gossipMenuOption = new GossipOption
                {
                    RequiredMoney = packet.ReadUInt32("Message Box Required Money", i),
                    OptionText = packet.ReadWoWString("Gossip Option Text", OptionsMessageLength[i], i),
                    Index = packet.ReadUInt32("Gossip Option Index", i),
                    OptionIcon = packet.ReadEnum<GossipOptionIcon>("Gossip Option Icon", TypeCode.Byte, i),
                    BoxText = packet.ReadWoWString("Message Box Text", BoxMessageLength[i], i),
                    Box = packet.ReadBoolean("Message Box Coded", i), // True if it has a password.
                };

                ObjectGossip.GossipOptions.Add(gossipMenuOption);
            }

            packet.ReadXORByte(guid, 2);

            var GossipMenuTextId = packet.ReadUInt32("Gossip Menu Text Id");

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

            var GossipMenuId = packet.ReadUInt32("Gossip Menu Id");
            packet.ReadUInt32("Friendly Faction Id");

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

            packet.WriteGuid("Object Guid", guid);

            var ObjectGuid = new Guid(BitConverter.ToUInt64(guid, 0));
            ObjectGossip.ObjectEntry = ObjectGuid.GetEntry();
            ObjectGossip.ObjectType = ObjectGuid.GetObjectType();

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

            Storage.Gossips.Add(Tuple.Create(GossipMenuId, GossipMenuTextId), ObjectGossip, packet.TimeSpan);
            packet.AddSniffData(StoreNameType.Gossip, (int)GossipMenuId, ObjectGuid.GetEntry().ToString(CultureInfo.InvariantCulture));
        }
예제 #10
0
        public static void HandleNpcGossip(Packet packet)
        {
            var guidBytes = new byte[8];

            packet.StartBitStream(guidBytes, 0, 1);
            var questgossips = packet.ReadBits("Amount of Quest gossips", 19);
            guidBytes[2] = packet.ReadBit();
            var amountOfOptions = packet.ReadBits("Amount of Options", 20);

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

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

            packet.StartBitStream(guidBytes, 5, 4, 6, 7);
            packet.ResetBitReader();
            packet.ReadXORByte(guidBytes, 6);

            var gossip = new Gossip();

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

                gossip.GossipOptions.Add(gossipOption);
            }
            packet.ReadXORByte(guidBytes, 0);

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

            var textId = packet.ReadUInt32("Text Id");
            packet.ReadXORBytes(guidBytes, 4, 3);
            var menuId = packet.ReadUInt32("Menu Id");
            packet.ReadUInt32("Friendship Faction");
            packet.ReadXORBytes(guidBytes, 7, 1, 5, 2);
            var guid = packet.WriteGuid("GUID", guidBytes);

            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));
        }