示例#1
0
        public MyConfigDedicatedData <MyObjectBuilder_SessionSettings> LoadServerConfig( )
        {
            /*
             * if ( !registered )
             * {
             *  registered = true;
             *  MyObjectBuilderType.RegisterAssemblies( );
             * }*/

            if (File.Exists(System.IO.Path.Combine(Path, "SpaceEngineers-Dedicated.cfg.restart")))
            {
                File.Copy(System.IO.Path.Combine(Path, "SpaceEngineers-Dedicated.cfg.restart"), System.IO.Path.Combine(Path, "SpaceEngineers-Dedicated.cfg"), true);
                File.Delete(System.IO.Path.Combine(Path, "SpaceEngineers-Dedicated.cfg.restart"));
            }

            if (File.Exists(System.IO.Path.Combine(Path, "SpaceEngineers-Dedicated.cfg")))
            {
                MyConfigDedicatedData <MyObjectBuilder_SessionSettings> config = DedicatedConfigDefinition.Load(new FileInfo(System.IO.Path.Combine(Path, "SpaceEngineers-Dedicated.cfg")));
                _dedicatedConfigDefinition = new DedicatedConfigDefinition(config);
                _cfgWatch                     = new FileSystemWatcher(Path, "*.cfg");
                _cfgWatch.Changed            += Config_Changed;
                _cfgWatch.NotifyFilter        = NotifyFilters.Size;
                _cfgWatch.EnableRaisingEvents = true;
                return(config);
            }
            else
            {
                if (ExtenderOptions.IsDebugging)
                {
                    ApplicationLog.BaseLog.Info("Failed to load session settings");
                    ApplicationLog.BaseLog.Info(Path);
                }
                return(null);
            }


            /*
             * FileInfo fileInfo = new FileInfo(Path + @"\SpaceEngineers-Dedicated.cfg");
             * if (fileInfo.Exists)
             * {
             *      if (!File.Exists(Path + @"\SpaceEngineers-Dedicated.cfg.restart"))
             *              File.Copy(Path + @"\SpaceEngineers-Dedicated.cfg", Path + @"\SpaceEngineers-Dedicated.cfg.restart");
             *
             *      MyConfigDedicatedData config = DedicatedConfigDefinition.Load(fileInfo);
             *
             *      FileInfo restartFileInfo = new FileInfo(Path + @"\SpaceEngineers-Dedicated.cfg.restart");
             *
             *      if (restartFileInfo.Exists)
             *              config = DedicatedConfigDefinition.Load(restartFileInfo);
             *
             *      _dedicatedConfigDefinition = new DedicatedConfigDefinition(config);
             *      return config;
             * }
             * else
             *      return null;
             */
        }
示例#2
0
        public void LoadServerConfig()
        {
            FileInfo fileInfo = new FileInfo(Path + @"\SpaceEngineers-Dedicated.cfg");

            if (fileInfo.Exists)
            {
                MyConfigDedicatedData config = DedicatedConfigDefinition.Load(fileInfo);
                m_dedicatedConfigDefinition = new DedicatedConfigDefinition(config);
            }
        }
        public MyConfigDedicatedData LoadServerConfig()
        {
            FileInfo fileInfo = new FileInfo(Path + @"\SpaceEngineers-Dedicated.cfg.restart");

            if (fileInfo.Exists)
            {
                File.Copy(Path + @"\SpaceEngineers-Dedicated.cfg.restart", Path + @"\SpaceEngineers-Dedicated.cfg", true);
                File.Delete(Path + @"\SpaceEngineers-Dedicated.cfg.restart");
            }

            fileInfo = new FileInfo(Path + @"\SpaceEngineers-Dedicated.cfg");
            if (fileInfo.Exists)
            {
                MyConfigDedicatedData config = DedicatedConfigDefinition.Load(fileInfo);
                m_dedicatedConfigDefinition = new DedicatedConfigDefinition(config);
                m_cfgWatch                     = new FileSystemWatcher(Path, "*.cfg");
                m_cfgWatch.Changed            += Config_Changed;
                m_cfgWatch.NotifyFilter        = NotifyFilters.Size;
                m_cfgWatch.EnableRaisingEvents = true;
                return(config);
            }
            else
            {
                return(null);
            }


            /*
             * FileInfo fileInfo = new FileInfo(Path + @"\SpaceEngineers-Dedicated.cfg");
             * if (fileInfo.Exists)
             * {
             *      if (!File.Exists(Path + @"\SpaceEngineers-Dedicated.cfg.restart"))
             *              File.Copy(Path + @"\SpaceEngineers-Dedicated.cfg", Path + @"\SpaceEngineers-Dedicated.cfg.restart");
             *
             *      MyConfigDedicatedData config = DedicatedConfigDefinition.Load(fileInfo);
             *
             *      FileInfo restartFileInfo = new FileInfo(Path + @"\SpaceEngineers-Dedicated.cfg.restart");
             *
             *      if (restartFileInfo.Exists)
             *              config = DedicatedConfigDefinition.Load(restartFileInfo);
             *
             *      m_dedicatedConfigDefinition = new DedicatedConfigDefinition(config);
             *      return config;
             * }
             * else
             *      return null;
             */
        }
示例#4
0
        private void Config_Changed(object sender, FileSystemEventArgs e)
        {
            if (!e.Name.Contains("SpaceEngineers-Dedicated.cfg") || e.Name.Contains("SpaceEngineers-Dedicated.cfg.restart"))
            {
                return;
            }

            if (!_serverRan)
            {
                return;
            }

            if (e.ChangeType == WatcherChangeTypes.Changed)
            {
                try
                {
                    if (!File.Exists(Path + @"\SpaceEngineers-Dedicated.cfg.restart"))
                    {
                        ApplicationLog.BaseLog.Info("SpaceEngineers-Dedicated.cfg has changed updating configuration settings.");

                        MyConfigDedicatedData <MyObjectBuilder_SessionSettings> changedConfig = DedicatedConfigDefinition.Load(new FileInfo(e.FullPath));
                        Config = new DedicatedConfigDefinition(changedConfig);
                    }
                    else
                    {
                        ApplicationLog.BaseLog.Info("SpaceEngineers-Dedicated.cfg has changed with existing restart file.");

                        MyConfigDedicatedData <MyObjectBuilder_SessionSettings> restartConfig = DedicatedConfigDefinition.Load(new FileInfo(Path + @"\SpaceEngineers-Dedicated.cfg.restart"));
                        MyConfigDedicatedData <MyObjectBuilder_SessionSettings> changedConfig = DedicatedConfigDefinition.Load(new FileInfo(e.FullPath));

                        restartConfig.Mods           = restartConfig.Mods.Union(changedConfig.Mods).ToList( );
                        restartConfig.Banned         = changedConfig.Banned.Union(changedConfig.Banned).ToList( );
                        restartConfig.Administrators = changedConfig.Administrators.Union(changedConfig.Administrators).ToList( );
                        DedicatedConfigDefinition config = new DedicatedConfigDefinition(restartConfig);
                        config.Save(new FileInfo(Path + @"\SpaceEngineers-Dedicated.cfg.restart"));
                        Config = config;
                    }
                }
                catch (Exception ex)
                {
                    ApplicationLog.BaseLog.Error("Error on configuration change ({1})", e.FullPath);
                    ApplicationLog.BaseLog.Error(ex);
                }
            }
        }
示例#5
0
        public MyConfigDedicatedData <MyObjectBuilder_SessionSettings> LoadServerConfig( )
        {
            if (File.Exists(System.IO.Path.Combine(Path, "SpaceEngineers-Dedicated.cfg.restart")))
            {
                File.Copy(System.IO.Path.Combine(Path, "SpaceEngineers-Dedicated.cfg.restart"), System.IO.Path.Combine(Path, "SpaceEngineers-Dedicated.cfg"), true);
                File.Delete(System.IO.Path.Combine(Path, "SpaceEngineers-Dedicated.cfg.restart"));
            }

            if (File.Exists(System.IO.Path.Combine(Path, "SpaceEngineers-Dedicated.cfg")))
            {
                MyConfigDedicatedData <MyObjectBuilder_SessionSettings> config = DedicatedConfigDefinition.Load(new FileInfo(System.IO.Path.Combine(Path, "SpaceEngineers-Dedicated.cfg")));
                _dedicatedConfigDefinition = new DedicatedConfigDefinition(config);
                _cfgWatch                     = new FileSystemWatcher(Path, "*.cfg");
                _cfgWatch.Changed            += Config_Changed;
                _cfgWatch.NotifyFilter        = NotifyFilters.Size;
                _cfgWatch.EnableRaisingEvents = true;
                return(config);
            }
            else
            {
                return(null);
            }


            /*
             * FileInfo fileInfo = new FileInfo(Path + @"\SpaceEngineers-Dedicated.cfg");
             * if (fileInfo.Exists)
             * {
             *      if (!File.Exists(Path + @"\SpaceEngineers-Dedicated.cfg.restart"))
             *              File.Copy(Path + @"\SpaceEngineers-Dedicated.cfg", Path + @"\SpaceEngineers-Dedicated.cfg.restart");
             *
             *      MyConfigDedicatedData config = DedicatedConfigDefinition.Load(fileInfo);
             *
             *      FileInfo restartFileInfo = new FileInfo(Path + @"\SpaceEngineers-Dedicated.cfg.restart");
             *
             *      if (restartFileInfo.Exists)
             *              config = DedicatedConfigDefinition.Load(restartFileInfo);
             *
             *      _dedicatedConfigDefinition = new DedicatedConfigDefinition(config);
             *      return config;
             * }
             * else
             *      return null;
             */
        }
        private void Config_Changed(object sender, FileSystemEventArgs e)
        {
            if (!e.Name.Contains("SpaceEngineers-Dedicated.cfg") || e.Name.Contains("SpaceEngineers-Dedicated.cfg.restart"))
            {
                return;
            }

            if (!m_serverRan)
            {
                return;
            }

            if (e.ChangeType == WatcherChangeTypes.Changed)
            {
                try
                {
                    if (!File.Exists(Path + @"\SpaceEngineers-Dedicated.cfg.restart"))
                    {
                        LogManager.APILog.WriteLineAndConsole(string.Format("SpaceEngineers-Dedicated.cfg has changed updating configuration settings."));

                        MyConfigDedicatedData changedConfig = DedicatedConfigDefinition.Load(new FileInfo(e.FullPath));
                        Config = new DedicatedConfigDefinition(changedConfig);
                    }
                    else
                    {
                        LogManager.APILog.WriteLineAndConsole(string.Format("SpaceEngineers-Dedicated.cfg has changed with existing restart file."));

                        MyConfigDedicatedData restartConfig = DedicatedConfigDefinition.Load(new FileInfo(Path + @"\SpaceEngineers-Dedicated.cfg.restart"));
                        MyConfigDedicatedData changedConfig = DedicatedConfigDefinition.Load(new FileInfo(e.FullPath));

                        restartConfig.Mods           = restartConfig.Mods.Union(changedConfig.Mods).ToList();
                        restartConfig.Banned         = changedConfig.Banned.Union(changedConfig.Banned).ToList();
                        restartConfig.Administrators = changedConfig.Administrators.Union(changedConfig.Administrators).ToList();
                        DedicatedConfigDefinition config = new DedicatedConfigDefinition(restartConfig);
                        config.Save(new FileInfo(Path + @"\SpaceEngineers-Dedicated.cfg.restart"));
                        Config = config;
                    }
                }
                catch (Exception ex)
                {
                    LogManager.APILog.WriteLineAndConsole(string.Format("Error on configuration change ({1}): {0}", e.FullPath, ex.ToString()));
                }
            }
        }
        public bool LoadServerConfig()
        {
            FileInfo fileInfo = new FileInfo(Path + @"\SpaceEngineers-Dedicated.cfg");

            if (fileInfo.Exists)
            {
                try
                {
                    MyConfigDedicatedData config = DedicatedConfigDefinition.Load(fileInfo);
                    m_dedicatedConfigDefinition = new DedicatedConfigDefinition(config);
                }
                catch (GameInstallationInfoException ex)
                {
                    LogManager.APILog.WriteLineAndConsole("GameInstallationInfoException - " + ex.StateRepresentation[ex.ExceptionStateId] + " File: " + ex.AdditionnalInfo);
                    LogManager.ErrorLog.WriteLine("GameInstallationInfoException - " + ex.StateRepresentation[ex.ExceptionStateId] + " File: " + ex.AdditionnalInfo);
                    return(false);
                }
            }
            return(true);
        }