Ejemplo n.º 1
0
        public static void HandleNpcGossip(Packet packet)
        {
            var guidBytes = new byte[8];

            packet.StartBitStream(guidBytes, 0, 1);
            uint questgossips = packet.ReadBits("Amount of Quest gossips", 19);

            guidBytes[2] = packet.ReadBit();
            uint amountOfOptions = packet.ReadBits("Amount of Options", 20);

            var titleLen = new uint[questgossips];

            for (int 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 (int 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 gossipOptions     = new List <GossipMenuOption>((int)amountOfOptions);
            var gossipOptionBoxes = new List <GossipMenuOptionBox>((int)amountOfOptions);

            for (int i = 0; i < amountOfOptions; ++i)
            {
                GossipMenuOption    gossipOption        = new GossipMenuOption();
                GossipMenuOptionBox gossipMenuOptionBox = new GossipMenuOptionBox();
                gossipOption.OptionText      = packet.ReadWoWString("Text", optionTextLen[i], i);
                gossipMenuOptionBox.BoxText  = packet.ReadWoWString("Box Text", boxTextLen[i], i);
                gossipMenuOptionBox.BoxMoney = packet.ReadUInt32("Required money", i);
                gossipOption.OptionIcon      = packet.ReadByteE <GossipOptionIcon>("Icon", i);
                gossipMenuOptionBox.BoxCoded = packet.ReadBool("Box", i);
                gossipOption.OptionIndex     = gossipMenuOptionBox.OptionIndex = packet.ReadUInt32("Index", i);

                gossipOptions.Add(gossipOption);
                if (!gossipMenuOptionBox.IsEmpty)
                {
                    gossipOptionBoxes.Add(gossipMenuOptionBox);
                }
            }
            packet.ReadXORByte(guidBytes, 0);

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

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

            packet.ReadXORBytes(guidBytes, 4, 3);
            uint menuId = packet.ReadUInt32("Menu Id");

            packet.ReadUInt32("Friendship Faction");
            packet.ReadXORBytes(guidBytes, 7, 1, 5, 2);

            GossipMenu gossip = new GossipMenu
            {
                Entry  = menuId,
                TextID = textId
            };

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

            gossipOptions.ForEach(g =>
            {
                g.MenuId = menuId;
                Storage.GossipMenuOptions.Add(g, packet.TimeSpan);
            });
            gossipOptionBoxes.ForEach(gb =>
            {
                gb.MenuId = menuId;
                Storage.GossipMenuOptionBoxes.Add(gb, packet.TimeSpan);
            });

            Storage.Gossips.Add(gossip, packet.TimeSpan);

            var lastGossipOption    = CoreParsers.NpcHandler.LastGossipOption;
            var tempGossipOptionPOI = CoreParsers.NpcHandler.TempGossipOptionPOI;

            if (lastGossipOption.HasSelection)
            {
                if ((packet.TimeSpan - lastGossipOption.TimeSpan).Duration() <= TimeSpan.FromMilliseconds(2500))
                {
                    Storage.GossipMenuOptionActions.Add(new GossipMenuOptionAction {
                        MenuId = lastGossipOption.MenuId, OptionIndex = lastGossipOption.OptionIndex, ActionMenuId = menuId
                    }, packet.TimeSpan);

                    //keep temp data (for case SMSG_GOSSIP_POI is delayed)
                    tempGossipOptionPOI.Guid         = lastGossipOption.Guid;
                    tempGossipOptionPOI.MenuId       = lastGossipOption.MenuId;
                    tempGossipOptionPOI.OptionIndex  = lastGossipOption.OptionIndex;
                    tempGossipOptionPOI.ActionMenuId = gossip.Entry;
                    tempGossipOptionPOI.TimeSpan     = lastGossipOption.TimeSpan;

                    // clear lastgossip so no faulty linkings appear
                    lastGossipOption.Reset();
                }
                else
                {
                    lastGossipOption.Reset();
                    tempGossipOptionPOI.Reset();
                }
            }

            packet.AddSniffData(StoreNameType.Gossip, (int)menuId, guid.GetEntry().ToString(CultureInfo.InvariantCulture));
        }
Ejemplo n.º 2
0
        public static void HandleNpcGossip(Packet packet)
        {
            GossipMenu gossip = new GossipMenu();

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

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

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

            gossip.Entry = menuId;

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

            gossip.TextID = packet.ReadUInt32("Text Id");

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

            for (int i = 0; i < count; i++)
            {
                GossipMenuOption gossipOption = new GossipMenuOption
                {
                    MenuId = menuId,
                };
                GossipMenuOptionBox gossipMenuOptionBox = new GossipMenuOptionBox
                {
                    MenuId = menuId
                };

                gossipOption.OptionIndex     = gossipMenuOptionBox.OptionIndex = packet.ReadUInt32("Index", i);
                gossipOption.OptionIcon      = packet.ReadByteE <GossipOptionIcon>("Icon", i);
                gossipMenuOptionBox.BoxCoded = packet.ReadBool("Box", i);
                gossipMenuOptionBox.BoxMoney = packet.ReadUInt32("Required money", i);
                gossipOption.OptionText      = packet.ReadCString("Text", i);
                gossipMenuOptionBox.BoxText  = packet.ReadCString("Box Text", i);

                Storage.GossipMenuOptions.Add(gossipOption, packet.TimeSpan);
                if (!gossipMenuOptionBox.IsEmpty)
                {
                    Storage.GossipMenuOptionBoxes.Add(gossipMenuOptionBox, packet.TimeSpan);
                }
            }

            uint questgossips = packet.ReadUInt32("Amount of Quest gossips");

            for (int i = 0; i < questgossips; i++)
            {
                packet.ReadUInt32 <QuestId>("Quest ID", i);

                packet.ReadUInt32("Icon", i);
                packet.ReadInt32("Level", i);
                packet.ReadUInt32E <QuestFlags>("Flags", i);
                if (ClientVersion.AddedInVersion(ClientVersionBuild.V5_1_0_16309))
                {
                    packet.ReadUInt32E <QuestFlagsEx>("Flags 2", i);
                }

                packet.ReadBool("Change Icon", i);
                packet.ReadCString("Title", i);
            }

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

            Storage.Gossips.Add(gossip, packet.TimeSpan);
            if (LastGossipOption.HasSelection)
            {
                Storage.GossipMenuOptionActions.Add(new GossipMenuOptionAction {
                    MenuId = LastGossipOption.MenuId, OptionIndex = LastGossipOption.OptionIndex, ActionMenuId = menuId
                }, packet.TimeSpan);
            }

            packet.AddSniffData(StoreNameType.Gossip, (int)menuId, guid.GetEntry().ToString(CultureInfo.InvariantCulture));
        }
Ejemplo n.º 3
0
        public static void HandleNpcGossip(Packet packet)
        {
            GossipMenu gossip = new GossipMenu();

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

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

            int menuId = packet.ReadInt32("GossipID");

            gossip.Entry = (uint)menuId;

            packet.ReadInt32("FriendshipFactionID");

            gossip.TextID = (uint)packet.ReadInt32("TextID");

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

            for (int i = 0; i < int44; ++i)
            {
                V6_0_2_19033.Parsers.NpcHandler.ReadGossipOptionsData((uint)menuId, packet, i, "GossipOptions");
            }

            for (int i = 0; i < int60; ++i)
            {
                ReadGossipQuestTextData(packet, i, "GossipQuestText");
            }

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

            Storage.Gossips.Add(gossip, packet.TimeSpan);
            var lastGossipOption    = CoreParsers.NpcHandler.LastGossipOption;
            var tempGossipOptionPOI = CoreParsers.NpcHandler.TempGossipOptionPOI;

            if (lastGossipOption.HasSelection)
            {
                Storage.GossipMenuOptionActions.Add(new GossipMenuOptionAction {
                    MenuId = lastGossipOption.MenuId, OptionIndex = lastGossipOption.OptionIndex, ActionMenuId = gossip.Entry, ActionPoiId = lastGossipOption.ActionPoiId
                }, packet.TimeSpan);

                //keep temp data (for case SMSG_GOSSIP_POI is delayed)
                tempGossipOptionPOI.MenuId       = lastGossipOption.MenuId;
                tempGossipOptionPOI.OptionIndex  = lastGossipOption.OptionIndex;
                tempGossipOptionPOI.ActionMenuId = gossip.Entry;

                // clear lastgossip so no faulty linkings appear
                lastGossipOption.MenuId       = null;
                lastGossipOption.OptionIndex  = null;
                lastGossipOption.ActionMenuId = null;
                lastGossipOption.ActionPoiId  = null;
            }

            packet.AddSniffData(StoreNameType.Gossip, menuId, guid.GetEntry().ToString(CultureInfo.InvariantCulture));
        }
Ejemplo n.º 4
0
        public static void HandleNpcGossip(Packet packet)
        {
            PacketGossipMessage packetGossip = packet.Holder.GossipMessage = new();
            var guidBytes = new byte[8];

            uint amountOfOptions = packet.ReadBits(20);

            packet.StartBitStream(guidBytes, 5, 1, 7, 2);
            uint questgossips = packet.ReadBits(19);

            packet.StartBitStream(guidBytes, 6, 4, 0);

            var titleLen = new uint[questgossips];

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

            var optionTextLen = new uint[amountOfOptions];
            var boxTextLen    = new uint[amountOfOptions];

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

            guidBytes[3] = packet.ReadBit();
            for (int i = 0; i < questgossips; i++)
            {
                packet.ReadUInt32E <QuestFlags>("Flags", i);
                packet.ReadUInt32("Icon", i);
                packet.ReadInt32("Level", i);
                var title = packet.ReadWoWString("Title", titleLen[i], i);
                var quest = packet.ReadUInt32 <QuestId>("Quest ID", i);
                packet.ReadUInt32E <QuestFlagsEx>("Flags 2", i);

                packetGossip.Quests.Add(new GossipQuestOption()
                {
                    Title   = title,
                    QuestId = quest
                });
            }

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

            uint menuId = packetGossip.MenuId = packet.ReadUInt32("Menu Id");

            for (int i = 0; i < amountOfOptions; ++i)
            {
                GossipMenuOption gossipOption = new GossipMenuOption
                {
                    MenuId = menuId
                };
                GossipMenuOptionBox gossipMenuOptionBox = new GossipMenuOptionBox
                {
                    MenuId = menuId
                };

                gossipOption.OptionText      = packet.ReadWoWString("Text", optionTextLen[i], i);
                gossipMenuOptionBox.BoxCoded = packet.ReadBool("Box", i);
                gossipOption.OptionIcon      = packet.ReadByteE <GossipOptionIcon>("Icon", i);
                gossipMenuOptionBox.BoxMoney = packet.ReadUInt32("Required money", i);
                gossipMenuOptionBox.BoxText  = packet.ReadWoWString("Box Text", boxTextLen[i], i);
                gossipOption.OptionIndex     = gossipMenuOptionBox.OptionIndex = packet.ReadUInt32("Index", i);

                Storage.GossipMenuOptions.Add(gossipOption, packet.TimeSpan);
                if (!gossipMenuOptionBox.IsEmpty)
                {
                    Storage.GossipMenuOptionBoxes.Add(gossipMenuOptionBox, packet.TimeSpan);
                }

                packetGossip.Options.Add(new GossipMessageOption()
                {
                    OptionIndex = gossipOption.OptionIndex.Value,
                    OptionIcon  = (int)gossipOption.OptionIcon,
                    BoxCoded    = gossipMenuOptionBox.BoxCoded.Value,
                    BoxCost     = gossipMenuOptionBox.BoxMoney.Value,
                    Text        = gossipOption.OptionText,
                    BoxText     = gossipMenuOptionBox.BoxText
                });
            }

            packet.ReadXORByte(guidBytes, 7);
            packet.ReadXORByte(guidBytes, 4);
            packet.ReadXORByte(guidBytes, 6);
            packet.ReadUInt32("Friendship Faction");
            packet.ReadXORByte(guidBytes, 0);
            packet.ReadXORByte(guidBytes, 5);
            uint textId = packetGossip.TextId = packet.ReadUInt32("Text Id");

            packet.ReadXORByte(guidBytes, 3);

            GossipMenu gossip = new GossipMenu
            {
                Entry  = menuId,
                TextID = textId
            };

            WowGuid guid = packet.WriteGuid("Guid", guidBytes);

            packetGossip.GossipSource = guid;

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

            if (guid.GetObjectType() == ObjectType.Unit)
            {
                if (!Storage.CreatureDefaultGossips.ContainsKey(guid.GetEntry()))
                {
                    Storage.CreatureDefaultGossips.Add(guid.GetEntry(), menuId);
                }
            }

            Storage.Gossips.Add(gossip, packet.TimeSpan);
            var lastGossipOption    = CoreParsers.NpcHandler.LastGossipOption;
            var tempGossipOptionPOI = CoreParsers.NpcHandler.TempGossipOptionPOI;

            if (lastGossipOption.HasSelection)
            {
                if ((packet.TimeSpan - lastGossipOption.TimeSpan).Duration() <= TimeSpan.FromMilliseconds(2500))
                {
                    Storage.GossipMenuOptionActions.Add(new GossipMenuOptionAction {
                        MenuId = lastGossipOption.MenuId, OptionIndex = lastGossipOption.OptionIndex, ActionMenuId = menuId, ActionPoiId = 0
                    }, packet.TimeSpan);

                    //keep temp data (for case SMSG_GOSSIP_POI is delayed)
                    tempGossipOptionPOI.Guid         = lastGossipOption.Guid;
                    tempGossipOptionPOI.MenuId       = lastGossipOption.MenuId;
                    tempGossipOptionPOI.OptionIndex  = lastGossipOption.OptionIndex;
                    tempGossipOptionPOI.ActionMenuId = gossip.Entry;
                    tempGossipOptionPOI.TimeSpan     = lastGossipOption.TimeSpan;

                    // clear lastgossip so no faulty linkings appear
                    lastGossipOption.Reset();
                }
                else
                {
                    lastGossipOption.Reset();
                    tempGossipOptionPOI.Reset();
                }
            }

            packet.AddSniffData(StoreNameType.Gossip, (int)menuId, guid.GetEntry().ToString(CultureInfo.InvariantCulture));
        }
Ejemplo n.º 5
0
        public static void HandleNpcGossip(Packet packet)
        {
            var guidBytes = new byte[8];

            packet.StartBitStream(guidBytes, 0, 1);
            uint questgossips = packet.ReadBits("Amount of Quest gossips", 19);

            guidBytes[2] = packet.ReadBit();
            uint amountOfOptions = packet.ReadBits("Amount of Options", 20);

            var titleLen = new uint[questgossips];

            for (int 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 (int 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 gossipOptions = new List <GossipMenuOption>((int)amountOfOptions);

            for (int i = 0; i < amountOfOptions; ++i)
            {
                GossipMenuOption gossipOption = new GossipMenuOption
                {
                    OptionText = packet.ReadWoWString("Text", optionTextLen[i], i),
                    BoxText    = packet.ReadWoWString("Box Text", boxTextLen[i], i),
                    BoxMoney   = packet.ReadUInt32("Required money", i),
                    OptionIcon = packet.ReadByteE <GossipOptionIcon>("Icon", i),
                    BoxCoded   = packet.ReadBool("Box", i),
                    ID         = packet.ReadUInt32("Index", i)
                };

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

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

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

            packet.ReadXORBytes(guidBytes, 4, 3);
            uint menuId = packet.ReadUInt32("Menu Id");

            packet.ReadUInt32("Friendship Faction");
            packet.ReadXORBytes(guidBytes, 7, 1, 5, 2);

            GossipMenu gossip = new GossipMenu
            {
                Entry  = menuId,
                TextID = textId
            };

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

            gossipOptions.ForEach(g =>
            {
                g.MenuID = menuId;
                Storage.GossipMenuOptions.Add(g, packet.TimeSpan);
            });

            Storage.Gossips.Add(gossip, packet.TimeSpan);

            packet.AddSniffData(StoreNameType.Gossip, (int)menuId, guid.GetEntry().ToString(CultureInfo.InvariantCulture));
        }
Ejemplo n.º 6
0
        public static void HandleNpcGossip(Packet packet)
        {
            var guidBytes = new byte[8];

            uint questgossips = packet.ReadBits(19);

            var titleLen = new uint[questgossips];

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

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

            uint amountOfOptions = packet.ReadBits(20);

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

            var boxTextLen    = new uint[amountOfOptions];
            var optionTextLen = new uint[amountOfOptions];

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

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

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

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

            var gossipOptions     = new List <GossipMenuOption>((int)amountOfOptions);
            var gossipOptionBoxes = new List <GossipMenuOptionBox>((int)amountOfOptions);

            for (int i = 0; i < amountOfOptions; ++i)
            {
                GossipMenuOption    gossipMenuOption    = new GossipMenuOption();
                GossipMenuOptionBox gossipMenuOptionBox = new GossipMenuOptionBox();

                gossipMenuOptionBox.BoxMoney = packet.ReadUInt32("Required money", i);
                gossipMenuOptionBox.BoxText  = packet.ReadWoWString("Box Text", boxTextLen[i], i);
                gossipMenuOption.OptionIndex = gossipMenuOptionBox.OptionIndex = packet.ReadUInt32("Index", i);
                gossipMenuOptionBox.BoxCoded = packet.ReadBool("Box", i);
                gossipMenuOption.OptionText  = packet.ReadWoWString("Text", optionTextLen[i], i);
                gossipMenuOption.OptionIcon  = packet.ReadByteE <GossipOptionIcon>("Icon", i);

                gossipOptions.Add(gossipMenuOption);
                if (!gossipMenuOptionBox.IsEmpty)
                {
                    gossipOptionBoxes.Add(gossipMenuOptionBox);
                }
            }

            packet.ReadXORByte(guidBytes, 5);
            packet.ReadXORByte(guidBytes, 3);
            uint menuId = packet.ReadUInt32("Menu Id");

            packet.ReadXORByte(guidBytes, 2);
            packet.ReadXORByte(guidBytes, 6);
            packet.ReadXORByte(guidBytes, 4);
            packet.ReadUInt32("Friendship Faction");
            packet.ReadXORByte(guidBytes, 7);
            uint textId = packet.ReadUInt32("Text Id");

            GossipMenu gossip = new GossipMenu
            {
                Entry  = menuId,
                TextID = textId
            };

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

            gossipOptions.ForEach(g =>
            {
                g.MenuId = menuId;
                Storage.GossipMenuOptions.Add(g, packet.TimeSpan);
            });
            gossipOptionBoxes.ForEach(gb =>
            {
                gb.MenuId = menuId;
                Storage.GossipMenuOptionBoxes.Add(gb, packet.TimeSpan);
            });

            Storage.Gossips.Add(gossip, packet.TimeSpan);
            var lastGossipOption = CoreParsers.NpcHandler.LastGossipOption;

            if (lastGossipOption.HasSelection)
            {
                Storage.GossipMenuOptionActions.Add(new GossipMenuOptionAction {
                    MenuId = lastGossipOption.MenuId, OptionIndex = lastGossipOption.OptionIndex, ActionMenuId = gossip.Entry
                }, packet.TimeSpan);
            }

            packet.AddSniffData(StoreNameType.Gossip, (int)menuId, guid.GetEntry().ToString(CultureInfo.InvariantCulture));
        }
Ejemplo n.º 7
0
        public static void HandleNpcGossip(Packet packet)
        {
            PacketGossipMessage packetGossip = packet.Holder.GossipMessage = new();
            GossipMenu          gossip       = new GossipMenu();

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

            packetGossip.GossipSource = guid;

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

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

            gossip.Entry = packetGossip.MenuId = menuId;

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

            gossip.TextID = packetGossip.TextId = packet.ReadUInt32("Text Id");

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

            for (int i = 0; i < count; i++)
            {
                GossipMenuOption gossipOption = new GossipMenuOption
                {
                    MenuId = menuId,
                };
                GossipMenuOptionBox gossipMenuOptionBox = new GossipMenuOptionBox
                {
                    MenuId = menuId
                };

                gossipOption.OptionIndex     = gossipMenuOptionBox.OptionIndex = packet.ReadUInt32("Index", i);
                gossipOption.OptionIcon      = packet.ReadByteE <GossipOptionIcon>("Icon", i);
                gossipMenuOptionBox.BoxCoded = packet.ReadBool("Box", i);
                gossipMenuOptionBox.BoxMoney = packet.ReadUInt32("Required money", i);
                gossipOption.OptionText      = packet.ReadCString("Text", i);
                gossipMenuOptionBox.BoxText  = packet.ReadCString("Box Text", i);

                Storage.GossipMenuOptions.Add(gossipOption, packet.TimeSpan);
                if (!gossipMenuOptionBox.IsEmpty)
                {
                    Storage.GossipMenuOptionBoxes.Add(gossipMenuOptionBox, packet.TimeSpan);
                }

                packetGossip.Options.Add(new GossipMessageOption()
                {
                    OptionIndex = gossipOption.OptionIndex.Value,
                    OptionIcon  = (int)gossipOption.OptionIcon,
                    BoxCoded    = gossipMenuOptionBox.BoxCoded.Value,
                    BoxCost     = gossipMenuOptionBox.BoxMoney.Value,
                    Text        = gossipOption.OptionText,
                    BoxText     = gossipMenuOptionBox.BoxText
                });
            }

            uint questgossips = packet.ReadUInt32("Amount of Quest gossips");

            for (int i = 0; i < questgossips; i++)
            {
                packet.ReadUInt32 <QuestId>("Quest ID", i);

                packet.ReadUInt32("Icon", i);
                packet.ReadInt32("Level", i);
                packet.ReadUInt32E <QuestFlags>("Flags", i);
                if (ClientVersion.AddedInVersion(ClientVersionBuild.V5_1_0_16309))
                {
                    packet.ReadUInt32E <QuestFlagsEx>("Flags 2", i);
                }

                packet.ReadBool("Change Icon", i);
                packet.ReadCString("Title", i);
            }

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

            Storage.Gossips.Add(gossip, packet.TimeSpan);
            if (LastGossipOption.HasSelection)
            {
                if ((packet.TimeSpan - LastGossipOption.TimeSpan).Duration() <= TimeSpan.FromMilliseconds(2500))
                {
                    Storage.GossipMenuOptionActions.Add(new GossipMenuOptionAction {
                        MenuId = LastGossipOption.MenuId, OptionIndex = LastGossipOption.OptionIndex, ActionMenuId = menuId, ActionPoiId = LastGossipOption.ActionPoiId
                    }, packet.TimeSpan);

                    //keep temp data (for case SMSG_GOSSIP_POI is delayed)
                    TempGossipOptionPOI.Guid         = LastGossipOption.Guid;
                    TempGossipOptionPOI.MenuId       = LastGossipOption.MenuId;
                    TempGossipOptionPOI.OptionIndex  = LastGossipOption.OptionIndex;
                    TempGossipOptionPOI.ActionMenuId = gossip.Entry;
                    TempGossipOptionPOI.TimeSpan     = LastGossipOption.TimeSpan;

                    // clear lastgossip so no faulty linkings appear
                    LastGossipOption.Reset();
                }
                else
                {
                    LastGossipOption.Reset();
                    TempGossipOptionPOI.Reset();
                }
            }

            packet.AddSniffData(StoreNameType.Gossip, (int)menuId, guid.GetEntry().ToString(CultureInfo.InvariantCulture));
        }
Ejemplo n.º 8
0
        public static void HandleNpcGossip(Packet packet)
        {
            PacketGossipMessage packetGossip = packet.Holder.GossipMessage = new();
            var guidBytes = new byte[8];

            packet.StartBitStream(guidBytes, 0, 1);
            uint questgossips = packet.ReadBits("Amount of Quest gossips", 19);

            guidBytes[2] = packet.ReadBit();
            uint amountOfOptions = packet.ReadBits("Amount of Options", 20);

            var titleLen = new uint[questgossips];

            for (int 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 (int 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 gossipOptions = new List <GossipMenuOption>((int)amountOfOptions);

            for (int i = 0; i < amountOfOptions; ++i)
            {
                GossipMenuOption gossipOption = new GossipMenuOption();
                gossipOption.OptionText = packet.ReadWoWString("Text", optionTextLen[i], i);
                var boxText = packet.ReadWoWString("Box Text", boxTextLen[i], i);
                gossipOption.BoxMoney   = packet.ReadUInt32("Required money", i);
                gossipOption.OptionIcon = packet.ReadByteE <GossipOptionIcon>("Icon", i);
                gossipOption.BoxCoded   = packet.ReadBool("Box", i);
                gossipOption.OptionID   = packet.ReadUInt32("OptionID", i);

                if (!string.IsNullOrEmpty(boxText))
                {
                    gossipOption.BoxText = boxText;
                }

                gossipOptions.Add(gossipOption);

                packetGossip.Options.Add(new GossipMessageOption()
                {
                    OptionIndex = gossipOption.OptionID.Value,
                    OptionIcon  = (int)gossipOption.OptionIcon,
                    BoxCoded    = gossipOption.BoxCoded.Value,
                    BoxCost     = gossipOption.BoxMoney.Value,
                    Text        = gossipOption.OptionText,
                    BoxText     = gossipOption.BoxText
                });
            }
            packet.ReadXORByte(guidBytes, 0);

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

                packetGossip.Quests.Add(new GossipQuestOption()
                {
                    Title   = title,
                    QuestId = quest
                });
            }

            uint textId = packetGossip.TextId = packet.ReadUInt32("Text Id");

            packet.ReadXORBytes(guidBytes, 4, 3);
            uint menuId = packetGossip.MenuId = packet.ReadUInt32("Menu Id");

            packet.ReadUInt32("Friendship Faction");
            packet.ReadXORBytes(guidBytes, 7, 1, 5, 2);

            GossipMenu gossip = new GossipMenu
            {
                MenuID = menuId,
                TextID = textId
            };

            WowGuid guid = packet.WriteGuid("GUID", guidBytes);

            packetGossip.GossipSource = guid;

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

            if (guid.GetObjectType() == ObjectType.Unit)
            {
                if (!Storage.CreatureDefaultGossips.ContainsKey(guid.GetEntry()))
                {
                    Storage.CreatureDefaultGossips.Add(guid.GetEntry(), menuId);
                }
            }

            gossipOptions.ForEach(g =>
            {
                g.MenuID = menuId;
                g.FillBroadcastTextIDs();
                Storage.GossipMenuOptions.Add((g.MenuID, g.OptionID), g, packet.TimeSpan);
            });

            Storage.Gossips.Add(gossip, packet.TimeSpan);
            CoreParsers.NpcHandler.UpdateLastGossipOptionActionMessage(packet.TimeSpan, menuId);

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