Пример #1
0
        public void LoadDedicatedConfig(TorchConfig torchConfig)
        {
            MySandboxGame.Config = new MyConfig(MyPerServerSettings.GameNameSafe + ".cfg");
            var path = Path.Combine(torchConfig.InstancePath, "SpaceEngineers-Dedicated.cfg");

            if (!File.Exists(path))
            {
                DataContext = null;
                return;
            }

            Config = new MyConfigDedicated <MyObjectBuilder_SessionSettings>(path);
            Config.Load(path);
            _configPath = path;

            _viewModel = new ConfigDedicatedViewModel(Config);
            var worldFolders = Directory.EnumerateDirectories(Path.Combine(torchConfig.InstancePath, "Saves"));

            foreach (var f in worldFolders)
            {
                _viewModel.WorldPaths.Add(f);
            }

            DataContext = _viewModel;
        }
Пример #2
0
        public void LoadInstance(string path, bool validate = true)
        {
            Log.Info($"Loading instance {path}");

            if (validate)
            {
                ValidateInstance(path);
            }

            MyFileSystem.Reset();
            MyFileSystem.Init("Content", path);
            //Initializes saves path. Why this isn't in Init() we may never know.
            MyFileSystem.InitUserSpecific(null);

            var configPath = Path.Combine(path, CONFIG_NAME);

            if (!File.Exists(configPath))
            {
                Log.Error($"Failed to load dedicated config at {path}");
                return;
            }

            var config = new MyConfigDedicated <MyObjectBuilder_SessionSettings>(configPath);

            config.Load(configPath);

            DedicatedConfig = new ConfigDedicatedViewModel(config);

            var worldFolders = Directory.EnumerateDirectories(Path.Combine(Torch.Config.InstancePath, "Saves"));

            foreach (var f in worldFolders)
            {
                try
                {
                    if (!string.IsNullOrEmpty(f) && File.Exists(Path.Combine(f, "Sandbox.sbc")))
                    {
                        DedicatedConfig.Worlds.Add(new WorldViewModel(f));
                    }
                }
                catch (Exception ex)
                {
                    Log.Error("Failed to load world at path: " + f);
                    continue;
                }
            }

            if (DedicatedConfig.Worlds.Count == 0)
            {
                Log.Warn($"No worlds found in the current instance {path}.");
                return;
            }

            SelectWorld(DedicatedConfig.LoadWorld ?? DedicatedConfig.Worlds.First().WorldPath, false);

            InstanceLoaded?.Invoke(DedicatedConfig);
        }
Пример #3
0
        public void LoadInstance(string path)
        {
            if (!Directory.Exists(path))
            {
                throw new FileNotFoundException($"Instance directory not found at '{path}'");
            }

            var configPath = Path.Combine(path, CONFIG_NAME);
            var config     = new MyConfigDedicated <MyObjectBuilder_SessionSettings>(configPath);

            config.Load();
            DedicatedConfig = new ConfigDedicatedViewModel(config);
        }
Пример #4
0
        public void LoadInstance(string path, bool validate = true)
        {
            if (validate)
            {
                ValidateInstance(path);
            }

            MyFileSystem.Reset();
            MyFileSystem.ExePath = Path.Combine(_filesystemManager.TorchDirectory, "DedicatedServer64");
            MyFileSystem.Init("Content", path);
            //Initializes saves path. Why this isn't in Init() we may never know.
            MyFileSystem.InitUserSpecific(null);

            var configPath = Path.Combine(path, CONFIG_NAME);

            if (!File.Exists(configPath))
            {
                Log.Error($"Failed to load dedicated config at {path}");
                return;
            }

            var config = new MyConfigDedicated <MyObjectBuilder_SessionSettings>(configPath);

            config.Load(configPath);

            DedicatedConfig = new ConfigDedicatedViewModel(config);
            var worldFolders = Directory.EnumerateDirectories(Path.Combine(Torch.Config.InstancePath, "Saves"));

            foreach (var f in worldFolders)
            {
                DedicatedConfig.WorldPaths.Add(f);
            }

            if (DedicatedConfig.WorldPaths.Count == 0)
            {
                Log.Warn($"No worlds found in the current instance {path}.");
                return;
            }

            ImportWorldConfig();

            /*
             * if (string.IsNullOrEmpty(DedicatedConfig.LoadWorld))
             * {
             *  Log.Warn("No world specified, importing first available world.");
             *  SelectWorld(DedicatedConfig.WorldPaths[0], false);
             * }*/
        }