Add validation for world load settings

This commit is contained in:
John Gross
2018-01-27 09:19:03 -08:00
parent 47c7c37fa9
commit b3d9a64632
2 changed files with 28 additions and 3 deletions

View File

@@ -67,7 +67,10 @@ namespace Torch.Server.Managers
var worldFolders = Directory.EnumerateDirectories(Path.Combine(Torch.Config.InstancePath, "Saves"));
foreach (var f in worldFolders)
DedicatedConfig.Worlds.Add(new WorldViewModel(f));
{
if (!string.IsNullOrEmpty(f) && File.Exists(Path.Combine(f, "Sandbox.sbc")))
DedicatedConfig.Worlds.Add(new WorldViewModel(f));
}
if (DedicatedConfig.Worlds.Count == 0)
{
@@ -196,6 +199,8 @@ namespace Torch.Server.Managers
public class WorldViewModel : ViewModel
{
private static readonly Logger Log = LogManager.GetCurrentClassLogger();
public string FolderName { get; set; }
public string WorldPath { get; }
public long WorldSizeKB { get; }
@@ -224,6 +229,7 @@ namespace Torch.Server.Managers
{
Task.Run(() =>
{
Log.Info($"Preloading checkpoint {_checkpointPath}");
MyObjectBuilderSerializer.DeserializeXML(_checkpointPath, out MyObjectBuilder_Checkpoint checkpoint);
Checkpoint = new CheckpointViewModel(checkpoint);
OnPropertyChanged(nameof(Checkpoint));