コード例 #1
0
        private bool SetupManagers()
        {
            m_serverWrapper       = ServerAssemblyWrapper.Instance;
            m_pluginManager       = PluginManager.Instance;
            m_gameAssemblyWrapper = SandboxGameAssemblyWrapper.Instance;
            m_factionsManager     = FactionsManager.Instance;
            m_logManager          = LogManager.Instance;
            m_entityEventManager  = EntityEventManager.Instance;
            m_chatManager         = ChatManager.Instance;

            return(true);
        }
コード例 #2
0
        private bool SetupManagers( )
        {
            _serverWrapper       = ServerAssemblyWrapper.Instance;
            _pluginManager       = PluginManager.Instance;
            _gameAssemblyWrapper = SandboxGameAssemblyWrapper.Instance;
            _factionsManager     = FactionsManager.Instance;
            _entityEventManager  = EntityEventManager.Instance;
            _chatManager         = ChatManager.Instance;
            _sessionManager      = SessionManager.Instance;

            return(true);
        }
コード例 #3
0
        protected bool RunBaseReflectionUnitTests()
        {
            bool result = true;

            if (!SandboxGameAssemblyWrapper.ReflectionUnitTest())
            {
                result = false;
                Console.WriteLine("SandboxGameAssemblyWrapper reflection validation failed!");
            }

            if (!ServerAssemblyWrapper.ReflectionUnitTest())
            {
                result = false;
                Console.WriteLine("ServerAssemblyWrapper reflection validation failed!");
            }

            if (!NetworkManager.ReflectionUnitTest())
            {
                result = false;
                Console.WriteLine("NetworkManager reflection validation failed!");
            }

            if (!ServerNetworkManager.ReflectionUnitTest())
            {
                result = false;
                Console.WriteLine("ServerNetworkManager reflection validation failed!");
            }

            if (!UtilityFunctions.ReflectionUnitTest())
            {
                result = false;
                Console.WriteLine("UtilityFunctions reflection validation failed!");
            }

            if (!ChatManager.ReflectionUnitTest())
            {
                result = false;
                Console.WriteLine("ChatManager reflection validation failed!");
            }

            if (!PlayerMap.ReflectionUnitTest())
            {
                result = false;
                Console.WriteLine("PlayerMap reflection validation failed!");
            }

            if (!PlayerManager.ReflectionUnitTest())
            {
                result = false;
                Console.WriteLine("PlayerManager reflection validation failed!");
            }

            if (!WorldManager.ReflectionUnitTest())
            {
                result = false;
                Console.WriteLine("WorldManager reflection validation failed!");
            }

            if (!RadioManager.ReflectionUnitTest())
            {
                result = false;
                Console.WriteLine("RadioManager reflection validation failed!");
            }

            if (!RadioManagerNetworkManager.ReflectionUnitTest())
            {
                result = false;
                Console.WriteLine("RadioManagerNetworkManager reflection validation failed!");
            }

            if (!PowerManager.ReflectionUnitTest())
            {
                result = false;
                Console.WriteLine("PowerManager reflection validation failed!");
            }

            if (!FactionsManager.ReflectionUnitTest())
            {
                result = false;
                Console.WriteLine("FactionsManager reflection validation failed!");
            }

            if (!Faction.ReflectionUnitTest())
            {
                result = false;
                Console.WriteLine("Faction reflection validation failed!");
            }

            if (!GameEntityManager.ReflectionUnitTest())
            {
                result = false;
                Console.WriteLine("GameEntityManager reflection validation failed!");
            }

            if (result)
            {
                Console.WriteLine("All main types passed reflection unit tests!");
            }

            return(result);
        }
コード例 #4
0
        private void RunServer()
        {
            if (m_restartLimit < 0)
            {
                return;
            }

            m_lastRestart = DateTime.Now;

            try
            {
                SandboxGameAssemblyWrapper.InstanceName = InstanceName;
                m_serverWrapper = ServerAssemblyWrapper.Instance;
                bool result = m_serverWrapper.StartServer(m_commandLineArgs.instanceName, m_commandLineArgs.path, !m_commandLineArgs.noConsole);
                Console.WriteLine("Server has stopped running");

                m_isServerRunning = false;

                m_pluginMainLoop.Stop();
                m_autosaveTimer.Stop();

                m_pluginManager.Shutdown();

                if (!result && m_commandLineArgs.closeOnCrash)
                {
                    Thread.Sleep(5000);
                    Environment.Exit(1);
                }

                if (!result && m_commandLineArgs.restartOnCrash)
                {
                    Thread.Sleep(5000);

                    String restartText = "timeout /t 20\r\n";
                    restartText += String.Format("cd /d \"{0}\"\r\n", System.IO.Path.GetDirectoryName(Application.ExecutablePath));
                    restartText += System.IO.Path.GetFileName(Application.ExecutablePath) + " " + m_commandLineArgs.args + "\r\n";

                    File.WriteAllText("RestartApp.bat", restartText);
                    System.Diagnostics.Process.Start("RestartApp.bat");
                    Environment.Exit(1);
                }

                /*
                 * if (!result)
                 * {
                 *      LogManager.APILog.WriteLineAndConsole("Server crashed, attempting auto-restart ...");
                 *
                 *      TimeSpan timeSinceLastRestart = DateTime.Now - m_lastRestart;
                 *
                 *      //Reset the restart limit if the server has been running for more than 5 minutes before the crash
                 *      if (timeSinceLastRestart.TotalMinutes > 5)
                 *              m_restartLimit = 3;
                 *
                 *      m_restartLimit--;
                 *
                 *      m_isServerRunning = true;
                 *      SectorObjectManager.Instance.IsShutDown = false;
                 *
                 *      m_runServerThread = new Thread(new ThreadStart(this.RunServer));
                 *      m_runServerThread.Start();
                 * }*/
            }
            catch (Exception ex)
            {
                Console.WriteLine("Uncaught");
                LogManager.ErrorLog.WriteLine(ex);
            }
            finally
            {
                m_serverWrapper = null;
            }
        }
コード例 #5
0
        private void RunServer( )
        {
            if (_restartLimit < 0)
            {
                return;
            }

            try
            {
                SandboxGameAssemblyWrapper.InstanceName = InstanceName;
                _serverWrapper = ServerAssemblyWrapper.Instance;
                bool result = _serverWrapper.StartServer(_commandLineArgs.InstanceName, _commandLineArgs.InstancePath, !_commandLineArgs.NoConsole);
                ApplicationLog.BaseLog.Info("Server has stopped running");

                _isServerRunning = false;

                _pluginMainLoop.Stop( );
                _autosaveTimer.Stop( );

                _pluginManager.Shutdown( );

                if (!result && _commandLineArgs.CloseOnCrash)
                {
                    Thread.Sleep(5000);
                    Environment.Exit(1);
                }

                if (!result && _commandLineArgs.RestartOnCrash)
                {
                    Thread.Sleep(5000);

                    string restartText = "timeout /t 20\r\n";
                    restartText += string.Format("cd /d \"{0}\"\r\n", System.IO.Path.GetDirectoryName(Application.ExecutablePath));
                    restartText += string.Format("{0} {1}\r\n", System.IO.Path.GetFileName(Application.ExecutablePath), _commandLineArgs.Args);

                    File.WriteAllText("RestartApp.bat", restartText);
                    Process.Start("RestartApp.bat");
                    Environment.Exit(1);
                }

                /*
                 * if (!result)
                 * {
                 *      LogManager.APILog.WriteLineAndConsole("Server crashed, attempting auto-restart ...");
                 *
                 *      TimeSpan timeSinceLastRestart = DateTime.Now - m_lastRestart;
                 *
                 *      //Reset the restart limit if the server has been running for more than 5 minutes before the crash
                 *      if (timeSinceLastRestart.TotalMinutes > 5)
                 *              _restartLimit = 3;
                 *
                 *      _restartLimit--;
                 *
                 *      _isServerRunning = true;
                 *      SectorObjectManager.Instance.IsShutDown = false;
                 *
                 *      _runServerThread = new Thread(new ThreadStart(this.RunServer));
                 *      _runServerThread.Start();
                 * }*/
            }
            catch (Exception ex)
            {
                ApplicationLog.BaseLog.Error(ex);
            }
            finally
            {
                _serverWrapper = null;
            }
        }