Skip to content

Commit aceb6c3

Browse files
authored
.203 update. (#567)
* .203 update. * Update Torch.Server.csproj
1 parent a26ec21 commit aceb6c3

4 files changed

Lines changed: 20 additions & 13 deletions

File tree

‎Torch.Server/Managers/InstanceManager.cs‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
using VRage.Game;
2727
using VRage.Game.ObjectBuilder;
2828
using VRage.ObjectBuilders;
29+
using VRage.ObjectBuilders.Private;
2930
using VRage.Plugins;
3031

3132
namespace Torch.Server.Managers
@@ -288,22 +289,20 @@ public WorldViewModel(string worldPath)
288289

289290
public void SaveSandbox()
290291
{
291-
using (var f = File.Open(_checkpointPath, FileMode.Create))
292-
MyObjectBuilderSerializer.SerializeXML(f, Checkpoint);
293-
294-
using (var f = File.Open(_worldConfigPath, FileMode.Create))
295-
MyObjectBuilderSerializer.SerializeXML(f, WorldConfiguration);
292+
MyObjectBuilderSerializerKeen.SerializeXML(_checkpointPath, false,Checkpoint);
293+
294+
MyObjectBuilderSerializerKeen.SerializeXML(_worldConfigPath,false, WorldConfiguration);
296295
}
297296

298297
private void LoadSandbox()
299298
{
300-
MyObjectBuilderSerializer.DeserializeXML(_checkpointPath, out MyObjectBuilder_Checkpoint checkpoint);
299+
MyObjectBuilderSerializerKeen.DeserializeXML(_checkpointPath, out MyObjectBuilder_Checkpoint checkpoint);
301300
Checkpoint = new CheckpointViewModel(checkpoint);
302301

303302
// migrate old saves
304303
if (File.Exists(_worldConfigPath))
305304
{
306-
MyObjectBuilderSerializer.DeserializeXML(_worldConfigPath, out MyObjectBuilder_WorldConfiguration worldConfig);
305+
MyObjectBuilderSerializerKeen.DeserializeXML(_worldConfigPath, out MyObjectBuilder_WorldConfiguration worldConfig);
307306
WorldConfiguration = new WorldConfigurationViewModel(worldConfig);
308307
}
309308
else

‎Torch.Server/Torch.Server.csproj‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,4 +538,4 @@
538538
<PropertyGroup>
539539
<PostBuildEvent>copy "$(SolutionDir)NLog.config" "$(TargetDir)" &amp; copy "$(SolutionDir)NLog-user.config" "$(TargetDir)"</PostBuildEvent>
540540
</PropertyGroup>
541-
</Project>
541+
</Project>

‎Torch/Managers/EntityManager.cs‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
using VRage.Groups;
2828
using VRage.ModAPI;
2929
using VRage.ObjectBuilders;
30+
using VRage.ObjectBuilders.Private;
3031
using VRage.Sync;
3132
using VRageMath;
3233

@@ -46,15 +47,15 @@ public void ExportGrid(IMyCubeGrid grid, string path)
4647
{
4748

4849
var ob = grid.GetObjectBuilder(true);
49-
using (var f = File.Open(path, FileMode.CreateNew))
50-
MyObjectBuilderSerializer.SerializeXML(f, ob, MyObjectBuilderSerializer.XmlCompression.Uncompressed);
50+
51+
MyObjectBuilderSerializerKeen.SerializeXML(path, false,ob);
5152
}
5253

5354
public void ImportGrid(string path, Vector3D position)
5455
{
5556
MyObjectBuilder_EntityBase gridOb;
56-
using (var f = File.OpenRead(path))
57-
MyObjectBuilderSerializer.DeserializeXML(f, out gridOb);
57+
58+
MyObjectBuilderSerializerKeen.DeserializeXML(path, out gridOb);
5859

5960
var grid = MyEntities.CreateFromObjectBuilderParallel(gridOb);
6061
grid.PositionComp.SetPosition(position);

‎Torch/Patches/KeenLogPatch.cs‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,14 @@ private static bool PrefixAppendToClosedLog(MyLog __instance, string text)
117117
}
118118
private static bool PrefixWriteLineOptions(MyLog __instance, string message, LoggingOptions option)
119119
{
120-
if (__instance.LogFlag(option))
120+
var logFlagMethod = typeof(MyLog).GetMethod("LogFlag", BindingFlags.Instance | BindingFlags.NonPublic);
121+
122+
if(logFlagMethod == null)
123+
throw new Exception("Failed to find LogFlag method");
124+
125+
var logFlag = (bool)logFlagMethod.Invoke(__instance, new object[] { option });
126+
127+
if (logFlag)
121128
_log.Info(PrepareLog(__instance).Append(message));
122129
return false;
123130
}

0 commit comments

Comments
 (0)