Moar engine changes
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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>();
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user