]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Merge branch 'master' of https://github.com/space-wizards/space-station-14 into pr...
authorElectroJr <leonsfriedrich@gmail.com>
Sun, 16 Feb 2025 12:16:22 +0000 (01:16 +1300)
committerElectroJr <leonsfriedrich@gmail.com>
Sun, 16 Feb 2025 12:16:22 +0000 (01:16 +1300)
1  2 
Content.IntegrationTests/Tests/PostMapInitTest.cs
Resources/Prototypes/Entities/Clothing/Head/hardsuit-helmets.yml
Resources/Prototypes/Entities/Objects/Fun/toys.yml
Resources/Prototypes/Entities/Structures/Machines/Computers/computers.yml

index 7fc65606947517c57fae6006bbd1a0279ba2248a,94214c609aab9fb1a9361ab3cc0e915b6a180d1c..dcb2e222a4531a2657c50e63a9ca5540361873a4
@@@ -36,17 -38,9 +38,14 @@@ namespace Content.IntegrationTests.Test
  
          private static readonly string[] Grids =
          {
-             "/Maps/centcomm.yml",
-             "/Maps/Shuttles/cargo.yml",
-             "/Maps/Shuttles/emergency.yml",
-             "/Maps/Shuttles/infiltrator.yml",
+             "/Maps/centcomm.yml"
          };
  
 +        private static readonly string[] DoNotMapWhitelist =
 +        {
 +            "/Maps/centcomm.yml",
 +        };
 +
          private static readonly string[] GameMaps =
          {
              "Dev",
              var server = pair.Server;
  
              var resourceManager = server.ResolveDependency<IResourceManager>();
 +            var protoManager = server.ResolveDependency<IPrototypeManager>();
+             var loader = server.System<MapLoaderSystem>();
              var mapFolder = new ResPath("/Maps");
              var maps = resourceManager
                  .ContentFindFiles(mapFolder)
  
                  var root = yamlStream.Documents[0].RootNode;
                  var meta = root["meta"];
-                 var postMapInit = meta["postmapinit"].AsBool();
+                 var version = meta["format"].AsInt();
  
+                 if (version >= 7)
+                 {
+                     v7Maps.Add(map);
+                     continue;
+                 }
+                 var postMapInit = meta["postmapinit"].AsBool();
                  Assert.That(postMapInit, Is.False, $"Map {map.Filename} was saved postmapinit");
 +
 +                // testing that maps have nothing with the DoNotMap entity category
 +                // I do it here because it's basically copy-paste code for the most part
 +                var yamlEntities = root["entities"];
 +                if (!protoManager.TryIndex<EntityCategoryPrototype>("DoNotMap", out var dnmCategory))
 +                    return;
 +                foreach (var yamlEntity in (YamlSequenceNode)yamlEntities)
 +                {
 +                    var protoId = yamlEntity["proto"].AsString();
 +                    protoManager.TryIndex(protoId, out var proto, false);
 +                    if (proto is null || proto.EditorSuffix is null)
 +                        continue;
 +                    if (proto.Categories.Contains(dnmCategory) && !DoNotMapWhitelist.Contains(map.ToString()))
 +                    {
 +                        Assert.Fail($"\nMap {map} has the DO NOT MAP category in prototype {proto.Name}");
 +                    }
 +                }
              }
+             var deps = server.ResolveDependency<IEntitySystemManager>().DependencyCollection;
+             foreach (var map in v7Maps)
+             {
+                 Assert.That(IsPreInit(map, loader, deps));
+             }
+             // Check that the test actually does manage to catch post-init maps and isn't just blindly passing everything.
+             // To that end, create a new post-init map and try verify it.
+             var mapSys = server.System<SharedMapSystem>();
+             MapId id = default;
+             await server.WaitPost(() => mapSys.CreateMap(out id, runMapInit: false));
+             await server.WaitPost(() => server.EntMan.Spawn(null, new MapCoordinates(0, 0, id)));
+             // First check that a pre-init version passes
+             var path = new ResPath($"{nameof(NoSavedPostMapInitTest)}.yml");
+             Assert.That(loader.TrySaveMap(id, path));
+             Assert.That(IsPreInit(path, loader, deps));
+             // and the post-init version fails.
+             await server.WaitPost(() => mapSys.InitializeMap(id));
+             Assert.That(loader.TrySaveMap(id, path));
+             Assert.That(IsPreInit(path, loader, deps), Is.False);
              await pair.CleanReturnAsync();
          }