public static void HandlePageTextResponse(Packet packet)
        {
            packet.ReadUInt32("PageTextID");
            packet.ResetBitReader();

            Bit hasData = packet.ReadBit("Allow");

            if (!hasData)
            {
                return; // nothing to do
            }
            var pagesCount = packet.ReadInt32("PagesCount");

            for (int i = 0; i < pagesCount; i++)
            {
                PageText pageText = new PageText();

                uint entry = packet.ReadUInt32("ID", i);
                pageText.ID         = entry;
                pageText.NextPageID = packet.ReadUInt32("NextPageID", i);

                pageText.PlayerConditionID = packet.ReadInt32("PlayerConditionID", i);
                pageText.Flags             = packet.ReadByte("Flags", i);

                packet.ResetBitReader();
                uint textLen = packet.ReadBits(12);
                pageText.Text = packet.ReadWoWString("Text", textLen, i);

                packet.AddSniffData(StoreNameType.PageText, (int)entry, "QUERY_RESPONSE");
                Storage.PageTexts.Add(pageText, packet.TimeSpan);

                if (ClientLocale.PacketLocale != LocaleConstant.enUS && pageText.Text != string.Empty)
                {
                    PageTextLocale localesPageText = new PageTextLocale
                    {
                        ID   = pageText.ID,
                        Text = pageText.Text
                    };
                    Storage.LocalesPageText.Add(localesPageText, packet.TimeSpan);
                }
            }
        }
Exemple #2
0
        void HandleQueryPageText(QueryPageText packet)
        {
            QueryPageTextResponse response = new QueryPageTextResponse();

            response.PageTextID = packet.PageTextID;

            uint pageID = packet.PageTextID;

            while (pageID != 0)
            {
                PageText pageText = Global.ObjectMgr.GetPageText(pageID);

                if (pageText == null)
                {
                    break;
                }

                QueryPageTextResponse.PageTextInfo page;
                page.ID                = pageID;
                page.NextPageID        = pageText.NextPageID;
                page.Text              = pageText.Text;
                page.PlayerConditionID = pageText.PlayerConditionID;
                page.Flags             = pageText.Flags;

                LocaleConstant locale = GetSessionDbLocaleIndex();
                if (locale != LocaleConstant.enUS)
                {
                    PageTextLocale pageLocale = Global.ObjectMgr.GetPageTextLocale(pageID);
                    if (pageLocale != null)
                    {
                        ObjectManager.GetLocaleString(pageLocale.Text, locale, ref page.Text);
                    }
                }

                response.Pages.Add(page);
                pageID = pageText.NextPageID;
            }

            response.Allow = !response.Pages.Empty();
            SendPacket(response);
        }