ModernUO/Projects/UOContent.Tests/Tests/Items/Books/Packets.cs
Kamron Batman 60a3a6f501
feat: Splits Server in Core and Application (#1806)
> [!Note]
> **Developer Note**
> Now developers will only need to build/run the Application project instead of everything.
> When adding new projects, make sure to: 
> 1. Add a reference to that project in the Application project.
> 2. Add the dll file to the Distribution/Data/assemblies.json file

### Summary
- Adds an application project
- Consolidates process restarts to use `Core.Kill(true)`
- Removes some old messaging, for example processor optimization
- Fixes missing build cleanup
2024-05-30 23:34:03 -07:00

58 lines
No EOL
1.7 KiB
C#

using Server.Items;
using Server.Text;
namespace Server.Network;
public sealed class BookPageDetails : Packet
{
public BookPageDetails(BaseBook book) : base(0x66)
{
EnsureCapacity(256);
Stream.Write(book.Serial);
Stream.Write((ushort)book.PagesCount);
for (var i = 0; i < book.PagesCount; ++i)
{
var page = book.Pages[i];
Stream.Write((ushort)(i + 1));
Stream.Write((ushort)page.Lines.Length);
for (var j = 0; j < page.Lines.Length; ++j)
{
var buffer = page.Lines[j].GetBytesUtf8();
Stream.Write(buffer, 0, buffer.Length);
Stream.Write((byte)0);
}
}
}
}
public sealed class BookHeader : Packet
{
public BookHeader(Mobile from, BaseBook book) : base(0xD4)
{
var title = book.Title ?? "";
var author = book.Author ?? "";
var titleBuffer = title.GetBytesUtf8();
var authorBuffer = author.GetBytesUtf8();
EnsureCapacity(15 + titleBuffer.Length + authorBuffer.Length);
Stream.Write(book.Serial);
Stream.Write(true);
Stream.Write(book.Writable && from.InRange(book.GetWorldLocation(), 1));
Stream.Write((ushort)book.PagesCount);
Stream.Write((ushort)(titleBuffer.Length + 1));
Stream.Write(titleBuffer, 0, titleBuffer.Length);
Stream.Write((byte)0); // terminate
Stream.Write((ushort)(authorBuffer.Length + 1));
Stream.Write(authorBuffer, 0, authorBuffer.Length);
Stream.Write((byte)0); // terminate
}
}