]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Even more engine changes
authorElectroJr <leonsfriedrich@gmail.com>
Tue, 24 Dec 2024 08:00:53 +0000 (21:00 +1300)
committerElectroJr <leonsfriedrich@gmail.com>
Tue, 24 Dec 2024 08:00:53 +0000 (21:00 +1300)
Content.IntegrationTests/Tests/PostMapInitTest.cs
Content.Server/DeviceNetwork/Systems/DeviceListSystem.cs
Content.Server/DeviceNetwork/Systems/NetworkConfiguratorSystem.cs
Content.Server/Mapping/MappingManager.cs
Content.Server/Maps/ResaveCommand.cs
Content.Server/Procedural/DungeonSystem.cs
Content.Shared/Follower/FollowerSystem.cs

index 9e908371df5d4fb12251222c2f675db7646b09ad..f07d1e4996895114415679a015ad949c9f8bf9f5 100644 (file)
@@ -426,7 +426,7 @@ namespace Content.IntegrationTests.Tests
                     {
                         try
                         {
-                            Assert.That(mapLoader.TryLoadEntities(path, out maps, out _, opts));
+                            Assert.That(mapLoader.TryLoadGeneric(path, out maps, out _, opts));
                         }
                         catch (Exception ex)
                         {
index 4defec0aabac93294c84561810d89ad715273fea..1988a07cea096c6a96a93d6e7ab867d95c9a532e 100644 (file)
@@ -131,7 +131,7 @@ public sealed class DeviceListSystem : SharedDeviceListSystem
         var enumerator = AllEntityQuery<DeviceListComponent, TransformComponent>();
         while (enumerator.MoveNext(out var uid, out var device, out var xform))
         {
-            if (xform.MapUid != ev.Map)
+            if (!ev.MapIds.Contains(xform.MapID))
                 continue;
 
             foreach (var ent in device.Devices)
@@ -144,7 +144,10 @@ public sealed class DeviceListSystem : SharedDeviceListSystem
                     continue;
                 }
 
-                if (linkedXform.MapUid == ev.Map)
+                // This is assuming that **all** of the map is getting saved.
+                // Which is not necessarily true.
+                // AAAAAAAAAAAAAA
+                if (ev.MapIds.Contains(linkedXform.MapID))
                     continue;
 
                 toRemove.Add(ent);
index 7e6452d955b9a29248ae27b57641db49a7275936..645d28f6d240d7ed4cb04eebf4e5630bce31618b 100644 (file)
@@ -75,7 +75,10 @@ public sealed class NetworkConfiguratorSystem : SharedNetworkConfiguratorSystem
         var enumerator = AllEntityQuery<NetworkConfiguratorComponent>();
         while (enumerator.MoveNext(out var uid, out var conf))
         {
-            if (CompOrNull<TransformComponent>(conf.ActiveDeviceList)?.MapUid != ev.Map)
+            if (!TryComp(conf.ActiveDeviceList, out TransformComponent? listXform))
+                continue;
+
+            if (!ev.MapIds.Contains(listXform.MapID))
                 continue;
 
             // The linked device list is (probably) being saved. Make sure that the configurator is also being saved
@@ -83,9 +86,10 @@ public sealed class NetworkConfiguratorSystem : SharedNetworkConfiguratorSystem
             // containing a set of all entities that are about to be saved, which would make checking this much easier.
             // This is a shitty bandaid, and will force close the UI during auto-saves.
             // TODO Map serialization refactor
+            // I'm refactoring it now and I still dont know what to do
 
             var xform = Transform(uid);
-            if (xform.MapUid == ev.Map && IsSaveable(uid))
+            if (ev.MapIds.Contains(xform.MapID) && IsSaveable(uid))
                 continue;
 
             _uiSystem.CloseUi(uid, NetworkConfiguratorUiKey.Configure);
index be6f503bf0b553219978e7a3d5f9790d2e220b3e..0097df2e553cb26672cdbb3fb324d402e024a5ae 100644 (file)
@@ -54,7 +54,8 @@ public sealed class MappingManager : IPostInjectInit
                 return;
             }
 
-            var data = _systems.GetEntitySystem<MapLoaderSystem>().SerializeEntityRecursive(mapUid).Node;
+            var sys = _systems.GetEntitySystem<MapLoaderSystem>();
+            var data = sys.SerializeEntitiesRecursive([mapUid]).Node;
             var document = new YamlDocument(data.ToYaml());
             var stream = new YamlStream { document };
             var writer = new StringWriter();
index 39507c850ff5a4372e981369400edcc149c31117..c48c02c1f73d51a8fd5e870e6c51842679ee1db0 100644 (file)
@@ -44,7 +44,7 @@ public sealed class ResaveCommand : LocalizedCommands
             var fn = files[i];
             log.Info($"Re-saving file {i}/{files.Count} : {fn}");
 
-            if (!loader.TryLoadEntities(fn, out var result, opts))
+            if (!loader.TryLoadGeneric(fn, out var result, opts))
                 continue;
 
             if (result.Maps.Count != 1)
index 75cdb69130ea868835b20c62d94a48f6c158494d..521ebed7ec7b8115ccc71c794e174ddc7464c705 100644 (file)
@@ -182,7 +182,7 @@ public sealed partial class DungeonSystem : SharedDungeonSystem
             ExpectedCategory = FileCategory.Map
         };
 
-        if (!_loader.TryLoadEntities(proto.AtlasPath, out var res, opts) || !res.Maps.TryFirstOrNull(out var map))
+        if (!_loader.TryLoadGeneric(proto.AtlasPath, out var res, opts) || !res.Maps.TryFirstOrNull(out var map))
             throw new Exception($"Failed to load dungeon template.");
 
         comp = AddComp<DungeonAtlasTemplateComponent>(map.Value.Owner);
index ec13a4f7c2ac73549375d4b0e9689d39953d1650..feea40fb2ff1e18b509b876eae3c552f421e7da3 100644 (file)
@@ -1,3 +1,4 @@
+using System.Linq;
 using System.Numerics;
 using Content.Shared.Administration.Managers;
 using Content.Shared.Database;
@@ -62,8 +63,14 @@ public sealed class FollowerSystem : EntitySystem
 
     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.
+        // Some followers will not be map savable. This ensures that maps don't get saved with some entities that have
+        // empty/invalid followers, by just stopping any following happening on the map being saved.
+        // I hate this so much.
+        // TODO WeakEntityReference
+        // We need some way to store entity references in a way that doesn't imply that the entity still exists.
+        // Then we wouldn't have to deal with this shit.
+
+        var maps = ev.Entities.Select(x => Transform(x).MapUid).ToHashSet();
 
         var query = AllEntityQuery<FollowerComponent, TransformComponent, MetaDataComponent>();
         while (query.MoveNext(out var uid, out var follower, out var xform, out var meta))
@@ -71,7 +78,7 @@ public sealed class FollowerSystem : EntitySystem
             if (meta.EntityPrototype == null || meta.EntityPrototype.MapSavable)
                 continue;
 
-            if (xform.MapUid != ev.Map)
+            if (!maps.Contains(xform.MapUid))
                 continue;
 
             StopFollowingEntity(uid, follower.Following);