示例#1
0
        public static void ContentChange(NetState state, PacketReader pvSrc)
        {
            Mobile   from = state.Mobile;
            BaseBook book = World.FindItem(pvSrc.ReadInt32()) as BaseBook;

            if (book == null || !book.Writable || !from.InRange(book.GetWorldLocation(), 1) || !book.IsAccessibleTo(from))
            {
                return;
            }

            int pageCount = pvSrc.ReadUInt16();

            if (pageCount > book.PagesCount)
            {
                return;
            }

            for (int i = 0; i < pageCount; ++i)
            {
                int index = pvSrc.ReadUInt16();

                if (index >= 1 && index <= book.PagesCount)
                {
                    --index;

                    int lineCount = pvSrc.ReadUInt16();

                    if (lineCount <= 8)
                    {
                        string[] lines = new string[lineCount];

                        for (int j = 0; j < lineCount; ++j)
                        {
                            if ((lines[j] = pvSrc.ReadUTF8StringSafe()).Length >= 80)
                            {
                                return;
                            }
                        }

                        book.Pages[index].Lines = lines;
                    }
                    else
                    {
                        return;
                    }
                }
                else
                {
                    return;
                }
            }
        }
示例#2
0
        public static void ContentChange(NetState state, PacketReader pvSrc)
        {
            Mobile   from = state.Mobile;
            BaseBook book = World.FindItem(pvSrc.ReadInt32()) as BaseBook;

            if (book == null || !book.Writable || !from.InRange(book.GetWorldLocation(), 1) || !book.IsAccessibleTo(from))
            {
                return;
            }

            int pageCount = pvSrc.ReadUInt16();

            if (pageCount > book.PagesCount)
            {
                return;
            }

            for (int i = 0; i < pageCount; ++i)
            {
                int index = pvSrc.ReadUInt16();

                if (index >= 1 && index <= book.PagesCount)
                {
                    --index;

                    int lineCount = pvSrc.ReadUInt16();

                    if (lineCount <= 8)
                    {
                        string[] lines = new string[lineCount];

                        lines.SetAll(
                            j =>
                        {
                            string line = pvSrc.ReadUTF8StringSafe();

                            if (!String.IsNullOrWhiteSpace(line))
                            {
                                if (line.Length > 80)
                                {
                                    line = line.Substring(0, 80);
                                }

                                #region AntiAdverts
                                int exit = 100;
                                string detected;

                                while (AntiAdverts.Detect(line, out detected) && !String.IsNullOrWhiteSpace(detected) && --exit >= 0)
                                {
                                    line = line.Replace(detected, new String('*', detected.Length));
                                }
                                #endregion
                            }

                            return(line);
                        });

                        book.Pages[index].Lines = lines;
                    }
                    else
                    {
                        return;
                    }
                }
                else
                {
                    return;
                }
            }
        }
示例#3
0
        public static void HeaderChange(NetState state, PacketReader pvSrc)
        {
            Mobile   from = state.Mobile;
            BaseBook book = World.FindItem(pvSrc.ReadInt32()) as BaseBook;

            if (book == null || !book.Writable || !from.InRange(book.GetWorldLocation(), 1) || !book.IsAccessibleTo(from))
            {
                return;
            }

            pvSrc.Seek(4, SeekOrigin.Current);               // Skip flags and page count

            int titleLength = pvSrc.ReadUInt16();

            if (titleLength > 60)
            {
                return;
            }

            string title = pvSrc.ReadUTF8StringSafe(titleLength);

            int authorLength = pvSrc.ReadUInt16();

            if (authorLength > 30)
            {
                return;
            }

            string author = pvSrc.ReadUTF8StringSafe(authorLength);

            book.Title  = Utility.FixHtml(title);
            book.Author = Utility.FixHtml(author);
        }
示例#4
0
        public static void HeaderChange(NetState state, PacketReader pvSrc)
        {
            Mobile   from = state.Mobile;
            BaseBook book = World.FindItem(pvSrc.ReadInt32()) as BaseBook;

            if (book == null || !book.Writable || !from.InRange(book.GetWorldLocation(), 1) || !book.IsAccessibleTo(from))
            {
                return;
            }

            pvSrc.Seek(4, SeekOrigin.Current);               // Skip flags and page count

            int titleLength = pvSrc.ReadUInt16();

            if (titleLength > 60)
            {
                return;
            }

            string title = pvSrc.ReadUTF8StringSafe(titleLength);

            int authorLength = pvSrc.ReadUInt16();

            if (authorLength > 30)
            {
                return;
            }

            string author = pvSrc.ReadUTF8StringSafe(authorLength);

            title  = Utility.FixHtml(title);
            author = Utility.FixHtml(author);

            #region AntiAdverts
            if (!String.IsNullOrWhiteSpace(title))
            {
                int    exit = 100;
                string detected;

                while (AntiAdverts.Detect(title, out detected) && !String.IsNullOrWhiteSpace(detected) && --exit >= 0)
                {
                    title = title.Replace(detected, new String('*', detected.Length));
                }
            }

            if (!String.IsNullOrWhiteSpace(author))
            {
                int    exit = 100;
                string detected;

                while (AntiAdverts.Detect(author, out detected) && !String.IsNullOrWhiteSpace(detected) && --exit >= 0)
                {
                    author = author.Replace(detected, new String('*', detected.Length));
                }
            }
            #endregion

            book.Title  = title;
            book.Author = author;
        }