Пример #1
0
		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;
		}
Пример #2
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 );
				}
			}
		}
Пример #3
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;	
			 */
		}
Пример #4
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;
             */
        }
Пример #5
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"))
					{
						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 ) );
				}
			}
		}
Пример #6
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);
     }
 }