using System; using System.Text; using Server.Mobiles; namespace Server.Custom { /// /// Logs the global town-crier entry list every few seconds so a towncrier.add / remove /// round-trip can be observed landing in the actual game state, not just acknowledged. /// /// Test scaffolding. Never deployed. Read-only. /// public static class BridgeCrierProbe { public static void Initialize() { if (Config.Get("Bridge.CrierProbeOnStart", false)) EventSink.ServerStarted += () => Timer.DelayCall(TimeSpan.FromSeconds(3.0), TimeSpan.FromSeconds(3.0), Dump); } private static int _tick; private static void Dump() { try { var list = GlobalTownCrierEntryList.Instance; var entries = list == null ? null : list.Entries; int count = entries == null ? 0 : entries.Count; var sb = new StringBuilder(); sb.AppendFormat("[CrierProbe] tick {0}: {1} entries", ++_tick, count); if (entries != null) { for (int i = 0; i < entries.Count; i++) { var e = entries[i]; if (e == null || e.Lines == null) continue; sb.AppendFormat(" | [{0}]", String.Join(" / ", e.Lines)); } } Console.WriteLine(sb.ToString()); if (_tick >= 6) Timer.DelayCall(TimeSpan.Zero, () => { }); // no-op; probe stops being interesting } catch (Exception ex) { Console.WriteLine("[CrierProbe] FAILED: " + ex); } } } }