public static void ContentChange(NetState state, PacketReader pvSrc)
{
// need to deal with actual books
//string entryText = String.Empty;
//Mobile from = state.Mobile;
int pos = pvSrc.Seek(0, SeekOrigin.Current);
int serial = pvSrc.ReadInt32();
Item bookitem = World.FindItem(serial);
// first try it as a normal basebook
if (bookitem is BaseBook)
{
// do the base book content change
//BaseContentChange(bookitem as BaseBook, state, pvSrc);
pvSrc.Seek(pos, SeekOrigin.Begin);
if (PacketHandlerOverrides.ContentChangeParent != null)
{
PacketHandlerOverrides.ContentChangeParent.OnReceive(state, pvSrc);
}
else
{
BaseBook.ContentChange(state, pvSrc);
}
return;
}
// then try it as a text entry book
var book = bookitem as BaseEntryBook;
if (book == null)
{
return;
}
// get the number of available pages in the book
int pageCount = pvSrc.ReadUInt16();
if (pageCount > book.PagesCount)
{
return;
}
for (int i = 0; i < pageCount; ++i)
{
// get the current page number being read
int index = pvSrc.ReadUInt16();
if (index >= 1 && index <= book.PagesCount)
{
--index;
int lineCount = pvSrc.ReadUInt16();
if (lineCount <= 8)
{
var 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;
}
}
var sb = new StringBuilder();
// add the book lines to the entry string
for (int i = 0; i < book.PagesCount; ++i)
{
foreach (string line in book.Pages[i].Lines)
{
sb.Append(line);
}
}
// send the book text off to be processed by invoking the callback if it is a textentry book
var tebook = book as XmlTextEntryBook;
if (tebook != null && tebook.m_bookcallback != null)
{
tebook.m_bookcallback(state.Mobile, tebook.m_args, sb.ToString());
}
}