]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Thou shall not map items with "do not map" suffix
authorKillerqu00 <killerqueen1777@gmail.com>
Tue, 28 Jan 2025 16:42:17 +0000 (17:42 +0100)
committerKillerqu00 <killerqueen1777@gmail.com>
Tue, 28 Jan 2025 16:42:17 +0000 (17:42 +0100)
Content.IntegrationTests/Tests/PostMapInitTest.cs

index 9ebd32a40a1e167fa4e22a44312004698d9a8930..d1420bc4922771f593f36e5679f889e7aa129af1 100644 (file)
@@ -42,6 +42,11 @@ namespace Content.IntegrationTests.Tests
             "/Maps/Shuttles/infiltrator.yml",
         };
 
+        private static readonly string[] DoNotMapWhitelist =
+        {
+            "/Maps/centcomm.yml",
+        };
+
         private static readonly string[] GameMaps =
         {
             "Dev",
@@ -120,6 +125,7 @@ namespace Content.IntegrationTests.Tests
             var server = pair.Server;
 
             var resourceManager = server.ResolveDependency<IResourceManager>();
+            var protoManager = server.ResolveDependency<IPrototypeManager>();
             var mapFolder = new ResPath("/Maps");
             var maps = resourceManager
                 .ContentFindFiles(mapFolder)
@@ -151,6 +157,21 @@ namespace Content.IntegrationTests.Tests
                 var postMapInit = meta["postmapinit"].AsBool();
 
                 Assert.That(postMapInit, Is.False, $"Map {map.Filename} was saved postmapinit");
+
+                // testing that maps have nothing with the "DO NOT MAP" suffix
+                // I do it here because it's basically copy-paste code for the most part
+                var yamlEntities = root["entities"];
+                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.EditorSuffix.ToUpper().Contains("DO NOT MAP") && !DoNotMapWhitelist.Contains(map.ToString()))
+                    {
+                        Assert.Fail($"\nMap {map} has the DO NOT MAP prototype {proto}");
+                    }
+                }
             }
             await pair.CleanReturnAsync();
         }