public static void Broadcast(int hue, bool ascii, string text) { Packet p; ascii = true; if (ascii) { p = new AsciiMessage(Serial.MinusOne, -1, MessageType.Regular, hue, 3, "System", text); } else { p = new UnicodeMessage(Serial.MinusOne, -1, MessageType.Regular, hue, 3, "ENU", "System", text); } List <NetState> list = NetState.Instances; p.Acquire(); for (int i = 0; i < list.Count; ++i) { if (list[i].Mobile != null) { list[i].Send(p); } } p.Release(); NetState.FlushAll(); }
public static void GenTeleporter_OnCommand(CommandEventArgs e) { var from = e.Mobile; from.SendMessage("Generating teleporters, please wait."); NetState.FlushAll(); var c = new TeleportersCreator(); if (!ProcessTeleporterData(from, c.CreateTeleporter)) { if (c.DelCount > 0) { from.SendMessage(WarningHue, $"Partial Completion: {c.DelCount} Teleporters Removed."); } if (c.Count > 0) { from.SendMessage(WarningHue, $"Partial Completion: {c.Count} Teleporters Added."); } return; } from.SendMessage(SuccessHue, "Teleporter generating complete."); from.SendMessage(WarningHue, $"{c.DelCount} Teleporters Removed."); from.SendMessage(SuccessHue, $"{c.Count} Teleporters Added."); }
public static void Broadcast(int hue, bool ascii, string text) { Packet p; if (ascii) { p = new AsciiMessage(Serial.MinusOne, -1, MessageType.Regular, hue, 3, "System", text); } else { p = new UnicodeMessage(Serial.MinusOne, -1, MessageType.Regular, hue, 3, "ENU", "System", text); } ArrayList list = NetState.Instances; for (int i = 0; i < list.Count; ++i) { if (((NetState)list[i]).Mobile != null) { ((NetState)list[i]).Send(p); } } NetState.FlushAll(); }
public override void ExecuteList(CommandEventArgs e, List <object> list) { string path = e.Arguments.Length == 0 ? string.Empty : e.Arguments[0].Trim(); string condition = e.Arguments.Length == 2 ? e.Arguments[1].Trim() : string.Empty; if (string.IsNullOrEmpty(path)) { path = Path.Combine(Core.BaseDirectory, $"Data/Spawns/{Utility.GetTimeStamp()}.json"); } else { var directory = Path.GetDirectoryName(Path.GetFullPath(path !)) !; if (!Path.IsPathRooted(path)) { path = Path.Combine(Core.BaseDirectory, path); PathUtility.EnsureDirectory(directory); } else if (!Directory.Exists(directory)) { LogFailure("Directory doesn't exist."); return; } } NetState.FlushAll(); var options = JsonConfig.GetOptions(new TextDefinitionConverterFactory()); var spawnRecords = new List <DynamicJson>(list.Count); for (var i = 0; i < list.Count; i++) { if (list[i] is BaseSpawner spawner) { if (!string.IsNullOrEmpty(spawner.Name) && spawner.Name.StartsWith( condition, StringComparison.OrdinalIgnoreCase )) { var dynamicJson = DynamicJson.Create(spawner.GetType()); spawner.ToJson(dynamicJson, options); spawnRecords.Add(dynamicJson); } } } if (spawnRecords.Count == 0) { LogFailure("No matching spawners found."); return; } e.Mobile.SendMessage("Exporting spawners..."); JsonConfig.Serialize(path, spawnRecords, options); e.Mobile.SendMessage($"Spawners exported to {path}"); }
public virtual void WorldBroadcast(string message, params object[] args) { var text = String.Format(message, args); switch (Options.Broadcasts.World.Mode) { case PvPBattleWorldBroadcastMode.Notify: { foreach (var pm in GetWorldBroadcastList()) { pm.SendNotification(text, true, 0.5, 10.0); } } break; case PvPBattleWorldBroadcastMode.Broadcast: { Packet p = new AsciiMessage( Server.Serial.MinusOne, -1, MessageType.Regular, Options.Broadcasts.World.MessageHue, 3, "System", text); p.Acquire(); foreach (var pm in GetWorldBroadcastList()) { pm.Send(p); } p.Release(); NetState.FlushAll(); } break; case PvPBattleWorldBroadcastMode.TownCrier: { foreach (var tc in TownCrier.Instances) { tc.PublicOverheadMessage( MessageType.Yell, Options.Broadcasts.World.MessageHue, true, String.Format(message, args)); } } break; default: return; } AutoPvP.InvokeBattleWorldBroadcast(this, text); }
public static void Optimize(Mobile m, bool message) { if (World.Saving || World.Loading || _Optimizing) { return; } NetState.FlushAll(); NetState.Pause(); _Optimizing = true; var now = DateTime.UtcNow; if (message) { World.Broadcast(0x35, true, "[{0}]: The world is optimizing, please wait.", now.ToShortTimeString()); } var watch = new Stopwatch(); watch.Start(); double mem = GC.GetTotalMemory(false); GC.Collect(); mem -= GC.GetTotalMemory(false); mem = (mem / 1024.0) / 1024.0; watch.Stop(); _Optimizing = false; if (m != null) { m.SendMessage("[{0}]: GC done in {1:F2} seconds.", now.ToShortTimeString(), watch.Elapsed.TotalSeconds); m.SendMessage("[{0}]: GC reports {1:#,0.00} MB freed memory.", now.ToShortTimeString(), mem); } Console.WriteLine("[{0}]: GC done in {1:F2} seconds.", now.ToShortTimeString(), watch.Elapsed.TotalSeconds); Console.WriteLine("[{0}]: GC reports {1:#,0.00} MB freed memory.", now.ToShortTimeString(), mem); if (message) { World.Broadcast( 0x35, true, "[{0}]: World optimization complete. The entire process took {1:F1} seconds.", DateTime.UtcNow.ToShortTimeString(), watch.Elapsed.TotalSeconds); } NetState.Resume(); }
private static void Run() { m_Now = DateTime.Now; m_TotalProfile = new MainProfile(m_Now); m_CurrentProfile = new MainProfile(m_Now); while (!m_Closing) { m_Now = DateTime.Now; /* wait until event happens */ m_Signal.WaitOne(); ClockProfile(MainProfile.TimerId.Idle); /* process mobiles */ Mobile.ProcessDeltaQueue(); ClockProfile(MainProfile.TimerId.MobileDelta); /* process items */ Item.ProcessDeltaQueue(); ClockProfile(MainProfile.TimerId.ItemDelta); /* process timers */ Timer.Slice(); ClockProfile(MainProfile.TimerId.Timers); /* network */ m_MessagePump.Slice(); NetState.FlushAll(); NetState.ProcessDisposedQueue(); ClockProfile(MainProfile.TimerId.Network); if (Slice != null) { Slice(); } /* done with this iteration */ m_TotalProfile.Next(); m_CurrentProfile.Next(); } }
public static void Save( bool message ) { if ( m_Saving || AsyncWriter.ThreadCount > 0 ) return; NetState.FlushAll(); NetState.Pause(); m_Saving = true; if ( message ) Broadcast( 0x35, true, "The world is saving, please wait." ); SaveStrategy strategy = SaveStrategy.Acquire(); Console.WriteLine( "Core: Using {0} save strategy", strategy.Name.ToLowerInvariant() ); Console.Write( "World: Saving..." ); Stopwatch watch = Stopwatch.StartNew(); if ( !Directory.Exists( "Saves/Mobiles/" ) ) Directory.CreateDirectory( "Saves/Mobiles/" ); if ( !Directory.Exists( "Saves/Items/" ) ) Directory.CreateDirectory( "Saves/Items/" ); if ( !Directory.Exists( "Saves/Guilds/" ) ) Directory.CreateDirectory( "Saves/Guilds/" ); /*using ( SaveMetrics metrics = new SaveMetrics() ) {*/ strategy.Save( null ); /*}*/ try { EventSink.InvokeWorldSave( new WorldSaveEventArgs( message ) ); } catch ( Exception e ) { throw new Exception( "World Save event threw an exception. Save failed!", e ); } watch.Stop(); m_Saving = false; ProcessSafetyQueues(); strategy.ProcessDecay(); Console.WriteLine( "done in {0:F2} seconds.", watch.Elapsed.TotalSeconds ); if ( message ) Broadcast( 0x35, true, "World save complete. The entire process took {0:F1} seconds.", watch.Elapsed.TotalSeconds ); NetState.Resume(); }
public static void Generate() { World.Broadcast(0x35, true, "Generating doors, please wait."); NetState.FlushAll(); NetState.Pause(); m_Map = Map.Trammel; m_Count = 0; for (int i = 0; i < m_BritRegions.Length; ++i) { Generate(m_BritRegions[i]); } int trammelCount = m_Count; m_Map = Map.Felucca; m_Count = 0; for (int i = 0; i < m_BritRegions.Length; ++i) { Generate(m_BritRegions[i]); } int feluccaCount = m_Count; m_Map = Map.Ilshenar; m_Count = 0; for (int i = 0; i < m_IlshRegions.Length; ++i) { Generate(m_IlshRegions[i]); } int ilshenarCount = m_Count; m_Map = Map.Malas; m_Count = 0; for (int i = 0; i < m_MalasRegions.Length; ++i) { Generate(m_MalasRegions[i]); } int malasCount = m_Count; NetState.Resume(); World.Broadcast(0x35, true, "Door generation complete. Trammel: {0}; Felucca: {1}; Ilshenar: {2}; Malas: {3};", trammelCount, feluccaCount, ilshenarCount, malasCount); }
private static void DecorateMag_OnCommand(CommandEventArgs e) { m_Mobile = e.Mobile; m_Count = 0; m_Mobile.SendMessage("Generating world decoration, please wait."); NetState.FlushAll(); Generate("Data/Decoration/RuinedMaginciaTram", Map.Trammel); Generate("Data/Decoration/RuinedMaginciaFel", Map.Felucca); m_Mobile.SendMessage("World generating complete. {0} items were generated.", m_Count); }
private static void LoadQuests(Mobile from) { if (Quests.Count > 0) { Quests.Clear(); } var di = new DirectoryInfo(Core.BaseDirectory); var files = di.GetFiles("questsystemadvanced.json", SearchOption.AllDirectories); if (files.Length == 0) { if (from != null) { from.SendMessage("QuestSystem: No files found."); } return; } var options = JsonConfig.GetOptions(new TextDefinitionConverterFactory()); for (var i = 0; i < files.Length; i++) { var file = files[i]; if (from != null) { from.SendMessage("Generating quests from: {0}", file.Name); } NetState.FlushAll(); try { var quests = JsonConfig.Deserialize <List <DynamicJson> >(file.FullName); ParseQuestList(from, quests, options); } catch (JsonException) { if (from != null) { from.SendMessage( "QuestSystem: Exception parsing {0}, file may not be in the correct format.", file.FullName ); } } } }
public static void Generate(Map map = null) { World.Broadcast(0x35, true, "Generating doors, please wait."); NetState.FlushAll(); m_Map = map ?? Map.Felucca; m_Count = 0; foreach (var t in m_BritRegions) { Generate(t); } World.Broadcast(0x35, true, $"Door generation complete. {m_Map.Name}: {m_Count}"); }
public static void Broadcast(int hue, bool ascii, AccessLevel access, string text) { WorldBroadcastEventArgs e = new WorldBroadcastEventArgs(hue, ascii, access, text); EventSink.InvokeWorldBroadcast(e); hue = e.Hue; ascii = e.Ascii; text = e.Text; access = e.Access; if (string.IsNullOrWhiteSpace(text)) { return; } Packet p; if (ascii) { p = new AsciiMessage(Serial.MinusOne, -1, MessageType.Regular, hue, 3, "System", text); } else { p = new UnicodeMessage(Serial.MinusOne, -1, MessageType.Regular, hue, 3, "ENU", "System", text); } List <NetState> list = NetState.Instances; p.Acquire(); for (var index = 0; index < list.Count; index++) { NetState s = list[index]; if (s.Mobile != null && s.Mobile.AccessLevel >= access) { s.Send(p); } } p.Release(); NetState.FlushAll(); }
public static void MergeAccounts_OnCommand(CommandEventArgs e) { NetState.FlushAll(); NetState.Pause(); DateTime start = DateTime.Now; MergeTagsFromMain(); MergeAccountsFromPrison(); RemoveUnusedTags(); DateTime end = DateTime.Now; NetState.Resume(); World.Broadcast(0x35, true, "Les accounts ont été fusionnés. The entire process took {0:F1} seconds.", (end - start).TotalSeconds); Console.WriteLine("Les accounts ont été fusionnés"); }
public static void SendChatMessage(string from, string msg) { msg = "[" + from + "]: " + msg; Packet p = new AsciiMessage(Serial.MinusOne, -1, MessageType.Regular, Hue, 3, "System", msg); List <NetState> list = NetState.Instances; p.Acquire(); for (int i = 0; i < list.Count; ++i) { if (list[i].Mobile != null && ((MythikPlayerMobile)list[i].Mobile).ChatEnabled) { list[i].Send(p); } } p.Release(); NetState.FlushAll(); }
public static void generateDescriptor_onCommand(CommandEventArgs args) { World.Broadcast(0x485, true, "Generating assembly descriptor, please wait..."); NetState.FlushAll(); NetState.Pause(); Stopwatch sw = new Stopwatch(); sw.Start(); Generate(); sw.Stop(); NetState.Resume(); World.Broadcast(0x485, true, "Assembly descriptor has been compiled. The entire process took {0:F2} seconds.", (sw.ElapsedMilliseconds / 1000)); }
public static void Broadcast(int hue, bool ascii, string text) { var p = ascii ? (Packet) new AsciiMessage(Serial.MinusOne, -1, MessageType.Regular, hue, 3, "System", text) : new UnicodeMessage(Serial.MinusOne, -1, MessageType.Regular, hue, 3, "ENU", "System", text); var list = NetState.Instances; p.Acquire(); for (var i = 0; i < list.Count; ++i) { if (list[i].Mobile != null) { list[i].Send(p); } } p.Release(); NetState.FlushAll(); }
private static void Decorate_OnCommand(CommandEventArgs e) { m_Mobile = e.Mobile; m_Count = 0; m_Mobile.SendMessage("Generating world decoration, please wait."); NetState.FlushAll(); Generate("Data/Decoration/Britannia", Map.Trammel, Map.Felucca); Generate("Data/Decoration/Trammel", Map.Trammel); Generate("Data/Decoration/Felucca", Map.Felucca); Generate("Data/Decoration/Ilshenar", Map.Ilshenar); Generate("Data/Decoration/Malas", Map.Malas); Generate("Data/Decoration/Tokuno", Map.Tokuno); m_Mobile.SendMessage("World generating complete. {0} items were generated.", m_Count); }
public static void Generate() { World.Broadcast(0x35, true, "Generating doors, please wait."); NetState.FlushAll(); m_Map = Map.Felucca; m_Count = 0; foreach (var t in m_BritRegions) { Generate(t); } int feluccaCount = m_Count; World.Broadcast(0x35, true, $"Door generation complete. Felucca: {feluccaCount}"); }
private static void GenerateSpawners_OnCommand(CommandEventArgs e) { var from = e.Mobile; if (e.Arguments.Length == 0) { from.SendMessage("Usage: [GenerateSpawners <path|search pattern>"); return; } var di = new DirectoryInfo(Core.BaseDirectory); var files = di.GetFiles(e.Arguments[0], SearchOption.AllDirectories); if (files.Length == 0) { from.SendMessage("GenerateSpawners: No files found matching the pattern"); return; } var options = JsonConfig.GetOptions(new TextDefinitionConverterFactory()); for (var i = 0; i < files.Length; i++) { var file = files[i]; from.SendMessage("GenerateSpawners: Generating spawners for {0}...", file.Name); NetState.FlushAll(); try { var spawners = JsonConfig.Deserialize <List <DynamicJson> >(file.FullName); ParseSpawnerList(from, spawners, options); } catch (JsonException) { from.SendMessage( "GenerateSpawners: Exception parsing {0}, file may not be in the correct format.", file.FullName ); } } }
private static void ConvertPremiumSpawners_OnCommand(CommandEventArgs args) { var from = args.Mobile; if (args.Arguments.Length != 2) { from.SendMessage("Usage: [ConvertPremiumSpawners <relative search pattern to distribution> <output directory relative to distribution>"); return; } var inputDi = new DirectoryInfo(Core.BaseDirectory); var patternMatches = new Matcher() .AddInclude(args.Arguments[0]) .Execute(new DirectoryInfoWrapper(inputDi)) .Files; List <(FileInfo, string)> files = new List <(FileInfo, string)>(); foreach (var match in patternMatches) { files.Add((new FileInfo(match.Path), match.Stem)); } if (files.Count == 0) { from.SendMessage("ConvertPremiumSpawners: No files found."); return; } var outputDir = Path.Combine(Core.BaseDirectory, args.Arguments[1]); var options = JsonConfig.GetOptions(new TextDefinitionConverterFactory()); for (var i = 0; i < files.Count; i++) { var(file, stem) = files[i]; from.SendMessage("ConvertPremiumSpawners: Converting spawners for {0}...", stem); NetState.FlushAll(); try { var stemDir = stem[..^ file.Name.Length];
/*public static void Broadcast( int hue, bool ascii, string text ) { * Packet p; * * if ( ascii ) * p = new AsciiMessage( Serial.MinusOne, -1, MessageType.Regular, hue, 3, "System", text ); * else * p = new UnicodeMessage( Serial.MinusOne, -1, MessageType.Regular, hue, 3, "ENU", "System", text ); * * List<NetState> list = NetState.Instances; * * p.Acquire(); * * for ( int i = 0; i < list.Count; ++i ) { * if ( list[i].Mobile != null ) * list[i].Send( p ); * } * * p.Release(); * * NetState.FlushAll(); * }*/ public static void Broadcast(int hue, bool ascii, string text) { Packet p; p = new AsciiMessage(Serial.MinusOne, -1, MessageType.Regular, hue, 0, "System", String.Format("System: {0}", text)); List <NetState> list = NetState.Instances; p.Acquire(); for (int i = 0; i < list.Count; ++i) { if (list[i].Mobile != null) { list[i].Send(p); } } p.Release(); NetState.FlushAll(); }
public override void ExecuteList(CommandEventArgs e, List <object> list) { if (list.Count == 0) { LogFailure("No matching objects found."); return; } e.Mobile.SendMessage("Respawning..."); NetState.FlushAll(); foreach (var obj in list) { if (obj is ISpawner spawner) { spawner.Respawn(); } } e.Mobile.SendMessage("Respawn completed."); }
private async static Task RunCoreLoopAsync() { long now, last = Timing.Ticks; const int sampleInterval = 100; long sample = 0; while (!Closing) { await Task.Delay(1); Timing.Slice(); MessagePump.Slice(); NetState.FlushAll(); NetState.ProcessDisposedQueue(); Slice?.Invoke(); if (sample++ % sampleInterval != 0) { continue; } now = Timing.Ticks; last = now; } }
public static void Main(string[] args) { AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; AppDomain.CurrentDomain.ProcessExit += CurrentDomain_ProcessExit; foreach (string a in args) { if (Insensitive.Equals(a, "-debug")) { Debug = true; } else if (Insensitive.Equals(a, "-service")) { Service = true; } else if (Insensitive.Equals(a, "-profile")) { Profiling = true; } else if (Insensitive.Equals(a, "-nocache")) { _Cache = false; } else if (Insensitive.Equals(a, "-haltonwarning")) { HaltOnWarning = true; } else if (Insensitive.Equals(a, "-vb")) { VBdotNet = true; } else if (Insensitive.Equals(a, "-usehrt")) { _UseHRT = true; } } try { if (Service) { if (!Directory.Exists("Logs")) { Directory.CreateDirectory("Logs"); } Console.SetOut(MultiConsoleOut = new MultiTextWriter(new FileLogger("Logs/Console.log"))); } else { Console.SetOut(MultiConsoleOut = new MultiTextWriter(Console.Out)); } } catch { } Thread = Thread.CurrentThread; Process = Process.GetCurrentProcess(); Assembly = Assembly.GetEntryAssembly(); if (Thread != null) { Thread.Name = "Core Thread"; } if (BaseDirectory.Length > 0) { Directory.SetCurrentDirectory(BaseDirectory); } Timer.TimerThread ttObj = new Timer.TimerThread(); _TimerThread = new Thread(ttObj.TimerMain) { Name = "Timer Thread" }; Version ver = Assembly.GetName().Version; // Added to help future code support on forums, as a 'check' people can ask for to it see if they recompiled core or not Utility.PushColor(ConsoleColor.DarkGreen); Console.WriteLine(new String('-', Console.BufferWidth)); Utility.PopColor(); Utility.PushColor(ConsoleColor.Cyan); Console.WriteLine( "ServUO - [http://www.servuo.com] Version {0}.{1}, Build {2}.{3}", ver.Major, ver.Minor, ver.Build, ver.Revision); Utility.PopColor(); string s = Arguments; if (s.Length > 0) { Utility.PushColor(ConsoleColor.Yellow); Console.WriteLine("Core: Running with arguments: {0}", s); Utility.PopColor(); } ProcessorCount = Environment.ProcessorCount; if (ProcessorCount > 1) { MultiProcessor = true; } if (MultiProcessor || Is64Bit) { Utility.PushColor(ConsoleColor.Green); Console.WriteLine( "Core: Optimizing for {0} {2}processor{1}", ProcessorCount, ProcessorCount == 1 ? "" : "s", Is64Bit ? "64-bit " : ""); Utility.PopColor(); } int platform = (int)Environment.OSVersion.Platform; if (platform == 4 || platform == 128) { // MS 4, MONO 128 Unix = true; Utility.PushColor(ConsoleColor.Yellow); Console.WriteLine("Core: Unix environment detected"); Utility.PopColor(); } else { m_ConsoleEventHandler = OnConsoleEvent; UnsafeNativeMethods.SetConsoleCtrlHandler(m_ConsoleEventHandler, true); } if (GCSettings.IsServerGC) { Utility.PushColor(ConsoleColor.DarkYellow); Console.WriteLine("Core: Server garbage collection mode enabled"); Utility.PopColor(); } if (_UseHRT) { Utility.PushColor(ConsoleColor.DarkYellow); Console.WriteLine( "Core: Requested high resolution timing ({0})", UsingHighResolutionTiming ? "Supported" : "Unsupported"); Utility.PopColor(); } Utility.PushColor(ConsoleColor.DarkYellow); Console.WriteLine("RandomImpl: {0} ({1})", RandomImpl.Type.Name, RandomImpl.IsHardwareRNG ? "Hardware" : "Software"); Utility.PopColor(); Utility.PushColor(ConsoleColor.DarkYellow); Console.WriteLine("Core: Loading config..."); Config.Load(); Utility.PopColor(); while (!ScriptCompiler.Compile(Debug, _Cache)) { Utility.PushColor(ConsoleColor.Red); Console.WriteLine("Scripts: One or more scripts failed to compile or no script files were found."); Utility.PopColor(); if (Service) { return; } Console.WriteLine(" - Press return to exit, or R to try again."); if (Console.ReadKey(true).Key != ConsoleKey.R) { return; } } ScriptCompiler.Invoke("Configure"); Region.Load(); World.Load(); ScriptCompiler.Invoke("Initialize"); MessagePump messagePump = MessagePump = new MessagePump(); _TimerThread.Start(); foreach (Map m in Map.AllMaps) { m.Tiles.Force(); } NetState.Initialize(); EventSink.InvokeServerStarted(); try { long now, last = TickCount; const int sampleInterval = 100; const float ticksPerSecond = 1000.0f * sampleInterval; long sample = 0; while (!Closing) { _Signal.WaitOne(); Mobile.ProcessDeltaQueue(); Item.ProcessDeltaQueue(); Timer.Slice(); messagePump.Slice(); NetState.FlushAll(); NetState.ProcessDisposedQueue(); if (Slice != null) { Slice(); } if (sample++ % sampleInterval != 0) { continue; } now = TickCount; _CyclesPerSecond[_CycleIndex++ % _CyclesPerSecond.Length] = ticksPerSecond / (now - last); last = now; } } catch (Exception e) { CurrentDomain_UnhandledException(null, new UnhandledExceptionEventArgs(e, true)); } }
public static void Main(string[] args) { AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); AppDomain.CurrentDomain.ProcessExit += new EventHandler(CurrentDomain_ProcessExit); for (int i = 0; i < args.Length; ++i) { if (Insensitive.Equals(args[i], "-debug")) { m_Debug = true; } else if (Insensitive.Equals(args[i], "-service")) { m_Service = true; } else if (Insensitive.Equals(args[i], "-profile")) { Profiling = true; } else if (Insensitive.Equals(args[i], "-nocache")) { m_Cache = false; } else if (Insensitive.Equals(args[i], "-haltonwarning")) { m_HaltOnWarning = true; } else if (Insensitive.Equals(args[i], "-vb")) { m_VBdotNET = true; } } try { if (m_Service) { if (!Directory.Exists("Logs")) { Directory.CreateDirectory("Logs"); } Console.SetOut(m_MultiConOut = new MultiTextWriter(new FileLogger("Logs/Console.log"))); } else { Console.SetOut(m_MultiConOut = new MultiTextWriter(Console.Out)); } } catch { } m_Thread = Thread.CurrentThread; m_Process = Process.GetCurrentProcess(); m_Assembly = Assembly.GetEntryAssembly(); if (m_Thread != null) { m_Thread.Name = "Core Thread"; } if (BaseDirectory.Length > 0) { Directory.SetCurrentDirectory(BaseDirectory); } Timer.TimerThread ttObj = new Timer.TimerThread(); timerThread = new Thread(new ThreadStart(ttObj.TimerMain)); timerThread.Name = "Timer Thread"; Version ver = m_Assembly.GetName().Version; // Added to help future code support on forums, as a 'check' people can ask for to it see if they recompiled core or not Console.WriteLine("RunUO - [www.runuo.com] Version {0}.{1}, Build {2}.{3}", ver.Major, ver.Minor, ver.Build, ver.Revision); Console.WriteLine("Core: Running on .NET Framework Version {0}.{1}.{2}", Environment.Version.Major, Environment.Version.Minor, Environment.Version.Build); string s = Arguments; if (s.Length > 0) { Console.WriteLine("Core: Running with arguments: {0}", s); } m_ProcessorCount = Environment.ProcessorCount; if (m_ProcessorCount > 1) { m_MultiProcessor = true; } if (m_MultiProcessor || Is64Bit) { Console.WriteLine("Core: Optimizing for {0} {2}processor{1}", m_ProcessorCount, m_ProcessorCount == 1 ? "" : "s", Is64Bit ? "64-bit " : ""); } int platform = (int)Environment.OSVersion.Platform; if (platform == 4 || platform == 128) // MS 4, MONO 128 { m_Unix = true; Console.WriteLine("Core: Unix environment detected"); } else { m_ConsoleEventHandler = new ConsoleEventHandler(OnConsoleEvent); UnsafeNativeMethods.SetConsoleCtrlHandler(m_ConsoleEventHandler, true); } if (GCSettings.IsServerGC) { Console.WriteLine("Core: Server garbage collection mode enabled"); } Console.WriteLine("RandomImpl: {0} ({1})", RandomImpl.Type.Name, RandomImpl.IsHardwareRNG ? "Hardware" : "Software"); while (!ScriptCompiler.Compile(m_Debug, m_Cache)) { Console.WriteLine("Scripts: One or more scripts failed to compile or no script files were found."); if (m_Service) { return; } Console.WriteLine(" - Press return to exit, or R to try again."); if (Console.ReadKey(true).Key != ConsoleKey.R) { return; } } ScriptCompiler.Invoke("Configure"); Region.Load(); World.Load(); ScriptCompiler.Invoke("Initialize"); MessagePump messagePump = m_MessagePump = new MessagePump(); timerThread.Start(); for (int i = 0; i < Map.AllMaps.Count; ++i) { Map.AllMaps[i].Tiles.Force(); } NetState.Initialize(); EventSink.InvokeServerStarted(); try { long now, last = TickCount; const int sampleInterval = 100; const float ticksPerSecond = (float)(1000 * sampleInterval); long sample = 0; while (!m_Closing) { m_Signal.WaitOne(); Mobile.ProcessDeltaQueue(); Item.ProcessDeltaQueue(); Timer.Slice(); messagePump.Slice(); NetState.FlushAll(); NetState.ProcessDisposedQueue(); if (Slice != null) { Slice(); } if ((++sample % sampleInterval) == 0) { now = TickCount; m_CyclesPerSecond[m_CycleIndex++ % m_CyclesPerSecond.Length] = ticksPerSecond / (now - last); last = now; } } } catch (Exception e) { CurrentDomain_UnhandledException(null, new UnhandledExceptionEventArgs(e, true)); } }
public static void Main(string[] args) { AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); AppDomain.CurrentDomain.ProcessExit += new EventHandler(CurrentDomain_ProcessExit); for (int i = 0; i < args.Length; ++i) { if (Insensitive.Equals(args[i], "-debug")) { m_Debug = true; } else if (Insensitive.Equals(args[i], "-service")) { m_Service = true; } else if (Insensitive.Equals(args[i], "-profile")) { Profiling = true; } else if (Insensitive.Equals(args[i], "-nocache")) { m_Cache = false; } else if (Insensitive.Equals(args[i], "-haltonwarning")) { m_HaltOnWarning = true; } else if (Insensitive.Equals(args[i], "-vb")) { m_VBdotNET = true; } } try { if (m_Service) { if (!Directory.Exists("Logs")) { Directory.CreateDirectory("Logs"); } Console.SetOut(m_MultiConOut = new MultiTextWriter(new FileLogger("Logs/Console.log"))); } else { Console.SetOut(m_MultiConOut = new MultiTextWriter(Console.Out)); } } catch { } m_Thread = Thread.CurrentThread; m_Process = Process.GetCurrentProcess(); m_Assembly = Assembly.GetEntryAssembly(); if (m_Thread != null) { m_Thread.Name = "Core Thread"; } if (BaseDirectory.Length > 0) { Directory.SetCurrentDirectory(BaseDirectory); } Timer.TimerThread ttObj = new Timer.TimerThread(); timerThread = new Thread(new ThreadStart(ttObj.TimerMain)); timerThread.Name = "Timer Thread"; Version ver = m_Assembly.GetName().Version; String publishNumber = ""; if (File.Exists("publish.txt")) { try { FileStream fs = new FileStream("publish.txt", FileMode.Open, FileAccess.Read, FileShare.Read); StreamReader sr = new StreamReader(fs); publishNumber = sr.ReadLine(); sr.Close(); fs.Close(); } catch { } } // Added to help future code support on forums, as a 'check' people can ask for to it see if they recompiled core or not Utility.PushColor(ConsoleColor.DarkGreen); Console.WriteLine(@"----------------------------------------------------------------------------"); Utility.PopColor(); Utility.PushColor(ConsoleColor.Cyan); Console.WriteLine("ServUO - [http://www.servuo.com] Version {0}.{1}, Build {2}.{3}", ver.Major, ver.Minor, ver.Build, ver.Revision); Console.WriteLine("Publish {0}", publishNumber); Utility.PopColor(); string s = Arguments; if (s.Length > 0) { Utility.PushColor(ConsoleColor.Yellow); Console.WriteLine("Core: Running with arguments: {0}", s); Utility.PopColor(); } m_ProcessorCount = Environment.ProcessorCount; if (m_ProcessorCount > 1) { m_MultiProcessor = true; } if (m_MultiProcessor || Is64Bit) { Utility.PushColor(ConsoleColor.Green); Console.WriteLine("Core: Optimizing for {0} {2}processor{1}", m_ProcessorCount, m_ProcessorCount == 1 ? "" : "s", Is64Bit ? "64-bit " : ""); Utility.PopColor(); } int platform = (int)Environment.OSVersion.Platform; if (platform == 4 || platform == 128) { // MS 4, MONO 128 m_Unix = true; Utility.PushColor(ConsoleColor.Yellow); Console.WriteLine("Core: Unix environment detected"); Utility.PopColor(); } else { m_ConsoleEventHandler = new ConsoleEventHandler(OnConsoleEvent); SetConsoleCtrlHandler(m_ConsoleEventHandler, true); } if (GCSettings.IsServerGC) { Utility.PushColor(ConsoleColor.DarkYellow); Console.WriteLine("Core: Server garbage collection mode enabled"); Utility.PopColor(); } _openUOSDK = new OpenUOSDK(); while (!ScriptCompiler.Compile(m_Debug, m_Cache)) { Utility.PushColor(ConsoleColor.Red); Console.WriteLine("Scripts: One or more scripts failed to compile or no script files were found."); Utility.PopColor(); if (m_Service) { return; } Console.WriteLine(" - Press return to exit, or R to try again."); if (Console.ReadKey(true).Key != ConsoleKey.R) { return; } } ScriptCompiler.Invoke("Configure"); Region.Load(); World.Load(); ScriptCompiler.Invoke("Initialize"); MessagePump messagePump = new MessagePump(); timerThread.Start(); for (int i = 0; i < Map.AllMaps.Count; ++i) { Map.AllMaps[i].Tiles.Force(); } NetState.Initialize(); EventSink.InvokeServerStarted(); try { DateTime now, last = DateTime.UtcNow; const int sampleInterval = 100; const float ticksPerSecond = (float)(TimeSpan.TicksPerSecond * sampleInterval); long sample = 0; while (m_Signal.WaitOne()) { Mobile.ProcessDeltaQueue(); Item.ProcessDeltaQueue(); Timer.Slice(); messagePump.Slice(); NetState.FlushAll(); NetState.ProcessDisposedQueue(); if (Slice != null) { Slice(); } if ((++sample % sampleInterval) == 0) { now = DateTime.UtcNow; m_CyclesPerSecond[m_CycleIndex++ % m_CyclesPerSecond.Length] = ticksPerSecond / (now.Ticks - last.Ticks); last = now; } } } catch (Exception e) { CurrentDomain_UnhandledException(null, new UnhandledExceptionEventArgs(e, true)); } }
public static void Save(bool message, bool permitBackgroundWrite) { if (m_Saving) { return; } ++m_Saves; NetState.FlushAll(); NetState.Pause(); World.WaitForWriteCompletion();//Blocks Save until current disk flush is done. m_Saving = true; m_DiskWriteHandle.Reset(); if (message) { Broadcast(0x35, true, "The world is saving, please wait."); } SaveStrategy strategy = SaveStrategy.Acquire(); Console.WriteLine("Core: Using {0} save strategy", strategy.Name.ToLowerInvariant()); Console.Write("World: Saving..."); Stopwatch watch = Stopwatch.StartNew(); if (!Directory.Exists("Saves/Mobiles/")) { Directory.CreateDirectory("Saves/Mobiles/"); } if (!Directory.Exists("Saves/Items/")) { Directory.CreateDirectory("Saves/Items/"); } /*using ( SaveMetrics metrics = new SaveMetrics() ) {*/ strategy.Save(null, permitBackgroundWrite); /*}*/ try { EventSink.InvokeWorldSave(new WorldSaveEventArgs(message)); } catch (Exception e) { throw new Exception("World Save event threw an exception. Save failed!", e); } watch.Stop(); m_Saving = false; if (!permitBackgroundWrite) { World.NotifyDiskWriteComplete(); //Sets the DiskWriteHandle. If we allow background writes, we leave this upto the individual save strategies. } ProcessSafetyQueues(); strategy.ProcessDecay(); Console.WriteLine("Save done in {0:F2} seconds.", watch.Elapsed.TotalSeconds); if (message) { Broadcast(0x35, true, "World save complete. The entire process took {0:F1} seconds.", watch.Elapsed.TotalSeconds); } NetState.Resume(); }
public static void Main(string[] args) { AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); AppDomain.CurrentDomain.ProcessExit += new EventHandler(CurrentDomain_ProcessExit); for (int i = 0; i < args.Length; ++i) { if (Insensitive.Equals(args[i], "-debug")) { m_Debug = true; } else if (Insensitive.Equals(args[i], "-service")) { m_Service = true; } else if (Insensitive.Equals(args[i], "-profile")) { Profiling = true; } else if (Insensitive.Equals(args[i], "-nocache")) { m_Cache = false; } else if (Insensitive.Equals(args[i], "-haltonwarning")) { m_HaltOnWarning = true; } else if (Insensitive.Equals(args[i], "-vb")) { m_VBdotNET = true; } else if (Insensitive.Equals(args[i], "-publish")) { m_Publish = true; } } try { if (m_Service) { if (!Directory.Exists("Logs")) { Directory.CreateDirectory("Logs"); } Console.SetOut(m_MultiConOut = new MultiTextWriter(new FileLogger("Logs/Console.log"))); } else { Console.SetOut(m_MultiConOut = new MultiTextWriter(Console.Out)); } } catch { } m_Thread = Thread.CurrentThread; m_Process = Process.GetCurrentProcess(); m_Assembly = Assembly.GetEntryAssembly(); if (m_Thread != null) { m_Thread.Name = "Core Thread"; } if (BaseDirectory.Length > 0) { Directory.SetCurrentDirectory(BaseDirectory); } Timer.TimerThread ttObj = new Timer.TimerThread(); timerThread = new Thread(new ThreadStart(ttObj.TimerMain)); timerThread.Name = "Timer Thread"; Version ver = m_Assembly.GetName().Version; // Added to help future code support on forums, as a 'check' people can ask for to it see if they recompiled core or not Console.WriteLine("RunUO - [www.runuo.com] Version {0}.{1}, Build {2}.{3}", ver.Major, ver.Minor, ver.Build, ver.Revision); #if Framework_3_5 string version = "3.5"; #elif Mono string version = "MONO"; #else string version = Environment.Version.ToString(); #endif Console.WriteLine("Core: Running on .NET Framework Version {0}", version); string s = Arguments; if (s.Length > 0) { Console.WriteLine("Core: Running with arguments: {0}", s); } m_ProcessorCount = Environment.ProcessorCount; if (m_ProcessorCount > 1) { m_MultiProcessor = true; } if (m_MultiProcessor || Is64Bit) { Console.WriteLine("Core: Optimizing for {0} {2}processor{1}", m_ProcessorCount, m_ProcessorCount == 1 ? "" : "s", Is64Bit ? "64-bit " : ""); } int platform = (int)Environment.OSVersion.Platform; if (platform == 4 || platform == 128) // MS 4, MONO 128 { m_Unix = true; Console.WriteLine("Core: Unix environment detected"); } else { m_ConsoleEventHandler = new ConsoleEventHandler(OnConsoleEvent); SetConsoleCtrlHandler(m_ConsoleEventHandler, true); } if (GCSettings.IsServerGC) { Console.WriteLine("Core: Server garbage collection mode enabled"); } if (File.Exists("Data/Culture.cfg")) { using (StreamReader ip = new StreamReader("Data/Culture.cfg")) { string line = ip.ReadLine(); if (!String.IsNullOrEmpty(line)) { m_Thread.CurrentCulture = new CultureInfo(line); Console.WriteLine("Core: Culture modified to {0}", m_Thread.CurrentCulture.NativeName); } } } while (!ScriptCompiler.Compile(m_Debug, m_Cache, m_Publish)) { Console.WriteLine("Scripts: One or more scripts failed to compile or no script files were found."); if (m_Publish || m_Service) { return; } Console.WriteLine(" - Press return to exit, or R to try again."); if (Console.ReadKey(true).Key != ConsoleKey.R) { return; } } ScriptCompiler.Invoke("Configure"); Console.Write("Core: Initializing localization strings..."); ClilocHandler.AddCliloc("ENU"); //English - No Argument sets the default ClilocHandler.AddCliloc("CHS"); //Chinese ClilocHandler.AddCliloc("CHT"); //Chinese ClilocHandler.AddCliloc("DEU"); //German ClilocHandler.AddCliloc("ESP"); //Spanish ClilocHandler.AddCliloc("FRA"); //French ClilocHandler.AddCliloc("JPN"); //Japan ClilocHandler.AddCliloc("KOR"); //Korean Console.WriteLine("done ({0} languages)", StringList.StringLists.Count); Region.Load(); World.Load(); ScriptCompiler.Invoke("Initialize"); MessagePump ms = m_MessagePump = new MessagePump(); timerThread.Start(); for (int i = 0; i < Map.AllMaps.Count; ++i) { Map.AllMaps[i].Tiles.Force(); } NetState.Initialize(); EventSink.InvokeServerStarted(); try { DateTime now, last = DateTime.Now; const int sampleInterval = 100; const float ticksPerSecond = (float)(TimeSpan.TicksPerSecond * sampleInterval); long sample = 0; while (m_Signal.WaitOne()) { Mobile.ProcessDeltaQueue(); Item.ProcessDeltaQueue(); Timer.Slice(); m_MessagePump.Slice(); NetState.FlushAll(); NetState.ProcessDisposedQueue(); if (Slice != null) { Slice(); } if ((++sample % sampleInterval) == 0) { now = DateTime.Now; m_CyclesPerSecond[m_CycleIndex++ % m_CyclesPerSecond.Length] = ticksPerSecond / (now.Ticks - last.Ticks); last = now; } } } catch (Exception e) { CurrentDomain_UnhandledException(null, new UnhandledExceptionEventArgs(e, true)); } }
public static void Main(string[] args) { AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; AppDomain.CurrentDomain.ProcessExit += CurrentDomain_ProcessExit; foreach (string a in args) { if (Insensitive.Equals(a, "-debug")) { Debug = true; } else if (Insensitive.Equals(a, "-service")) { Service = true; } else if (Insensitive.Equals(a, "-profile")) { Profiling = true; } else if (Insensitive.Equals(a, "-nocache")) { _Cache = false; } else if (Insensitive.Equals(a, "-haltonwarning")) { HaltOnWarning = true; } else if (Insensitive.Equals(a, "-vb")) { VBdotNet = true; } else if (Insensitive.Equals(a, "-usehrt")) { _UseHRT = true; } } try { if (Service) { if (!Directory.Exists("Logs")) { Directory.CreateDirectory("Logs"); } Console.SetOut(MultiConsoleOut = new MultiTextWriter(new FileLogger("Logs/Console.log"))); } else { Console.SetOut(MultiConsoleOut = new MultiTextWriter(Console.Out)); } } catch { } Thread = Thread.CurrentThread; Process = Process.GetCurrentProcess(); Assembly = Assembly.GetEntryAssembly(); if (Thread != null) { Thread.Name = "Core Thread"; } if (BaseDirectory.Length > 0) { Directory.SetCurrentDirectory(BaseDirectory); } Timer.TimerThread ttObj = new Timer.TimerThread(); _TimerThread = new Thread(ttObj.TimerMain) { Name = "Timer Thread" }; Version ver = Assembly.GetName().Version; String publishNumber = ""; if (File.Exists("publish.txt")) { publishNumber = File.ReadAllText("publish.txt"); } Utility.PushColor(ConsoleColor.Magenta); Console.WriteLine(" ___ _ _ ___ _ "); Console.WriteLine(" / __| |_ __ _ _ _ __| | | __|_ _ __ _(_)_ _ ___ "); Console.WriteLine(" \\__ \\ ' \\/ _` | '_/ _` | | _|| ' \\/ _` | | ' \\/ -_)"); Console.WriteLine(" |___/_||_\\__,_|_| \\__,_| |___|_||_\\__, |_|_||_\\___|"); Console.WriteLine(" |___/ "); Utility.PushColor(ConsoleColor.Cyan); Console.WriteLine(" _ __ ___ _ "); Console.WriteLine(" / |/ /| _ ) ___| |_____ __ __ "); Console.WriteLine(" | / _ \\ _ \\/ -_) / _ \\ V V / "); Console.WriteLine(" |_\\___/___/\\___|_\\___/\\_/\\_/ "); Console.WriteLine(); // Console.WriteLine(" 16Below "); Utility.PushColor(ConsoleColor.White); Console.WriteLine(" Running Shard Engine Version {0}.{1}.{2}", new object[] { ver.Major, ver.Minor, ver.MinorRevision, // ver.Revision }); if (Environment.Version.Build == 30319) { Console.WriteLine(" .NET Framework Version 4.6.1"); } else { Console.WriteLine(" .NET Framework Version {0}.{1}.{2}", new object[] { Environment.Version.Major, Environment.Version.Minor, Environment.Version.Build, }); } Console.WriteLine(" http://www.shardengine.com"); Utility.PushColor(ConsoleColor.Blue); Console.WriteLine(new String('_', Console.BufferWidth)); Utility.PushColor(ConsoleColor.White); int platform = (int)Environment.OSVersion.Platform; Utility.PushColor(ConsoleColor.Magenta); Console.Write("Shard: "); Utility.PushColor(ConsoleColor.White); Console.Write("Detecting Operating System"); Utility.PushColor(ConsoleColor.DarkGray); Console.Write("....................................."); Utility.PushColor(ConsoleColor.White); if (platform == 4 || platform == 128) { Unix = true; Console.WriteLine("[Unix]"); Utility.PopColor(); } else { // _ConsoleEventHandler = new ConsoleEventHandler(OnConsoleEvent); // UnsafeNativeMethods.SetConsoleCtrlHandler(_ConsoleEventHandler, true); switch (Environment.OSVersion.Platform) { case PlatformID.Win32S: Console.WriteLine("[Win3.1]"); Utility.PopColor(); break; case PlatformID.Win32Windows: { int minor = Environment.OSVersion.Version.Minor; if (minor != 0) { if (minor != 10) { if (minor == 90) { Console.WriteLine("[WinME]"); Utility.PopColor(); } } else { Console.WriteLine("[Win98]"); Utility.PopColor(); } } else { Console.WriteLine("[Win95]"); Utility.PopColor(); } break; } case PlatformID.Win32NT: switch (Environment.OSVersion.Version.Major) { case 3: Console.WriteLine("[NT 3.51]"); Utility.PopColor(); break; case 4: Console.WriteLine("[NT 4.0]"); Utility.PopColor(); break; case 5: switch (Environment.OSVersion.Version.Minor) { case 0: Console.WriteLine("[Win2000]"); Utility.PopColor(); break; case 1: Console.WriteLine("[WinXP]"); Utility.PopColor(); break; case 2: Console.WriteLine("[Win2003]"); Utility.PopColor(); break; } break; case 6: switch (Environment.OSVersion.Version.Minor) { case 0: Console.WriteLine("[Vista]"); Utility.PopColor(); break; case 1: Console.WriteLine("[Win7]"); Utility.PopColor(); break; case 2: Console.WriteLine("[Win8]"); Utility.PopColor(); break; case 3: Console.WriteLine("[Win8.1]"); Utility.PopColor(); break; case 4: Console.WriteLine("[Win10]"); Utility.PopColor(); break; } break; } break; case PlatformID.WinCE: Console.WriteLine("[WinCE]"); Utility.PopColor(); break; default: // _ConsoleEventHandler = new ConsoleEventHandler(OnConsoleEvent); // UnsafeNativeMethods.SetConsoleCtrlHandler(_ConsoleEventHandler, true); Console.WriteLine("[Unknown]"); Utility.PopColor(); break; } } Utility.PushColor(ConsoleColor.Magenta); Console.Write("Shard: "); Utility.PushColor(ConsoleColor.White); Console.Write("Processor Configuration"); Utility.PushColor(ConsoleColor.Cyan); Console.Write("(Core Count {0})", Environment.ProcessorCount); Utility.PushColor(ConsoleColor.DarkGray); Console.Write(".........................."); Utility.PushColor(ConsoleColor.White); if (Is64Bit) { Console.WriteLine("[64-bit]"); Utility.PopColor(); } else { Console.WriteLine("[32-bit]"); Utility.PopColor(); } string arguments = Arguments; Utility.PushColor(ConsoleColor.Magenta); Console.Write("Shard: "); Utility.PushColor(ConsoleColor.White); Console.Write("Operating Mode"); Utility.PushColor(ConsoleColor.DarkGray); Console.Write("................................................."); if (arguments.Length > 0) { if (arguments.Length > 8) { Console.SetCursorPosition(63, Console.CursorTop); } else if (arguments.Length == 8) { Console.SetCursorPosition(69, Console.CursorTop); } Utility.PushColor(ConsoleColor.Yellow); Console.WriteLine("[{0}]", new object[] { arguments }); Utility.PopColor(); } else { Utility.PushColor(ConsoleColor.Gray); Console.WriteLine("[default]"); Utility.PopColor(); } Utility.PushColor(ConsoleColor.Magenta); Console.Write("Shard: "); Utility.PushColor(ConsoleColor.White); Console.Write("Garbage Collection Mode"); Utility.PushColor(ConsoleColor.DarkGray); Console.Write("........................................"); if (GCSettings.IsServerGC) { Utility.PushColor(ConsoleColor.White); Console.WriteLine("[Enabled]"); Utility.PopColor(); } else { Utility.PushColor(ConsoleColor.DarkGray); Console.SetCursorPosition(69, Console.CursorTop); Console.WriteLine("[Disabled]"); Utility.PopColor(); } // string text = "....................................................."; int num = 70 - (RandomImpl.Type.Name.Length + 18); if (num < 0) { num = 0; } Utility.PushColor(ConsoleColor.Magenta); Console.Write("Shard: "); Utility.PushColor(ConsoleColor.White); Console.Write("RandomImpl {0}", new object[] { RandomImpl.Type.Name }); Utility.PushColor(ConsoleColor.DarkGray); Console.Write("............................................"); Utility.PushColor(ConsoleColor.White); Console.SetCursorPosition(69, Console.CursorTop); Console.WriteLine("[{0}]", new object[] { RandomImpl.IsHardwareRNG ? "Hardware" : "Software" }); Utility.PopColor(); if (_UseHRT) { Utility.PushColor(ConsoleColor.Magenta); Console.Write("Shard: "); Utility.PushColor(ConsoleColor.White); Console.Write("High Resolution Timing requested"); Utility.PushColor(ConsoleColor.DarkGray); Console.Write("..............................."); if (UsingHighResolutionTiming) { Utility.PushColor(ConsoleColor.Green); Console.WriteLine("[Success]"); Utility.PopColor(); } else { Utility.PushColor(ConsoleColor.Red); Console.WriteLine("[Failure]"); Utility.PopColor(); } } else { Utility.PushColor(ConsoleColor.Magenta); Console.Write("Shard: "); Utility.PushColor(ConsoleColor.White); Console.Write("Standard Timing requested"); Utility.PushColor(ConsoleColor.DarkGray); Console.Write("......................................"); Utility.PushColor(ConsoleColor.Green); Console.WriteLine("[Success]"); Utility.PopColor(); } Utility.PushColor(ConsoleColor.Magenta); Console.Write("Shard: "); Utility.PushColor(ConsoleColor.White); Console.Write("Initializing Shard Engine settings"); Utility.PushColor(ConsoleColor.DarkGray); Console.Write("............................."); Configs.Load(); bEnforceExpansionClient = Configs.Get("16Below.EnforceExpansionClient", false); bDemoVersionEnabled = Configs.Get("16Below.DemoVersionEnabled", false); Utility.PopColor(); Utility.PushColor(ConsoleColor.Magenta); Console.Write("Shard: "); Utility.PushColor(ConsoleColor.White); Console.Write("Compiling Scripts"); Utility.PushColor(ConsoleColor.DarkGray); Console.Write(".............................................."); Utility.PopColor(); while (!ScriptCompiler.Compile(Debug, _Cache)) { Utility.PushColor(ConsoleColor.Red); Console.WriteLine("Scripts: One or more scripts failed to compile or no script files were found."); Utility.PopColor(); if (Service) { return; } Utility.PushColor(ConsoleColor.Yellow); Console.WriteLine(""); Console.Write("Shard: Press <return> to exit, or <R> to try again. "); if (Console.ReadKey(true).Key != ConsoleKey.R) { return; } } ScriptCompiler.Invoke("Configure"); Region.Load(); World.Load(); ScriptCompiler.Invoke("Initialize"); Utility.PushColor(ConsoleColor.Green); Console.WriteLine(new String('_', Console.BufferWidth)); Utility.PopColor(); Utility.PushColor(ConsoleColor.Magenta); Console.Write("Shard: "); Utility.PushColor(ConsoleColor.White); Console.Write("Initializing Network"); Utility.PushColor(ConsoleColor.DarkGray); Console.Write("...(F5 for a list of available IP's)....."); Utility.PushColor(ConsoleColor.White); if (Configs.Get("16Below.ConsoleBeep", false)) { Console.WriteLine("\a[Listening]"); } else { Console.WriteLine("[Listening]"); } Utility.PopColor(); Utility.PushColor(ConsoleColor.Green); Console.WriteLine(new String('_', Console.BufferWidth)); Utility.PopColor(); MessagePump messagePump = MessagePump = new MessagePump(); _TimerThread.Start(); foreach (Map m in Map.AllMaps) { m.Tiles.Force(); } NetState.Initialize(); EventSink.InvokeServerStarted(); try { long now, last = TickCount; const int sampleInterval = 100; const float ticksPerSecond = 1000.0f * sampleInterval; long sample = 0; while (!Closing) { _Signal.WaitOne(); Mobile.ProcessDeltaQueue(); Item.ProcessDeltaQueue(); Timer.Slice(); messagePump.Slice(); NetState.FlushAll(); NetState.ProcessDisposedQueue(); if (Slice != null) { Slice(); } if (sample++ % sampleInterval != 0) { continue; } now = TickCount; _CyclesPerSecond[_CycleIndex++ % _CyclesPerSecond.Length] = ticksPerSecond / (now - last); last = now; } } catch (Exception e) { CurrentDomain_UnhandledException(null, new UnhandledExceptionEventArgs(e, true)); } }