Exemplo n.º 1
0
        private void ImportWorldConfig(WorldViewModel world, bool modsOnly = true)
        {
            var mods = new MtObservableList <ModItemInfo>();

            foreach (var mod in world.WorldConfiguration.Mods)
            {
                mods.Add(new ModItemInfo(mod));
            }
            DedicatedConfig.Mods = mods;


            Log.Debug("Loaded mod list from world");

            if (!modsOnly)
            {
                DedicatedConfig.SessionSettings = world.WorldConfiguration.Settings;
            }
        }
Exemplo n.º 2
0
        private void ImportWorldConfig(bool modsOnly = true)
        {
            if (string.IsNullOrEmpty(DedicatedConfig.LoadWorld))
            {
                return;
            }

            var sandboxPath = Path.Combine(DedicatedConfig.LoadWorld, "Sandbox.sbc");

            if (!File.Exists(sandboxPath))
            {
                return;
            }

            try
            {
                MyObjectBuilderSerializer.DeserializeXML(sandboxPath, out MyObjectBuilder_Checkpoint checkpoint, out ulong sizeInBytes);
                if (checkpoint == null)
                {
                    Log.Error($"Failed to load {DedicatedConfig.LoadWorld}, checkpoint null ({sizeInBytes} bytes, instance {Torch.Config.InstancePath})");
                    return;
                }

                var mods = new MtObservableList <ModItemInfo>();
                foreach (var mod in checkpoint.Mods)
                {
                    mods.Add(new ModItemInfo(mod));
                }
                DedicatedConfig.Mods = mods;

                Log.Debug("Loaded mod list from world");

                if (!modsOnly)
                {
                    DedicatedConfig.SessionSettings = new SessionSettingsViewModel(checkpoint.Settings);
                }
            }
            catch (Exception e)
            {
                Log.Error($"Error loading mod list from world, verify that your mod list is accurate. '{DedicatedConfig.LoadWorld}'.");
                Log.Error(e);
            }
        }