]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Moar engine changes
authorElectroJr <leonsfriedrich@gmail.com>
Tue, 24 Dec 2024 05:57:52 +0000 (18:57 +1300)
committerElectroJr <leonsfriedrich@gmail.com>
Tue, 24 Dec 2024 05:57:52 +0000 (18:57 +1300)
Content.IntegrationTests/Tests/Body/SaveLoadReparentTest.cs
Content.IntegrationTests/Tests/PostMapInitTest.cs
Content.IntegrationTests/Tests/SaveLoadMapTest.cs
Content.IntegrationTests/Tests/SaveLoadSaveTest.cs
Content.Server/Administration/Commands/PersistenceSaveCommand.cs
Content.Server/DeviceNetwork/Systems/DeviceListSystem.cs
Content.Server/DeviceNetwork/Systems/NetworkConfiguratorSystem.cs
Content.Server/Mapping/MappingSystem.cs
Content.Server/Maps/ResaveCommand.cs
Content.Shared/Follower/FollowerSystem.cs

index f56b5c28501823f558073bbb3dbb936d868e2cec..67163d0796177dbb5e200aed3fbe97452d7e3ba8 100644 (file)
@@ -2,7 +2,6 @@
 using System.Linq;
 using Content.Shared.Body.Components;
 using Content.Shared.Body.Systems;
-using Robust.Server.GameObjects;
 using Robust.Shared.Containers;
 using Robust.Shared.EntitySerialization.Systems;
 using Robust.Shared.GameObjects;
@@ -115,7 +114,7 @@ public sealed class SaveLoadReparentTest
 
             var mapPath = new ResPath($"/{nameof(SaveLoadReparentTest)}{nameof(Test)}map.yml");
 
-            mapLoader.SaveMap(mapId, mapPath);
+            Assert.That(mapLoader.TrySaveMap(mapId, mapPath));
             mapSys.DeleteMap(mapId);
 
             Assert.That(mapLoader.TryLoadMap(mapPath, out var map, out _), Is.True);
index 80e8e7b3182c2b62704c80843cb3dfdcb21cab40..9e908371df5d4fb12251222c2f675db7646b09ad 100644 (file)
@@ -170,12 +170,12 @@ namespace Content.IntegrationTests.Tests
 
             // First check that a pre-init version passes
             var path = new ResPath($"{nameof(NoSavedPostMapInitTest)}.yml");
-            loader.SaveMap(id, path);
+            Assert.That(loader.TrySaveMap(id, path));
             Assert.That(IsPreInit(path, loader, deps));
 
             // and the post-init version fails.
             await server.WaitPost(() => mapSys.InitializeMap(id));
-            loader.SaveMap(id, path);
+            Assert.That(loader.TrySaveMap(id, path));
             Assert.That(IsPreInit(path, loader, deps), Is.False);
 
             await pair.CleanReturnAsync();
index b1f6dd843301919cd99a2f6d0ccf4ede3d38e398..b96fbe5767351b737794340c0bb46831bed6fef9 100644 (file)
@@ -48,8 +48,8 @@ namespace Content.IntegrationTests.Tests
                     mapSystem.SetTile(mapGrid, new Vector2i(0, 0), new Tile(2, (TileRenderFlag) 1, 254));
                 }
 
-                Assert.Multiple(() => mapLoader.SaveMap(mapId, mapPath));
-                Assert.Multiple(() => mapSystem.DeleteMap(mapId));
+                Assert.That(mapLoader.TrySaveMap(mapId, mapPath));
+                mapSystem.DeleteMap(mapId);
             });
 
             await server.WaitIdleAsync();
index a398b55919743a585dfaca5caed74179e3a553e4..b41aa0bf2f3d1210a452a33e81a0f187503a0d42 100644 (file)
@@ -41,10 +41,10 @@ namespace Content.IntegrationTests.Tests
                 mapSystem.CreateMap(out var mapId0);
                 var grid0 = mapManager.CreateGridEntity(mapId0);
                 entManager.RunMapInit(grid0.Owner, entManager.GetComponent<MetaDataComponent>(grid0));
-                mapLoader.SaveGrid(grid0.Owner, rp1);
+                Assert.That(mapLoader.TrySaveGrid(grid0.Owner, rp1));
                 mapSystem.CreateMap(out var mapId1);
                 Assert.That(mapLoader.TryLoadGrid(mapId1, rp1, out var grid1));
-                mapLoader.SaveGrid(grid1!.Value, rp2);
+                Assert.That(mapLoader.TrySaveGrid(grid1!.Value, rp2));
             });
 
             await server.WaitIdleAsync();
@@ -116,7 +116,7 @@ namespace Content.IntegrationTests.Tests
                 var path = new ResPath(TestMap);
                 Assert.That(mapLoader.TryLoadMap(path, out var map, out _), $"Failed to load test map {TestMap}");
                 mapId = map!.Value.Comp.MapId;
-                mapLoader.SaveMap(mapId, rp1);
+                Assert.That(mapLoader.TrySaveMap(mapId, rp1));
             });
 
             // Run 5 ticks.
@@ -124,7 +124,7 @@ namespace Content.IntegrationTests.Tests
 
             await server.WaitPost(() =>
             {
-                mapLoader.SaveMap(mapId, rp2);
+                Assert.That(mapLoader.TrySaveMap(mapId, rp2));
             });
 
             await server.WaitIdleAsync();
@@ -196,8 +196,8 @@ namespace Content.IntegrationTests.Tests
 
             MapId mapId1 = default;
             MapId mapId2 = default;
-            const string fileA = "/load tick load a.yml";
-            const string fileB = "/load tick load b.yml";
+            var fileA = new ResPath("/load tick load a.yml");
+            var fileB = new ResPath("/load tick load b.yml");
             string yamlA;
             string yamlB;
 
@@ -207,11 +207,11 @@ namespace Content.IntegrationTests.Tests
                 var path = new ResPath(TestMap);
                 Assert.That(mapLoader.TryLoadMap(path, out var map, out _), $"Failed to load test map {TestMap}");
                 mapId1 = map!.Value.Comp.MapId;
-                mapLoader.SaveMap(mapId1, fileA);
+                Assert.That(mapLoader.TrySaveMap(mapId1, fileA));
             });
 
             await server.WaitIdleAsync();
-            await using (var stream = userData.Open(new ResPath(fileA), FileMode.Open))
+            await using (var stream = userData.Open(fileA, FileMode.Open))
             using (var reader = new StreamReader(stream))
             {
                 yamlA = await reader.ReadToEndAsync();
@@ -225,12 +225,12 @@ namespace Content.IntegrationTests.Tests
                 var path = new ResPath(TestMap);
                 Assert.That(mapLoader.TryLoadMap(path, out var map, out _), $"Failed to load test map {TestMap}");
                 mapId2 = map!.Value.Comp.MapId;
-                mapLoader.SaveMap(mapId2, fileB);
+                Assert.That(mapLoader.TrySaveMap(mapId2, fileB));
             });
 
             await server.WaitIdleAsync();
 
-            await using (var stream = userData.Open(new ResPath(fileB), FileMode.Open))
+            await using (var stream = userData.Open(fileB, FileMode.Open))
             using (var reader = new StreamReader(stream))
             {
                 yamlB = await reader.ReadToEndAsync();
@@ -253,10 +253,10 @@ namespace Content.IntegrationTests.Tests
             public bool Enabled;
             public override void Initialize()
             {
-                SubscribeLocalEvent<AfterSaveEvent>(OnAfterSave);
+                SubscribeLocalEvent<AfterSerializationEvent>(OnAfterSave);
             }
 
-            private void OnAfterSave(AfterSaveEvent ev)
+            private void OnAfterSave(AfterSerializationEvent ev)
             {
                 if (!Enabled)
                     return;
index dffe1eff7f3ac6e5fb9e3876819a9bb5bcd65a86..cae507f6d8e69d0f698984761ecda16586c0fabf 100644 (file)
@@ -1,11 +1,10 @@
 using Content.Shared.Administration;
 using Content.Shared.CCVar;
-using Robust.Server.GameObjects;
 using Robust.Shared.Configuration;
 using Robust.Shared.Console;
 using Robust.Shared.Map;
-using System.Linq;
 using Robust.Shared.EntitySerialization.Systems;
+using Robust.Shared.Utility;
 
 namespace Content.Server.Administration.Commands;
 
@@ -49,7 +48,7 @@ public sealed class PersistenceSave : IConsoleCommand
         }
 
         var mapLoader = _system.GetEntitySystem<MapLoaderSystem>();
-        mapLoader.SaveMap(mapId, saveFilePath);
+        mapLoader.TrySaveMap(mapId, new ResPath(saveFilePath));
         shell.WriteLine(Loc.GetString("cmd-savemap-success"));
     }
 }
index a8d40882c4d0b493cd2819256d422c3fc1d4cace..4defec0aabac93294c84561810d89ad715273fea 100644 (file)
@@ -20,7 +20,7 @@ public sealed class DeviceListSystem : SharedDeviceListSystem
         SubscribeLocalEvent<DeviceListComponent, ComponentShutdown>(OnShutdown);
         SubscribeLocalEvent<DeviceListComponent, BeforeBroadcastAttemptEvent>(OnBeforeBroadcast);
         SubscribeLocalEvent<DeviceListComponent, BeforePacketSentEvent>(OnBeforePacketSent);
-        SubscribeLocalEvent<BeforeSaveEvent>(OnMapSave);
+        SubscribeLocalEvent<BeforeSerializationEvent>(OnMapSave);
     }
 
     private void OnShutdown(EntityUid uid, DeviceListComponent component, ComponentShutdown args)
@@ -124,7 +124,7 @@ public sealed class DeviceListSystem : SharedDeviceListSystem
         Dirty(list);
     }
 
-    private void OnMapSave(BeforeSaveEvent ev)
+    private void OnMapSave(BeforeSerializationEvent ev)
     {
         List<EntityUid> toRemove = new();
         var query = GetEntityQuery<TransformComponent>();
index efaf56809475e55f58ad87d79071920ec0bfe463..7e6452d955b9a29248ae27b57641db49a7275936 100644 (file)
@@ -67,10 +67,10 @@ public sealed class NetworkConfiguratorSystem : SharedNetworkConfiguratorSystem
 
         SubscribeLocalEvent<DeviceListComponent, ComponentRemove>(OnComponentRemoved);
 
-        SubscribeLocalEvent<BeforeSaveEvent>(OnMapSave);
+        SubscribeLocalEvent<BeforeSerializationEvent>(OnMapSave);
     }
 
-    private void OnMapSave(BeforeSaveEvent ev)
+    private void OnMapSave(BeforeSerializationEvent ev)
     {
         var enumerator = AllEntityQuery<NetworkConfiguratorComponent>();
         while (enumerator.MoveNext(out var uid, out var conf))
index ecdbbe081c15baf8b2d96c1631295d6510317b8c..1ef6944924ef309c7e942746f9ea716d0d0c3716 100644 (file)
@@ -78,7 +78,7 @@ public sealed class MappingSystem : EntitySystem
             var path = Path.Combine(saveDir, $"{DateTime.Now.ToString("yyyy-M-dd_HH.mm.ss")}-AUTO.yml");
             _currentlyAutosaving[map] = (CalculateNextTime(), name);
             Log.Info($"Autosaving map {name} ({map}) to {path}. Next save in {ReadableTimeLeft(map)} seconds.");
-            _loader.SaveMap(map, path);
+            _loader.TrySaveMap(map, new ResPath(path));
         }
     }
 
index 0d48f946be8d1450cc81f12eecfb5e2253d6fe31..39507c850ff5a4372e981369400edcc149c31117 100644 (file)
@@ -62,11 +62,11 @@ public sealed class ResaveCommand : LocalizedCommands
 
             if (_entManager.HasComponent<LoadedMapComponent>(map))
             {
-                loader.SaveMap(map.Comp.MapId, fn);
+                loader.TrySaveMap(map.Comp.MapId, fn);
             }
             else if (result.Grids.Count == 1)
             {
-                loader.SaveGrid(result.Grids.First(), fn);
+                loader.TrySaveGrid(result.Grids.First(), fn);
             }
             else
             {
index 0c7bc99c4648b968cccd1e62a77401c4cf059d47..ec13a4f7c2ac73549375d4b0e9689d39953d1650 100644 (file)
@@ -42,7 +42,7 @@ public sealed class FollowerSystem : EntitySystem
         SubscribeLocalEvent<FollowedComponent, ComponentGetStateAttemptEvent>(OnFollowedAttempt);
         SubscribeLocalEvent<FollowerComponent, GotEquippedHandEvent>(OnGotEquippedHand);
         SubscribeLocalEvent<FollowedComponent, EntityTerminatingEvent>(OnFollowedTerminating);
-        SubscribeLocalEvent<BeforeSaveEvent>(OnBeforeSave);
+        SubscribeLocalEvent<BeforeSerializationEvent>(OnBeforeSave);
     }
 
     private void OnFollowedAttempt(Entity<FollowedComponent> ent, ref ComponentGetStateAttemptEvent args)
@@ -60,7 +60,7 @@ public sealed class FollowerSystem : EntitySystem
         }
     }
 
-    private void OnBeforeSave(BeforeSaveEvent ev)
+    private void OnBeforeSave(BeforeSerializationEvent ev)
     {
         // Some followers will not be map savable. This ensures that maps don't get saved with empty/invalid
         // followers, but just stopping any following on the map being saved.