From 1960d2a0de90ce58d1f341047af0ce18c008a06d Mon Sep 17 00:00:00 2001 From: zznty <94796179+zznty@users.noreply.github.com> Date: Mon, 14 Oct 2024 23:20:49 +0700 Subject: [PATCH] fix world path being truncated if missing trailing slash --- Torch.Server/Managers/InstanceManager.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Torch.Server/Managers/InstanceManager.cs b/Torch.Server/Managers/InstanceManager.cs index a4e4a9e..0a33755 100644 --- a/Torch.Server/Managers/InstanceManager.cs +++ b/Torch.Server/Managers/InstanceManager.cs @@ -134,7 +134,7 @@ namespace Torch.Server.Managers worldPath = DedicatedConfig.Worlds.First().WorldPath; else // make sure we won't end up with a file path when we expect it to be a directory - worldPath = Path.EndsInDirectorySeparator(worldPath) ? worldPath : Path.GetDirectoryName(worldPath); + worldPath = worldPath.EndsWith(".sbc") ? Path.GetDirectoryName(worldPath) : worldPath; SelectWorld(worldPath, false); @@ -235,7 +235,7 @@ namespace Torch.Server.Managers try { - MyObjectBuilderSerializer.DeserializeXML(sandboxPath, out MyObjectBuilder_Checkpoint checkpoint, out ulong sizeInBytes); + MyObjectBuilderSerializerKeen.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})"); @@ -368,14 +368,14 @@ namespace Torch.Server.Managers public void LoadSandbox() { - if (!MyObjectBuilderSerializer.DeserializeXML(_checkpointPath, out MyObjectBuilder_Checkpoint checkpoint)) + if (!MyObjectBuilderSerializerKeen.DeserializeXML(_checkpointPath, out MyObjectBuilder_Checkpoint checkpoint)) throw new SerializationException("Error reading checkpoint, see keen log for details"); Checkpoint = new CheckpointViewModel(checkpoint); // migrate old saves if (File.Exists(_worldConfigPath)) { - if (!MyObjectBuilderSerializer.DeserializeXML(_worldConfigPath, out MyObjectBuilder_WorldConfiguration worldConfig)) + if (!MyObjectBuilderSerializerKeen.DeserializeXML(_worldConfigPath, out MyObjectBuilder_WorldConfiguration worldConfig)) throw new SerializationException("Error reading settings, see keen log for details"); WorldConfiguration = new WorldConfigurationViewModel(worldConfig); }