diff --git a/TSOClient/tso.client/UI/Panels/UILotControl.cs b/TSOClient/tso.client/UI/Panels/UILotControl.cs index 49a695fc3..a86a9d49d 100644 --- a/TSOClient/tso.client/UI/Panels/UILotControl.cs +++ b/TSOClient/tso.client/UI/Panels/UILotControl.cs @@ -1233,7 +1233,7 @@ private void SaveLot() try { var exporter = new VMWorldExporter(); exporter.SaveHouse(vm, Path.Combine(FSOEnvironment.UserDir, ("Blueprints/"+LotSaveDialog.ResponseText+".xml"))); - var marshal = vm.Save(); + var marshal = vm.Save(!(UIScreen.Current is SandboxGameScreen)); Directory.CreateDirectory(Path.Combine(FSOEnvironment.UserDir, "LocalHouse/")); using (var output = new FileStream(Path.Combine(FSOEnvironment.UserDir, "LocalHouse/"+LotSaveDialog.ResponseText+".fsov"), FileMode.Create)) { diff --git a/TSOClient/tso.client/UI/Screens/CoreGameScreen.cs b/TSOClient/tso.client/UI/Screens/CoreGameScreen.cs index e438d7294..84d4c6ed1 100644 --- a/TSOClient/tso.client/UI/Screens/CoreGameScreen.cs +++ b/TSOClient/tso.client/UI/Screens/CoreGameScreen.cs @@ -822,21 +822,6 @@ private void VMDebug_OnButtonClick(UIElement button) } - private void SaveHouseButton_OnButtonClick(UIElement button) - { - if (vm == null) return; - - var exporter = new VMWorldExporter(); - exporter.SaveHouse(vm, GameFacade.GameFilePath("housedata/blueprints/house_00.xml")); - var marshal = vm.Save(); - Directory.CreateDirectory(Path.Combine(FSOEnvironment.UserDir, "LocalHouse/")); - using (var output = new FileStream(Path.Combine(FSOEnvironment.UserDir, "LocalHouse/house_00.fsov"), FileMode.Create)) - { - marshal.SerializeInto(new BinaryWriter(output)); - } - if (vm.GlobalLink != null) ((VMTSOGlobalLinkStub)vm.GlobalLink).Database.Save(); - } - public void CloseInbox() { Inbox.Visible = false; diff --git a/TSOClient/tso.client/UI/Screens/SandboxGameScreen.cs b/TSOClient/tso.client/UI/Screens/SandboxGameScreen.cs index 0b371a7b0..3da54040f 100644 --- a/TSOClient/tso.client/UI/Screens/SandboxGameScreen.cs +++ b/TSOClient/tso.client/UI/Screens/SandboxGameScreen.cs @@ -678,20 +678,5 @@ private void VMRefreshed() LotControl.ActiveEntity = null; LotControl.RefreshCut(); } - - private void SaveHouseButton_OnButtonClick(UIElement button) - { - if (vm == null) return; - - var exporter = new VMWorldExporter(); - exporter.SaveHouse(vm, GameFacade.GameFilePath("housedata/blueprints/house_00.xml")); - var marshal = vm.Save(); - Directory.CreateDirectory(Path.Combine(FSOEnvironment.UserDir, "LocalHouse/")); - using (var output = new FileStream(Path.Combine(FSOEnvironment.UserDir, "LocalHouse/house_00.fsov"), FileMode.Create)) - { - marshal.SerializeInto(new BinaryWriter(output)); - } - if (vm.GlobalLink != null) ((VMTSOGlobalLinkStub)vm.GlobalLink).Database.Save(); - } } } diff --git a/TSOClient/tso.simantics/Entities/VMEntity.cs b/TSOClient/tso.simantics/Entities/VMEntity.cs index 4600df301..73656c28f 100644 --- a/TSOClient/tso.simantics/Entities/VMEntity.cs +++ b/TSOClient/tso.simantics/Entities/VMEntity.cs @@ -1822,7 +1822,8 @@ public enum VMMovementFlags PlayersCanMove = 1 << 1, SelfPropelled = 1 << 2, //unused PlayersCanDelete = 1 << 3, - StaysAfterEvict = 1 << 4 + StaysAfterEvict = 1 << 4, + FSOExcludeUserSave = 1 << 8 } [Flags] diff --git a/TSOClient/tso.simantics/VM.cs b/TSOClient/tso.simantics/VM.cs index 816d47054..999ecefea 100644 --- a/TSOClient/tso.simantics/VM.cs +++ b/TSOClient/tso.simantics/VM.cs @@ -664,7 +664,7 @@ public void SandboxRestore(VMSandboxRestoreState state) } #region VM Marshalling Functions - public VMMarshal Save() + public VMMarshal Save(bool user = false) { var ents = new VMEntityMarshal[Entities.Count]; var threads = new VMThreadMarshal[Entities.Count]; @@ -673,6 +673,11 @@ public VMMarshal Save() int i = 0; foreach (var ent in Entities) { + if (user && ((VMMovementFlags)ent.GetValue(VMStackObjectVariable.MovementFlags)).HasFlag(VMMovementFlags.FSOExcludeUserSave)) + { + continue; + } + if (ent is VMAvatar) { ents[i] = ((VMAvatar)ent).Save(); @@ -688,6 +693,12 @@ public VMMarshal Save() } } + if (i != ents.Length) + { + Array.Resize(ref ents, i); + Array.Resize(ref threads, i); + } + return new VMMarshal { Context = Context.Save(),