Save Torch config on server start, remove concealment code (moved to plugin)

This commit is contained in:
John Gross
2017-04-18 10:58:23 -07:00
parent 32f5147060
commit 03a22851af
8 changed files with 23 additions and 379 deletions

View File

@@ -6,9 +6,9 @@ using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;
using NLog;
using VRage.Dedicated;
using Sandbox.ModAPI.Ingame;
namespace Torch.Server
namespace Torch
{
public class TorchConfig
{
@@ -19,13 +19,15 @@ namespace Torch.Server
public int Autosave { get; set; }
public bool AutoRestart { get; set; }
public bool LogChat { get; set; }
[NonSerialized]
private string _path;
public TorchConfig() : this("Torch") { }
public TorchConfig(string instanceName = "Torch", string instancePath = null, int autosaveInterval = 5, bool autoRestart = false)
{
InstanceName = instanceName;
InstancePath = instancePath ?? Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "SpaceEngineersDedicated", InstanceName);
InstancePath = instancePath ?? Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "Torch", InstanceName);
Autosave = autosaveInterval;
AutoRestart = autoRestart;
}
@@ -40,6 +42,7 @@ namespace Torch.Server
{
config = (TorchConfig)serializer.Deserialize(f);
}
config._path = path;
return config;
}
catch (Exception e)
@@ -49,8 +52,13 @@ namespace Torch.Server
}
}
public bool SaveTo(string path)
public bool Save(string path = null)
{
if (path == null)
path = _path;
else
_path = path;
try
{
var serializer = new XmlSerializer(typeof(TorchConfig));