示例#1
0
        public static void Main( string[] args )
        {
            m_Assembly = Assembly.GetEntryAssembly();

            /* print a banner */
            Version ver = m_Assembly.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();

            /* prepare SunUO */
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler( CurrentDomain_UnhandledException );
            AppDomain.CurrentDomain.ProcessExit += new EventHandler( CurrentDomain_ProcessExit );

            bool debug = false;

            for ( int i = 0; i < args.Length; ++i )
            {
                if ( Insensitive.Equals( args[i], "-debug" ) )
                    debug = true;
                else if ( Insensitive.Equals( args[i], "-service" ) )
                    m_Service = true;
                else if ( Insensitive.Equals( args[i], "-profile" ) )
                    Profiling = true;
                else if (args[i] == "--logfile") {
                    string logfile = args[++i];
                    StreamWriter writer = new StreamWriter(new FileStream(logfile, FileMode.Append, FileAccess.Write));
                    writer.AutoFlush = true;
                    Console.SetOut(writer);
                    Console.SetError(writer);
                }
            }

            config = new Config(Path.Combine(BaseDirectoryInfo.CreateSubdirectory("etc").FullName, "sunuo.xml"));

            try
            {
                m_MultiConOut = new MultiTextWriter(Console.Out);
                Console.SetOut(m_MultiConOut);

                if (m_Service) {
                    string filename = Path.Combine(LogDirectoryInfo.FullName, "console.log");
                    m_MultiConOut.Add(new FileLogger(filename));
                }
            }
            catch
            {
            }

            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;

            Console.Write("Verifying scripts:");
            m_ItemCount = 0;
            m_MobileCount = 0;
            foreach (Library l in ScriptCompiler.Libraries) {
                int itemCount = 0, mobileCount = 0;
                Console.Write(" {0}[", l.Name);
                l.Verify(ref itemCount, ref mobileCount);
                Console.Write("{0} items, {1} mobiles]", itemCount, mobileCount);
                m_ItemCount += itemCount;
                m_MobileCount += mobileCount;
            }
            Console.WriteLine(" - done ({0} items, {1} mobiles)", m_ItemCount, m_MobileCount);

            try {
                ScriptCompiler.Configure();
            } catch (TargetInvocationException e) {
                Console.WriteLine("Configure exception: {0}", e.InnerException);
                return;
            }

            if (!config.Exists)
                config.Save();

            World.Load();

            try {
                ScriptCompiler.Initialize();
            } catch (TargetInvocationException e) {
                Console.WriteLine("Initialize exception: {0}", e.InnerException);
                return;
            }

            Region.Load();

            m_MessagePump = new MessagePump( new Listener( Listener.Port ) );

            timerThread.Start();

            NetState.Initialize();
            Encryption.Initialize();

            EventSink.InvokeServerStarted();

            try
            {
                while ( !m_Closing )
                {
                    Thread.Sleep( 1 );

                    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();
        }
示例#2
0
        public static void Main( string[] args )
        {
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler( CurrentDomain_UnhandledException );
            AppDomain.CurrentDomain.ProcessExit += new EventHandler( CurrentDomain_ProcessExit );

            bool debug = false;

            for ( int i = 0; i < args.Length; ++i )
            {
                if ( Insensitive.Equals( args[i], "-debug" ) )
                    debug = true;
                else if ( Insensitive.Equals( args[i], "-service" ) )
                    m_Service = true;
                else if ( Insensitive.Equals( args[i], "-profile" ) )
                    Profiling = true;
            }

            config = new Config(Path.Combine(BaseDirectoryInfo.CreateSubdirectory("etc").FullName, "sunuo.xml"));

            try
            {
                m_MultiConOut = new MultiTextWriter(Console.Out);
                Console.SetOut(m_MultiConOut);

                if (m_Service) {
                    string filename = Path.Combine(LogDirectoryInfo.FullName, "console.log");
                    m_MultiConOut.Add(new FileLogger(filename));
                }
            }
            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("SunUO Version {0}.{1}.{2} http://max.kellermann.name/projects/sunuo/",
                              ver.Major, ver.Minor, ver.Revision);

            while ( !ScriptCompiler.Compile( debug ) )
            {
                Console.WriteLine( "Scripts: One or more scripts failed to compile or no script files were found." );
                Console.WriteLine( " - Press return to exit, or R to try again." );

                string line = Console.ReadLine();
                if ( line == null || line.ToLower() != "r" )
                    return;
            }

            Console.Write("Verifying scripts:");
            m_ItemCount = 0;
            m_MobileCount = 0;
            foreach (Library l in ScriptCompiler.Libraries) {
                int itemCount = 0, mobileCount = 0;
                Console.Write(" {0}[", l.Name);
                l.Verify(ref itemCount, ref mobileCount);
                Console.Write("{0} items, {1} mobiles]", itemCount, mobileCount);
                m_ItemCount += itemCount;
                m_MobileCount += mobileCount;
            }
            Console.WriteLine(" - done ({0} items, {1} mobiles)", m_ItemCount, m_MobileCount);

            try {
                ScriptCompiler.Configure();
            } catch (TargetInvocationException e) {
                Console.WriteLine("Configure exception: {0}", e.InnerException);
                return;
            }

            config.Save();

            World.Load();

            try {
                ScriptCompiler.Initialize();
            } catch (TargetInvocationException e) {
                Console.WriteLine("Initialize exception: {0}", e.InnerException);
                return;
            }

            Region.Load();

            MessagePump ms = m_MessagePump = new MessagePump( new Listener( Listener.Port ) );

            timerThread.Start();

            NetState.Initialize();

            EventSink.InvokeServerStarted();

            try
            {
                while ( !m_Closing )
                {
                    Thread.Sleep( 1 );

                    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();
        }
示例#3
0
        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 );

            for ( int i = 0; i < args.Length; ++i )
            {
                if ( Insensitive.Equals( args[i], "-service" ) )
                    m_Service = true;
                else if ( Insensitive.Equals( args[i], "-profile" ) )
                    Profiling = true;
                else if (args[i] == "--logfile") {
                    string logfile = args[++i];
                    StreamWriter writer = new StreamWriter(new FileStream(logfile, FileMode.Append, FileAccess.Write));
                    writer.AutoFlush = true;
                    Console.SetOut(writer);
                    Console.SetError(writer);
                }
            }

            config = new Config(Path.Combine(BaseDirectoryInfo.CreateSubdirectory("etc").FullName, "sunuo.xml"));

            try
            {
                m_MultiConOut = new MultiTextWriter(Console.Out);
                Console.SetOut(m_MultiConOut);

                if (m_Service) {
                    string filename = Path.Combine(LogDirectoryInfo.FullName, "console.log");
                    m_MultiConOut.Add(new FileLogger(filename));
                }
            }
            catch
            {
            }

            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();
            Server.Accounting.AccountHandler.Initialize();

            EventSink.InvokeServerStarted();

            try
            {
                while ( !m_Closing )
                {
                    Thread.Sleep( 1 );

                    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();
        }
示例#4
0
        public static void Main(string[] args)
        {
            m_Assembly = Assembly.GetEntryAssembly();

            /* print a banner */
            Version ver = m_Assembly.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();

            /* prepare SunUO */
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
            AppDomain.CurrentDomain.ProcessExit        += new EventHandler(CurrentDomain_ProcessExit);

            bool debug = false;

            for (int i = 0; i < args.Length; ++i)
            {
                if (Insensitive.Equals(args[i], "-debug"))
                {
                    debug = true;
                }
                else if (Insensitive.Equals(args[i], "-service"))
                {
                    m_Service = true;
                }
                else if (Insensitive.Equals(args[i], "-profile"))
                {
                    Profiling = true;
                }
                else if (args[i] == "--logfile")
                {
                    string       logfile = args[++i];
                    StreamWriter writer  = new StreamWriter(new FileStream(logfile, FileMode.Append, FileAccess.Write));
                    writer.AutoFlush = true;
                    Console.SetOut(writer);
                    Console.SetError(writer);
                }
            }

            config = new Config(Path.Combine(BaseDirectoryInfo.CreateSubdirectory("etc").FullName, "sunuo.xml"));

            try
            {
                m_MultiConOut = new MultiTextWriter(Console.Out);
                Console.SetOut(m_MultiConOut);

                if (m_Service)
                {
                    string filename = Path.Combine(LogDirectoryInfo.FullName, "console.log");
                    m_MultiConOut.Add(new FileLogger(filename));
                }
            }
            catch
            {
            }

            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;
            }

            Console.Write("Verifying scripts:");
            m_ItemCount   = 0;
            m_MobileCount = 0;
            foreach (Library l in ScriptCompiler.Libraries)
            {
                int itemCount = 0, mobileCount = 0;
                Console.Write(" {0}[", l.Name);
                l.Verify(ref itemCount, ref mobileCount);
                Console.Write("{0} items, {1} mobiles]", itemCount, mobileCount);
                m_ItemCount   += itemCount;
                m_MobileCount += mobileCount;
            }
            Console.WriteLine(" - done ({0} items, {1} mobiles)", m_ItemCount, m_MobileCount);

            try {
                ScriptCompiler.Configure();
            } catch (TargetInvocationException e) {
                Console.WriteLine("Configure exception: {0}", e.InnerException);
                return;
            }

            if (!config.Exists)
            {
                config.Save();
            }

            World.Load();

            try {
                ScriptCompiler.Initialize();
            } catch (TargetInvocationException e) {
                Console.WriteLine("Initialize exception: {0}", e.InnerException);
                return;
            }

            Region.Load();

            m_MessagePump = new MessagePump(new Listener(Listener.Port));

            timerThread.Start();

            NetState.Initialize();

            EventSink.InvokeServerStarted();

            try
            {
                while (!m_Closing)
                {
                    Thread.Sleep(1);

                    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();
            }
        }