#region Header
// **********
// ServUO - TownCrierPersistence.cs
// **********
#endregion
#region References
using System.IO;
using System.Linq;
using Server.Mobiles;
#endregion
namespace Server.Items
{
public static class TownCrierPersistence
{
private static string FilePath = Path.Combine("Saves", "TownCrierMessages", "Persistence.bin");
public static void Configure()
{
EventSink.WorldSave += OnSave;
EventSink.WorldLoad += OnLoad;
}
private static void OnSave(WorldSaveEventArgs e)
{
Persistence.Serialize(
FilePath,
writer =>
{
writer.Write(0); // version
writer.Write(GlobalTownCrierEntryList.Entries.Count);
foreach (var entry in GlobalTownCrierEntryList.Entries)
{
writer.Write(entry);
}
});
}
private static void OnLoad()
{
Persistence.Deserialize(
FilePath,
reader =>
{
var version = reader.ReadInt();
switch (version)
{
case 0:
{
var list = GlobalTownCrierEntryList.Instance;
var count = reader.ReadInt();
for (var i = 0; i < count; ++i)
{
var entry = (TownCrierEntry)reader.Read();
list.Entries.Add(entry);
}
}
break;
}
});
}
}
}
We use essential cookies to make this site work, and optional cookies to enhance your experience.