Dan

Moderator
I have always wondered this.

Is there any reason why the town crier was never re-coded to save his messages between world saves?
 
between world saves? you mean the messages get deleted whenever the server does a world save? Or do you mean the messages are deleted when restarting the server?

If it's when restarting, i guess making a file specifically to handle the town crier messages would be enough.
Take a look at how the disguisement kits are saved, it could simply save the list of town crier's messages and there could even be two types of messages/checkbox to choose when inserting messages.

deleteinoctober.png


Personally, i think the town crier system is due for some improvements.
 
Just on restarts.

I will set my town crier to spew a bunch of nonsense in regards to new events, or a new publish ect, and set the hours to = 5 days however my shard resets, on the dot, at 5am EST each day. Thus it gets deleted. Why not just hard code town criers to persist their message?

I would almost report this as a BUG since on real UO some shard towncriers spam day after day and the shards reset daily.

What do you think? @Dexter_Lexia If in my favor feel free to move me over to bug reports :)
 
See:
DisguisePersistence.cs

Use:
GlobalTownCrierEntryList in TownCrier.cs

Something like that:
Code:
#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;
                    }
                });
        }
    }
}

Didn't compile, that's just to give a general idea.
 

Active Shards

Donations

Total amount
$0.00
Goal
$1,000.00
Back