public static void Initialize(Config.Root _config, bool _service, bool _profiling) { config = _config; m_Service = _service; Profiling = _profiling; m_Assembly = Assembly.GetEntryAssembly(); /* prepare SunUO */ AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); AppDomain.CurrentDomain.ProcessExit += new EventHandler(CurrentDomain_ProcessExit); /* redirect Console to file in service mode */ if (m_Service) { string filename = Path.Combine(Config.LogDirectory, "console.log"); FileStream stream = new FileStream(filename, FileMode.Create, FileAccess.Write, FileShare.Read); StreamWriter writer = new StreamWriter(stream); Console.SetOut(writer); Console.SetError(writer); } m_Thread = Thread.CurrentThread; m_Process = Process.GetCurrentProcess(); if (m_Thread != null) { m_Thread.Name = "Core Thread"; } }
public static void Main( string[] args ) { /* print a banner */ Version ver = Assembly.GetEntryAssembly().GetName().Version; Console.WriteLine("SunUO Version {0}.{1}.{2} http://www.sunuo.org/", ver.Major, ver.Minor, ver.Revision); Console.WriteLine(" on {0}, runtime {1}", Environment.OSVersion, Environment.Version); Console.WriteLine(); #if MONO if ((int)Environment.OSVersion.Platform != 128) { Console.WriteLine("WARNING: This is the Mono optimized binary, and it will probably crash on Windows!"); Console.WriteLine(); } #else if ((int)Environment.OSVersion.Platform == 128) { Console.WriteLine("WARNING: This is the Windows optimized binary, and you're running Mono."); Console.WriteLine(); } #endif /* parse command line */ bool repair = false, service = false, profiling = false; string baseDirectory = null; string configFile = null; for ( int i = 0; i < args.Length; ++i ) { switch (args[i]) { case "-debug": case "--debug": /* deprecated, debug is always on */ break; case "--repair": repair = true; break; case "-service": case "--service": service = true; break; case "-profile": case "--profile": profiling = true; break; case "-c": case "--config": if (i == args.Length - 1) { Console.Error.WriteLine("file name expected after {0}", args[i]); return; } configFile = args[++i]; if (!File.Exists(configFile)) { Console.Error.WriteLine("{0} does not exist", configFile); return; } break; case "-b": case "--base": if (i == args.Length - 1) { Console.Error.WriteLine("directory name expected after {0}", args[i]); return; } baseDirectory = args[++i]; if (!Directory.Exists(baseDirectory)) { Console.Error.WriteLine("{0} does not exist", baseDirectory); return; } break; default: Console.Error.WriteLine("Unrecognized command line argument: {0}", args[i]); return; } } if (baseDirectory == null) baseDirectory = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName); if (configFile == null) { string confDirectory = new DirectoryInfo(baseDirectory) .CreateSubdirectory("etc").FullName; configFile = Path.Combine(confDirectory, "sunuo.xml"); } /* prepare environment */ Directory.SetCurrentDirectory(baseDirectory); /* load configuration */ Config.Root config = new Config.Root(baseDirectory, configFile); /* enter stage II */ Core.Initialize(config, service, profiling); Core.Start(repair); }
public static void Main(string[] args) { /* print a banner */ Version ver = Assembly.GetEntryAssembly().GetName().Version; Console.WriteLine("SunUO Version {0}.{1}.{2} http://www.sunuo.org/", ver.Major, ver.Minor, ver.Revision); Console.WriteLine(" on {0}, runtime {1}", Environment.OSVersion, Environment.Version); Console.WriteLine(); #if MONO if ((int)Environment.OSVersion.Platform != 128) { Console.WriteLine("WARNING: This is the Mono optimized binary, and it will probably crash on Windows!"); Console.WriteLine(); } #else if ((int)Environment.OSVersion.Platform == 128) { Console.WriteLine("WARNING: This is the Windows optimized binary, and you're running Mono."); Console.WriteLine(); } #endif /* parse command line */ bool repair = false, service = false, profiling = false; string baseDirectory = null; string configFile = null; for (int i = 0; i < args.Length; ++i) { switch (args[i]) { case "-debug": case "--debug": /* deprecated, debug is always on */ break; case "--repair": repair = true; break; case "-service": case "--service": service = true; break; case "-profile": case "--profile": profiling = true; break; case "-c": case "--config": if (i == args.Length - 1) { Console.Error.WriteLine("file name expected after {0}", args[i]); return; } configFile = args[++i]; if (!File.Exists(configFile)) { Console.Error.WriteLine("{0} does not exist", configFile); return; } break; case "-b": case "--base": if (i == args.Length - 1) { Console.Error.WriteLine("directory name expected after {0}", args[i]); return; } baseDirectory = args[++i]; if (!Directory.Exists(baseDirectory)) { Console.Error.WriteLine("{0} does not exist", baseDirectory); return; } break; default: Console.Error.WriteLine("Unrecognized command line argument: {0}", args[i]); return; } } if (baseDirectory == null) { baseDirectory = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName); } if (configFile == null) { string confDirectory = new DirectoryInfo(baseDirectory) .CreateSubdirectory("etc").FullName; configFile = Path.Combine(confDirectory, "sunuo.xml"); } /* prepare environment */ Directory.SetCurrentDirectory(baseDirectory); /* load configuration */ Config.Root config = new Config.Root(baseDirectory, configFile); /* enter stage II */ Core.Initialize(config, service, profiling); Core.Start(repair); }
public static void Main( string[] args ) { /* print a banner */ Version ver = Assembly.GetEntryAssembly().GetName().Version; Console.WriteLine("SunUO Version {0}.{1}.{2} http://www.sunuo.org/", ver.Major, ver.Minor, ver.Revision); Console.WriteLine(" on {0}, runtime {1}", Environment.OSVersion, Environment.Version); if ((int)Environment.OSVersion.Platform == 128) Console.WriteLine("Please make sure you have Mono 1.1.7 or newer! (mono -V)"); Console.WriteLine(); /* parse command line */ bool debug = false, service = false, profiling = false; string baseDirectory = null; string configFile = null; for ( int i = 0; i < args.Length; ++i ) { switch (args[i]) { case "-debug": case "--debug": debug = true; break; case "-service": case "--service": service = true; break; case "-profile": case "--profile": profiling = true; break; case "-c": case "--config": if (i == args.Length - 1) { Console.Error.WriteLine("file name expected after {0}", args[i]); return; } configFile = args[++i]; if (!File.Exists(configFile)) { Console.Error.WriteLine("{0} does not exist", configFile); return; } break; case "-b": case "--base": if (i == args.Length - 1) { Console.Error.WriteLine("directory name expected after {0}", args[i]); return; } baseDirectory = args[++i]; if (!Directory.Exists(baseDirectory)) { Console.Error.WriteLine("{0} does not exist", baseDirectory); return; } break; default: Console.Error.WriteLine("Unrecognized command line argument: {0}", args[i]); return; } } if (baseDirectory == null) baseDirectory = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName); if (configFile == null) { string confDirectory = new DirectoryInfo(baseDirectory) .CreateSubdirectory("etc").FullName; configFile = Path.Combine(confDirectory, "sunuo.xml"); } /* prepare environment */ Directory.SetCurrentDirectory(baseDirectory); /* load configuration */ Config.Root config = new Config.Root(baseDirectory, configFile); /* enter stage II */ Core.Start(config, debug, service, profiling); }
public static void Start(Config.Root _config, bool debug, bool _service, bool _profiling) { config = _config; m_Service = _service; Profiling = _profiling; m_Assembly = Assembly.GetEntryAssembly(); /* prepare SunUO */ AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler( CurrentDomain_UnhandledException ); AppDomain.CurrentDomain.ProcessExit += new EventHandler( CurrentDomain_ProcessExit ); /* redirect Console to file in service mode */ if (m_Service) { string filename = Path.Combine(LogDirectoryInfo.FullName, "console.log"); FileStream stream = new FileStream(filename, FileMode.Create, FileAccess.Write, FileShare.Read); StreamWriter writer = new StreamWriter(stream); Console.SetOut(writer); Console.SetError(writer); } m_Thread = Thread.CurrentThread; m_Process = Process.GetCurrentProcess(); 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"; if (!ScriptCompiler.Compile(debug)) return; m_ItemCount = 0; m_MobileCount = 0; foreach (Library l in ScriptCompiler.Libraries) { int itemCount = 0, mobileCount = 0; l.Verify(ref itemCount, ref mobileCount); log.Info(String.Format("Library {0} verified: {1} items, {2} mobiles", l.Name, itemCount, mobileCount)); m_ItemCount += itemCount; m_MobileCount += mobileCount; } log.Info(String.Format("All libraries verified: {0} items, {1} mobiles)", m_ItemCount, m_MobileCount)); try { ScriptCompiler.Configure(); } catch (TargetInvocationException e) { log.Fatal("Configure exception: {0}", e.InnerException); return; } if (!config.Exists) config.Save(); World.Load(); try { ScriptCompiler.Initialize(); } catch (TargetInvocationException e) { log.Fatal("Initialize exception: {0}", e.InnerException); return; } Region.Load(); m_MessagePump = new MessagePump( new Listener( Listener.Port ) ); timerThread.Start(); NetState.Initialize(); Encryption.Initialize(); EventSink.InvokeServerStarted(); log.Info("SunUO initialized, entering main loop"); try { while ( !m_Closing ) { m_Signal.WaitOne(); m_Now = DateTime.Now; Mobile.ProcessDeltaQueue(); Item.ProcessDeltaQueue(); Timer.Slice(); m_MessagePump.Slice(); NetState.FlushAll(); NetState.ProcessDisposedQueue(); if ( Slice != null ) Slice(); } } catch ( Exception e ) { CurrentDomain_UnhandledException( null, new UnhandledExceptionEventArgs( e, true ) ); } if ( timerThread.IsAlive ) timerThread.Abort(); }
public static void Main(string[] args) { /* print a banner */ Version ver = Assembly.GetEntryAssembly().GetName().Version; Console.WriteLine("SunUO Version {0}.{1}.{2} http://www.sunuo.org/", ver.Major, ver.Minor, ver.Revision); Console.WriteLine(" on {0}, runtime {1}", Environment.OSVersion, Environment.Version); if ((int)Environment.OSVersion.Platform == 128) { Console.WriteLine("Please make sure you have Mono 1.1.7 or newer! (mono -V)"); } Console.WriteLine(); /* parse command line */ bool debug = false, service = false, profiling = false; string baseDirectory = null; string configFile = null; for (int i = 0; i < args.Length; ++i) { switch (args[i]) { case "-debug": case "--debug": debug = true; break; case "-service": case "--service": service = true; break; case "-profile": case "--profile": profiling = true; break; case "-c": case "--config": if (i == args.Length - 1) { Console.Error.WriteLine("file name expected after {0}", args[i]); return; } configFile = args[++i]; if (!File.Exists(configFile)) { Console.Error.WriteLine("{0} does not exist", configFile); return; } break; case "-b": case "--base": if (i == args.Length - 1) { Console.Error.WriteLine("directory name expected after {0}", args[i]); return; } baseDirectory = args[++i]; if (!Directory.Exists(baseDirectory)) { Console.Error.WriteLine("{0} does not exist", baseDirectory); return; } break; default: Console.Error.WriteLine("Unrecognized command line argument: {0}", args[i]); return; } } if (baseDirectory == null) { baseDirectory = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName); } if (configFile == null) { string confDirectory = new DirectoryInfo(baseDirectory) .CreateSubdirectory("etc").FullName; configFile = Path.Combine(confDirectory, "sunuo.xml"); } /* prepare environment */ Directory.SetCurrentDirectory(baseDirectory); /* load configuration */ Config.Root config = new Config.Root(baseDirectory, configFile); /* enter stage II */ Core.Start(config, debug, service, profiling); }
public static void Main(string[] args) { m_Assembly = Assembly.GetEntryAssembly(); /* print a banner */ Version ver = m_Assembly.GetName().Version; Console.WriteLine("SunLogin Version {0}.{1}.{2} http://www.sunuo.org/", ver.Major, ver.Minor, ver.Revision); Console.WriteLine(" on {0}, runtime {1}", Environment.OSVersion, Environment.Version); if ((int)Environment.OSVersion.Platform == 128) { Console.WriteLine("Please make sure you have Mono 1.1.7 or newer! (mono -V)"); } Console.WriteLine(); /* prepare SunUO */ AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); AppDomain.CurrentDomain.ProcessExit += new EventHandler(CurrentDomain_ProcessExit); if (args.Length > 0) { Console.WriteLine("SunLogin does not understand command line arguments"); return; } string baseDirectory = Path.GetDirectoryName(ExePath); string confDirectory = new DirectoryInfo(baseDirectory) .CreateSubdirectory("etc").FullName; config = new Config.Root(baseDirectory, Path.Combine(confDirectory, "sunuo.xml")); Directory.SetCurrentDirectory(config.BaseDirectory); m_Thread = Thread.CurrentThread; 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"; if (!config.Exists) { config.Save(); } m_MessagePump = new MessagePump(new Listener(Listener.Port)); timerThread.Start(); NetState.Initialize(); Encryption.Initialize(); ServerList.Initialize(); ServerQueryTimer.Initialize(); Server.Accounting.AccountHandler.Initialize(); EventSink.InvokeServerStarted(); log.Info("SunLogin initialized, entering main loop"); try { while (!m_Closing) { m_Signal.WaitOne(); Timer.Slice(); m_MessagePump.Slice(); NetState.FlushAll(); NetState.ProcessDisposedQueue(); } } catch (Exception e) { CurrentDomain_UnhandledException(null, new UnhandledExceptionEventArgs(e, true)); } if (timerThread.IsAlive) { timerThread.Abort(); } }
public static void Main( string[] args ) { m_Assembly = Assembly.GetEntryAssembly(); /* print a banner */ Version ver = m_Assembly.GetName().Version; Console.WriteLine("SunLogin Version {0}.{1}.{2} http://www.sunuo.org/", ver.Major, ver.Minor, ver.Revision); Console.WriteLine(" on {0}, runtime {1}", Environment.OSVersion, Environment.Version); if ((int)Environment.OSVersion.Platform == 128) Console.WriteLine("Please make sure you have Mono 1.1.7 or newer! (mono -V)"); Console.WriteLine(); /* prepare SunUO */ AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler( CurrentDomain_UnhandledException ); AppDomain.CurrentDomain.ProcessExit += new EventHandler( CurrentDomain_ProcessExit ); if (args.Length > 0) { Console.WriteLine("SunLogin does not understand command line arguments"); return; } string baseDirectory = Path.GetDirectoryName(ExePath); string confDirectory = new DirectoryInfo(baseDirectory) .CreateSubdirectory("etc").FullName; config = new Config.Root(baseDirectory, Path.Combine(confDirectory, "sunuo.xml")); Directory.SetCurrentDirectory(config.BaseDirectory); m_Thread = Thread.CurrentThread; 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"; if (!config.Exists) config.Save(); m_MessagePump = new MessagePump(); foreach (IPEndPoint ipep in Config.Network.Bind) m_MessagePump.AddListener(new Listener(ipep)); timerThread.Start(); NetState.Initialize(); Encryption.Initialize(); ServerList.Initialize(); ServerQueryTimer.Initialize(); Server.Accounting.AccountHandler.Initialize(); EventSink.InvokeServerStarted(); log.Info("SunLogin initialized, entering main loop"); try { while ( !m_Closing ) { m_Signal.WaitOne(); Timer.Slice(); m_MessagePump.Slice(); NetState.FlushAll(); NetState.ProcessDisposedQueue(); } } catch ( Exception e ) { CurrentDomain_UnhandledException( null, new UnhandledExceptionEventArgs( e, true ) ); } if ( timerThread.IsAlive ) timerThread.Abort(); }
public static void Initialize(Config.Root _config, bool _service, bool _profiling) { config = _config; m_Service = _service; Profiling = _profiling; m_Assembly = Assembly.GetEntryAssembly(); /* prepare SunUO */ AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler( CurrentDomain_UnhandledException ); AppDomain.CurrentDomain.ProcessExit += new EventHandler( CurrentDomain_ProcessExit ); /* redirect Console to file in service mode */ if (m_Service) { string filename = Path.Combine(LogDirectoryInfo.FullName, "console.log"); FileStream stream = new FileStream(filename, FileMode.Create, FileAccess.Write, FileShare.Read); StreamWriter writer = new StreamWriter(stream); Console.SetOut(writer); Console.SetError(writer); } m_Thread = Thread.CurrentThread; m_Process = Process.GetCurrentProcess(); if ( m_Thread != null ) m_Thread.Name = "Core Thread"; if ( BaseDirectory.Length > 0 ) Directory.SetCurrentDirectory( BaseDirectory ); }
public static void Start(Config.Root _config, bool debug, bool _service, bool _profiling) { config = _config; m_Service = _service; Profiling = _profiling; m_Assembly = Assembly.GetEntryAssembly(); /* prepare SunUO */ AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); AppDomain.CurrentDomain.ProcessExit += new EventHandler(CurrentDomain_ProcessExit); /* redirect Console to file in service mode */ if (m_Service) { string filename = Path.Combine(LogDirectoryInfo.FullName, "console.log"); FileStream stream = new FileStream(filename, FileMode.Create, FileAccess.Write, FileShare.Read); StreamWriter writer = new StreamWriter(stream); Console.SetOut(writer); Console.SetError(writer); } m_Thread = Thread.CurrentThread; m_Process = Process.GetCurrentProcess(); 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"; if (!ScriptCompiler.Compile(debug)) { return; } m_ItemCount = 0; m_MobileCount = 0; foreach (Library l in ScriptCompiler.Libraries) { int itemCount = 0, mobileCount = 0; l.Verify(ref itemCount, ref mobileCount); log.Info(String.Format("Library {0} verified: {1} items, {2} mobiles", l.Name, itemCount, mobileCount)); m_ItemCount += itemCount; m_MobileCount += mobileCount; } log.Info(String.Format("All libraries verified: {0} items, {1} mobiles)", m_ItemCount, m_MobileCount)); try { ScriptCompiler.Configure(); } catch (TargetInvocationException e) { log.Fatal("Configure exception: {0}", e.InnerException); return; } if (!config.Exists) { config.Save(); } World.Load(); try { ScriptCompiler.Initialize(); } catch (TargetInvocationException e) { log.Fatal("Initialize exception: {0}", e.InnerException); return; } Region.Load(); m_MessagePump = new MessagePump(new Listener(Listener.Port)); timerThread.Start(); NetState.Initialize(); Encryption.Initialize(); EventSink.InvokeServerStarted(); log.Info("SunUO initialized, entering main loop"); try { while (!m_Closing) { m_Signal.WaitOne(); m_Now = DateTime.Now; Mobile.ProcessDeltaQueue(); Item.ProcessDeltaQueue(); Timer.Slice(); m_MessagePump.Slice(); NetState.FlushAll(); NetState.ProcessDisposedQueue(); if (Slice != null) { Slice(); } } } catch (Exception e) { CurrentDomain_UnhandledException(null, new UnhandledExceptionEventArgs(e, true)); } if (timerThread.IsAlive) { timerThread.Abort(); } }