diff --git a/Content.IntegrationTests/Tests/Body/SaveLoadReparentTest.cs b/Content.IntegrationTests/Tests/Body/SaveLoadReparentTest.cs index f56b5c2850..67163d0796 100644 --- a/Content.IntegrationTests/Tests/Body/SaveLoadReparentTest.cs +++ b/Content.IntegrationTests/Tests/Body/SaveLoadReparentTest.cs @@ -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); diff --git a/Content.IntegrationTests/Tests/PostMapInitTest.cs b/Content.IntegrationTests/Tests/PostMapInitTest.cs index 80e8e7b318..9e908371df 100644 --- a/Content.IntegrationTests/Tests/PostMapInitTest.cs +++ b/Content.IntegrationTests/Tests/PostMapInitTest.cs @@ -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(); diff --git a/Content.IntegrationTests/Tests/SaveLoadMapTest.cs b/Content.IntegrationTests/Tests/SaveLoadMapTest.cs index b1f6dd8433..b96fbe5767 100644 --- a/Content.IntegrationTests/Tests/SaveLoadMapTest.cs +++ b/Content.IntegrationTests/Tests/SaveLoadMapTest.cs @@ -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(); diff --git a/Content.IntegrationTests/Tests/SaveLoadSaveTest.cs b/Content.IntegrationTests/Tests/SaveLoadSaveTest.cs index a398b55919..b41aa0bf2f 100644 --- a/Content.IntegrationTests/Tests/SaveLoadSaveTest.cs +++ b/Content.IntegrationTests/Tests/SaveLoadSaveTest.cs @@ -41,10 +41,10 @@ namespace Content.IntegrationTests.Tests mapSystem.CreateMap(out var mapId0); var grid0 = mapManager.CreateGridEntity(mapId0); entManager.RunMapInit(grid0.Owner, entManager.GetComponent(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(OnAfterSave); + SubscribeLocalEvent(OnAfterSave); } - private void OnAfterSave(AfterSaveEvent ev) + private void OnAfterSave(AfterSerializationEvent ev) { if (!Enabled) return; diff --git a/Content.Server/Administration/Commands/PersistenceSaveCommand.cs b/Content.Server/Administration/Commands/PersistenceSaveCommand.cs index dffe1eff7f..cae507f6d8 100644 --- a/Content.Server/Administration/Commands/PersistenceSaveCommand.cs +++ b/Content.Server/Administration/Commands/PersistenceSaveCommand.cs @@ -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(); - mapLoader.SaveMap(mapId, saveFilePath); + mapLoader.TrySaveMap(mapId, new ResPath(saveFilePath)); shell.WriteLine(Loc.GetString("cmd-savemap-success")); } } diff --git a/Content.Server/DeviceNetwork/Systems/DeviceListSystem.cs b/Content.Server/DeviceNetwork/Systems/DeviceListSystem.cs index a8d40882c4..4defec0aab 100644 --- a/Content.Server/DeviceNetwork/Systems/DeviceListSystem.cs +++ b/Content.Server/DeviceNetwork/Systems/DeviceListSystem.cs @@ -20,7 +20,7 @@ public sealed class DeviceListSystem : SharedDeviceListSystem SubscribeLocalEvent(OnShutdown); SubscribeLocalEvent(OnBeforeBroadcast); SubscribeLocalEvent(OnBeforePacketSent); - SubscribeLocalEvent(OnMapSave); + SubscribeLocalEvent(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 toRemove = new(); var query = GetEntityQuery(); diff --git a/Content.Server/DeviceNetwork/Systems/NetworkConfiguratorSystem.cs b/Content.Server/DeviceNetwork/Systems/NetworkConfiguratorSystem.cs index efaf568094..7e6452d955 100644 --- a/Content.Server/DeviceNetwork/Systems/NetworkConfiguratorSystem.cs +++ b/Content.Server/DeviceNetwork/Systems/NetworkConfiguratorSystem.cs @@ -67,10 +67,10 @@ public sealed class NetworkConfiguratorSystem : SharedNetworkConfiguratorSystem SubscribeLocalEvent(OnComponentRemoved); - SubscribeLocalEvent(OnMapSave); + SubscribeLocalEvent(OnMapSave); } - private void OnMapSave(BeforeSaveEvent ev) + private void OnMapSave(BeforeSerializationEvent ev) { var enumerator = AllEntityQuery(); while (enumerator.MoveNext(out var uid, out var conf)) diff --git a/Content.Server/Mapping/MappingSystem.cs b/Content.Server/Mapping/MappingSystem.cs index ecdbbe081c..1ef6944924 100644 --- a/Content.Server/Mapping/MappingSystem.cs +++ b/Content.Server/Mapping/MappingSystem.cs @@ -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)); } } diff --git a/Content.Server/Maps/ResaveCommand.cs b/Content.Server/Maps/ResaveCommand.cs index 0d48f946be..39507c850f 100644 --- a/Content.Server/Maps/ResaveCommand.cs +++ b/Content.Server/Maps/ResaveCommand.cs @@ -62,11 +62,11 @@ public sealed class ResaveCommand : LocalizedCommands if (_entManager.HasComponent(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 { diff --git a/Content.Shared/Follower/FollowerSystem.cs b/Content.Shared/Follower/FollowerSystem.cs index 0c7bc99c46..ec13a4f7c2 100644 --- a/Content.Shared/Follower/FollowerSystem.cs +++ b/Content.Shared/Follower/FollowerSystem.cs @@ -42,7 +42,7 @@ public sealed class FollowerSystem : EntitySystem SubscribeLocalEvent(OnFollowedAttempt); SubscribeLocalEvent(OnGotEquippedHand); SubscribeLocalEvent(OnFollowedTerminating); - SubscribeLocalEvent(OnBeforeSave); + SubscribeLocalEvent(OnBeforeSave); } private void OnFollowedAttempt(Entity 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.